Hide related attachments and related tasks
parent
82cf43082e
commit
dcd62dc098
|
@ -227,6 +227,19 @@ RelatedTasksDirective = ($repo, $rs, $rootscope) ->
|
||||||
$scope.tasks = _.sortBy(tasks, 'ref')
|
$scope.tasks = _.sortBy(tasks, 'ref')
|
||||||
return tasks
|
return tasks
|
||||||
|
|
||||||
|
_isVisible = ->
|
||||||
|
if $scope.project
|
||||||
|
return $scope.project.my_permissions.indexOf("view_tasks") != -1
|
||||||
|
return false
|
||||||
|
|
||||||
|
_isEditable = ->
|
||||||
|
if $scope.project
|
||||||
|
return $scope.project.my_permissions.indexOf("modify_task") != -1
|
||||||
|
return false
|
||||||
|
|
||||||
|
$scope.showRelatedTasks = ->
|
||||||
|
return _isVisible() && ( _isEditable() || $scope.tasks?.length )
|
||||||
|
|
||||||
$scope.$on "related-tasks:add", ->
|
$scope.$on "related-tasks:add", ->
|
||||||
loadTasks().then ->
|
loadTasks().then ->
|
||||||
$rootscope.$broadcast("related-tasks:update")
|
$rootscope.$broadcast("related-tasks:update")
|
||||||
|
|
|
@ -25,10 +25,11 @@ class AttachmentsFullController
|
||||||
"$tgConfirm",
|
"$tgConfirm",
|
||||||
"$tgConfig",
|
"$tgConfig",
|
||||||
"$tgStorage",
|
"$tgStorage",
|
||||||
"tgAttachmentsFullService"
|
"tgAttachmentsFullService",
|
||||||
|
"tgProjectService"
|
||||||
]
|
]
|
||||||
|
|
||||||
constructor: (@translate, @confirm, @config, @storage, @attachmentsFullService) ->
|
constructor: (@translate, @confirm, @config, @storage, @attachmentsFullService, @projectService) ->
|
||||||
@.mode = @storage.get('attachment-mode', 'list')
|
@.mode = @storage.get('attachment-mode', 'list')
|
||||||
|
|
||||||
@.maxFileSize = @config.get("maxUploadFileSize", null)
|
@.maxFileSize = @config.get("maxUploadFileSize", null)
|
||||||
|
@ -85,4 +86,12 @@ class AttachmentsFullController
|
||||||
updateAttachment: (toUpdateAttachment) ->
|
updateAttachment: (toUpdateAttachment) ->
|
||||||
@attachmentsFullService.updateAttachment(toUpdateAttachment, @.type)
|
@attachmentsFullService.updateAttachment(toUpdateAttachment, @.type)
|
||||||
|
|
||||||
|
_isEditable: ->
|
||||||
|
if @projectService.project
|
||||||
|
return @projectService.hasPermission(@.editPermission)
|
||||||
|
return false
|
||||||
|
|
||||||
|
showAttachments: ->
|
||||||
|
return @._isEditable() || @attachmentsFullService.attachments.size
|
||||||
|
|
||||||
angular.module("taigaComponents").controller("AttachmentsFull", AttachmentsFullController)
|
angular.module("taigaComponents").controller("AttachmentsFull", AttachmentsFullController)
|
||||||
|
|
|
@ -53,6 +53,14 @@ describe "AttachmentsController", ->
|
||||||
|
|
||||||
$provide.value("tgAttachmentsFullService", mocks.attachmentsFullService)
|
$provide.value("tgAttachmentsFullService", mocks.attachmentsFullService)
|
||||||
|
|
||||||
|
_mockProjectService = ->
|
||||||
|
mocks.projectService = {
|
||||||
|
project: sinon.stub()
|
||||||
|
hasPermission: sinon.stub()
|
||||||
|
}
|
||||||
|
|
||||||
|
$provide.value("tgProjectService", mocks.projectService)
|
||||||
|
|
||||||
_mocks = ->
|
_mocks = ->
|
||||||
module (_$provide_) ->
|
module (_$provide_) ->
|
||||||
$provide = _$provide_
|
$provide = _$provide_
|
||||||
|
@ -62,6 +70,7 @@ describe "AttachmentsController", ->
|
||||||
_mockConfig()
|
_mockConfig()
|
||||||
_mockStorage()
|
_mockStorage()
|
||||||
_mockAttachmetsFullService()
|
_mockAttachmetsFullService()
|
||||||
|
_mockProjectService()
|
||||||
|
|
||||||
return null
|
return null
|
||||||
|
|
||||||
|
@ -213,3 +222,17 @@ describe "AttachmentsController", ->
|
||||||
ctrl.updateAttachment(file, 5)
|
ctrl.updateAttachment(file, 5)
|
||||||
|
|
||||||
expect(mocks.attachmentsFullService.updateAttachment).to.have.been.calledWith(file, 'us')
|
expect(mocks.attachmentsFullService.updateAttachment).to.have.been.calledWith(file, 'us')
|
||||||
|
|
||||||
|
it "if attachments editable", () ->
|
||||||
|
mocks.projectService.project = true
|
||||||
|
ctrl = $controller("AttachmentsFull")
|
||||||
|
|
||||||
|
ctrl._isEditable()
|
||||||
|
|
||||||
|
expect(mocks.projectService.hasPermission).has.been.called
|
||||||
|
|
||||||
|
it "if attachments are not editable", () ->
|
||||||
|
mocks.projectService.project = false
|
||||||
|
ctrl = $controller("AttachmentsFull")
|
||||||
|
|
||||||
|
expect(ctrl._isEditable()).to.be.false
|
||||||
|
|
|
@ -28,8 +28,9 @@ AttachmentsFullDirective = () ->
|
||||||
scope: {},
|
scope: {},
|
||||||
bindToController: {
|
bindToController: {
|
||||||
type: "@",
|
type: "@",
|
||||||
objId: "="
|
objId: "=",
|
||||||
projectId: "="
|
projectId: "=",
|
||||||
|
editPermission: "@"
|
||||||
},
|
},
|
||||||
controller: "AttachmentsFull",
|
controller: "AttachmentsFull",
|
||||||
controllerAs: "vm",
|
controllerAs: "vm",
|
||||||
|
|
|
@ -1,4 +1,7 @@
|
||||||
section.attachments(tg-attachments-drop="vm.addAttachments(files, false)")
|
section.attachments(
|
||||||
|
tg-attachments-drop="vm.addAttachments(files, false)"
|
||||||
|
ng-show="vm.showAttachments()"
|
||||||
|
)
|
||||||
.attachments-header
|
.attachments-header
|
||||||
h3.attachments-title #[span.attachments-num {{vm.attachments.size}}] #[span.attachments-text(translate="ATTACHMENT.SECTION_NAME")]
|
h3.attachments-title #[span.attachments-num {{vm.attachments.size}}] #[span.attachments-text(translate="ATTACHMENT.SECTION_NAME")]
|
||||||
.options
|
.options
|
||||||
|
|
|
@ -1,4 +1,7 @@
|
||||||
section.related-tasks(tg-related-tasks)
|
section.related-tasks(
|
||||||
|
tg-related-tasks
|
||||||
|
ng-show="showRelatedTasks()"
|
||||||
|
)
|
||||||
.related-tasks-header
|
.related-tasks-header
|
||||||
span.related-tasks-title(translate="COMMON.RELATED_TASKS")
|
span.related-tasks-title(translate="COMMON.RELATED_TASKS")
|
||||||
div(tg-related-task-create-button)
|
div(tg-related-task-create-button)
|
||||||
|
|
|
@ -77,6 +77,7 @@ div.wrapper(
|
||||||
obj-id="issue.id"
|
obj-id="issue.id"
|
||||||
type="issue",
|
type="issue",
|
||||||
project-id="projectId"
|
project-id="projectId"
|
||||||
|
edit-permission = "modify_issue"
|
||||||
)
|
)
|
||||||
|
|
||||||
tg-history(ng-model="issue", type="issue")
|
tg-history(ng-model="issue", type="issue")
|
||||||
|
|
|
@ -92,8 +92,9 @@ div.wrapper(
|
||||||
|
|
||||||
tg-attachments-full(
|
tg-attachments-full(
|
||||||
obj-id="task.id"
|
obj-id="task.id"
|
||||||
type="task",
|
type="task"
|
||||||
project-id="projectId"
|
project-id="projectId"
|
||||||
|
edit-permission = "modify_task"
|
||||||
)
|
)
|
||||||
|
|
||||||
tg-history(ng-model="task", type="task")
|
tg-history(ng-model="task", type="task")
|
||||||
|
|
|
@ -89,6 +89,7 @@ div.wrapper(
|
||||||
obj-id="us.id"
|
obj-id="us.id"
|
||||||
type="us",
|
type="us",
|
||||||
project-id="projectId"
|
project-id="projectId"
|
||||||
|
edit-permission = "modify_us"
|
||||||
)
|
)
|
||||||
|
|
||||||
tg-history(
|
tg-history(
|
||||||
|
|
|
@ -21,6 +21,7 @@ div.wrapper(ng-controller="WikiDetailController as ctrl",
|
||||||
obj-id="wiki.id"
|
obj-id="wiki.id"
|
||||||
type="wiki_page",
|
type="wiki_page",
|
||||||
project-id="projectId"
|
project-id="projectId"
|
||||||
|
edit-permission = "modify_wiki_page"
|
||||||
)
|
)
|
||||||
|
|
||||||
a.remove(href="", ng-click="ctrl.delete()", ng-if="wiki.id", title="{{'WIKI.REMOVE' | translate}}", tg-check-permission="delete_wiki_page")
|
a.remove(href="", ng-click="ctrl.delete()", ng-if="wiki.id", title="{{'WIKI.REMOVE' | translate}}", tg-check-permission="delete_wiki_page")
|
||||||
|
|
Loading…
Reference in New Issue