[Pkg-owncloud-commits] [owncloud] 09/215: LDAP Wizard: have always-increasing 'nth Server' number per full page load, fixes #15766

David Prévot taffit at moszumanska.debian.org
Tue May 5 01:01:12 UTC 2015


This is an automated email from the git hooks/post-receive script.

taffit pushed a commit to branch stable8
in repository owncloud.

commit 8593415c12cc4b675e2740e46f637125fd2d6b75
Author: Arthur Schiwon <blizzz at owncloud.com>
Date:   Tue Apr 21 13:14:35 2015 +0200

    LDAP Wizard: have always-increasing 'nth Server' number per full page load, fixes #15766
---
 apps/user_ldap/js/wizard/wizardTabElementary.js | 34 +++++++++++++++++--------
 1 file changed, 23 insertions(+), 11 deletions(-)

diff --git a/apps/user_ldap/js/wizard/wizardTabElementary.js b/apps/user_ldap/js/wizard/wizardTabElementary.js
index c7767b9..9619f9f 100644
--- a/apps/user_ldap/js/wizard/wizardTabElementary.js
+++ b/apps/user_ldap/js/wizard/wizardTabElementary.js
@@ -14,6 +14,9 @@ OCA = OCA || {};
 	 * in the LDAP wizard.
 	 */
 	var WizardTabElementary = OCA.LDAP.Wizard.WizardTabGeneric.subClass({
+		/** @property {number} */
+		_configChooserNextServerNumber: 1,
+
 		/**
 		 * initializes the instance. Always call it after initialization.
 		 *
@@ -24,7 +27,7 @@ OCA = OCA || {};
 			tabIndex = 0;
 			this._super(tabIndex, tabID);
 			this.isActive = true;
-			this.configChooserID = '#ldap_serverconfig_chooser';
+			this.$configChooser = $('#ldap_serverconfig_chooser');
 
 			var items = {
 				ldap_host: {
@@ -88,7 +91,7 @@ OCA = OCA || {};
 		 * @returns {string}
 		 */
 		getConfigID: function() {
-			return $(this.configChooserID).val();
+			return this.$configChooser.val();
 		},
 
 		/**
@@ -204,9 +207,17 @@ OCA = OCA || {};
 		 */
 		onNewConfiguration: function(view, result) {
 			if(result.isSuccess === true) {
-				$(view.configChooserID + ' option:selected').removeAttr('selected');
-				var html = '<option value="'+result.configPrefix+'" selected="selected">'+t('user_ldap','{nthServer}. Server', {nthServer: $(view.configChooserID + ' option').length + 1})+'</option>';
-				$(view.configChooserID + ' option:last').after(html);
+				console.log('new config');
+				var nthServer = view._configChooserNextServerNumber;
+				view.$configChooser.find('option:selected').removeAttr('selected');
+				var html = '<option value="'+result.configPrefix+'" selected="selected">'+t('user_ldap','{nthServer}. Server', {nthServer: nthServer})+'</option>';
+				if(view.$configChooser.find('option:last').length > 0) {
+					view.$configChooser.find('option:last').after(html);
+				} else {
+					view.$configChooser.html(html);
+				}
+
+				view._configChooserNextServerNumber++;
 			}
 		},
 
@@ -222,16 +233,16 @@ OCA = OCA || {};
 				if(view.getConfigID() === result.configPrefix) {
 					// if the deleted value is still the selected one (99% of
 					// the cases), remove it from the list and load the topmost
-					$(view.configChooserID + ' option:selected').remove();
-					$(view.configChooserID + ' option:first').select();
-					if($(view.configChooserID +  ' option').length < 2) {
+					view.$configChooser.find('option:selected').remove();
+					view.$configChooser.find('option:first').select();
+					if(view.$configChooser.find(' option').length < 1) {
 						view.configModel.newConfig(false);
 					} else {
 						view.configModel.load(view.getConfigID());
 					}
 				} else {
 					// otherwise just remove the entry
-					$(view.configChooserID + ' option[value=' + result.configPrefix + ']').remove();
+					view.$configChooser.find('option[value=' + result.configPrefix + ']').remove();
 				}
 			} else {
 				OC.Notification.showTemporary(result.errorMessage);
@@ -303,9 +314,10 @@ OCA = OCA || {};
 		 * @private
 		 */
 		_enableConfigChooser: function() {
+			this._configChooserNextServerNumber = this.$configChooser.find(' option').length + 1;
 			var view = this;
-			$(this.configChooserID).change(function(){
-				var value = $(view.configChooserID + ' option:selected:first').attr('value');
+			this.$configChooser.change(function(){
+				var value = view.$configChooser.find(' option:selected:first').attr('value');
 				view.configModel.load(value);
 			});
 		},

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-owncloud/owncloud.git



More information about the Pkg-owncloud-commits mailing list