@controller = new Controller app: @
- App.addInitializer ->
- @controller.fetchFilters()
-
-
App.addInitializer ->
@issuesView = new WorkspaceListView
app: @
App.addInitializer ->
- key.setScope 'list'
- @router = new Router app: @
- Backbone.history.start()
+ @controller.fetchFilters().done =>
+ key.setScope 'list'
+ @router = new Router app: @
+ Backbone.history.start()
l10nXHR = window.requestMessages()
@options.app.state.setQuery resolved: 'false'
- applyFilter: (filter) ->
- query = @parseQuery filter.get 'query'
- @options.app.state.setQuery query
+ applyFilter: (filter, ignoreQuery = false) ->
+ unless ignoreQuery
+ filterQuery = @parseQuery filter.get 'query'
+ @options.app.state.setQuery filterQuery
@options.app.state.set filter: filter, changed: false
route.join separator
+ getRoute: (separator = '|') ->
+ filter = @options.app.state.get 'filter'
+ query = @getQuery separator
+ if filter?
+ if @options.app.state.get('changed') && query.length > 0
+ query = "id=#{filter.id}|#{query}"
+ else
+ query = "id=#{filter.id}"
+ query
+
+
_prepareComponent: (issue) ->
key: issue.get 'component'
name: issue.get 'componentLongName'
setQuery: (query) ->
@set { query: query }, { silent: true }
- @trigger 'change:query'
@set changed: true
+ @trigger 'change:query'
initialize: (options) ->
@options = options
@listenTo @options.app.state, 'change:query', @updateRoute
+ @listenTo @options.app.state, 'change:filter', @updateRoute
emptyQuery: ->
index: (query) ->
- filter = @options.app.controller.parseQuery query
- @options.app.state.setQuery filter
+ query = @options.app.controller.parseQuery query
+ if query.id?
+ filter = @options.app.filters.get query.id
+ delete query.id
+ filter.fetch().done =>
+ if Object.keys(query).length > 0
+ @options.app.controller.applyFilter filter, true
+ @options.app.state.setQuery query
+ @options.app.state.set changed: true
+ else
+ @options.app.controller.applyFilter filter
+ else
+ @options.app.state.setQuery query
updateRoute: ->
- route = @options.app.controller.getQuery()
+ route = @options.app.controller.getRoute()
@navigate route