diff --git a/app/assets/javascripts/gl_dropdown.js.coffee b/app/assets/javascripts/gl_dropdown.js.coffee index 2b56ab2e6de..b03a95a80e8 100644 --- a/app/assets/javascripts/gl_dropdown.js.coffee +++ b/app/assets/javascripts/gl_dropdown.js.coffee @@ -145,11 +145,10 @@ class GitLabDropdown selector = ".dropdown-page-one .dropdown-content a" @dropdown.on "click", selector, (e) -> - e.preventDefault() - self.rowClicked $(@) + selected = self.rowClicked $(@) if self.options.clicked - self.options.clicked.call(@,e) + self.options.clicked(selected) toggleLoading: -> $('.dropdown-menu', @dropdown).toggleClass LOADING_CLASS @@ -288,6 +287,10 @@ class GitLabDropdown if el.hasClass(ACTIVE_CLASS) el.removeClass(ACTIVE_CLASS) field.remove() + + # Toggle the dropdown label + if @options.toggleLabel + $(@el).find(".dropdown-toggle-text").text @options.toggleLabel else fieldName = @options.fieldName selectedIndex = el.parent().index() @@ -304,7 +307,7 @@ class GitLabDropdown @dropdown.parent().find("input[name='#{fieldName}']").remove() # Toggle active class for the tick mark - el.toggleClass "is-active" + el.addClass ACTIVE_CLASS # Toggle the dropdown label if @options.toggleLabel @@ -313,11 +316,15 @@ class GitLabDropdown if !field.length # Create hidden input for form input = "" - if @options.inputId? + if @options.inputId? input = $(input) .attr('id', @options.inputId) @dropdown.before input + @dropdown.parent().find("input[name='#{fieldName}']").val value + + return selectedObject + selectFirstRow: -> selector = '.dropdown-content li:first-child a' if @dropdown.find(".dropdown-toggle-page").length diff --git a/app/assets/javascripts/issues.js.coffee b/app/assets/javascripts/issues.js.coffee index 1127b289264..b1479bfb449 100644 --- a/app/assets/javascripts/issues.js.coffee +++ b/app/assets/javascripts/issues.js.coffee @@ -1,7 +1,6 @@ @Issues = init: -> Issues.initSearch() - Issues.initSelects() Issues.initChecks() $("body").on "ajax:success", ".close_issue, .reopen_issue", -> @@ -17,18 +16,9 @@ $(this).html totalIssues - 1 reload: -> - Issues.initSelects() Issues.initChecks() $('#filter_issue_search').val($('#issue_search').val()) - initSelects: -> - $("select#update_state_event").select2(width: 'resolve', dropdownAutoWidth: true) - $("select#update_assignee_id").select2(width: 'resolve', dropdownAutoWidth: true) - $("select#update_milestone_id").select2(width: 'resolve', dropdownAutoWidth: true) - $("select#label_name").select2(width: 'resolve', dropdownAutoWidth: true) - $("#milestone_id, #assignee_id, #label_name").on "change", -> - $(this).closest("form").submit() - initChecks: -> $(".check_all_issues").click -> $(".selected_issue").prop("checked", @checked) diff --git a/app/assets/javascripts/labels_select.js.coffee b/app/assets/javascripts/labels_select.js.coffee index b5c7af9a8ad..e69a9e3e4b1 100644 --- a/app/assets/javascripts/labels_select.js.coffee +++ b/app/assets/javascripts/labels_select.js.coffee @@ -231,13 +231,14 @@ class @LabelsSelect saveLabelData() multiSelect: $dropdown.hasClass 'js-multiselect' - - clicked: -> + clicked: (label) -> page = $('body').data 'page' isIssueIndex = page is 'projects:issues:index' isMRIndex = page is page is 'projects:merge_requests:index' if $dropdown.hasClass('js-filter-submit') and (isIssueIndex or isMRIndex) + selectedLabel = label.title + Issues.filterResults $dropdown.closest('form') else if $dropdown.hasClass 'js-filter-submit' $dropdown.closest('form').submit() diff --git a/app/assets/javascripts/milestone_select.js.coffee b/app/assets/javascripts/milestone_select.js.coffee index d1746c38e74..5f5f38e0d47 100644 --- a/app/assets/javascripts/milestone_select.js.coffee +++ b/app/assets/javascripts/milestone_select.js.coffee @@ -27,6 +27,18 @@ class @MilestoneSelect milestoneLinkNoneTemplate = '
None
' + extraOptions = [{ + isAny: true + title: 'Any Milestone' + }, { + id: '0' + title: 'No Milestone' + }, { + upcoming: true + id: '#upcoming' + title: 'Upcoming' + }] + $dropdown.glDropdown( data: (term, callback) -> $.ajax( @@ -73,11 +85,13 @@ class @MilestoneSelect hidden: -> $selectbox.hide() $value.show() - clicked: (e) -> + clicked: (selected) -> if $dropdown.hasClass 'js-filter-bulk-update' return - + if $dropdown.hasClass 'js-filter-submit' + if selected.title? + selectedMilestone = selected.title $dropdown.parents('form').submit() else selected = $selectbox @@ -104,4 +118,4 @@ class @MilestoneSelect $value.html(milestoneLinkTemplate(data.milestone)) else $value.html(milestoneLinkNoneTemplate) - ) \ No newline at end of file + ) diff --git a/app/assets/javascripts/users_select.js.coffee b/app/assets/javascripts/users_select.js.coffee index 3262d8b8c90..aec13e54c98 100644 --- a/app/assets/javascripts/users_select.js.coffee +++ b/app/assets/javascripts/users_select.js.coffee @@ -133,7 +133,7 @@ class @UsersSelect $selectbox.hide() $value.show() - clicked: -> + clicked: (user) -> page = $('body').data 'page' isIssueIndex = page is 'projects:issues:index' isMRIndex = page is page is 'projects:merge_requests:index' @@ -141,6 +141,7 @@ class @UsersSelect return if $dropdown.hasClass('js-filter-submit') and (isIssueIndex or isMRIndex) + selectedId = user.id Issues.filterResults $dropdown.closest('form') else if $dropdown.hasClass 'js-filter-submit' $dropdown.closest('form').submit() diff --git a/app/finders/issuable_finder.rb b/app/finders/issuable_finder.rb index 046286dd9e1..a7799b91eb8 100644 --- a/app/finders/issuable_finder.rb +++ b/app/finders/issuable_finder.rb @@ -243,7 +243,7 @@ class IssuableFinder end def filter_by_upcoming_milestone? - params[:milestone_title] == '#upcoming' + params[:milestone_title] == 'Upcoming' end def by_milestone(items) @@ -252,7 +252,7 @@ class IssuableFinder items = items.where(milestone_id: [-1, nil]) elsif filter_by_upcoming_milestone? upcoming = Milestone.where(project_id: projects).upcoming - items = items.joins(:milestone).where(milestones: { title: upcoming.title }) + items = items.joins(:milestone).where(milestones: { title: upcoming.try(:title) }) else items = items.joins(:milestone).where(milestones: { title: params[:milestone_title] })