From f8e90b20d08bbd00cd7d5657c91c364b47288ae6 Mon Sep 17 00:00:00 2001 From: Abyss777 Date: Sat, 11 Mar 2017 10:53:33 +0500 Subject: - Pass selfEdit parameter to UserDialog - Group Geofence fields --- web/app/view/GeofenceDialog.js | 48 ++++++++++++++++++++-------------- web/app/view/SettingsMenuController.js | 4 ++- web/app/view/UserDialog.js | 12 +++------ web/app/view/UserDialogController.js | 11 ++++---- web/app/view/UsersController.js | 9 +++++++ 5 files changed, 49 insertions(+), 35 deletions(-) diff --git a/web/app/view/GeofenceDialog.js b/web/app/view/GeofenceDialog.js index f55a8b2..4c2781e 100644 --- a/web/app/view/GeofenceDialog.js +++ b/web/app/view/GeofenceDialog.js @@ -28,26 +28,36 @@ Ext.define('Traccar.view.GeofenceDialog', { items: { xtype: 'form', items: [{ - xtype: 'textfield', - name: 'name', - fieldLabel: Strings.sharedName + xtype: 'fieldset', + title: Strings.sharedRequired, + items: [{ + xtype: 'textfield', + name: 'name', + fieldLabel: Strings.sharedName + }] }, { - xtype: 'textfield', - name: 'description', - fieldLabel: Strings.sharedDescription - }, { - xtype: 'combobox', - name: 'calendarId', - store: 'Calendars', - queryMode: 'local', - displayField: 'name', - valueField: 'id', - fieldLabel: Strings.sharedCalendar - }, { - xtype: 'hiddenfield', - name: 'area', - allowBlank: false, - reference: 'areaField' + xtype: 'fieldset', + title: Strings.sharedExtra, + collapsible: true, + collapsed: true, + items: [{ + xtype: 'textfield', + name: 'description', + fieldLabel: Strings.sharedDescription + }, { + xtype: 'combobox', + name: 'calendarId', + store: 'Calendars', + queryMode: 'local', + displayField: 'name', + valueField: 'id', + fieldLabel: Strings.sharedCalendar + }, { + xtype: 'hiddenfield', + name: 'area', + allowBlank: false, + reference: 'areaField' + }] }] }, diff --git a/web/app/view/SettingsMenuController.js b/web/app/view/SettingsMenuController.js index 41867f6..8d1e563 100644 --- a/web/app/view/SettingsMenuController.js +++ b/web/app/view/SettingsMenuController.js @@ -61,7 +61,9 @@ Ext.define('Traccar.view.SettingsMenuController', { }, onUserClick: function () { - var dialog = Ext.create('Traccar.view.UserDialog'); + var dialog = Ext.create('Traccar.view.UserDialog', { + selfEdit: true + }); dialog.down('form').loadRecord(Traccar.app.getUser()); dialog.lookupReference('testNotificationButton').setHidden(false); dialog.show(); diff --git a/web/app/view/UserDialog.js b/web/app/view/UserDialog.js index 5e4e00a..d4235e9 100644 --- a/web/app/view/UserDialog.js +++ b/web/app/view/UserDialog.js @@ -123,7 +123,7 @@ Ext.define('Traccar.view.UserDialog', { uncheckedValue: false, name: 'disabled', fieldLabel: Strings.userDisabled, - hidden: true, + disabled: true, reference: 'disabledField' }, { xtype: 'checkboxfield', @@ -131,8 +131,7 @@ Ext.define('Traccar.view.UserDialog', { uncheckedValue: false, name: 'admin', fieldLabel: Strings.userAdmin, - allowBlank: false, - hidden: true, + disabled: true, reference: 'adminField' }, { xtype: 'checkboxfield', @@ -140,8 +139,7 @@ Ext.define('Traccar.view.UserDialog', { uncheckedValue: false, name: 'readonly', fieldLabel: Strings.serverReadonly, - allowBlank: false, - hidden: true, + disabled: true, reference: 'readonlyField' }, { xtype: 'checkboxfield', @@ -186,10 +184,6 @@ Ext.define('Traccar.view.UserDialog', { }] }, - listeners: { - show: 'onShow' - }, - buttons: [{ text: Strings.sharedAttributes, handler: 'showAttributesView' diff --git a/web/app/view/UserDialogController.js b/web/app/view/UserDialogController.js index d187dec..f001dea 100644 --- a/web/app/view/UserDialogController.js +++ b/web/app/view/UserDialogController.js @@ -19,16 +19,15 @@ Ext.define('Traccar.view.UserDialogController', { extend: 'Traccar.view.MapPickerDialogController', alias: 'controller.userDialog', - onShow: function () { + init: function () { if (Traccar.app.getUser().get('admin')) { - this.lookupReference('adminField').setHidden(false); + this.lookupReference('adminField').setDisabled(false); this.lookupReference('deviceLimitField').setDisabled(false); this.lookupReference('userLimitField').setDisabled(false); } - if (Traccar.app.getUser().get('admin') || - Traccar.app.getUser().getId() !== this.getView().down('form').getRecord().getId()) { - this.lookupReference('readonlyField').setHidden(false); - this.lookupReference('disabledField').setHidden(false); + if (Traccar.app.getUser().get('admin') || !this.getView().selfEdit) { + this.lookupReference('readonlyField').setDisabled(false); + this.lookupReference('disabledField').setDisabled(false); this.lookupReference('expirationTimeField').setDisabled(false); this.lookupReference('deviceReadonlyField').setDisabled(false); } diff --git a/web/app/view/UsersController.js b/web/app/view/UsersController.js index 2744be7..a79f958 100644 --- a/web/app/view/UsersController.js +++ b/web/app/view/UsersController.js @@ -41,6 +41,15 @@ Ext.define('Traccar.view.UsersController', { this.lookupReference('userUsersButton').setHidden(!Traccar.app.getUser().get('admin')); }, + onEditClick: function () { + var dialog, user = this.getView().getSelectionModel().getSelection()[0]; + dialog = Ext.create('Traccar.view.UserDialog', { + selfEdit: user.get('id') === Traccar.app.getUser().get('id') + }); + dialog.down('form').loadRecord(user); + dialog.show(); + }, + onAddClick: function () { var user, dialog; user = Ext.create('Traccar.model.User'); -- cgit v1.2.3