aboutsummaryrefslogtreecommitdiff
path: root/web/app/view/NotificationsController.js
diff options
context:
space:
mode:
authorAbyss777 <abyss@fox5.ru>2016-11-29 10:03:51 +0500
committerAbyss777 <abyss@fox5.ru>2016-11-29 10:03:51 +0500
commit9289e40a4e32fc0f9a41dea6674ac8b2a2e4d313 (patch)
tree84640852ffbdef6179c7728c0eccd761d5069928 /web/app/view/NotificationsController.js
parent957b3f0ed0e71ae1312a3790ba0a23c45dd3db5f (diff)
downloadetbsa-traccar-web-9289e40a4e32fc0f9a41dea6674ac8b2a2e4d313.tar.gz
etbsa-traccar-web-9289e40a4e32fc0f9a41dea6674ac8b2a2e4d313.tar.bz2
etbsa-traccar-web-9289e40a4e32fc0f9a41dea6674ac8b2a2e4d313.zip
Improve Notifications handling
Diffstat (limited to 'web/app/view/NotificationsController.js')
-rw-r--r--web/app/view/NotificationsController.js36
1 files changed, 11 insertions, 25 deletions
diff --git a/web/app/view/NotificationsController.js b/web/app/view/NotificationsController.js
index 70b99f1..ec9be56 100644
--- a/web/app/view/NotificationsController.js
+++ b/web/app/view/NotificationsController.js
@@ -28,22 +28,14 @@ Ext.define('Traccar.view.NotificationsController', {
this.getView().getStore().load({
scope: this,
callback: function (records, operation, success) {
- var notificationsStore = Ext.create('Traccar.store.Notifications');
- notificationsStore.load({
+ Ext.create('Traccar.store.Notifications').load({
params: {
userId: this.userId
},
scope: this,
callback: function (records, operation, success) {
- var i, index, attributes, storeRecord;
if (success) {
- for (i = 0; i < records.length; i++) {
- index = this.getView().getStore().findExact('type', records[i].get('type'));
- attributes = records[i].get('attributes');
- storeRecord = this.getView().getStore().getAt(index);
- storeRecord.set('attributes', attributes);
- storeRecord.commit();
- }
+ this.getView().getStore().loadData(records);
}
}
});
@@ -51,29 +43,23 @@ Ext.define('Traccar.view.NotificationsController', {
});
},
- onBeforeCheckChange: function (column, rowIndex, checked, eOpts) {
- var fields, record, data;
- fields = column.dataIndex.split('\.', 2);
+ onCheckChange: function (column, rowIndex, checked, eOpts) {
+ var record, attributes;
record = this.getView().getStore().getAt(rowIndex);
- data = record.get(fields[0]);
- if (!data[fields[1]]) {
- data[fields[1]] = 'true';
- } else {
- delete data[fields[1]];
+ attributes = {};
+ if (record.get('attributes.web')) {
+ attributes.web = 'true';
+ }
+ if (record.get('attributes.mail')) {
+ attributes.mail = 'true';
}
- record.set(fields[0], data);
- 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: {
userId: this.userId,
type: record.get('type'),
- attributes: record.get('attributes')
+ attributes: attributes
},
callback: function (options, success, response) {
if (!success) {