From 17157262fef1c046d116b2270f4e1d335fe9da1b Mon Sep 17 00:00:00 2001 From: Abyss777 Date: Tue, 26 Jun 2018 12:00:15 +0500 Subject: Implement refactored notifications --- web/app/view/ArrayListFilter.js | 9 ++++++- web/app/view/dialog/Notification.js | 25 +++++++------------- web/app/view/edit/Notifications.js | 33 +++++++++++++++----------- web/app/view/permissions/Notifications.js | 39 +++++++++++++++---------------- 4 files changed, 54 insertions(+), 52 deletions(-) (limited to 'web/app/view') diff --git a/web/app/view/ArrayListFilter.js b/web/app/view/ArrayListFilter.js index b6c1512..e8d1c13 100644 --- a/web/app/view/ArrayListFilter.js +++ b/web/app/view/ArrayListFilter.js @@ -25,7 +25,7 @@ Ext.define('Traccar.view.ArrayListFilter', { constructor: function (config) { this.callParent([config]); this.filter.setFilterFn(function (item) { - var i, property, value; + var i, property, value, splits; property = item.get(this.getProperty()); value = this.getValue(); if (Ext.isArray(property)) { @@ -34,6 +34,13 @@ Ext.define('Traccar.view.ArrayListFilter', { return true; } } + } else if (property.indexOf(',') !== -1) { + splits = property.split(/[ ,]+/).filter(Boolean); + for (i = 0; i < splits.length; i++) { + if (value.indexOf(splits[i]) !== -1) { + return true; + } + } } else if (value.indexOf(property) !== -1) { return true; } diff --git a/web/app/view/dialog/Notification.js b/web/app/view/dialog/Notification.js index 4cba519..dc4362d 100644 --- a/web/app/view/dialog/Notification.js +++ b/web/app/view/dialog/Notification.js @@ -49,23 +49,14 @@ Ext.define('Traccar.view.dialog.Notification', { name: 'always', fieldLabel: Strings.notificationAlways }, { - xtype: 'checkboxfield', - inputValue: true, - uncheckedValue: false, - name: 'web', - fieldLabel: Strings.notificationWeb - }, { - xtype: 'checkboxfield', - inputValue: true, - uncheckedValue: false, - name: 'mail', - fieldLabel: Strings.notificationMail - }, { - xtype: 'checkboxfield', - inputValue: true, - uncheckedValue: false, - name: 'sms', - fieldLabel: Strings.notificationSms + fieldLabel: Strings.notificationNotificators, + xtype: 'tagfield', + name: 'notificators', + maxWidth: Traccar.Style.formFieldWidth, + store: 'AllNotificators', + valueField: 'type', + displayField: 'name', + queryMode: 'local' }] }, { xtype: 'fieldset', diff --git a/web/app/view/edit/Notifications.js b/web/app/view/edit/Notifications.js index 3620682..9e24d3d 100644 --- a/web/app/view/edit/Notifications.js +++ b/web/app/view/edit/Notifications.js @@ -60,20 +60,25 @@ Ext.define('Traccar.view.edit.Notifications', { renderer: Traccar.AttributeFormatter.getFormatter('always'), filter: 'boolean' }, { - text: Strings.notificationWeb, - dataIndex: 'web', - renderer: Traccar.AttributeFormatter.getFormatter('web'), - filter: 'boolean' - }, { - text: Strings.notificationMail, - dataIndex: 'mail', - renderer: Traccar.AttributeFormatter.getFormatter('mail'), - filter: 'boolean' - }, { - text: Strings.notificationSms, - dataIndex: 'sms', - renderer: Traccar.AttributeFormatter.getFormatter('sms'), - filter: 'boolean' + text: Strings.notificationNotificators, + dataIndex: 'notificators', + flex: 2, + filter: { + type: 'arraylist', + idField: 'type', + labelField: 'name', + store: 'AllNotificators' + }, + renderer: function (value) { + var result = '', i, notificators; + if (value) { + notificators = value.split(/[ ,]+/).filter(Boolean); + for (i = 0; i < notificators.length; i++) { + result += Traccar.app.getNotificatorString(notificators[i]) + (i < notificators.length - 1 ? ', ' : ''); + } + } + return result; + } }, { text: Strings.sharedCalendar, dataIndex: 'calendarId', diff --git a/web/app/view/permissions/Notifications.js b/web/app/view/permissions/Notifications.js index e21d277..a8570fe 100644 --- a/web/app/view/permissions/Notifications.js +++ b/web/app/view/permissions/Notifications.js @@ -42,26 +42,25 @@ Ext.define('Traccar.view.permissions.Notifications', { renderer: Traccar.AttributeFormatter.getFormatter('always'), filter: 'boolean' }, { - text: Strings.notificationWeb, - dataIndex: 'web', - flex: 1, - minWidth: Traccar.Style.columnWidthNormal, - renderer: Traccar.AttributeFormatter.getFormatter('web'), - filter: 'boolean' - }, { - text: Strings.notificationMail, - dataIndex: 'mail', - flex: 1, - minWidth: Traccar.Style.columnWidthNormal, - renderer: Traccar.AttributeFormatter.getFormatter('mail'), - filter: 'boolean' - }, { - text: Strings.notificationSms, - dataIndex: 'sms', - flex: 1, - minWidth: Traccar.Style.columnWidthNormal, - renderer: Traccar.AttributeFormatter.getFormatter('sms'), - filter: 'boolean' + text: Strings.notificationNotificators, + dataIndex: 'notificators', + flex: 2, + filter: { + type: 'arraylist', + idField: 'type', + labelField: 'name', + store: 'AllNotificators' + }, + renderer: function (value) { + var result = '', i, notificators; + if (value) { + notificators = value.split(/[ ,]+/).filter(Boolean); + for (i = 0; i < notificators.length; i++) { + result += Traccar.app.getNotificatorString(notificators[i]) + (i < notificators.length - 1 ? ', ' : ''); + } + } + return result; + } }, { text: Strings.sharedCalendar, dataIndex: 'calendarId', -- cgit v1.2.3 From 8e69514733aace4690a9e80a6dd5158d625a66e2 Mon Sep 17 00:00:00 2001 From: Abyss777 Date: Thu, 28 Jun 2018 10:02:41 +0500 Subject: - Make strings more laconic - Make ArrayListFilter consistent --- web/app/Application.js | 2 +- web/app/view/ArrayListFilter.js | 2 +- web/l10n/en.json | 8 ++++---- 3 files changed, 6 insertions(+), 6 deletions(-) (limited to 'web/app/view') diff --git a/web/app/Application.js b/web/app/Application.js index fe92039..d0b6713 100644 --- a/web/app/Application.js +++ b/web/app/Application.js @@ -130,7 +130,7 @@ Ext.define('Traccar.Application', { }, getNotificatorString: function (eventType) { - var key = 'notification' + eventType.charAt(0).toUpperCase() + eventType.slice(1); + var key = 'notificator' + eventType.charAt(0).toUpperCase() + eventType.slice(1); return Strings[key] || key; }, diff --git a/web/app/view/ArrayListFilter.js b/web/app/view/ArrayListFilter.js index e8d1c13..519096e 100644 --- a/web/app/view/ArrayListFilter.js +++ b/web/app/view/ArrayListFilter.js @@ -34,7 +34,7 @@ Ext.define('Traccar.view.ArrayListFilter', { return true; } } - } else if (property.indexOf(',') !== -1) { + } else if (property.match(/[ ,]+/)) { splits = property.split(/[ ,]+/).filter(Boolean); for (i = 0; i < splits.length; i++) { if (value.indexOf(splits[i]) !== -1) { diff --git a/web/l10n/en.json b/web/l10n/en.json index fbb7f01..e6a8a99 100644 --- a/web/l10n/en.json +++ b/web/l10n/en.json @@ -356,10 +356,10 @@ "alarmRemoving": "Removing Alarm", "notificationType": "Type of Notification", "notificationAlways": "All Devices", - "notificationWeb": "Send via Web", - "notificationMail": "Send via Mail", - "notificationSms": "Send via SMS", - "notificationNotificators": "Way of Notification", + "notificationNotificators": "Channels", + "notificatorWeb": "Web", + "notificatorMail": "Mail", + "notificatorSms": "SMS", "reportRoute": "Route", "reportEvents": "Events", "reportTrips": "Trips", -- cgit v1.2.3