diff options
author | Rémy Coutable <remy@rymai.me> | 2018-02-21 16:17:03 +0100 |
---|---|---|
committer | Rémy Coutable <remy@rymai.me> | 2018-02-22 13:34:35 +0100 |
commit | 97793a16165243ce3f92395988e8250cc09f4ec8 (patch) | |
tree | 293dc21af5a6d8917d89c77947c977481bb7f1ec /app/assets/javascripts/gl_dropdown.js | |
parent | e818bc67e5b0f8271f1357a282434bb865f6d4d4 (diff) | |
download | gitlab-ce-97793a16165243ce3f92395988e8250cc09f4ec8.tar.gz |
Harmonize CE and EE JS codereduce-ce-ee-disrepancies-in-js
Signed-off-by: Rémy Coutable <remy@rymai.me>
Diffstat (limited to 'app/assets/javascripts/gl_dropdown.js')
-rw-r--r-- | app/assets/javascripts/gl_dropdown.js | 18 |
1 files changed, 15 insertions, 3 deletions
diff --git a/app/assets/javascripts/gl_dropdown.js b/app/assets/javascripts/gl_dropdown.js index e322756f256..6cf78bab6ad 100644 --- a/app/assets/javascripts/gl_dropdown.js +++ b/app/assets/javascripts/gl_dropdown.js @@ -607,7 +607,20 @@ GitLabDropdown = (function() { }; GitLabDropdown.prototype.renderItem = function(data, group, index) { - var field, fieldName, html, selected, text, url, value; + var field, fieldName, html, selected, text, url, value, rowHidden; + + if (!this.options.renderRow) { + value = this.options.id ? this.options.id(data) : data.id; + + if (value) { + value = value.toString().replace(/'/g, '\\\''); + } + } + + // Hide element + if (this.options.hideRow && this.options.hideRow(value)) { + rowHidden = true; + } if (group == null) { group = false; } @@ -616,6 +629,7 @@ GitLabDropdown = (function() { index = false; } html = document.createElement('li'); + if (data === 'divider' || data === 'separator') { html.className = data; return html; @@ -631,11 +645,9 @@ GitLabDropdown = (function() { html = this.options.renderRow.call(this.options, data, this); } else { if (!selected) { - value = this.options.id ? this.options.id(data) : data.id; fieldName = this.options.fieldName; if (value) { - value = value.toString().replace(/'/g, '\\\''); field = this.dropdown.parent().find(`input[name='${fieldName}'][value='${value}']`); if (field.length) { selected = true; |