From 7744b67f7518727dceb83682402772432870cdab Mon Sep 17 00:00:00 2001 From: Phil Hughes Date: Tue, 8 Mar 2016 15:18:01 +0000 Subject: Stops excute remote data fetcher when already recieved data --- app/assets/javascripts/gl_dropdown.js.coffee | 3 ++- app/assets/javascripts/labels_select.js.coffee | 18 +++++++++++++++++- 2 files changed, 19 insertions(+), 2 deletions(-) (limited to 'app/assets/javascripts') diff --git a/app/assets/javascripts/gl_dropdown.js.coffee b/app/assets/javascripts/gl_dropdown.js.coffee index a714ba3d675..591e0b6f41d 100644 --- a/app/assets/javascripts/gl_dropdown.js.coffee +++ b/app/assets/javascripts/gl_dropdown.js.coffee @@ -148,7 +148,8 @@ class GitLabDropdown @appendMenu(full_html) opened: => - if @remote + contentHtml = $('.dropdown-content', @dropdown).html() + if @remote && contentHtml is "" @remote.execute() if @options.filterable diff --git a/app/assets/javascripts/labels_select.js.coffee b/app/assets/javascripts/labels_select.js.coffee index 14ee529ba35..b4708f6537a 100644 --- a/app/assets/javascripts/labels_select.js.coffee +++ b/app/assets/javascripts/labels_select.js.coffee @@ -6,6 +6,8 @@ class @LabelsSelect selectedLabel = $(dropdown).data('selected') newLabelField = $('#new_label_name') newColorField = $('#new_label_color') + showNo = $(dropdown).data('show-no') + showAny = $(dropdown).data('show-any') if newLabelField.length $('.suggest-colors-dropdown a').on "click", (e) -> @@ -45,6 +47,20 @@ class @LabelsSelect title: $(@).text().trim() ) + if showNo + data.unshift( + id: "0" + title: 'No label' + ) + + if showAny + data.unshift( + title: 'Any label' + ) + + if data.length > 2 + data.splice 2, 0, "divider" + callback data renderRow: (label) -> selected = if label.title is selectedLabel then "is-active" else "" @@ -56,7 +72,7 @@ class @LabelsSelect " filterable: true search: - fields: ['name'] + fields: ['title'] selectable: true fieldName: $(dropdown).data('field-name') id: (label) -> -- cgit v1.2.1