Commit 911b3d88 authored by Jacob Schatz's avatar Jacob Schatz

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
parents d2370422 c67d2f46
...@@ -352,7 +352,13 @@ ...@@ -352,7 +352,13 @@
if (self.options.clicked) { if (self.options.clicked) {
self.options.clicked(selected, $el, e); 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');
}); });
} }
} }
...@@ -529,7 +535,7 @@ ...@@ -529,7 +535,7 @@
} else { } else {
if (!selected) { if (!selected) {
value = this.options.id ? this.options.id(data) : data.id; 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 + "']"); field = this.dropdown.parent().find("input[name='" + fieldName + "'][value='" + value + "']");
if (field.length) { if (field.length) {
...@@ -589,6 +595,7 @@ ...@@ -589,6 +595,7 @@
GitLabDropdown.prototype.rowClicked = function(el) { GitLabDropdown.prototype.rowClicked = function(el) {
var field, fieldName, groupName, isInput, selectedIndex, selectedObject, value; var field, fieldName, groupName, isInput, selectedIndex, selectedObject, value;
fieldName = this.options.fieldName;
isInput = $(this.el).is('input'); isInput = $(this.el).is('input');
if (this.renderedData) { if (this.renderedData) {
groupName = el.data('group'); groupName = el.data('group');
...@@ -600,7 +607,6 @@ ...@@ -600,7 +607,6 @@
selectedObject = this.renderedData[selectedIndex]; 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; value = this.options.id ? this.options.id(selectedObject, el) : selectedObject.id;
if (isInput) { if (isInput) {
field = $(this.el); field = $(this.el);
...@@ -644,11 +650,6 @@ ...@@ -644,11 +650,6 @@
} }
} }
// Update label right after input has been added
if (this.options.toggleLabel) {
this.updateLabel(selectedObject, el, this);
}
return selectedObject; return selectedObject;
}; };
...@@ -659,9 +660,6 @@ ...@@ -659,9 +660,6 @@
if (this.options.inputId != null) { if (this.options.inputId != null) {
$input.attr('id', this.options.inputId); $input.attr('id', this.options.inputId);
} }
if (selectedObject && selectedObject.type) {
$input.attr('data-type', selectedObject.type);
}
return this.dropdown.before($input); return this.dropdown.before($input);
}; };
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment