aboutsummaryrefslogtreecommitdiff
path: root/web/app
diff options
context:
space:
mode:
authorAnton Tananaev <anton.tananaev@gmail.com>2016-11-29 18:17:38 +1300
committerGitHub <noreply@github.com>2016-11-29 18:17:38 +1300
commitd10d51eb9def4e9ce77d053503ba3eccd3ad23aa (patch)
treeee78f48e70b88453ae2aee31459c27a6eecf0c5e /web/app
parent957b3f0ed0e71ae1312a3790ba0a23c45dd3db5f (diff)
parent6ddb811f1c2000d3e7f805388b1e02212dd03f2e (diff)
downloadtrackermap-web-d10d51eb9def4e9ce77d053503ba3eccd3ad23aa.tar.gz
trackermap-web-d10d51eb9def4e9ce77d053503ba3eccd3ad23aa.tar.bz2
trackermap-web-d10d51eb9def4e9ce77d053503ba3eccd3ad23aa.zip
Merge pull request #342 from Abyss777/improve_notifications
Improve Notifications dialog and controller
Diffstat (limited to 'web/app')
-rw-r--r--web/app/model/Notification.js8
-rw-r--r--web/app/view/Notifications.js10
-rw-r--r--web/app/view/NotificationsController.js35
3 files changed, 18 insertions, 35 deletions
diff --git a/web/app/model/Notification.js b/web/app/model/Notification.js
index 1e6c36c5..04dca9bf 100644
--- a/web/app/model/Notification.js
+++ b/web/app/model/Notification.js
@@ -30,5 +30,13 @@ Ext.define('Traccar.model.Notification', {
type: 'int'
}, {
name: 'attributes'
+ }, {
+ name: 'attributes.web',
+ type: 'bool',
+ mapping: 'attributes.web'
+ }, {
+ name: 'attributes.mail',
+ type: 'bool',
+ mapping: 'attributes.mail'
}]
});
diff --git a/web/app/view/Notifications.js b/web/app/view/Notifications.js
index 250a6b5f..795cf326 100644
--- a/web/app/view/Notifications.js
+++ b/web/app/view/Notifications.js
@@ -51,24 +51,14 @@ Ext.define('Traccar.view.Notifications', {
dataIndex: 'attributes.web',
xtype: 'checkcolumn',
listeners: {
- beforeCheckChange: 'onBeforeCheckChange',
checkChange: 'onCheckChange'
- },
- renderer: function (value, metaData, record) {
- var fields = this.dataIndex.split('\.', 2);
- return (new Ext.ux.CheckColumn()).renderer(record.get(fields[0])[fields[1]], metaData);
}
}, {
text: Strings.notificationMail,
dataIndex: 'attributes.mail',
xtype: 'checkcolumn',
listeners: {
- beforeCheckChange: 'onBeforeCheckChange',
checkChange: 'onCheckChange'
- },
- renderer: function (value, metaData, record) {
- 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 70b99f1b..b920c181 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,22 @@ 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]];
+ 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) {