Fix "Other" value handling in quota dropdown in users page

Prevents "other" value to be deleted.
When appending custom value, put it above the "other" entry.
This commit is contained in:
Vincent Petry 2016-06-23 18:42:11 +02:00
parent cc2aec11af
commit 9092d7f5ea
1 changed files with 9 additions and 3 deletions

View File

@ -138,10 +138,13 @@ var UserList = {
.find('option').attr('selected', null) .find('option').attr('selected', null)
.first().attr('selected', 'selected'); .first().attr('selected', 'selected');
} else { } else {
if ($quotaSelect.find('option').filterAttr('value', user.quota).length > 0) { var $options = $quotaSelect.find('option');
$quotaSelect.find('option').filterAttr('value', user.quota).attr('selected', 'selected'); var $foundOption = $options.filterAttr('value', user.quota);
if ($foundOption.length > 0) {
$foundOption.attr('selected', 'selected');
} else { } else {
$quotaSelect.append('<option value="' + escapeHTML(user.quota) + '" selected="selected">' + escapeHTML(user.quota) + '</option>'); // append before "Other" entry
$options.last().before('<option value="' + escapeHTML(user.quota) + '" selected="selected">' + escapeHTML(user.quota) + '</option>');
} }
} }
@ -576,6 +579,9 @@ var UserList = {
var $select = $(ev.target); var $select = $(ev.target);
var uid = UserList.getUID($select); var uid = UserList.getUID($select);
var quota = $select.val(); var quota = $select.val();
if (quota === 'other') {
return;
}
UserList._updateQuota(uid, quota, function(returnedQuota){ UserList._updateQuota(uid, quota, function(returnedQuota){
if (quota !== returnedQuota) { if (quota !== returnedQuota) {
$select.find(':selected').text(returnedQuota); $select.find(':selected').text(returnedQuota);