diff options
author | Abyss777 <abyss@fox5.ru> | 2016-06-27 14:34:37 +0500 |
---|---|---|
committer | Abyss777 <abyss@fox5.ru> | 2016-06-27 14:34:37 +0500 |
commit | 1972191b8802f3f9295cb151202c50d115a87f0e (patch) | |
tree | ab0ab29708fdb7fb35a792d3961bd5f180fc8fba /web/app/view/NotificationsController.js | |
parent | 6c0c508ef8afe602a12dbeb2b68ea708fdffedd2 (diff) | |
download | trackermap-server-1972191b8802f3f9295cb151202c50d115a87f0e.tar.gz trackermap-server-1972191b8802f3f9295cb151202c50d115a87f0e.tar.bz2 trackermap-server-1972191b8802f3f9295cb151202c50d115a87f0e.zip |
Do not use plane record fields to handle attributes nested fields
Diffstat (limited to 'web/app/view/NotificationsController.js')
-rw-r--r-- | web/app/view/NotificationsController.js | 41 |
1 files changed, 18 insertions, 23 deletions
diff --git a/web/app/view/NotificationsController.js b/web/app/view/NotificationsController.js index 7a609ef19..1638e4520 100644 --- a/web/app/view/NotificationsController.js +++ b/web/app/view/NotificationsController.js @@ -36,13 +36,7 @@ Ext.define('Traccar.view.NotificationsController', { index = this.getView().getStore().find('type', records[i].getData().type); attributes = records[i].getData().attributes; storeRecord = this.getView().getStore().getAt(index); - if (typeof attributes.web != 'undefined') { - storeRecord.set('web', attributes.web); - } - if (typeof attributes.mail != 'undefined') { - storeRecord.set('mail', attributes.mail); - } - + storeRecord.set('attributes', attributes); storeRecord.commit(); } } @@ -52,32 +46,33 @@ Ext.define('Traccar.view.NotificationsController', { }); }, - onCheckChange: function (column, rowIndex, checked, eOpts) { + onBeforeCheckChange: function (column, rowIndex, checked, eOpts) { var record = this.getView().getStore().getAt(rowIndex); - var web, mail; - var data = { - userId: this.userId, - type: record.getData().type, - attributes: {} - }; - web = record.getData().web; - if (typeof web != 'undefined' && web) { - data.attributes.web = "true"; - } - mail = record.getData().mail; - if (typeof mail != 'undefined' && mail) { - data.attributes.mail = "true"; + var attributes = record.getData().attributes; + if (!attributes[column.dataIndex]) { + attributes[column.dataIndex] = "true"; + } else { + delete attributes[column.dataIndex]; } + record.set('attributes', attributes); + record.commit(); + }, + + onCheckChange: function (column, rowIndex, checked, eOpts) { + var record = this.getView().getStore().getAt(rowIndex); Ext.Ajax.request({ scope: this, url: '/api/users/notifications', - jsonData: data, + jsonData: { + userId: this.userId, + type: record.getData().type, + attributes: record.getData().attributes + }, callback: function (options, success, response) { if (!success) { Traccar.app.showError(response); } } }); - } }); |