summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJacob Schatz <jacobschatz@Jacobs-MBP.fios-router.home>2016-04-09 00:09:09 -0400
committerJacob Schatz <jacobschatz@Jacobs-MBP.fios-router.home>2016-04-13 16:10:49 -0400
commit42e0625dfb2a791affd592df1f879083702e6f86 (patch)
tree328494558d9c9b6a38d576534ed94164f2778a31
parent1617d1e0267f389e040772bfed0dd29e34b25c06 (diff)
downloadgitlab-ce-42e0625dfb2a791affd592df1f879083702e6f86.tar.gz
Filter by multiple labels with little animation.
-rw-r--r--app/assets/javascripts/issues.js.coffee36
-rw-r--r--app/assets/javascripts/labels_select.js.coffee9
-rw-r--r--app/assets/javascripts/lib/animate.js.coffee32
-rw-r--r--app/controllers/projects/issues_controller.rb5
-rw-r--r--app/views/shared/_label_row.html.haml8
-rw-r--r--app/views/shared/issuable/_filter.html.haml6
-rw-r--r--app/views/shared/issuable/_label_dropdown.html.haml4
7 files changed, 79 insertions, 21 deletions
diff --git a/app/assets/javascripts/issues.js.coffee b/app/assets/javascripts/issues.js.coffee
index fc9f6301bcc..320b92d2a60 100644
--- a/app/assets/javascripts/issues.js.coffee
+++ b/app/assets/javascripts/issues.js.coffee
@@ -1,5 +1,6 @@
@Issues =
init: ->
+ Issues.initTemplates()
Issues.initSearch()
Issues.initChecks()
@@ -15,6 +16,15 @@
else
$(this).html totalIssues - 1
+ initTemplates: ->
+ Issue.labelRow = _.template(
+ '<% _.each(labels, function(label){ %>
+ <span class="label-row">
+ <a href="#"><span class="label color-label" style="background-color: <%= label.color %>; color: #FFFFFF" title="<%= label.description %>" data-container="body"><%= label.title %></span></a>
+ </span>
+ <% }); %>'
+ )
+
reload: ->
Issues.initChecks()
$('#filter_issue_search').val($('#issue_search').val())
@@ -50,7 +60,6 @@
, 500)
filterResults: (form) =>
-
formData = form.serialize()
$('.issues-holder, .merge-requests-holder').css("opacity", '0.5')
@@ -70,6 +79,31 @@
history.replaceState {page: issuesUrl}, document.title, issuesUrl
Issues.reload()
Issues.updateStateFilters()
+ $filteredLabels = $('.filtered-labels')
+ $filteredLabelsSpans = $filteredLabels.find('span')
+ gl.animate.animateEach(
+ $filteredLabelsSpans,
+ 'fadeOutDown', 20, {
+ cssStart: {
+ opacity: 1
+ },
+ cssEnd: {
+ opacity: 0
+ }
+ }).then( ->
+ $filteredLabels.html(Issue.labelRow(data))
+ $spans = $filteredLabels.find('span')
+ $spans.css('opacity',0)
+ return gl.animate.animateEach($spans, 'fadeInUp', 20, {
+ cssStart: {
+ opacity: 0
+ },
+ cssEnd: {
+ opacity: 1
+ }
+ })
+ )
+
dataType: "json"
checkChanged: ->
diff --git a/app/assets/javascripts/labels_select.js.coffee b/app/assets/javascripts/labels_select.js.coffee
index 9cebc26e668..97a813577ed 100644
--- a/app/assets/javascripts/labels_select.js.coffee
+++ b/app/assets/javascripts/labels_select.js.coffee
@@ -16,6 +16,7 @@ class @LabelsSelect
abilityName = $dropdown.data('ability-name')
$selectbox = $dropdown.closest('.selectbox')
$block = $selectbox.closest('.block')
+ $form = $dropdown.closest('form')
$sidebarCollapsedValue = $block.find('.sidebar-collapsed-icon span')
$value = $block.find('.value')
$loading = $block.find('.block-loading').fadeOut()
@@ -171,7 +172,7 @@ class @LabelsSelect
.find('a')
.each((i) ->
setTimeout(=>
- glAnimate($(@), 'pulse')
+ gl.animate.animate($(@), 'pulse')
,200 * i
)
)
@@ -201,9 +202,9 @@ class @LabelsSelect
renderRow: (label) ->
selectedClass = ''
- if $selectbox.find("input[type='hidden']\
+ if $form.find("input[type='hidden']\
[name='#{$dropdown.data('field-name')}']\
- [value='#{label.id}']").length
+ [value='#{this.id(label)}']").length
selectedClass = 'is-active'
color = if label.color? then "<span class='dropdown-label-box' style='background-color: #{label.color}'></span>" else ""
@@ -248,8 +249,6 @@ class @LabelsSelect
.find("input[type='hidden'][name='#{$dropdown.data('field-name')}']")
Issues.filterResults(
$dropdown.closest('form'),
- selectedLabels,
- $dropdown.data('singularFieldName'),
$dropdown.data('fieldName')
)
else if $dropdown.hasClass('js-filter-submit')
diff --git a/app/assets/javascripts/lib/animate.js.coffee b/app/assets/javascripts/lib/animate.js.coffee
index 8f892b5a2b9..64aef4c6d43 100644
--- a/app/assets/javascripts/lib/animate.js.coffee
+++ b/app/assets/javascripts/lib/animate.js.coffee
@@ -1,13 +1,37 @@
((w) ->
+ if not w.gl? then w.gl = {}
+ if not gl.animate? then gl.animate = {}
- w.glAnimate = ($el, animation, done) ->
+ gl.animate.animate = ($el, animation, options, done) ->
+ if options?.cssStart?
+ $el.css(options.cssStart)
$el
- .removeClass()
+ .removeClass(animation + ' animated')
.addClass(animation + ' animated')
.one 'webkitAnimationEnd mozAnimationEnd MSAnimationEnd oanimationend animationend', ->
- $(this).removeClass()
+ $(this).removeClass(animation + ' animated')
+ if done?
+ done()
+ if options?.cssEnd?
+ $el.css(options.cssEnd)
return
return
- return
+ gl.animate.animateEach = ($els, animation, time, options, done) ->
+ dfd = $.Deferred()
+ $els.each((i) ->
+ setTimeout(=>
+ $this = $(@)
+ gl.animate.animate($this, animation, options, =>
+ if i is $els.length - 1
+ dfd.resolve()
+ if done?
+ done()
+ )
+ ,time * i
+ )
+ return
+ )
+ return dfd.promise()
+ return
) window \ No newline at end of file
diff --git a/app/controllers/projects/issues_controller.rb b/app/controllers/projects/issues_controller.rb
index c26cfeccf1d..8ce6772c400 100644
--- a/app/controllers/projects/issues_controller.rb
+++ b/app/controllers/projects/issues_controller.rb
@@ -33,14 +33,15 @@ class Projects::IssuesController < Projects::ApplicationController
end
@issues = @issues.page(params[:page])
- @label = @project.labels.find_by(title: params[:label_name])
+ @labels = @project.labels.where(title: params[:label_name])
respond_to do |format|
format.html
format.atom { render layout: false }
format.json do
render json: {
- html: view_to_html_string("projects/issues/_issues")
+ html: view_to_html_string("projects/issues/_issues"),
+ labels: @labels
}
end
end
diff --git a/app/views/shared/_label_row.html.haml b/app/views/shared/_label_row.html.haml
index b38c5e18efb..f81a04a3c86 100644
--- a/app/views/shared/_label_row.html.haml
+++ b/app/views/shared/_label_row.html.haml
@@ -1,5 +1,3 @@
-%span.label-row
- %span.label-name
- = link_to_label(label, tooltip: false)
- %span.prepend-left-10
- = markdown(label.description, pipeline: :single_line)
+- labels.each do |l|
+ %span.label-row
+ = link_to_label(l, tooltip: false) \ No newline at end of file
diff --git a/app/views/shared/issuable/_filter.html.haml b/app/views/shared/issuable/_filter.html.haml
index 921eaefd79a..02982516de9 100644
--- a/app/views/shared/issuable/_filter.html.haml
+++ b/app/views/shared/issuable/_filter.html.haml
@@ -46,9 +46,9 @@
.filter-item.inline
= button_tag "Update issues", class: "btn update_selected_issues btn-save"
-- if @label
- .gray-content-block.second-block
- = render "shared/label_row", label: @label
+- if @labels
+ .gray-content-block.second-block.filtered-labels
+ = render "shared/label_row", labels: @labels
:javascript
new UsersSelect();
diff --git a/app/views/shared/issuable/_label_dropdown.html.haml b/app/views/shared/issuable/_label_dropdown.html.haml
index 4ded2d98f37..6df1bd0ca35 100644
--- a/app/views/shared/issuable/_label_dropdown.html.haml
+++ b/app/views/shared/issuable/_label_dropdown.html.haml
@@ -1,5 +1,7 @@
- if params[:label_name].present?
- = hidden_field_tag(:label_name, params[:label_name])
+ - if params[:label_name].respond_to?('any?')
+ - params[:label_name].each do |label|
+ = hidden_field_tag "label_name[]", label, id: nil
.dropdown
%button.dropdown-menu-toggle.js-label-select.js-filter-submit.js-extra-options{type: "button", data: {toggle: "dropdown", field_name: "label_name", show_no: "true", show_any: "true", selected: params[:label_name], project_id: @project.try(:id), labels: labels_filter_path, default_label: "Label"}}
%button.dropdown-menu-toggle.js-label-select.js-filter-submit.js-multiselect.js-extra-options{type: "button", data: {toggle: "dropdown", field_name: "label_name[]", show_no: "true", show_any: "true", selected: params[:label_name], project_id: @project.try(:id), labels: labels_filter_path, default_label: "Label"}}