Save and read filtering options from local storage.

This commit is contained in:
Paulo Reis 2017-04-27 16:07:03 +01:00
parent 3bdd5a4a2e
commit 884a89893d

View file

@ -2,7 +2,7 @@ define [
"base"
], (App) ->
App.controller "ProjectPageController", ($scope, $modal, $q, $window, queuedHttp, event_tracking, $timeout) ->
App.controller "ProjectPageController", ($scope, $modal, $q, $window, queuedHttp, event_tracking, $timeout, localStorage) ->
$scope.projects = window.data.projects
$scope.tags = window.data.tags
$scope.notifications = window.data.notifications
@ -18,6 +18,8 @@ define [
recalculateProjectListHeight()
, 10
storedUIOpts = JSON.parse(localStorage("project_list"))
recalculateProjectListHeight = () ->
topOffset = $(".project-list-card")?.offset()?.top
bottomOffset = $("footer").outerHeight() + 25
@ -52,6 +54,13 @@ define [
project.tags ||= []
project.tags.push tag
markTagAsSelected = (id) ->
for tag in $scope.tags
if tag._id == id
tag.selected = true
else
tag.selected = false
$scope.changePredicate = (newPredicate)->
if $scope.predicate == newPredicate
$scope.reverse = !$scope.reverse
@ -126,6 +135,11 @@ define [
else
# We don't want hidden selections
project.selected = false
localStorage("project_list", JSON.stringify({
filter: $scope.filter,
selectedTagId: selectedTag?._id
}))
$scope.updateSelectedProjects()
$scope.getSelectedTag = () ->
@ -425,8 +439,6 @@ define [
window.location = path
$scope.updateVisibleProjects()
App.controller "ProjectListItemController", ($scope) ->
$scope.ownerName = () ->
if $scope.project.accessLevel == "owner"