aboutsummaryrefslogtreecommitdiff
path: root/web
diff options
context:
space:
mode:
authorAbyss777 <abyss@fox5.ru>2016-06-27 14:34:37 +0500
committerAbyss777 <abyss@fox5.ru>2016-06-27 14:34:37 +0500
commit1972191b8802f3f9295cb151202c50d115a87f0e (patch)
treeab0ab29708fdb7fb35a792d3961bd5f180fc8fba /web
parent6c0c508ef8afe602a12dbeb2b68ea708fdffedd2 (diff)
downloadtraccar-server-1972191b8802f3f9295cb151202c50d115a87f0e.tar.gz
traccar-server-1972191b8802f3f9295cb151202c50d115a87f0e.tar.bz2
traccar-server-1972191b8802f3f9295cb151202c50d115a87f0e.zip
Do not use plane record fields to handle attributes nested fields
Diffstat (limited to 'web')
-rw-r--r--web/app/view/Notifications.js8
-rw-r--r--web/app/view/NotificationsController.js41
2 files changed, 26 insertions, 23 deletions
diff --git a/web/app/view/Notifications.js b/web/app/view/Notifications.js
index 8efebd038..2ae980afe 100644
--- a/web/app/view/Notifications.js
+++ b/web/app/view/Notifications.js
@@ -43,7 +43,11 @@ Ext.define('Traccar.view.Notifications', {
xtype: 'checkcolumn',
flex: 1,
listeners: {
+ beforeCheckChange: 'onBeforeCheckChange',
checkChange: 'onCheckChange'
+ },
+ renderer: function (value, metaData, record) {
+ return (new Ext.ux.CheckColumn()).renderer(record.getData().attributes.web, metaData);
}
}, {
text: Strings.notificationMail,
@@ -51,7 +55,11 @@ Ext.define('Traccar.view.Notifications', {
xtype: 'checkcolumn',
flex: 1,
listeners: {
+ beforeCheckChange: 'onBeforeCheckChange',
checkChange: 'onCheckChange'
+ },
+ renderer: function (value, metaData, record) {
+ return (new Ext.ux.CheckColumn()).renderer(record.getData().attributes.mail, metaData);
}
}],
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);
}
}
});
-
}
});