diff options
author | Abyss777 <abyss@fox5.ru> | 2016-06-27 17:41:39 +0500 |
---|---|---|
committer | Abyss777 <abyss@fox5.ru> | 2016-06-27 17:41:39 +0500 |
commit | 2716bcccafb3ec2f19858a5e5fea262af2a8cb30 (patch) | |
tree | 6bbdd9311c87677a5edbb862a83604771c4ec23b | |
parent | 395779143dd61df7ba526ee7a80a91094291a30b (diff) | |
download | trackermap-server-2716bcccafb3ec2f19858a5e5fea262af2a8cb30.tar.gz trackermap-server-2716bcccafb3ec2f19858a5e5fea262af2a8cb30.tar.bz2 trackermap-server-2716bcccafb3ec2f19858a5e5fea262af2a8cb30.zip |
Made code more universal
-rw-r--r-- | web/app/view/Notifications.js | 10 | ||||
-rw-r--r-- | web/app/view/NotificationsController.js | 13 |
2 files changed, 13 insertions, 10 deletions
diff --git a/web/app/view/Notifications.js b/web/app/view/Notifications.js index 2ae980afe..211e5cd15 100644 --- a/web/app/view/Notifications.js +++ b/web/app/view/Notifications.js @@ -39,7 +39,7 @@ Ext.define('Traccar.view.Notifications', { } }, { text: Strings.notificationWeb, - dataIndex: 'web', + dataIndex: 'attributes.web', xtype: 'checkcolumn', flex: 1, listeners: { @@ -47,11 +47,12 @@ Ext.define('Traccar.view.Notifications', { checkChange: 'onCheckChange' }, renderer: function (value, metaData, record) { - return (new Ext.ux.CheckColumn()).renderer(record.getData().attributes.web, metaData); + var fields = this.dataIndex.split('\.',2); + return (new Ext.ux.CheckColumn()).renderer(record.get(fields[0])[fields[1]], metaData); } }, { text: Strings.notificationMail, - dataIndex: 'mail', + dataIndex: 'attributes.mail', xtype: 'checkcolumn', flex: 1, listeners: { @@ -59,7 +60,8 @@ Ext.define('Traccar.view.Notifications', { checkChange: 'onCheckChange' }, renderer: function (value, metaData, record) { - return (new Ext.ux.CheckColumn()).renderer(record.getData().attributes.mail, metaData); + var fields = this.dataIndex.split('\.',2); + return (new Ext.ux.CheckColumn()).renderer(record.get(fields[0])[fields[1]], metaData); } }], diff --git a/web/app/view/NotificationsController.js b/web/app/view/NotificationsController.js index 1638e4520..a7c4290ca 100644 --- a/web/app/view/NotificationsController.js +++ b/web/app/view/NotificationsController.js @@ -45,16 +45,17 @@ Ext.define('Traccar.view.NotificationsController', { } }); }, - + onBeforeCheckChange: function (column, rowIndex, checked, eOpts) { + var fields = column.dataIndex.split('\.',2); var record = this.getView().getStore().getAt(rowIndex); - var attributes = record.getData().attributes; - if (!attributes[column.dataIndex]) { - attributes[column.dataIndex] = "true"; + var data = record.get(fields[0]); + if (!data[fields[1]]) { + data[fields[1]] = "true"; } else { - delete attributes[column.dataIndex]; + delete data[fields[1]]; } - record.set('attributes', attributes); + record.set(fields[0], data); record.commit(); }, |