Other minor changes on filters.
parent
275b3c81f7
commit
778cd3ff4f
|
@ -63,6 +63,10 @@ class FiltersMixin
|
||||||
location = if load then @location else @location.noreload(@scope)
|
location = if load then @location else @location.noreload(@scope)
|
||||||
location.search(name, value)
|
location.search(name, value)
|
||||||
|
|
||||||
|
replaceFilter: (name, value, load=false) ->
|
||||||
|
location = if load then @location else @location.noreload(@scope)
|
||||||
|
location.search(name, value)
|
||||||
|
|
||||||
unselectFilter: (name, value, load=false) ->
|
unselectFilter: (name, value, load=false) ->
|
||||||
params = @location.search()
|
params = @location.search()
|
||||||
|
|
||||||
|
|
|
@ -27,6 +27,7 @@ toString = @.taiga.toString
|
||||||
joinStr = @.taiga.joinStr
|
joinStr = @.taiga.joinStr
|
||||||
groupBy = @.taiga.groupBy
|
groupBy = @.taiga.groupBy
|
||||||
bindOnce = @.taiga.bindOnce
|
bindOnce = @.taiga.bindOnce
|
||||||
|
debounce = @.taiga.debounce
|
||||||
|
|
||||||
module = angular.module("taigaIssues")
|
module = angular.module("taigaIssues")
|
||||||
|
|
||||||
|
@ -124,7 +125,7 @@ class IssuesController extends mixOf(taiga.Controller, taiga.PageMixin, taiga.Fi
|
||||||
return obj
|
return obj
|
||||||
|
|
||||||
if urlfilters.subject
|
if urlfilters.subject
|
||||||
@scope.filters.subject = urlfilters.subject
|
@scope.filtersSubject = urlfilters.subject
|
||||||
|
|
||||||
@rootscope.$broadcast("filters:loaded", @scope.filters)
|
@rootscope.$broadcast("filters:loaded", @scope.filters)
|
||||||
return data
|
return data
|
||||||
|
@ -149,7 +150,6 @@ class IssuesController extends mixOf(taiga.Controller, taiga.PageMixin, taiga.Fi
|
||||||
|
|
||||||
filters[name] = values
|
filters[name] = values
|
||||||
|
|
||||||
console.log "filter query params:", filters
|
|
||||||
return filters
|
return filters
|
||||||
|
|
||||||
loadIssues: ->
|
loadIssues: ->
|
||||||
|
@ -315,7 +315,9 @@ IssuesDirective = ($log, $location) ->
|
||||||
|
|
||||||
return {link:link}
|
return {link:link}
|
||||||
|
|
||||||
|
#############################################################################
|
||||||
|
## Issues Filters Directive
|
||||||
|
#############################################################################
|
||||||
|
|
||||||
IssuesFiltersDirective = ($log, $location) ->
|
IssuesFiltersDirective = ($log, $location) ->
|
||||||
template = _.template("""
|
template = _.template("""
|
||||||
|
@ -351,35 +353,35 @@ IssuesFiltersDirective = ($log, $location) ->
|
||||||
|
|
||||||
selectedFilters = []
|
selectedFilters = []
|
||||||
|
|
||||||
showFilters = ($el) ->
|
link = ($scope, $el, $attrs) ->
|
||||||
|
$ctrl = $el.closest(".wrapper").controller()
|
||||||
|
|
||||||
|
showFilters = (title) ->
|
||||||
$el.find(".filters-cats").hide()
|
$el.find(".filters-cats").hide()
|
||||||
$el.find(".filter-list").show()
|
$el.find(".filter-list").show()
|
||||||
|
$el.find("h1 a.subfilter").removeClass("hidden")
|
||||||
|
$el.find("h1 a.subfilter span.title").html(title)
|
||||||
|
|
||||||
showCategories = ($el) ->
|
showCategories = ->
|
||||||
$el.find(".filters-cats").show()
|
$el.find(".filters-cats").show()
|
||||||
$el.find(".filter-list").hide()
|
$el.find(".filter-list").hide()
|
||||||
|
$el.find("h1 a.subfilter").addClass("hidden")
|
||||||
|
|
||||||
initializeSelectedFilters = ($el, filters) ->
|
initializeSelectedFilters = (filters) ->
|
||||||
for name, values of filters
|
for name, values of filters
|
||||||
for val in values
|
for val in values
|
||||||
selectedFilters.push(val) if val.selected
|
selectedFilters.push(val) if val.selected
|
||||||
|
|
||||||
renderSelectedFilters($el)
|
renderSelectedFilters()
|
||||||
|
|
||||||
renderSelectedFilters = ($el) ->
|
renderSelectedFilters = ->
|
||||||
html = templateSelected({filters:selectedFilters})
|
html = templateSelected({filters:selectedFilters})
|
||||||
$el.find(".filters-applied").html(html)
|
$el.find(".filters-applied").html(html)
|
||||||
|
|
||||||
renderFilters = ($el, filters) ->
|
renderFilters = (filters) ->
|
||||||
html = template({filters:filters})
|
html = template({filters:filters})
|
||||||
$el.find(".filter-list").html(html)
|
$el.find(".filter-list").html(html)
|
||||||
|
|
||||||
link = ($scope, $el, $attrs) ->
|
|
||||||
$ctrl = $el.closest(".wrapper").controller()
|
|
||||||
|
|
||||||
$scope.$on "filters:loaded", (ctx, filters) ->
|
|
||||||
initializeSelectedFilters($el, filters)
|
|
||||||
|
|
||||||
toggleFilterSelection = (type, id) ->
|
toggleFilterSelection = (type, id) ->
|
||||||
filters = $scope.filters[type]
|
filters = $scope.filters[type]
|
||||||
filter = _.find(filters, {id:id})
|
filter = _.find(filters, {id:id})
|
||||||
|
@ -397,16 +399,31 @@ IssuesFiltersDirective = ($log, $location) ->
|
||||||
$ctrl.selectFilter("page", 1)
|
$ctrl.selectFilter("page", 1)
|
||||||
$ctrl.loadIssues()
|
$ctrl.loadIssues()
|
||||||
|
|
||||||
renderSelectedFilters($el, selectedFilters)
|
renderSelectedFilters(selectedFilters)
|
||||||
renderFilters($el, filters)
|
renderFilters(_.reject(filters, "selected"))
|
||||||
|
|
||||||
|
# Angular Watchers
|
||||||
|
$scope.$on "filters:loaded", (ctx, filters) ->
|
||||||
|
initializeSelectedFilters(filters)
|
||||||
|
|
||||||
|
selectSubjectFilter = debounce 400, (value) ->
|
||||||
|
return if value is undefined
|
||||||
|
if value.length == 0
|
||||||
|
$ctrl.replaceFilter("subject", null)
|
||||||
|
else
|
||||||
|
$ctrl.replaceFilter("subject", value)
|
||||||
|
$ctrl.loadIssues()
|
||||||
|
|
||||||
|
$scope.$watch("filtersSubject", selectSubjectFilter)
|
||||||
|
|
||||||
|
# Dom Event Handlers
|
||||||
$el.on "click", ".filters-cats > ul > li > a", (event) ->
|
$el.on "click", ".filters-cats > ul > li > a", (event) ->
|
||||||
event.preventDefault()
|
event.preventDefault()
|
||||||
target = angular.element(event.currentTarget)
|
target = angular.element(event.currentTarget)
|
||||||
tags = $scope.filters[target.data("type")]
|
tags = $scope.filters[target.data("type")]
|
||||||
|
|
||||||
renderFilters($el, tags)
|
renderFilters(_.reject(tags, "selected"))
|
||||||
showFilters($el)
|
showFilters(target.attr("title"))
|
||||||
|
|
||||||
$el.on "click", ".filters-inner > h1 > a.title", (event) ->
|
$el.on "click", ".filters-inner > h1 > a.title", (event) ->
|
||||||
event.preventDefault()
|
event.preventDefault()
|
||||||
|
|
|
@ -2,31 +2,22 @@ section.filters
|
||||||
div.filters-inner
|
div.filters-inner
|
||||||
h1
|
h1
|
||||||
a.title(href="", title="back to categories") filters
|
a.title(href="", title="back to categories") filters
|
||||||
a.subfilter(href="", title="cat-name")
|
a.hidden.subfilter(href="", title="cat-name")
|
||||||
span.icon.icon-arrow-right
|
span.icon.icon-arrow-right
|
||||||
span status
|
span.title status
|
||||||
form
|
form
|
||||||
fieldset
|
fieldset
|
||||||
input(type="text", placeholder="Search by subject...", ng-model="filters.subject")
|
input(type="text", placeholder="Search by subject...", ng-model="filtersSubject")
|
||||||
a.icon.icon-search(href="", title="search")
|
a.icon.icon-search(href="", title="search")
|
||||||
|
|
||||||
//- First step for selecting category
|
|
||||||
div.filters-step-cat
|
div.filters-step-cat
|
||||||
//- $(.filters-applied) only visible when filters are being applied
|
|
||||||
div.filters-applied
|
div.filters-applied
|
||||||
// a.single-filter.selected
|
|
||||||
// span.name Filter23
|
|
||||||
// span.icon.icon-delete
|
|
||||||
div.filters-cats
|
div.filters-cats
|
||||||
ul
|
ul
|
||||||
li
|
li
|
||||||
a(href="", title="Status", data-type="statuses")
|
a(href="", title="Status", data-type="statuses")
|
||||||
span.title Status
|
span.title Status
|
||||||
span.icon.icon-arrow-right
|
span.icon.icon-arrow-right
|
||||||
// li
|
|
||||||
// a(href="", title="Type", data-type="types")
|
|
||||||
// span.title Type
|
|
||||||
// span.icon.icon-arrow-right
|
|
||||||
li
|
li
|
||||||
a(href="", title="Severity", data-type="severities")
|
a(href="", title="Severity", data-type="severities")
|
||||||
span.title Severity
|
span.title Severity
|
||||||
|
@ -44,5 +35,4 @@ section.filters
|
||||||
span.title Assigned to
|
span.title Assigned to
|
||||||
span.icon.icon-arrow-right
|
span.icon.icon-arrow-right
|
||||||
|
|
||||||
//- Second step for selecting single filters to apply
|
|
||||||
div.filter-list.hidden
|
div.filter-list.hidden
|
||||||
|
|
Loading…
Reference in New Issue