new baclklog/issues filters implementation
- all filter attributes are OR except tagsstable
parent
74193e681f
commit
f98bb43c1d
|
@ -35,7 +35,7 @@ module = angular.module("taigaBacklog")
|
|||
## Issues Filters Directive
|
||||
#############################################################################
|
||||
|
||||
BacklogFiltersDirective = ($log, $location, $templates) ->
|
||||
BacklogFiltersDirective = ($q, $log, $location, $templates) ->
|
||||
template = $templates.get("backlog/filters.html", true)
|
||||
templateSelected = $templates.get("backlog/filter-selected.html", true)
|
||||
|
||||
|
@ -88,6 +88,13 @@ BacklogFiltersDirective = ($log, $location, $templates) ->
|
|||
getFiltersType = () ->
|
||||
return $el.find("h2 a.subfilter span.title").prop('data-type')
|
||||
|
||||
reloadUserstories = () ->
|
||||
currentFiltersType = getFiltersType()
|
||||
|
||||
$q.all([$ctrl.loadUserstories(), $ctrl.generateFilters()]).then () ->
|
||||
currentFilters = $scope.filters[currentFiltersType]
|
||||
renderFilters(_.reject(currentFilters, "selected"))
|
||||
|
||||
toggleFilterSelection = (type, id) ->
|
||||
currentFiltersType = getFiltersType()
|
||||
|
||||
|
@ -110,22 +117,17 @@ BacklogFiltersDirective = ($log, $location, $templates) ->
|
|||
if type == currentFiltersType
|
||||
renderFilters(_.reject(filters, "selected"))
|
||||
|
||||
$ctrl.loadUserstories()
|
||||
.then () ->
|
||||
# reload the tags when a tag is select or unselected
|
||||
# and the filters/tags is open
|
||||
if currentFiltersType == 'tags'
|
||||
$ctrl.generateFilters().then () ->
|
||||
tags = $scope.filters["tags"]
|
||||
renderFilters(_.reject(tags, "selected"))
|
||||
reloadUserstories()
|
||||
|
||||
selectQFilter = debounceLeading 100, (value) ->
|
||||
return if value is undefined
|
||||
|
||||
if value.length == 0
|
||||
$ctrl.replaceFilter("q", null)
|
||||
else
|
||||
$ctrl.replaceFilter("q", value)
|
||||
$ctrl.loadUserstories()
|
||||
|
||||
reloadUserstories()
|
||||
|
||||
$scope.$watch("filtersQ", selectQFilter)
|
||||
|
||||
|
@ -174,4 +176,4 @@ BacklogFiltersDirective = ($log, $location, $templates) ->
|
|||
|
||||
return {link:link}
|
||||
|
||||
module.directive("tgBacklogFilters", ["$log", "$tgLocation", "$tgTemplate", BacklogFiltersDirective])
|
||||
module.directive("tgBacklogFilters", ["$q", "$log", "$tgLocation", "$tgTemplate", BacklogFiltersDirective])
|
||||
|
|
|
@ -149,10 +149,6 @@ class BacklogController extends mixOf(taiga.Controller, taiga.PageMixin, taiga.F
|
|||
|
||||
return stats
|
||||
|
||||
refreshTagsColors: ->
|
||||
return @rs.projects.tagsColors(@scope.projectId).then (tags_colors) =>
|
||||
@scope.project.tags_colors = tags_colors
|
||||
|
||||
unloadClosedSprints: ->
|
||||
@scope.$apply =>
|
||||
@scope.closedSprints = []
|
||||
|
@ -205,10 +201,9 @@ class BacklogController extends mixOf(taiga.Controller, taiga.PageMixin, taiga.F
|
|||
@scope.httpParams = @.getUrlFilters()
|
||||
@rs.userstories.storeQueryParams(@scope.projectId, @scope.httpParams)
|
||||
|
||||
promise = @q.all([@.refreshTagsColors(), @rs.userstories.listUnassigned(@scope.projectId, @scope.httpParams)])
|
||||
promise = @rs.userstories.listUnassigned(@scope.projectId, @scope.httpParams)
|
||||
|
||||
return promise.then (data) =>
|
||||
userstories = data[1]
|
||||
return promise.then (userstories) =>
|
||||
# NOTE: Fix order of USs because the filter orderBy does not work propertly in the partials files
|
||||
@scope.userstories = _.sortBy(userstories, "backlog_order")
|
||||
|
||||
|
@ -433,26 +428,21 @@ class BacklogController extends mixOf(taiga.Controller, taiga.PageMixin, taiga.F
|
|||
loadFilters = {}
|
||||
loadFilters.project = @scope.projectId
|
||||
loadFilters.tags = urlfilters.tags
|
||||
loadFilters.status = urlfilters.status
|
||||
loadFilters.q = urlfilters.q
|
||||
loadFilters.milestone = 'null'
|
||||
|
||||
return @rs.userstories.filtersData(loadFilters).then (data) =>
|
||||
choicesFiltersFormat = (choices, type, byIdObject) =>
|
||||
_.map choices, (t) ->
|
||||
return {
|
||||
id: t[0],
|
||||
name: byIdObject[t[0]].name,
|
||||
color: byIdObject[t[0]].color,
|
||||
count: t[1],
|
||||
type: type}
|
||||
t.type = type
|
||||
return t
|
||||
|
||||
tagsFilterFormat = (tags) =>
|
||||
return _.map tags, (t) =>
|
||||
return {
|
||||
id: t[0],
|
||||
name: t[0],
|
||||
color: @scope.project.tags_colors[t[0]],
|
||||
count: t[1],
|
||||
type: "tags"
|
||||
}
|
||||
return _.map tags, (t) ->
|
||||
t.id = t.name
|
||||
t.type = 'tags'
|
||||
return t
|
||||
|
||||
# Build filters data structure
|
||||
@scope.filters.status = choicesFiltersFormat(data.statuses, "status", @scope.usStatusById)
|
||||
|
|
|
@ -182,6 +182,13 @@ class IssuesController extends mixOf(taiga.Controller, taiga.PageMixin, taiga.Fi
|
|||
loadFilters = {}
|
||||
loadFilters.project = @scope.projectId
|
||||
loadFilters.tags = urlfilters.tags
|
||||
loadFilters.status = urlfilters.status
|
||||
loadFilters.q = urlfilters.q
|
||||
loadFilters.types = urlfilters.types
|
||||
loadFilters.severities = urlfilters.severities
|
||||
loadFilters.priorities = urlfilters.priorities
|
||||
loadFilters.assigned_to = urlfilters.assignedTo
|
||||
loadFilters.owner = urlfilters.createdBy
|
||||
|
||||
# Load default filters data
|
||||
promise = promise.then =>
|
||||
|
@ -191,12 +198,11 @@ class IssuesController extends mixOf(taiga.Controller, taiga.PageMixin, taiga.Fi
|
|||
return promise.then (data) =>
|
||||
usersFiltersFormat = (users, type, unknownOption) =>
|
||||
reformatedUsers = _.map users, (t) =>
|
||||
return {
|
||||
id: t[0],
|
||||
count: t[1],
|
||||
type: type
|
||||
name: if t[0] then @scope.usersById[t[0]].full_name_display else unknownOption
|
||||
}
|
||||
t.type = type
|
||||
t.name = if t.full_name then t.full_name else unknownOption
|
||||
|
||||
return t
|
||||
|
||||
unknownItem = _.remove(reformatedUsers, (u) -> not u.id)
|
||||
reformatedUsers = _.sortBy(reformatedUsers, (u) -> u.name.toUpperCase())
|
||||
if unknownItem.length > 0
|
||||
|
@ -205,22 +211,14 @@ class IssuesController extends mixOf(taiga.Controller, taiga.PageMixin, taiga.Fi
|
|||
|
||||
choicesFiltersFormat = (choices, type, byIdObject) =>
|
||||
_.map choices, (t) ->
|
||||
return {
|
||||
id: t[0],
|
||||
name: byIdObject[t[0]].name,
|
||||
color: byIdObject[t[0]].color,
|
||||
count: t[1],
|
||||
type: type}
|
||||
t.type = type
|
||||
return t
|
||||
|
||||
tagsFilterFormat = (tags) =>
|
||||
return _.map tags, (t) =>
|
||||
return {
|
||||
id: t[0],
|
||||
name: t[0],
|
||||
color: @scope.project.tags_colors[t[0]],
|
||||
count: t[1],
|
||||
type: "tags"
|
||||
}
|
||||
return _.map tags, (t) ->
|
||||
t.id = t.name
|
||||
t.type = 'tags'
|
||||
return t
|
||||
|
||||
# Build filters data structure
|
||||
@scope.filters.status = choicesFiltersFormat(data.statuses, "status", @scope.issueStatusById)
|
||||
|
@ -448,7 +446,7 @@ module.directive("tgIssues", ["$log", "$tgLocation", "$tgTemplate", "$compile",
|
|||
## Issues Filters Directive
|
||||
#############################################################################
|
||||
|
||||
IssuesFiltersDirective = ($log, $location, $rs, $confirm, $loading, $template, $translate, $compile, $auth) ->
|
||||
IssuesFiltersDirective = ($q, $log, $location, $rs, $confirm, $loading, $template, $translate, $compile, $auth) ->
|
||||
template = $template.get("issue/issues-filters.html", true)
|
||||
templateSelected = $template.get("issue/issues-filters-selected.html", true)
|
||||
|
||||
|
@ -500,6 +498,16 @@ IssuesFiltersDirective = ($log, $location, $rs, $confirm, $loading, $template, $
|
|||
html = $compile(html)($scope)
|
||||
$el.find(".filter-list").html(html)
|
||||
|
||||
getFiltersType = () ->
|
||||
return $el.find("h2 a.subfilter span.title").prop('data-type')
|
||||
|
||||
reloadIssues = () ->
|
||||
currentFiltersType = getFiltersType()
|
||||
|
||||
$q.all([$ctrl.loadIssues(), $ctrl.loadFilters()]).then () ->
|
||||
filters = $scope.filters[currentFiltersType]
|
||||
renderFilters(_.reject(filters, "selected"))
|
||||
|
||||
toggleFilterSelection = (type, id) ->
|
||||
if type == "myFilters"
|
||||
$rs.issues.getMyFilters($scope.projectId).then (data) ->
|
||||
|
@ -535,20 +543,12 @@ IssuesFiltersDirective = ($log, $location, $rs, $confirm, $loading, $template, $
|
|||
$ctrl.selectFilter("page", 1)
|
||||
$ctrl.storeFilters()
|
||||
|
||||
$ctrl.loadIssues()
|
||||
.then () ->
|
||||
# reload the tags when a tag is select or unselected
|
||||
# and the filters/tags is open
|
||||
if filter.type == 'tags'
|
||||
$ctrl.loadFilters().then () ->
|
||||
# re-render the tags if the tags filter is open
|
||||
if currentFiltersType == 'tags'
|
||||
tags = $scope.filters[filter.type]
|
||||
renderFilters(_.reject(tags, "selected"))
|
||||
reloadIssues()
|
||||
|
||||
renderSelectedFilters(selectedFilters)
|
||||
|
||||
currentFiltersType = $el.find("h2 a.subfilter span.title").prop('data-type')
|
||||
currentFiltersType = getFiltersType()
|
||||
|
||||
if type == currentFiltersType
|
||||
renderFilters(_.reject(filters, "selected"))
|
||||
|
||||
|
@ -572,7 +572,8 @@ IssuesFiltersDirective = ($log, $location, $rs, $confirm, $loading, $template, $
|
|||
else
|
||||
$ctrl.replaceFilter("q", value)
|
||||
$ctrl.storeFilters()
|
||||
$ctrl.loadIssues()
|
||||
|
||||
reloadIssues()
|
||||
|
||||
$scope.$watch("filtersQ", selectQFilter)
|
||||
|
||||
|
@ -679,7 +680,7 @@ IssuesFiltersDirective = ($log, $location, $rs, $confirm, $loading, $template, $
|
|||
|
||||
return {link:link}
|
||||
|
||||
module.directive("tgIssuesFilters", ["$log", "$tgLocation", "$tgResources", "$tgConfirm", "$tgLoading",
|
||||
module.directive("tgIssuesFilters", ["$q", "$log", "$tgLocation", "$tgResources", "$tgConfirm", "$tgLoading",
|
||||
"$tgTemplate", "$translate", "$compile", "$tgAuth", IssuesFiltersDirective])
|
||||
|
||||
|
||||
|
|
|
@ -3,11 +3,15 @@
|
|||
a.single-filter.active(data-type!="<%- f.type %>", data-id!="<%- f.id %>")
|
||||
span.name(style!="<%- f.style %>")
|
||||
| <%- f.name %>
|
||||
<% if (f.count){ %>
|
||||
span.number <%- f.count %>
|
||||
<% } %>
|
||||
<% } else { %>
|
||||
a.single-filter(data-type!="<%- f.type %>", data-id!="<%- f.id %>")
|
||||
span.name(style!="<%- f.style %>")
|
||||
| <%- f.name %>
|
||||
<% if (f.count){ %>
|
||||
span.number <%- f.count %>
|
||||
<% } %>
|
||||
<% } %>
|
||||
<% }) %>
|
Loading…
Reference in New Issue