diff options
author | Robin Appelman <icewind@owncloud.com> | 2016-02-01 17:44:58 +0100 |
---|---|---|
committer | Robin Appelman <icewind@owncloud.com> | 2016-02-02 15:10:59 +0100 |
commit | f4e1a1677ba6436f089cc8ad6aee5c06e71c4177 (patch) | |
tree | de990e79ab83f4d805c386b3eb2cb032bbeba246 /apps/files_external/js | |
parent | 2d1d89ee29e49412192b051412755610e0538198 (diff) | |
download | nextcloud-server-f4e1a1677ba6436f089cc8ad6aee5c06e71c4177.tar.gz nextcloud-server-f4e1a1677ba6436f089cc8ad6aee5c06e71c4177.zip |
Remove magic flags from files_external backend params
Diffstat (limited to 'apps/files_external/js')
-rw-r--r-- | apps/files_external/js/settings.js | 32 |
1 files changed, 20 insertions, 12 deletions
diff --git a/apps/files_external/js/settings.js b/apps/files_external/js/settings.js index 233215a4aa1..26df203091e 100644 --- a/apps/files_external/js/settings.js +++ b/apps/files_external/js/settings.js @@ -587,6 +587,19 @@ MountOptionsDropdown.prototype = { var MountConfigListView = function($el, options) { this.initialize($el, options); }; + +MountConfigListView.ParameterFlags = { + OPTIONAL: 1, + USER_PROVIDED: 2 +}; + +MountConfigListView.ParameterTypes = { + TEXT: 0, + BOOLEAN: 1, + PASSWORD: 2, + HIDDEN: 3 +}; + /** * @memberOf OCA.External.Settings */ @@ -961,16 +974,15 @@ MountConfigListView.prototype = _.extend({ */ writeParameterInput: function($td, parameter, placeholder, classes) { var hasFlag = function(flag) { - return placeholder.indexOf(flag) !== -1; + return (placeholder.flags & flag) === flag; }; classes = $.isArray(classes) ? classes : []; classes.push('added'); - if (placeholder.indexOf('&') === 0) { + if (hasFlag(MountConfigListView.ParameterFlags.OPTIONAL)) { classes.push('optional'); - placeholder = placeholder.substring(1); } - if (hasFlag('@')) { + if (hasFlag(MountConfigListView.ParameterFlags.USER_PROVIDED)) { if (this._isPersonal) { classes.push('user_provided'); } else { @@ -980,17 +992,13 @@ MountConfigListView.prototype = _.extend({ var newElement; - var trimmedPlaceholder = placeholder; - var flags = ['@', '*', '!', '#', '&']; // used to determine what kind of parameter - while(flags.indexOf(trimmedPlaceholder[0]) !== -1) { - trimmedPlaceholder = trimmedPlaceholder.substr(1); - } - if (hasFlag('*')) { + var trimmedPlaceholder = placeholder.value; + if (placeholder.type === MountConfigListView.ParameterTypes.PASSWORD) { newElement = $('<input type="password" class="'+classes.join(' ')+'" data-parameter="'+parameter+'" placeholder="'+ trimmedPlaceholder+'" />'); - } else if (hasFlag('!')) { + } else if (placeholder.type === MountConfigListView.ParameterTypes.BOOLEAN) { var checkboxId = _.uniqueId('checkbox_'); newElement = $('<input type="checkbox" id="'+checkboxId+'" class="'+classes.join(' ')+'" data-parameter="'+parameter+'" /><label for="'+checkboxId+'">'+ trimmedPlaceholder+'</label>'); - } else if (hasFlag('#')) { + } else if (placeholder.type === MountConfigListView.ParameterTypes.HIDDEN) { newElement = $('<input type="hidden" class="'+classes.join(' ')+'" data-parameter="'+parameter+'" />'); } else { newElement = $('<input type="text" class="'+classes.join(' ')+'" data-parameter="'+parameter+'" placeholder="'+ trimmedPlaceholder+'" />'); |