mirror of
https://github.com/overleaf/overleaf.git
synced 2024-11-21 20:47:08 -05:00
Post tag modifications to server
This commit is contained in:
parent
5fbbf6c452
commit
4494048cd4
1 changed files with 15 additions and 1 deletions
|
@ -85,7 +85,7 @@ ProjectPageApp.controller "TagListItemController", ($scope) ->
|
||||||
$scope.setActiveItem("tag")
|
$scope.setActiveItem("tag")
|
||||||
$scope.updateVisibleProjects()
|
$scope.updateVisibleProjects()
|
||||||
|
|
||||||
ProjectPageApp.controller "TagDropdownItemController", ($scope) ->
|
ProjectPageApp.controller "TagDropdownItemController", ($scope, $http) ->
|
||||||
$scope.$on "selection:change", (e, newValue, oldValue) ->
|
$scope.$on "selection:change", (e, newValue, oldValue) ->
|
||||||
console.log "selected watch listen"
|
console.log "selected watch listen"
|
||||||
$scope.recalculateProjectsInTag()
|
$scope.recalculateProjectsInTag()
|
||||||
|
@ -105,14 +105,28 @@ ProjectPageApp.controller "TagDropdownItemController", ($scope) ->
|
||||||
$scope.removeSelectedProjectsFromTag = () ->
|
$scope.removeSelectedProjectsFromTag = () ->
|
||||||
selected_project_ids = $scope.getSelectedProjectIds()
|
selected_project_ids = $scope.getSelectedProjectIds()
|
||||||
remaining_project_ids = []
|
remaining_project_ids = []
|
||||||
|
removed_project_ids = []
|
||||||
for project_id in $scope.tag.project_ids
|
for project_id in $scope.tag.project_ids
|
||||||
if project_id not in selected_project_ids
|
if project_id not in selected_project_ids
|
||||||
remaining_project_ids.push project_id
|
remaining_project_ids.push project_id
|
||||||
|
else
|
||||||
|
removed_project_ids.push project_id
|
||||||
$scope.tag.project_ids = remaining_project_ids
|
$scope.tag.project_ids = remaining_project_ids
|
||||||
|
|
||||||
|
for project_id in removed_project_ids
|
||||||
|
$http.post "/project/#{project_id}/tag", { deletedTag: $scope.tag.name, _csrf: window.csrfToken }
|
||||||
|
|
||||||
$scope.areSelectedProjectsInTag = false
|
$scope.areSelectedProjectsInTag = false
|
||||||
|
|
||||||
$scope.addSelectedProjectsToTag = () ->
|
$scope.addSelectedProjectsToTag = () ->
|
||||||
|
added_project_ids = []
|
||||||
for project_id in $scope.getSelectedProjectIds()
|
for project_id in $scope.getSelectedProjectIds()
|
||||||
unless project_id in $scope.tag.project_ids
|
unless project_id in $scope.tag.project_ids
|
||||||
$scope.tag.project_ids.push project_id
|
$scope.tag.project_ids.push project_id
|
||||||
|
added_project_ids.push project_id
|
||||||
|
|
||||||
|
for project_id in added_project_ids
|
||||||
|
# TODO Factor this out into another provider?
|
||||||
|
$http.post "/project/#{project_id}/tag", {tag: $scope.tag.name, _csrf: window.csrfToken}
|
||||||
|
|
||||||
$scope.areSelectedProjectsInTag = true
|
$scope.areSelectedProjectsInTag = true
|
||||||
|
|
Loading…
Reference in a new issue