diff options
author | Jacob Schatz <jschatz@gitlab.com> | 2016-09-16 01:23:07 +0300 |
---|---|---|
committer | Rémy Coutable <remy@rymai.me> | 2016-09-19 17:09:10 +0300 |
commit | 98ac1eee3e758ac856b01c7c0b3c6f6e030dd992 (patch) | |
tree | 6d66c69670b558d7be187821f5ff34e2f63d3e67 | |
parent | 3a713ef1badabd8ab91bee24b88bad54267d4df1 (diff) |
Merge branch 'ee-919-backport-changes' into 'master'
Restore gl_dropdown.js changes
Restores `fieldName` to allow only string values. `fieldName` was changed to accept function as a value in https://gitlab.com/gitlab-org/gitlab-ee/merge_requests/581 Since the approach changed in https://gitlab.com/gitlab-org/gitlab-ee/merge_requests/687 there's no need to accept function as value.
Backport changes from https://gitlab.com/gitlab-org/gitlab-ee/merge_requests/687
EE Issue: https://gitlab.com/gitlab-org/gitlab-ee/issues/919
See merge request !6234
Signed-off-by: Rémy Coutable <remy@rymai.me>
-rw-r--r-- | CHANGELOG | 1 | ||||
-rw-r--r-- | app/assets/javascripts/gl_dropdown.js | 20 |
2 files changed, 10 insertions, 11 deletions
diff --git a/CHANGELOG b/CHANGELOG index dd8049e8638..4f7681894e3 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -1,6 +1,7 @@ Please view this file on the master branch, on stable branches it's out of date. v 8.11.7 + - Restores `fieldName` to allow only string values in `gl_dropdown.js`. !6234 - Allow the Rails cookie to be used for API authentication. v 8.11.6 diff --git a/app/assets/javascripts/gl_dropdown.js b/app/assets/javascripts/gl_dropdown.js index 77b2082cba0..8714ddb3136 100644 --- a/app/assets/javascripts/gl_dropdown.js +++ b/app/assets/javascripts/gl_dropdown.js @@ -322,7 +322,13 @@ if (self.options.clicked) { self.options.clicked(selected, $el, e); } - return $el.trigger('blur'); + + // Update label right after all modifications in dropdown has been done + if (self.options.toggleLabel) { + self.updateLabel(selected, $el, self); + } + + $el.trigger('blur'); }); } } @@ -482,7 +488,7 @@ } else { if (!selected) { value = this.options.id ? this.options.id(data) : data.id; - fieldName = typeof this.options.fieldName === 'function' ? this.options.fieldName() : this.options.fieldName; + fieldName = this.options.fieldName; field = this.dropdown.parent().find("input[name='" + fieldName + "'][value='" + value + "']"); if (field.length) { @@ -540,6 +546,7 @@ GitLabDropdown.prototype.rowClicked = function(el) { var field, fieldName, groupName, isInput, selectedIndex, selectedObject, value; + fieldName = this.options.fieldName; isInput = $(this.el).is('input'); if (this.renderedData) { groupName = el.data('group'); @@ -551,7 +558,6 @@ selectedObject = this.renderedData[selectedIndex]; } } - fieldName = typeof this.options.fieldName === 'function' ? this.options.fieldName(selectedObject) : this.options.fieldName; value = this.options.id ? this.options.id(selectedObject, el) : selectedObject.id; if (isInput) { field = $(this.el); @@ -594,11 +600,6 @@ } } - // Update label right after input has been added - if (this.options.toggleLabel) { - this.updateLabel(selectedObject, el, this); - } - return selectedObject; }; @@ -608,9 +609,6 @@ if (this.options.inputId != null) { $input.attr('id', this.options.inputId); } - if (selectedObject && selectedObject.type) { - $input.attr('data-type', selectedObject.type); - } return this.dropdown.before($input); }; |