Browse Source

Disable "Remove All" if there are no services

Fixes #2264
pull/2290/head
Juan Manuel Gonzalez Alama 6 years ago
parent
commit
6fd77c45e8
  1. 6
      app/store/Services.js
  2. 3
      app/view/main/Main.js
  3. 6
      app/view/main/MainController.js
  4. 1
      app/view/main/MainModel.js

6
app/store/Services.js

@ -21,7 +21,7 @@ Ext.define('Rambox.store.Services', {
] ]
,listeners: { ,listeners: {
load: function( store, records, successful ) { load: function( store, records, successful ) {
Ext.cq1('app-main').suspendEvent('add'); Ext.cq1('app-main').suspendEvent('add');
var servicesLeft = []; var servicesLeft = [];
@ -76,5 +76,9 @@ Ext.define('Rambox.store.Services', {
store.suspendEvent('load'); store.suspendEvent('load');
Ext.cq1('app-main').resumeEvent('add'); Ext.cq1('app-main').resumeEvent('add');
} }
,datachanged: function(store, eOpts) {
var isEmpty = store.getCount() > 0 ? false : true;
Ext.cq1('app-main').getViewModel().set('emptyServices', isEmpty);
}
} }
}); });

3
app/view/main/Main.js

@ -148,6 +148,9 @@ Ext.define('Rambox.view.main.Main', {
,baseCls: '' ,baseCls: ''
,tooltip: locale['app.main[10]'] ,tooltip: locale['app.main[10]']
,handler: 'removeAllServices' ,handler: 'removeAllServices'
,bind: {
disabled: '{emptyServices}'
}
} }
] ]
,columns: [ ,columns: [

6
app/view/main/MainController.js

@ -192,12 +192,12 @@ Ext.define('Rambox.view.main.MainController', {
,removeAllServices: function(btn, callback) { ,removeAllServices: function(btn, callback) {
var me = this; var me = this;
// Clear counter for unread messaging
document.title = 'Rambox';
if ( btn ) { if ( btn ) {
Ext.Msg.confirm(locale['app.window[12]'], locale['app.window[14]'], function(btnId) { Ext.Msg.confirm(locale['app.window[12]'], locale['app.window[14]'], function(btnId) {
if ( btnId === 'yes' ) { if ( btnId === 'yes' ) {
// Clear counter for unread messaging
document.title = 'Rambox';
Ext.cq1('app-main').suspendEvent('remove'); Ext.cq1('app-main').suspendEvent('remove');
Ext.getStore('Services').load(); Ext.getStore('Services').load();
Ext.Msg.wait('Please wait until we clear all.', 'Removing...'); Ext.Msg.wait('Please wait until we clear all.', 'Removing...');

1
app/view/main/MainModel.js

@ -9,5 +9,6 @@ Ext.define('Rambox.view.main.MainModel', {
,username: localStorage.getItem('profile') ? JSON.parse(localStorage.getItem('profile')).name : '' ,username: localStorage.getItem('profile') ? JSON.parse(localStorage.getItem('profile')).name : ''
,avatar: localStorage.getItem('profile') ? JSON.parse(localStorage.getItem('profile')).picture : '' ,avatar: localStorage.getItem('profile') ? JSON.parse(localStorage.getItem('profile')).picture : ''
,last_sync: localStorage.getItem('profile') && JSON.parse(localStorage.getItem('profile')).user_metadata && JSON.parse(localStorage.getItem('profile')).user_metadata.services_lastupdate ? new Date(JSON.parse(localStorage.getItem('profile')).user_metadata.services_lastupdate).toUTCString() : '' ,last_sync: localStorage.getItem('profile') && JSON.parse(localStorage.getItem('profile')).user_metadata && JSON.parse(localStorage.getItem('profile')).user_metadata.services_lastupdate ? new Date(JSON.parse(localStorage.getItem('profile')).user_metadata.services_lastupdate).toUTCString() : ''
,emptyServices: true
} }
}); });

Loading…
Cancel
Save