mirror of
https://github.com/overleaf/overleaf.git
synced 2024-12-24 18:22:01 +00:00
Add folder labels next to the project name
This commit is contained in:
parent
290089407d
commit
db74e89f99
2 changed files with 38 additions and 1 deletions
|
@ -169,6 +169,9 @@ block content
|
|||
input.select-item(type="checkbox", ng-model="project.selected", ng-change="onSelectedChange()")
|
||||
span.title
|
||||
a.projectName(href="/project/{{project.id}}") {{project.name}}
|
||||
span
|
||||
span.label.label-default(ng-repeat='tag in project.tags')
|
||||
| {{tag.name}}
|
||||
.col-md-2
|
||||
span.owner {{project.publicAccesLevel}}
|
||||
.col-md-4
|
||||
|
|
|
@ -30,6 +30,18 @@ ProjectPageApp.controller "ProjectPageController", ($scope, $modal, $http) ->
|
|||
$scope.tags = window.data.tags
|
||||
$scope.allSelected = false
|
||||
|
||||
# Allow tags to be accessed on projects as well
|
||||
projectsById = {}
|
||||
for project in $scope.projects
|
||||
projectsById[project._id] = project
|
||||
|
||||
for tag in $scope.tags
|
||||
for project_id in tag.project_ids or []
|
||||
project = projectsById[project_id]
|
||||
if project?
|
||||
project.tags ||= []
|
||||
project.tags.push tag
|
||||
|
||||
# Any individual changes to the selection buttons invalidates
|
||||
# our 'select all'
|
||||
$scope.$on "selected:on-change", (e) ->
|
||||
|
@ -63,9 +75,12 @@ ProjectPageApp.controller "ProjectPageController", ($scope, $modal, $http) ->
|
|||
# Only show if it matches the selected tag
|
||||
if selectedTag? and project._id not in selectedTag.project_ids
|
||||
visible = false
|
||||
|
||||
if visible
|
||||
$scope.visibleProjects.push project
|
||||
$scope.clearProjectSelections()
|
||||
else
|
||||
# We don't want hidden selections
|
||||
project.selected = false
|
||||
|
||||
$scope.getSelectedProjects = () ->
|
||||
$scope.projects.filter (project) -> project.selected
|
||||
|
@ -80,6 +95,9 @@ ProjectPageApp.controller "ProjectPageController", ($scope, $modal, $http) ->
|
|||
|
||||
$scope.removeSelectedProjectsFromTag = (tag) ->
|
||||
selected_project_ids = $scope.getSelectedProjectIds()
|
||||
selected_projects = $scope.getSelectedProjects()
|
||||
|
||||
# Remove project_id from tag.project_ids
|
||||
remaining_project_ids = []
|
||||
removed_project_ids = []
|
||||
for project_id in tag.project_ids
|
||||
|
@ -89,6 +107,14 @@ ProjectPageApp.controller "ProjectPageController", ($scope, $modal, $http) ->
|
|||
removed_project_ids.push project_id
|
||||
tag.project_ids = remaining_project_ids
|
||||
|
||||
# Remove tag from project.tags
|
||||
remaining_tags = []
|
||||
for project in selected_projects
|
||||
project.tags ||= []
|
||||
index = project.tags.indexOf tag
|
||||
if index > -1
|
||||
project.tags.splice(index, 1)
|
||||
|
||||
for project_id in removed_project_ids
|
||||
$http.post "/project/#{project_id}/tag", {
|
||||
deletedTag: tag.name
|
||||
|
@ -100,12 +126,20 @@ ProjectPageApp.controller "ProjectPageController", ($scope, $modal, $http) ->
|
|||
$scope.updateVisibleProjects()
|
||||
|
||||
$scope.addSelectedProjectsToTag = (tag) ->
|
||||
selected_projects = $scope.getSelectedProjects()
|
||||
|
||||
# Add project_ids into tag.project_ids
|
||||
added_project_ids = []
|
||||
for project_id in $scope.getSelectedProjectIds()
|
||||
unless project_id in tag.project_ids
|
||||
tag.project_ids.push project_id
|
||||
added_project_ids.push project_id
|
||||
|
||||
# Add tag into each project.tags
|
||||
for project in selected_projects
|
||||
project.tags ||= []
|
||||
project.tags.push tag
|
||||
|
||||
for project_id in added_project_ids
|
||||
# TODO Factor this out into another provider?
|
||||
$http.post "/project/#{project_id}/tag", {
|
||||
|
|
Loading…
Reference in a new issue