aboutsummaryrefslogtreecommitdiff
path: root/web/app
diff options
context:
space:
mode:
authorAbyss777 <abyss@fox5.ru>2016-12-02 15:59:45 +0700
committerAbyss777 <abyss@fox5.ru>2016-12-04 17:47:22 +0700
commita3641de343252f405df7970c97c72fff3e7405b9 (patch)
tree837ca1f3382fd67fd1c2a12b56d3f553e6741242 /web/app
parentf8bf7ede29f2e063a30721e8ed415a6184646424 (diff)
downloadetbsa-traccar-web-a3641de343252f405df7970c97c72fff3e7405b9.tar.gz
etbsa-traccar-web-a3641de343252f405df7970c97c72fff3e7405b9.tar.bz2
etbsa-traccar-web-a3641de343252f405df7970c97c72fff3e7405b9.zip
Use model instead of attributes to store notifications options
Diffstat (limited to 'web/app')
-rw-r--r--web/app/model/Notification.js12
-rw-r--r--web/app/store/Notifications.js4
-rw-r--r--web/app/view/Notifications.js6
-rw-r--r--web/app/view/NotificationsController.js31
4 files changed, 15 insertions, 38 deletions
diff --git a/web/app/model/Notification.js b/web/app/model/Notification.js
index 04dca9b..54f6674 100644
--- a/web/app/model/Notification.js
+++ b/web/app/model/Notification.js
@@ -17,7 +17,7 @@
Ext.define('Traccar.model.Notification', {
extend: 'Ext.data.Model',
- identifier: 'negative',
+ idProperty: 'type',
fields: [{
name: 'id',
@@ -31,12 +31,10 @@ Ext.define('Traccar.model.Notification', {
}, {
name: 'attributes'
}, {
- name: 'attributes.web',
- type: 'bool',
- mapping: 'attributes.web'
+ name: 'web',
+ type: 'bool'
}, {
- name: 'attributes.mail',
- type: 'bool',
- mapping: 'attributes.mail'
+ name: 'mail',
+ type: 'bool'
}]
});
diff --git a/web/app/store/Notifications.js b/web/app/store/Notifications.js
index e4d2991..d79702f 100644
--- a/web/app/store/Notifications.js
+++ b/web/app/store/Notifications.js
@@ -22,5 +22,7 @@ Ext.define('Traccar.store.Notifications', {
proxy: {
type: 'rest',
url: 'api/users/notifications'
- }
+ },
+ sortOnLoad: true,
+ sorters: { property: 'type', direction : 'ASC' }
});
diff --git a/web/app/view/Notifications.js b/web/app/view/Notifications.js
index 795cf32..419d961 100644
--- a/web/app/view/Notifications.js
+++ b/web/app/view/Notifications.js
@@ -24,7 +24,7 @@ Ext.define('Traccar.view.Notifications', {
],
controller: 'notificationsController',
- store: 'AllNotifications',
+ store: 'Notifications',
selModel: {
selType: 'cellmodel'
@@ -48,14 +48,14 @@ Ext.define('Traccar.view.Notifications', {
}
}, {
text: Strings.notificationWeb,
- dataIndex: 'attributes.web',
+ dataIndex: 'web',
xtype: 'checkcolumn',
listeners: {
checkChange: 'onCheckChange'
}
}, {
text: Strings.notificationMail,
- dataIndex: 'attributes.mail',
+ dataIndex: 'mail',
xtype: 'checkcolumn',
listeners: {
checkChange: 'onCheckChange'
diff --git a/web/app/view/NotificationsController.js b/web/app/view/NotificationsController.js
index b920c18..4c83b14 100644
--- a/web/app/view/NotificationsController.js
+++ b/web/app/view/NotificationsController.js
@@ -24,42 +24,19 @@ Ext.define('Traccar.view.NotificationsController', {
],
init: function () {
- this.userId = this.getView().user.getId();
this.getView().getStore().load({
- scope: this,
- callback: function (records, operation, success) {
- Ext.create('Traccar.store.Notifications').load({
- params: {
- userId: this.userId
- },
- scope: this,
- callback: function (records, operation, success) {
- if (success) {
- this.getView().getStore().loadData(records);
- }
- }
- });
+ params: {
+ userId: this.getView().user.getId()
}
});
},
onCheckChange: function (column, rowIndex, checked, eOpts) {
- var record, attributes = {};
- record = this.getView().getStore().getAt(rowIndex);
- if (record.get('attributes.web')) {
- attributes.web = 'true';
- }
- if (record.get('attributes.mail')) {
- attributes.mail = 'true';
- }
+ 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: attributes
- },
+ jsonData: record.data,
callback: function (options, success, response) {
if (!success) {
Traccar.app.showError(response);