From 2716bcccafb3ec2f19858a5e5fea262af2a8cb30 Mon Sep 17 00:00:00 2001 From: Abyss777 Date: Mon, 27 Jun 2016 17:41:39 +0500 Subject: Made code more universal --- web/app/view/Notifications.js | 10 ++++++---- web/app/view/NotificationsController.js | 13 +++++++------ 2 files changed, 13 insertions(+), 10 deletions(-) (limited to 'web') 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(); }, -- cgit v1.2.3