diff options
Diffstat (limited to 'apps/user_ldap/js/wizard/wizardTabGeneric.js')
-rw-r--r-- | apps/user_ldap/js/wizard/wizardTabGeneric.js | 76 |
1 files changed, 57 insertions, 19 deletions
diff --git a/apps/user_ldap/js/wizard/wizardTabGeneric.js b/apps/user_ldap/js/wizard/wizardTabGeneric.js index 21085e3a584..3496dee5009 100644 --- a/apps/user_ldap/js/wizard/wizardTabGeneric.js +++ b/apps/user_ldap/js/wizard/wizardTabGeneric.js @@ -1,8 +1,7 @@ - /** - * Copyright (c) 2015, Arthur Schiwon <blizzz@owncloud.com> - * This file is licensed under the Affero General Public License version 3 or later. - * See the COPYING-README file. + * SPDX-FileCopyrightText: 2017-2024 Nextcloud GmbH and Nextcloud contributors + * SPDX-FileCopyrightText: 2015-2016 ownCloud, Inc. + * SPDX-License-Identifier: AGPL-3.0-or-later */ OCA = OCA || {}; @@ -29,7 +28,7 @@ OCA = OCA || {}; bjQuiButtonClass: 'ui-button', /** - * @property {bool} - indicates whether a filter mode toggle operation + * @property {boolean} - indicates whether a filter mode toggle operation * is still in progress */ isToggling: false, @@ -53,6 +52,7 @@ OCA = OCA || {}; setManagedItems: function(managedItems) { this.managedItems = managedItems; this._enableAutoSave(); + this._enableSaveButton(); }, /** @@ -73,7 +73,7 @@ OCA = OCA || {}; /** * the method can be used to display a different error/information - * message than provided by the ownCloud server response. The concrete + * message than provided by the Nextcloud server response. The concrete * Tab View may optionally implement it. Returning an empty string will * avoid any notification. * @@ -146,8 +146,8 @@ OCA = OCA || {}; /** * displays server error messages. * - * @param view - * @param payload + * @param {any} view - + * @param {any} payload - */ onServerError: function(view, payload) { if ( !_.isUndefined(view.managedItems[payload.relatedKey])) { @@ -227,10 +227,12 @@ OCA = OCA || {}; * @param {Array} options */ equipMultiSelect: function($element, options) { - $element.empty(); - for (var i in options) { - var name = options[i]; - $element.append($('<option>').val(name).text(name).attr('title', name)); + if($element.find('option').length === 0) { + $element.empty(); + for (var i in options) { + var name = options[i]; + $element.append($('<option>').val(name).text(name).attr('title', name)); + } } if(!$element.hasClass('ldapGroupList')) { $element.multiselect('refresh'); @@ -319,7 +321,10 @@ OCA = OCA || {}; for(var id in this.managedItems) { if(_.isUndefined(this.managedItems[id].$element) - || _.isUndefined(this.managedItems[id].setMethod)) { + || _.isUndefined(this.managedItems[id].setMethod) + || (!_.isUndefined(this.managedItems[id].preventAutoSave) + && this.managedItems[id].preventAutoSave === true) + ) { continue; } var $element = this.managedItems[id].$element; @@ -332,6 +337,39 @@ OCA = OCA || {}; }, /** + * set's up save-button behavior (essentially used for agent dn and pwd) + * + * @private + */ + _enableSaveButton: function() { + var view = this; + + // TODO: this is not nice, because it fires one request per change + // in the scenario this happens twice, causes detectors to run + // duplicated etc. To have this work properly, the wizard endpoint + // must accept setting multiple changes. Instead of messing around + // with old ajax/wizard.php use this opportunity and create a + // Controller + for(var id in this.managedItems) { + if(_.isUndefined(this.managedItems[id].$element) + || _.isUndefined(this.managedItems[id].$saveButton) + ) { + continue; + } + (function (item) { + item.$saveButton.click(function(event) { + event.preventDefault(); + view._requestSave(item.$element); + item.$saveButton.removeClass('primary'); + }); + item.$element.change(function () { + item.$saveButton.addClass('primary'); + }); + })(this.managedItems[id]); + } + }, + + /** * initializes a multiSelect element * * @param {jQuery} $element @@ -353,9 +391,9 @@ OCA = OCA || {}; /** * @typedef {object} viewSaveInfo - * @property {function} val - * @property {function} attr - * @property {function} is + * @property {Function} val + * @property {Function} attr + * @property {Function} is */ /** @@ -391,7 +429,7 @@ OCA = OCA || {}; */ _setCheckBox: function($element, value) { if(parseInt(value, 10) === 1) { - $element.attr('checked', 'checked'); + $element.prop('checked', 'checked'); } else { $element.removeAttr('checked'); } @@ -417,7 +455,7 @@ OCA = OCA || {}; * sets the filter mode initially and resets the "isToggling" marker. * This method is called after a save operation against the mode key. * - * @param mode + * @param {any} mode - */ setFilterModeOnce: function(mode) { this.isToggling = false; @@ -514,7 +552,7 @@ OCA = OCA || {}; ) { toggleFnc(true); } else { - OCdialogs.confirm( + OC.dialogs.confirm( t('user_ldap', 'Switching the mode will enable automatic LDAP queries. Depending on your LDAP size they may take a while. Do you still want to switch the mode?'), t('user_ldap', 'Mode switch'), toggleFnc |