summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorwinh <winnie@gitlab.com>2017-08-31 12:59:28 +0200
committerwinh <winnie@gitlab.com>2017-09-05 11:41:58 +0200
commita1e992e553c7fb3094f24352caf73bde35dfe08f (patch)
tree8fab65a54546ef529d0cc384c203ea93339204ff
parent601a5d73f7a653365c2f198888a63d94dbcede48 (diff)
downloadgitlab-ce-winh-search-dropdowns.tar.gz
Support null values in GitLabDropdownwinh-search-dropdowns
-rw-r--r--app/assets/javascripts/gl_dropdown.js14
1 files changed, 9 insertions, 5 deletions
diff --git a/app/assets/javascripts/gl_dropdown.js b/app/assets/javascripts/gl_dropdown.js
index d65bbc0d808..6f7671aa6fe 100644
--- a/app/assets/javascripts/gl_dropdown.js
+++ b/app/assets/javascripts/gl_dropdown.js
@@ -637,11 +637,15 @@ GitLabDropdown = (function() {
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;
+ if (value) {
+ value = value.toString().replace(/'/g, '\\\'');
+ field = this.dropdown.parent().find(`input[name='${fieldName}'][value='${value}']`);
+ if (field.length) {
+ selected = true;
+ }
+ } else {
+ field = this.dropdown.parent().find(`input[name='${fieldName}']`);
+ selected = !field.length;
}
}
// Set URL