detail model transformation to prevent collisions
parent
3466bf8333
commit
163fb4ab52
|
@ -263,6 +263,51 @@ Qqueue = ($q) ->
|
||||||
|
|
||||||
module.factory("$tgQqueue", ["$q", Qqueue])
|
module.factory("$tgQqueue", ["$q", Qqueue])
|
||||||
|
|
||||||
|
|
||||||
|
#############################################################################
|
||||||
|
## Queue model transformation
|
||||||
|
#############################################################################
|
||||||
|
|
||||||
|
class QueueModelTransformation extends taiga.Service
|
||||||
|
@.$inject = [
|
||||||
|
"$tgQqueue",
|
||||||
|
"$tgRepo",
|
||||||
|
"$q",
|
||||||
|
"$tgModel"
|
||||||
|
]
|
||||||
|
|
||||||
|
constructor: (@qqueue, @repo, @q, @model) ->
|
||||||
|
|
||||||
|
setObject: (@scope, @prop) ->
|
||||||
|
|
||||||
|
clone: () ->
|
||||||
|
attrs = _.cloneDeep(@.scope[@.prop]._attrs)
|
||||||
|
model = @model.make_model(@.scope[@.prop]._name, attrs)
|
||||||
|
|
||||||
|
return model
|
||||||
|
|
||||||
|
getObj: () ->
|
||||||
|
return @.scope[@.prop]
|
||||||
|
|
||||||
|
save: (transformation) ->
|
||||||
|
defered = @q.defer()
|
||||||
|
|
||||||
|
@qqueue.add () =>
|
||||||
|
clone = @.clone()
|
||||||
|
|
||||||
|
transformation(clone)
|
||||||
|
|
||||||
|
success = () =>
|
||||||
|
@.scope[@.prop] = clone
|
||||||
|
|
||||||
|
defered.resolve.apply(null, arguments)
|
||||||
|
|
||||||
|
@repo.save(clone).then(success, defered.reject)
|
||||||
|
|
||||||
|
return defered.promise
|
||||||
|
|
||||||
|
module.service("$tgQueueModelTransformation", QueueModelTransformation)
|
||||||
|
|
||||||
#############################################################################
|
#############################################################################
|
||||||
## Templates
|
## Templates
|
||||||
#############################################################################
|
#############################################################################
|
||||||
|
|
|
@ -169,7 +169,7 @@ module.directive("tgCreatedByDisplay", ["$tgTemplate", "$compile", "$translate",
|
||||||
## Watchers directive
|
## Watchers directive
|
||||||
#############################################################################
|
#############################################################################
|
||||||
|
|
||||||
WatchersDirective = ($rootscope, $confirm, $repo, $qqueue, $template, $compile, $translate) ->
|
WatchersDirective = ($rootscope, $confirm, $repo, $modelTransform, $template, $compile, $translate) ->
|
||||||
# You have to include a div with the tg-lb-watchers directive in the page
|
# You have to include a div with the tg-lb-watchers directive in the page
|
||||||
# where use this directive
|
# where use this directive
|
||||||
template = $template.get("common/components/watchers.html", true)
|
template = $template.get("common/components/watchers.html", true)
|
||||||
|
@ -178,32 +178,33 @@ WatchersDirective = ($rootscope, $confirm, $repo, $qqueue, $template, $compile,
|
||||||
isEditable = ->
|
isEditable = ->
|
||||||
return $scope.project?.my_permissions?.indexOf($attrs.requiredPerm) != -1
|
return $scope.project?.my_permissions?.indexOf($attrs.requiredPerm) != -1
|
||||||
|
|
||||||
save = $qqueue.bindAdd (watchers) =>
|
save = (watchers) ->
|
||||||
item = $model.$modelValue.clone()
|
transform = $modelTransform.save (item) ->
|
||||||
item.watchers = watchers
|
item.watchers = watchers
|
||||||
$model.$setViewValue(item)
|
|
||||||
|
|
||||||
promise = $repo.save($model.$modelValue)
|
return item
|
||||||
promise.then ->
|
|
||||||
|
transform.then ->
|
||||||
watchers = _.map(watchers, (watcherId) -> $scope.usersById[watcherId])
|
watchers = _.map(watchers, (watcherId) -> $scope.usersById[watcherId])
|
||||||
renderWatchers(watchers)
|
renderWatchers(watchers)
|
||||||
$rootscope.$broadcast("object:updated")
|
$rootscope.$broadcast("object:updated")
|
||||||
|
|
||||||
promise.then null, ->
|
transform.then null, ->
|
||||||
$model.$modelValue.revert()
|
|
||||||
$confirm.notify("error")
|
$confirm.notify("error")
|
||||||
|
|
||||||
deleteWatcher = $qqueue.bindAdd (watcherIds) =>
|
deleteWatcher = (watcherIds) ->
|
||||||
item = $model.$modelValue.clone()
|
transform = $modelTransform.save (item) ->
|
||||||
item.watchers = watcherIds
|
item.watchers = watcherIds
|
||||||
$model.$setViewValue(item)
|
|
||||||
|
|
||||||
promise = $repo.save($model.$modelValue)
|
return item
|
||||||
promise.then ->
|
|
||||||
|
transform.then () ->
|
||||||
|
item = $modelTransform.getObj()
|
||||||
watchers = _.map(item.watchers, (watcherId) -> $scope.usersById[watcherId])
|
watchers = _.map(item.watchers, (watcherId) -> $scope.usersById[watcherId])
|
||||||
renderWatchers(watchers)
|
renderWatchers(watchers)
|
||||||
$rootscope.$broadcast("object:updated")
|
$rootscope.$broadcast("object:updated")
|
||||||
promise.then null, ->
|
|
||||||
|
transform.then null, ->
|
||||||
item.revert()
|
item.revert()
|
||||||
$confirm.notify("error")
|
$confirm.notify("error")
|
||||||
|
|
||||||
|
@ -250,7 +251,7 @@ WatchersDirective = ($rootscope, $confirm, $repo, $qqueue, $template, $compile,
|
||||||
|
|
||||||
return {link:link, require:"ngModel"}
|
return {link:link, require:"ngModel"}
|
||||||
|
|
||||||
module.directive("tgWatchers", ["$rootScope", "$tgConfirm", "$tgRepo", "$tgQqueue", "$tgTemplate", "$compile",
|
module.directive("tgWatchers", ["$rootScope", "$tgConfirm", "$tgRepo", "$tgQueueModelTransformation", "$tgTemplate", "$compile",
|
||||||
"$translate", WatchersDirective])
|
"$translate", WatchersDirective])
|
||||||
|
|
||||||
|
|
||||||
|
@ -258,7 +259,7 @@ module.directive("tgWatchers", ["$rootScope", "$tgConfirm", "$tgRepo", "$tgQqueu
|
||||||
## Assigned to directive
|
## Assigned to directive
|
||||||
#############################################################################
|
#############################################################################
|
||||||
|
|
||||||
AssignedToDirective = ($rootscope, $confirm, $repo, $loading, $qqueue, $template, $translate, $compile, $currentUserService) ->
|
AssignedToDirective = ($rootscope, $confirm, $repo, $loading, $modelTransform, $template, $translate, $compile, $currentUserService) ->
|
||||||
# You have to include a div with the tg-lb-assignedto directive in the page
|
# You have to include a div with the tg-lb-assignedto directive in the page
|
||||||
# where use this directive
|
# where use this directive
|
||||||
template = $template.get("common/components/assigned-to.html", true)
|
template = $template.get("common/components/assigned-to.html", true)
|
||||||
|
@ -267,24 +268,29 @@ AssignedToDirective = ($rootscope, $confirm, $repo, $loading, $qqueue, $template
|
||||||
isEditable = ->
|
isEditable = ->
|
||||||
return $scope.project?.my_permissions?.indexOf($attrs.requiredPerm) != -1
|
return $scope.project?.my_permissions?.indexOf($attrs.requiredPerm) != -1
|
||||||
|
|
||||||
save = $qqueue.bindAdd (userId) =>
|
save = (userId) ->
|
||||||
$model.$modelValue.assigned_to = userId
|
item = $model.$modelValue.clone()
|
||||||
|
item.assigned_to = userId
|
||||||
|
|
||||||
currentLoading = $loading()
|
currentLoading = $loading()
|
||||||
.target($el)
|
.target($el)
|
||||||
.start()
|
.start()
|
||||||
|
|
||||||
promise = $repo.save($model.$modelValue)
|
transform = $modelTransform.save (item) ->
|
||||||
promise.then ->
|
item.assigned_to = userId
|
||||||
|
|
||||||
|
return item
|
||||||
|
|
||||||
|
transform.then ->
|
||||||
currentLoading.finish()
|
currentLoading.finish()
|
||||||
renderAssignedTo($model.$modelValue)
|
renderAssignedTo($modelTransform.getObj())
|
||||||
$rootscope.$broadcast("object:updated")
|
$rootscope.$broadcast("object:updated")
|
||||||
promise.then null, ->
|
|
||||||
$model.$modelValue.revert()
|
transform.then null, ->
|
||||||
$confirm.notify("error")
|
$confirm.notify("error")
|
||||||
currentLoading.finish()
|
currentLoading.finish()
|
||||||
|
|
||||||
return promise
|
return transform
|
||||||
|
|
||||||
renderAssignedTo = (assignedObject) ->
|
renderAssignedTo = (assignedObject) ->
|
||||||
if assignedObject?.assigned_to?
|
if assignedObject?.assigned_to?
|
||||||
|
@ -347,7 +353,7 @@ AssignedToDirective = ($rootscope, $confirm, $repo, $loading, $qqueue, $template
|
||||||
require:"ngModel"
|
require:"ngModel"
|
||||||
}
|
}
|
||||||
|
|
||||||
module.directive("tgAssignedTo", ["$rootScope", "$tgConfirm", "$tgRepo", "$tgLoading", "$tgQqueue", "$tgTemplate", "$translate", "$compile","tgCurrentUserService",
|
module.directive("tgAssignedTo", ["$rootScope", "$tgConfirm", "$tgRepo", "$tgLoading", "$tgQueueModelTransformation", "$tgTemplate", "$translate", "$compile","tgCurrentUserService",
|
||||||
AssignedToDirective])
|
AssignedToDirective])
|
||||||
|
|
||||||
|
|
||||||
|
@ -447,7 +453,7 @@ module.directive("tgDeleteButton", ["$log", "$tgRepo", "$tgConfirm", "$tgLocatio
|
||||||
## Editable subject directive
|
## Editable subject directive
|
||||||
#############################################################################
|
#############################################################################
|
||||||
|
|
||||||
EditableSubjectDirective = ($rootscope, $repo, $confirm, $loading, $qqueue, $template) ->
|
EditableSubjectDirective = ($rootscope, $repo, $confirm, $loading, $modelTransform, $template) ->
|
||||||
template = $template.get("common/components/editable-subject.html")
|
template = $template.get("common/components/editable-subject.html")
|
||||||
|
|
||||||
link = ($scope, $el, $attrs, $model) ->
|
link = ($scope, $el, $attrs, $model) ->
|
||||||
|
@ -459,25 +465,29 @@ EditableSubjectDirective = ($rootscope, $repo, $confirm, $loading, $qqueue, $tem
|
||||||
isEditable = ->
|
isEditable = ->
|
||||||
return $scope.project.my_permissions.indexOf($attrs.requiredPerm) != -1
|
return $scope.project.my_permissions.indexOf($attrs.requiredPerm) != -1
|
||||||
|
|
||||||
save = $qqueue.bindAdd (subject) =>
|
save = (subject) ->
|
||||||
$model.$modelValue.subject = subject
|
|
||||||
|
|
||||||
currentLoading = $loading()
|
currentLoading = $loading()
|
||||||
.target($el.find('.save-container'))
|
.target($el.find('.save-container'))
|
||||||
.start()
|
.start()
|
||||||
|
|
||||||
promise = $repo.save($model.$modelValue)
|
transform = $modelTransform.save (item) ->
|
||||||
promise.then ->
|
item.subject = subject
|
||||||
|
|
||||||
|
return item
|
||||||
|
|
||||||
|
transform.then =>
|
||||||
$confirm.notify("success")
|
$confirm.notify("success")
|
||||||
$rootscope.$broadcast("object:updated")
|
$rootscope.$broadcast("object:updated")
|
||||||
$el.find('.edit-subject').hide()
|
$el.find('.edit-subject').hide()
|
||||||
$el.find('.view-subject').show()
|
$el.find('.view-subject').show()
|
||||||
promise.then null, ->
|
|
||||||
|
transform.then null, ->
|
||||||
$confirm.notify("error")
|
$confirm.notify("error")
|
||||||
promise.finally ->
|
|
||||||
|
transform.finally ->
|
||||||
currentLoading.finish()
|
currentLoading.finish()
|
||||||
|
|
||||||
return promise
|
return transform
|
||||||
|
|
||||||
$el.click ->
|
$el.click ->
|
||||||
return if not isEditable()
|
return if not isEditable()
|
||||||
|
@ -521,7 +531,7 @@ EditableSubjectDirective = ($rootscope, $repo, $confirm, $loading, $qqueue, $tem
|
||||||
template: template
|
template: template
|
||||||
}
|
}
|
||||||
|
|
||||||
module.directive("tgEditableSubject", ["$rootScope", "$tgRepo", "$tgConfirm", "$tgLoading", "$tgQqueue",
|
module.directive("tgEditableSubject", ["$rootScope", "$tgRepo", "$tgConfirm", "$tgLoading", "$tgQueueModelTransformation",
|
||||||
"$tgTemplate", EditableSubjectDirective])
|
"$tgTemplate", EditableSubjectDirective])
|
||||||
|
|
||||||
|
|
||||||
|
@ -529,7 +539,7 @@ module.directive("tgEditableSubject", ["$rootScope", "$tgRepo", "$tgConfirm", "$
|
||||||
## Editable description directive
|
## Editable description directive
|
||||||
#############################################################################
|
#############################################################################
|
||||||
|
|
||||||
EditableDescriptionDirective = ($rootscope, $repo, $confirm, $compile, $loading, $selectedText, $qqueue, $template, $translate) ->
|
EditableDescriptionDirective = ($rootscope, $repo, $confirm, $compile, $loading, $selectedText, $modelTransform, $template, $translate) ->
|
||||||
template = $template.get("common/components/editable-description.html")
|
template = $template.get("common/components/editable-description.html")
|
||||||
noDescriptionMegEditMode = $template.get("common/components/editable-description-msg-edit-mode.html")
|
noDescriptionMegEditMode = $template.get("common/components/editable-description-msg-edit-mode.html")
|
||||||
noDescriptionMegReadMode = $template.get("common/components/editable-description-msg-read-mode.html")
|
noDescriptionMegReadMode = $template.get("common/components/editable-description-msg-read-mode.html")
|
||||||
|
@ -545,22 +555,26 @@ EditableDescriptionDirective = ($rootscope, $repo, $confirm, $compile, $loading,
|
||||||
isEditable = ->
|
isEditable = ->
|
||||||
return $scope.project.my_permissions.indexOf($attrs.requiredPerm) != -1
|
return $scope.project.my_permissions.indexOf($attrs.requiredPerm) != -1
|
||||||
|
|
||||||
save = $qqueue.bindAdd (description) =>
|
save = (description) ->
|
||||||
$model.$modelValue.description = description
|
|
||||||
|
|
||||||
currentLoading = $loading()
|
currentLoading = $loading()
|
||||||
.target($el.find('.save-container'))
|
.target($el.find('.save-container'))
|
||||||
.start()
|
.start()
|
||||||
|
|
||||||
promise = $repo.save($model.$modelValue)
|
transform = $modelTransform.save (item) ->
|
||||||
promise.then ->
|
item.description = description
|
||||||
|
|
||||||
|
return item
|
||||||
|
|
||||||
|
transform.then ->
|
||||||
$confirm.notify("success")
|
$confirm.notify("success")
|
||||||
$rootscope.$broadcast("object:updated")
|
$rootscope.$broadcast("object:updated")
|
||||||
$el.find('.edit-description').hide()
|
$el.find('.edit-description').hide()
|
||||||
$el.find('.view-description').show()
|
$el.find('.view-description').show()
|
||||||
promise.then null, ->
|
|
||||||
|
transform.then null, ->
|
||||||
$confirm.notify("error")
|
$confirm.notify("error")
|
||||||
promise.finally ->
|
|
||||||
|
transform.finally ->
|
||||||
currentLoading.finish()
|
currentLoading.finish()
|
||||||
|
|
||||||
cancelEdition = () ->
|
cancelEdition = () ->
|
||||||
|
@ -631,7 +645,7 @@ module.directive("tgEditableDescription", [
|
||||||
"$compile",
|
"$compile",
|
||||||
"$tgLoading",
|
"$tgLoading",
|
||||||
"$selectedText",
|
"$selectedText",
|
||||||
"$tgQqueue",
|
"$tgQueueModelTransformation",
|
||||||
"$tgTemplate",
|
"$tgTemplate",
|
||||||
"$translate",
|
"$translate",
|
||||||
EditableDescriptionDirective])
|
EditableDescriptionDirective])
|
||||||
|
|
|
@ -80,7 +80,7 @@ module.directive("tgLbUsEstimation", ["$tgEstimationsService", "$rootScope", "$t
|
||||||
## User story estimation directive
|
## User story estimation directive
|
||||||
#############################################################################
|
#############################################################################
|
||||||
|
|
||||||
UsEstimationDirective = ($tgEstimationsService, $rootScope, $repo, $qqueue, $template, $compile) ->
|
UsEstimationDirective = ($tgEstimationsService, $rootScope, $repo, $template, $compile) ->
|
||||||
# Display the points of a US and you can edit it.
|
# Display the points of a US and you can edit it.
|
||||||
#
|
#
|
||||||
# Example:
|
# Example:
|
||||||
|
@ -91,11 +91,14 @@ UsEstimationDirective = ($tgEstimationsService, $rootScope, $repo, $qqueue, $tem
|
||||||
# - scope.project object
|
# - scope.project object
|
||||||
|
|
||||||
link = ($scope, $el, $attrs, $model) ->
|
link = ($scope, $el, $attrs, $model) ->
|
||||||
$scope.$watch $attrs.ngModel, (us) ->
|
$scope.$watchCollection () ->
|
||||||
|
return $model.$modelValue && $model.$modelValue.points
|
||||||
|
, () ->
|
||||||
|
us = $model.$modelValue
|
||||||
if us
|
if us
|
||||||
estimationProcess = $tgEstimationsService.create($el, us, $scope.project)
|
estimationProcess = $tgEstimationsService.create($el, us, $scope.project)
|
||||||
estimationProcess.onSelectedPointForRole = (roleId, pointId) ->
|
estimationProcess.onSelectedPointForRole = (roleId, pointId) ->
|
||||||
@save(roleId, pointId).then ->
|
@save(roleId, pointId).then () ->
|
||||||
$rootScope.$broadcast("object:updated")
|
$rootScope.$broadcast("object:updated")
|
||||||
|
|
||||||
estimationProcess.render = () ->
|
estimationProcess.render = () ->
|
||||||
|
@ -121,7 +124,7 @@ UsEstimationDirective = ($tgEstimationsService, $rootScope, $repo, $qqueue, $tem
|
||||||
require: "ngModel"
|
require: "ngModel"
|
||||||
}
|
}
|
||||||
|
|
||||||
module.directive("tgUsEstimation", ["$tgEstimationsService", "$rootScope", "$tgRepo", "$tgQqueue",
|
module.directive("tgUsEstimation", ["$tgEstimationsService", "$rootScope", "$tgRepo",
|
||||||
"$tgTemplate", "$compile", UsEstimationDirective])
|
"$tgTemplate", "$compile", UsEstimationDirective])
|
||||||
|
|
||||||
|
|
||||||
|
@ -129,7 +132,7 @@ module.directive("tgUsEstimation", ["$tgEstimationsService", "$rootScope", "$tgR
|
||||||
## Estimations service
|
## Estimations service
|
||||||
#############################################################################
|
#############################################################################
|
||||||
|
|
||||||
EstimationsService = ($template, $qqueue, $repo, $confirm, $q) ->
|
EstimationsService = ($template, $modelTransform, $repo, $confirm, $q) ->
|
||||||
pointsTemplate = $template.get("common/estimation/us-estimation-points.html", true)
|
pointsTemplate = $template.get("common/estimation/us-estimation-points.html", true)
|
||||||
|
|
||||||
class EstimationProcess
|
class EstimationProcess
|
||||||
|
@ -143,17 +146,23 @@ EstimationsService = ($template, $qqueue, $repo, $confirm, $q) ->
|
||||||
|
|
||||||
save: (roleId, pointId) ->
|
save: (roleId, pointId) ->
|
||||||
deferred = $q.defer()
|
deferred = $q.defer()
|
||||||
$qqueue.add () =>
|
|
||||||
onSuccess = =>
|
|
||||||
deferred.resolve()
|
|
||||||
|
|
||||||
onError = =>
|
transform = $modelTransform.save (us) =>
|
||||||
$confirm.notify("error")
|
points = _.clone(@us.points, true)
|
||||||
@us.revert()
|
points[roleId] = pointId
|
||||||
@render()
|
|
||||||
deferred.reject()
|
|
||||||
|
|
||||||
$repo.save(@us).then(onSuccess, onError)
|
us.points = points
|
||||||
|
|
||||||
|
return us
|
||||||
|
|
||||||
|
onSuccess = =>
|
||||||
|
deferred.resolve()
|
||||||
|
|
||||||
|
onError = =>
|
||||||
|
$confirm.notify("error")
|
||||||
|
deferred.reject()
|
||||||
|
|
||||||
|
transform.then(onSuccess, onError)
|
||||||
|
|
||||||
return deferred.promise
|
return deferred.promise
|
||||||
|
|
||||||
|
@ -197,10 +206,6 @@ EstimationsService = ($template, $qqueue, $repo, $confirm, $q) ->
|
||||||
roleId = target.data("role-id")
|
roleId = target.data("role-id")
|
||||||
pointId = target.data("point-id")
|
pointId = target.data("point-id")
|
||||||
@$el.find(".popover").popover().close()
|
@$el.find(".popover").popover().close()
|
||||||
points = _.clone(@us.points, true)
|
|
||||||
points[roleId] = pointId
|
|
||||||
@us.points = points
|
|
||||||
@render()
|
|
||||||
@onSelectedPointForRole(roleId, pointId)
|
@onSelectedPointForRole(roleId, pointId)
|
||||||
|
|
||||||
renderPointsSelector: (roleId, target) ->
|
renderPointsSelector: (roleId, target) ->
|
||||||
|
@ -247,5 +252,5 @@ EstimationsService = ($template, $qqueue, $repo, $confirm, $q) ->
|
||||||
create: create
|
create: create
|
||||||
}
|
}
|
||||||
|
|
||||||
module.factory("$tgEstimationsService", ["$tgTemplate", "$tgQqueue", "$tgRepo", "$tgConfirm",
|
module.factory("$tgEstimationsService", ["$tgTemplate", "$tgQueueModelTransformation", "$tgRepo", "$tgConfirm",
|
||||||
"$q", EstimationsService])
|
"$q", EstimationsService])
|
||||||
|
|
|
@ -169,47 +169,51 @@ module.directive("lightbox", ["lightboxService", LightboxDirective])
|
||||||
|
|
||||||
# Issue/Userstory blocking message lightbox directive.
|
# Issue/Userstory blocking message lightbox directive.
|
||||||
|
|
||||||
BlockLightboxDirective = ($rootscope, $tgrepo, $confirm, lightboxService, $loading, $qqueue, $translate) ->
|
BlockLightboxDirective = ($rootscope, $tgrepo, $confirm, lightboxService, $loading, $modelTransform, $translate) ->
|
||||||
link = ($scope, $el, $attrs, $model) ->
|
link = ($scope, $el, $attrs, $model) ->
|
||||||
title = $translate.instant($attrs.title)
|
title = $translate.instant($attrs.title)
|
||||||
$el.find("h2.title").text(title)
|
$el.find("h2.title").text(title)
|
||||||
|
|
||||||
unblock = $qqueue.bindAdd (item, finishCallback) =>
|
unblock = (finishCallback) =>
|
||||||
promise = $tgrepo.save(item)
|
transform = $modelTransform.save (item) ->
|
||||||
promise.then ->
|
item.is_blocked = false
|
||||||
|
item.blocked_note = ""
|
||||||
|
|
||||||
|
return item
|
||||||
|
|
||||||
|
transform.then ->
|
||||||
$confirm.notify("success")
|
$confirm.notify("success")
|
||||||
$rootscope.$broadcast("object:updated")
|
$rootscope.$broadcast("object:updated")
|
||||||
$model.$setViewValue(item)
|
|
||||||
finishCallback()
|
finishCallback()
|
||||||
|
|
||||||
promise.then null, ->
|
transform.then null, ->
|
||||||
$confirm.notify("error")
|
$confirm.notify("error")
|
||||||
item.revert()
|
item.revert()
|
||||||
$model.$setViewValue(item)
|
|
||||||
|
|
||||||
promise.finally ->
|
transform.finally ->
|
||||||
finishCallback()
|
finishCallback()
|
||||||
|
|
||||||
return promise
|
return transform
|
||||||
|
|
||||||
block = $qqueue.bindAdd (item) =>
|
|
||||||
$model.$setViewValue(item)
|
|
||||||
|
|
||||||
|
block = () ->
|
||||||
currentLoading = $loading()
|
currentLoading = $loading()
|
||||||
.target($el.find(".button-green"))
|
.target($el.find(".button-green"))
|
||||||
.start()
|
.start()
|
||||||
|
|
||||||
promise = $tgrepo.save($model.$modelValue)
|
transform = $modelTransform.save (item) ->
|
||||||
promise.then ->
|
item.is_blocked = true
|
||||||
|
item.blocked_note = $el.find(".reason").val()
|
||||||
|
|
||||||
|
return item
|
||||||
|
|
||||||
|
transform.then ->
|
||||||
$confirm.notify("success")
|
$confirm.notify("success")
|
||||||
$rootscope.$broadcast("object:updated")
|
$rootscope.$broadcast("object:updated")
|
||||||
|
|
||||||
promise.then null, ->
|
transform.then null, ->
|
||||||
$confirm.notify("error")
|
$confirm.notify("error")
|
||||||
item.revert()
|
|
||||||
$model.$setViewValue(item)
|
|
||||||
|
|
||||||
promise.finally ->
|
transform.finally ->
|
||||||
currentLoading.finish()
|
currentLoading.finish()
|
||||||
lightboxService.close($el)
|
lightboxService.close($el)
|
||||||
|
|
||||||
|
@ -218,11 +222,7 @@ BlockLightboxDirective = ($rootscope, $tgrepo, $confirm, lightboxService, $loadi
|
||||||
lightboxService.open($el)
|
lightboxService.open($el)
|
||||||
|
|
||||||
$scope.$on "unblock", (event, model, finishCallback) =>
|
$scope.$on "unblock", (event, model, finishCallback) =>
|
||||||
item = $model.$modelValue.clone()
|
unblock(finishCallback)
|
||||||
item.is_blocked = false
|
|
||||||
item.blocked_note = ""
|
|
||||||
|
|
||||||
unblock(item, finishCallback)
|
|
||||||
|
|
||||||
$scope.$on "$destroy", ->
|
$scope.$on "$destroy", ->
|
||||||
$el.off()
|
$el.off()
|
||||||
|
@ -230,11 +230,7 @@ BlockLightboxDirective = ($rootscope, $tgrepo, $confirm, lightboxService, $loadi
|
||||||
$el.on "click", ".button-green", (event) ->
|
$el.on "click", ".button-green", (event) ->
|
||||||
event.preventDefault()
|
event.preventDefault()
|
||||||
|
|
||||||
item = $model.$modelValue.clone()
|
block()
|
||||||
item.is_blocked = true
|
|
||||||
item.blocked_note = $el.find(".reason").val()
|
|
||||||
|
|
||||||
block(item)
|
|
||||||
|
|
||||||
return {
|
return {
|
||||||
templateUrl: "common/lightbox/lightbox-block.html"
|
templateUrl: "common/lightbox/lightbox-block.html"
|
||||||
|
@ -242,7 +238,7 @@ BlockLightboxDirective = ($rootscope, $tgrepo, $confirm, lightboxService, $loadi
|
||||||
require: "ngModel"
|
require: "ngModel"
|
||||||
}
|
}
|
||||||
|
|
||||||
module.directive("tgLbBlock", ["$rootScope", "$tgRepo", "$tgConfirm", "lightboxService", "$tgLoading", "$tgQqueue", "$translate", BlockLightboxDirective])
|
module.directive("tgLbBlock", ["$rootScope", "$tgRepo", "$tgConfirm", "lightboxService", "$tgLoading", "$tgQueueModelTransformation", "$translate", BlockLightboxDirective])
|
||||||
|
|
||||||
|
|
||||||
#############################################################################
|
#############################################################################
|
||||||
|
|
|
@ -222,7 +222,7 @@ module.directive("tgLbTagLine", ["$tgResources", "$tgTemplate", "$compile", LbTa
|
||||||
## TagLine Directive (for detail pages)
|
## TagLine Directive (for detail pages)
|
||||||
#############################################################################
|
#############################################################################
|
||||||
|
|
||||||
TagLineDirective = ($rootScope, $repo, $rs, $confirm, $qqueue, $template, $compile) ->
|
TagLineDirective = ($rootScope, $repo, $rs, $confirm, $modelTransform, $template, $compile) ->
|
||||||
ENTER_KEY = 13
|
ENTER_KEY = 13
|
||||||
ESC_KEY = 27
|
ESC_KEY = 27
|
||||||
COMMA_KEY = 188
|
COMMA_KEY = 188
|
||||||
|
@ -269,48 +269,49 @@ TagLineDirective = ($rootScope, $repo, $rs, $confirm, $qqueue, $template, $compi
|
||||||
autocomplete.close()
|
autocomplete.close()
|
||||||
|
|
||||||
## Aux methods
|
## Aux methods
|
||||||
addValue = $qqueue.bindAdd (value) ->
|
addValue = (value) ->
|
||||||
value = trim(value.toLowerCase())
|
value = trim(value.toLowerCase())
|
||||||
return if value.length == 0
|
return if value.length == 0
|
||||||
|
|
||||||
tags = _.clone($model.$modelValue.tags, false)
|
transform = $modelTransform.save (item) ->
|
||||||
tags = [] if not tags?
|
if not item.tags
|
||||||
tags.push(value) if value not in tags
|
item.tags = []
|
||||||
|
|
||||||
model = $model.$modelValue.clone()
|
tags = _.clone(item.tags)
|
||||||
model.tags = tags
|
|
||||||
$model.$setViewValue(model)
|
tags.push(value) if value not in tags
|
||||||
|
|
||||||
|
item.tags = tags
|
||||||
|
|
||||||
|
return item
|
||||||
|
|
||||||
onSuccess = ->
|
onSuccess = ->
|
||||||
$rootScope.$broadcast("object:updated")
|
$rootScope.$broadcast("object:updated")
|
||||||
|
|
||||||
onError = ->
|
onError = ->
|
||||||
$confirm.notify("error")
|
$confirm.notify("error")
|
||||||
model.revert()
|
|
||||||
$model.$setViewValue(model)
|
|
||||||
|
|
||||||
hideSaveButton()
|
hideSaveButton()
|
||||||
|
|
||||||
return $repo.save(model).then(onSuccess, onError)
|
return transform.then(onSuccess, onError)
|
||||||
|
|
||||||
deleteValue = $qqueue.bindAdd (value) ->
|
deleteValue = (value) ->
|
||||||
value = trim(value.toLowerCase())
|
value = trim(value.toLowerCase())
|
||||||
return if value.length == 0
|
return if value.length == 0
|
||||||
|
|
||||||
tags = _.clone($model.$modelValue.tags, false)
|
transform = $modelTransform.save (item) ->
|
||||||
tags = _.pull(tags, value)
|
tags = _.clone(item.tags, false)
|
||||||
|
item.tags = _.pull(tags, value)
|
||||||
|
|
||||||
model = $model.$modelValue.clone()
|
return item
|
||||||
model.tags = tags
|
|
||||||
$model.$setViewValue(model)
|
|
||||||
|
|
||||||
onSuccess = ->
|
onSuccess = ->
|
||||||
$rootScope.$broadcast("object:updated")
|
$rootScope.$broadcast("object:updated")
|
||||||
|
|
||||||
onError = ->
|
onError = ->
|
||||||
$confirm.notify("error")
|
$confirm.notify("error")
|
||||||
model.revert()
|
|
||||||
$model.$setViewValue(model)
|
|
||||||
|
|
||||||
return $repo.save(model).then(onSuccess, onError)
|
return transform.then(onSuccess, onError)
|
||||||
|
|
||||||
saveInputTag = () ->
|
saveInputTag = () ->
|
||||||
value = $el.find("input").val()
|
value = $el.find("input").val()
|
||||||
|
@ -374,7 +375,12 @@ TagLineDirective = ($rootScope, $repo, $rs, $confirm, $qqueue, $template, $compi
|
||||||
addValue(input.val())
|
addValue(input.val())
|
||||||
input.val("")
|
input.val("")
|
||||||
|
|
||||||
$scope.$watch $attrs.ngModel, (model) ->
|
|
||||||
|
$scope.$watchCollection () ->
|
||||||
|
return $model.$modelValue?.tags
|
||||||
|
, () ->
|
||||||
|
model = $model.$modelValue
|
||||||
|
|
||||||
return if not model
|
return if not model
|
||||||
|
|
||||||
if model.tags?.length
|
if model.tags?.length
|
||||||
|
@ -394,5 +400,5 @@ TagLineDirective = ($rootScope, $repo, $rs, $confirm, $qqueue, $template, $compi
|
||||||
templateUrl: "common/tag/tag-line.html"
|
templateUrl: "common/tag/tag-line.html"
|
||||||
}
|
}
|
||||||
|
|
||||||
module.directive("tgTagLine", ["$rootScope", "$tgRepo", "$tgResources", "$tgConfirm", "$tgQqueue",
|
module.directive("tgTagLine", ["$rootScope", "$tgRepo", "$tgResources", "$tgConfirm", "$tgQueueModelTransformation",
|
||||||
"$tgTemplate", "$compile", TagLineDirective])
|
"$tgTemplate", "$compile", TagLineDirective])
|
||||||
|
|
|
@ -51,11 +51,12 @@ class IssueDetailController extends mixOf(taiga.Controller, taiga.PageMixin)
|
||||||
"tgAppMetaService",
|
"tgAppMetaService",
|
||||||
"$tgAnalytics",
|
"$tgAnalytics",
|
||||||
"$tgNavUrls",
|
"$tgNavUrls",
|
||||||
"$translate"
|
"$translate",
|
||||||
|
"$tgQueueModelTransformation"
|
||||||
]
|
]
|
||||||
|
|
||||||
constructor: (@scope, @rootscope, @repo, @confirm, @rs, @params, @q, @location,
|
constructor: (@scope, @rootscope, @repo, @confirm, @rs, @params, @q, @location,
|
||||||
@log, @appMetaService, @analytics, @navUrls, @translate) ->
|
@log, @appMetaService, @analytics, @navUrls, @translate, @modelTransform) ->
|
||||||
bindMethods(@)
|
bindMethods(@)
|
||||||
|
|
||||||
@scope.issueRef = @params.issueref
|
@scope.issueRef = @params.issueref
|
||||||
|
@ -130,6 +131,8 @@ class IssueDetailController extends mixOf(taiga.Controller, taiga.PageMixin)
|
||||||
@scope.issueId = issue.id
|
@scope.issueId = issue.id
|
||||||
@scope.commentModel = issue
|
@scope.commentModel = issue
|
||||||
|
|
||||||
|
@modelTransform.setObject(@scope, 'issue')
|
||||||
|
|
||||||
if @scope.issue.neighbors.previous?.ref?
|
if @scope.issue.neighbors.previous?.ref?
|
||||||
ctx = {
|
ctx = {
|
||||||
project: @scope.project.slug
|
project: @scope.project.slug
|
||||||
|
@ -245,7 +248,7 @@ module.directive("tgIssueStatusDisplay", ["$tgTemplate", "$compile", IssueStatus
|
||||||
## Issue status button directive
|
## Issue status button directive
|
||||||
#############################################################################
|
#############################################################################
|
||||||
|
|
||||||
IssueStatusButtonDirective = ($rootScope, $repo, $confirm, $loading, $qqueue, $template, $compile) ->
|
IssueStatusButtonDirective = ($rootScope, $repo, $confirm, $loading, $modelTransform, $template, $compile) ->
|
||||||
# Display the status of Issue and you can edit it.
|
# Display the status of Issue and you can edit it.
|
||||||
#
|
#
|
||||||
# Example:
|
# Example:
|
||||||
|
@ -256,7 +259,7 @@ IssueStatusButtonDirective = ($rootScope, $repo, $confirm, $loading, $qqueue, $t
|
||||||
# - scope.statusById object
|
# - scope.statusById object
|
||||||
# - $scope.project.my_permissions
|
# - $scope.project.my_permissions
|
||||||
|
|
||||||
template = $template.get("issue/issues-status-button.html", true)
|
template = $template.get("common/components/status-button.html", true)
|
||||||
|
|
||||||
link = ($scope, $el, $attrs, $model) ->
|
link = ($scope, $el, $attrs, $model) ->
|
||||||
isEditable = ->
|
isEditable = ->
|
||||||
|
@ -275,28 +278,27 @@ IssueStatusButtonDirective = ($rootScope, $repo, $confirm, $loading, $qqueue, $t
|
||||||
|
|
||||||
$el.html(html)
|
$el.html(html)
|
||||||
|
|
||||||
save = $qqueue.bindAdd (statusId) =>
|
save = (statusId) ->
|
||||||
$.fn.popover().closeAll()
|
$.fn.popover().closeAll()
|
||||||
|
|
||||||
issue = $model.$modelValue.clone()
|
|
||||||
issue.status = statusId
|
|
||||||
|
|
||||||
currentLoading = $loading()
|
currentLoading = $loading()
|
||||||
.target($el)
|
.target($el)
|
||||||
.start()
|
.start()
|
||||||
|
|
||||||
|
transform = $modelTransform.save (issue) ->
|
||||||
|
issue.status = statusId
|
||||||
|
|
||||||
|
return issue
|
||||||
|
|
||||||
onSuccess = ->
|
onSuccess = ->
|
||||||
$model.$setViewValue(issue)
|
|
||||||
$rootScope.$broadcast("object:updated")
|
$rootScope.$broadcast("object:updated")
|
||||||
currentLoading.finish()
|
currentLoading.finish()
|
||||||
|
|
||||||
onError = ->
|
onError = ->
|
||||||
$confirm.notify("error")
|
$confirm.notify("error")
|
||||||
issue.revert()
|
|
||||||
$model.$setViewValue(issue)
|
|
||||||
currentLoading.finish()
|
currentLoading.finish()
|
||||||
|
|
||||||
|
transform.then(onSuccess, onError)
|
||||||
$repo.save(issue).then(onSuccess, onError)
|
|
||||||
|
|
||||||
$el.on "click", ".js-edit-status", (event) ->
|
$el.on "click", ".js-edit-status", (event) ->
|
||||||
event.preventDefault()
|
event.preventDefault()
|
||||||
|
@ -314,7 +316,10 @@ IssueStatusButtonDirective = ($rootScope, $repo, $confirm, $loading, $qqueue, $t
|
||||||
|
|
||||||
save(target.data("status-id"))
|
save(target.data("status-id"))
|
||||||
|
|
||||||
$scope.$watch $attrs.ngModel, (issue) ->
|
$scope.$watch () ->
|
||||||
|
return $model.$modelValue?.status
|
||||||
|
, () ->
|
||||||
|
issue = $model.$modelValue
|
||||||
render(issue) if issue
|
render(issue) if issue
|
||||||
|
|
||||||
$scope.$on "$destroy", ->
|
$scope.$on "$destroy", ->
|
||||||
|
@ -326,13 +331,13 @@ IssueStatusButtonDirective = ($rootScope, $repo, $confirm, $loading, $qqueue, $t
|
||||||
require: "ngModel"
|
require: "ngModel"
|
||||||
}
|
}
|
||||||
|
|
||||||
module.directive("tgIssueStatusButton", ["$rootScope", "$tgRepo", "$tgConfirm", "$tgLoading", "$tgQqueue", "$tgTemplate", "$compile", IssueStatusButtonDirective])
|
module.directive("tgIssueStatusButton", ["$rootScope", "$tgRepo", "$tgConfirm", "$tgLoading", "$tgQueueModelTransformation", "$tgTemplate", "$compile", IssueStatusButtonDirective])
|
||||||
|
|
||||||
#############################################################################
|
#############################################################################
|
||||||
## Issue type button directive
|
## Issue type button directive
|
||||||
#############################################################################
|
#############################################################################
|
||||||
|
|
||||||
IssueTypeButtonDirective = ($rootScope, $repo, $confirm, $loading, $qqueue, $template, $compile) ->
|
IssueTypeButtonDirective = ($rootScope, $repo, $confirm, $loading, $modelTransform, $template, $compile) ->
|
||||||
# Display the type of Issue and you can edit it.
|
# Display the type of Issue and you can edit it.
|
||||||
#
|
#
|
||||||
# Example:
|
# Example:
|
||||||
|
@ -362,27 +367,27 @@ IssueTypeButtonDirective = ($rootScope, $repo, $confirm, $loading, $qqueue, $tem
|
||||||
|
|
||||||
$el.html(html)
|
$el.html(html)
|
||||||
|
|
||||||
save = $qqueue.bindAdd (type) =>
|
save = (type) ->
|
||||||
$.fn.popover().closeAll()
|
$.fn.popover().closeAll()
|
||||||
issue = $model.$modelValue.clone()
|
|
||||||
issue.type = type
|
|
||||||
|
|
||||||
currentLoading = $loading()
|
currentLoading = $loading()
|
||||||
.target($el.find(".level-name"))
|
.target($el.find(".level-name"))
|
||||||
.start()
|
.start()
|
||||||
|
|
||||||
|
transform = $modelTransform.save (issue) ->
|
||||||
|
issue.type = type
|
||||||
|
|
||||||
|
return issue
|
||||||
|
|
||||||
onSuccess = ->
|
onSuccess = ->
|
||||||
$model.$setViewValue(issue)
|
|
||||||
$rootScope.$broadcast("object:updated")
|
$rootScope.$broadcast("object:updated")
|
||||||
currentLoading.finish()
|
currentLoading.finish()
|
||||||
|
|
||||||
onError = ->
|
onError = ->
|
||||||
$confirm.notify("error")
|
$confirm.notify("error")
|
||||||
issue.revert()
|
|
||||||
$model.$setViewValue(issue)
|
|
||||||
currentLoading.finish()
|
currentLoading.finish()
|
||||||
|
|
||||||
$repo.save(issue).then(onSuccess, onError)
|
transform.then(onSuccess, onError)
|
||||||
|
|
||||||
$el.on "click", ".type-data", (event) ->
|
$el.on "click", ".type-data", (event) ->
|
||||||
event.preventDefault()
|
event.preventDefault()
|
||||||
|
@ -400,7 +405,10 @@ IssueTypeButtonDirective = ($rootScope, $repo, $confirm, $loading, $qqueue, $tem
|
||||||
type = target.data("type-id")
|
type = target.data("type-id")
|
||||||
save(type)
|
save(type)
|
||||||
|
|
||||||
$scope.$watch $attrs.ngModel, (issue) ->
|
$scope.$watch () ->
|
||||||
|
return $model.$modelValue?.type
|
||||||
|
, () ->
|
||||||
|
issue = $model.$modelValue
|
||||||
render(issue) if issue
|
render(issue) if issue
|
||||||
|
|
||||||
$scope.$on "$destroy", ->
|
$scope.$on "$destroy", ->
|
||||||
|
@ -412,14 +420,14 @@ IssueTypeButtonDirective = ($rootScope, $repo, $confirm, $loading, $qqueue, $tem
|
||||||
require: "ngModel"
|
require: "ngModel"
|
||||||
}
|
}
|
||||||
|
|
||||||
module.directive("tgIssueTypeButton", ["$rootScope", "$tgRepo", "$tgConfirm", "$tgLoading", "$tgQqueue", "$tgTemplate", "$compile", IssueTypeButtonDirective])
|
module.directive("tgIssueTypeButton", ["$rootScope", "$tgRepo", "$tgConfirm", "$tgLoading", "$tgQueueModelTransformation", "$tgTemplate", "$compile", IssueTypeButtonDirective])
|
||||||
|
|
||||||
|
|
||||||
#############################################################################
|
#############################################################################
|
||||||
## Issue severity button directive
|
## Issue severity button directive
|
||||||
#############################################################################
|
#############################################################################
|
||||||
|
|
||||||
IssueSeverityButtonDirective = ($rootScope, $repo, $confirm, $loading, $qqueue, $template, $compile) ->
|
IssueSeverityButtonDirective = ($rootScope, $repo, $confirm, $loading, $modelTransform, $template, $compile) ->
|
||||||
# Display the severity of Issue and you can edit it.
|
# Display the severity of Issue and you can edit it.
|
||||||
#
|
#
|
||||||
# Example:
|
# Example:
|
||||||
|
@ -449,27 +457,27 @@ IssueSeverityButtonDirective = ($rootScope, $repo, $confirm, $loading, $qqueue,
|
||||||
|
|
||||||
$el.html(html)
|
$el.html(html)
|
||||||
|
|
||||||
save = $qqueue.bindAdd (severity) =>
|
save = (severity) ->
|
||||||
$.fn.popover().closeAll()
|
$.fn.popover().closeAll()
|
||||||
|
|
||||||
issue = $model.$modelValue.clone()
|
|
||||||
issue.severity = severity
|
|
||||||
|
|
||||||
currentLoading = $loading()
|
currentLoading = $loading()
|
||||||
.target($el.find(".level-name"))
|
.target($el.find(".level-name"))
|
||||||
.start()
|
.start()
|
||||||
|
|
||||||
|
transform = $modelTransform.save (issue) ->
|
||||||
|
issue.severity = severity
|
||||||
|
|
||||||
|
return issue
|
||||||
|
|
||||||
onSuccess = ->
|
onSuccess = ->
|
||||||
$model.$setViewValue(issue)
|
|
||||||
$rootScope.$broadcast("object:updated")
|
$rootScope.$broadcast("object:updated")
|
||||||
currentLoading.finish()
|
currentLoading.finish()
|
||||||
|
|
||||||
onError = ->
|
onError = ->
|
||||||
$confirm.notify("error")
|
$confirm.notify("error")
|
||||||
issue.revert()
|
|
||||||
$model.$setViewValue(issue)
|
|
||||||
currentLoading.finish()
|
currentLoading.finish()
|
||||||
|
|
||||||
$repo.save(issue).then(onSuccess, onError)
|
transform.then(onSuccess, onError)
|
||||||
|
|
||||||
$el.on "click", ".severity-data", (event) ->
|
$el.on "click", ".severity-data", (event) ->
|
||||||
event.preventDefault()
|
event.preventDefault()
|
||||||
|
@ -488,7 +496,10 @@ IssueSeverityButtonDirective = ($rootScope, $repo, $confirm, $loading, $qqueue,
|
||||||
|
|
||||||
save(severity)
|
save(severity)
|
||||||
|
|
||||||
$scope.$watch $attrs.ngModel, (issue) ->
|
$scope.$watch () ->
|
||||||
|
return $model.$modelValue?.severity
|
||||||
|
, () ->
|
||||||
|
issue = $model.$modelValue
|
||||||
render(issue) if issue
|
render(issue) if issue
|
||||||
|
|
||||||
$scope.$on "$destroy", ->
|
$scope.$on "$destroy", ->
|
||||||
|
@ -500,14 +511,14 @@ IssueSeverityButtonDirective = ($rootScope, $repo, $confirm, $loading, $qqueue,
|
||||||
require: "ngModel"
|
require: "ngModel"
|
||||||
}
|
}
|
||||||
|
|
||||||
module.directive("tgIssueSeverityButton", ["$rootScope", "$tgRepo", "$tgConfirm", "$tgLoading", "$tgQqueue", "$tgTemplate", "$compile", IssueSeverityButtonDirective])
|
module.directive("tgIssueSeverityButton", ["$rootScope", "$tgRepo", "$tgConfirm", "$tgLoading", "$tgQueueModelTransformation", "$tgTemplate", "$compile", IssueSeverityButtonDirective])
|
||||||
|
|
||||||
|
|
||||||
#############################################################################
|
#############################################################################
|
||||||
## Issue priority button directive
|
## Issue priority button directive
|
||||||
#############################################################################
|
#############################################################################
|
||||||
|
|
||||||
IssuePriorityButtonDirective = ($rootScope, $repo, $confirm, $loading, $qqueue, $template, $compile) ->
|
IssuePriorityButtonDirective = ($rootScope, $repo, $confirm, $loading, $modelTransform, $template, $compile) ->
|
||||||
# Display the priority of Issue and you can edit it.
|
# Display the priority of Issue and you can edit it.
|
||||||
#
|
#
|
||||||
# Example:
|
# Example:
|
||||||
|
@ -537,27 +548,27 @@ IssuePriorityButtonDirective = ($rootScope, $repo, $confirm, $loading, $qqueue,
|
||||||
|
|
||||||
$el.html(html)
|
$el.html(html)
|
||||||
|
|
||||||
save = $qqueue.bindAdd (priority) =>
|
save = (priority) ->
|
||||||
$.fn.popover().closeAll()
|
$.fn.popover().closeAll()
|
||||||
|
|
||||||
issue = $model.$modelValue.clone()
|
|
||||||
issue.priority = priority
|
|
||||||
|
|
||||||
currentLoading = $loading()
|
currentLoading = $loading()
|
||||||
.target($el.find(".level-name"))
|
.target($el.find(".level-name"))
|
||||||
.start()
|
.start()
|
||||||
|
|
||||||
|
transform = $modelTransform.save (issue) ->
|
||||||
|
issue.priority = priority
|
||||||
|
|
||||||
|
return issue
|
||||||
|
|
||||||
onSuccess = ->
|
onSuccess = ->
|
||||||
$model.$setViewValue(issue)
|
|
||||||
$rootScope.$broadcast("object:updated")
|
$rootScope.$broadcast("object:updated")
|
||||||
currentLoading.finish()
|
currentLoading.finish()
|
||||||
|
|
||||||
onError = ->
|
onError = ->
|
||||||
$confirm.notify("error")
|
$confirm.notify("error")
|
||||||
issue.revert()
|
|
||||||
$model.$setViewValue(issue)
|
|
||||||
currentLoading.finish()
|
currentLoading.finish()
|
||||||
|
|
||||||
$repo.save(issue).then(onSuccess, onError)
|
transform.then(onSuccess, onError)
|
||||||
|
|
||||||
$el.on "click", ".priority-data", (event) ->
|
$el.on "click", ".priority-data", (event) ->
|
||||||
event.preventDefault()
|
event.preventDefault()
|
||||||
|
@ -576,7 +587,10 @@ IssuePriorityButtonDirective = ($rootScope, $repo, $confirm, $loading, $qqueue,
|
||||||
|
|
||||||
save(priority)
|
save(priority)
|
||||||
|
|
||||||
$scope.$watch $attrs.ngModel, (issue) ->
|
$scope.$watch () ->
|
||||||
|
return $model.$modelValue?.priority
|
||||||
|
, () ->
|
||||||
|
issue = $model.$modelValue
|
||||||
render(issue) if issue
|
render(issue) if issue
|
||||||
|
|
||||||
$scope.$on "$destroy", ->
|
$scope.$on "$destroy", ->
|
||||||
|
@ -588,17 +602,17 @@ IssuePriorityButtonDirective = ($rootScope, $repo, $confirm, $loading, $qqueue,
|
||||||
require: "ngModel"
|
require: "ngModel"
|
||||||
}
|
}
|
||||||
|
|
||||||
module.directive("tgIssuePriorityButton", ["$rootScope", "$tgRepo", "$tgConfirm", "$tgLoading", "$tgQqueue", "$tgTemplate", "$compile", IssuePriorityButtonDirective])
|
module.directive("tgIssuePriorityButton", ["$rootScope", "$tgRepo", "$tgConfirm", "$tgLoading", "$tgQueueModelTransformation", "$tgTemplate", "$compile", IssuePriorityButtonDirective])
|
||||||
|
|
||||||
|
|
||||||
#############################################################################
|
#############################################################################
|
||||||
## Promote Issue to US button directive
|
## Promote Issue to US button directive
|
||||||
#############################################################################
|
#############################################################################
|
||||||
|
|
||||||
PromoteIssueToUsButtonDirective = ($rootScope, $repo, $confirm, $qqueue, $translate) ->
|
PromoteIssueToUsButtonDirective = ($rootScope, $repo, $confirm, $translate) ->
|
||||||
link = ($scope, $el, $attrs, $model) ->
|
link = ($scope, $el, $attrs, $model) ->
|
||||||
|
|
||||||
save = $qqueue.bindAdd (issue, askResponse) =>
|
save = (issue, askResponse) =>
|
||||||
data = {
|
data = {
|
||||||
generated_from_issue: issue.id
|
generated_from_issue: issue.id
|
||||||
project: issue.project,
|
project: issue.project,
|
||||||
|
@ -620,7 +634,6 @@ PromoteIssueToUsButtonDirective = ($rootScope, $repo, $confirm, $qqueue, $transl
|
||||||
|
|
||||||
$repo.create("userstories", data).then(onSuccess, onError)
|
$repo.create("userstories", data).then(onSuccess, onError)
|
||||||
|
|
||||||
|
|
||||||
$el.on "click", "a", (event) ->
|
$el.on "click", "a", (event) ->
|
||||||
event.preventDefault()
|
event.preventDefault()
|
||||||
issue = $model.$modelValue
|
issue = $model.$modelValue
|
||||||
|
@ -642,5 +655,5 @@ PromoteIssueToUsButtonDirective = ($rootScope, $repo, $confirm, $qqueue, $transl
|
||||||
link: link
|
link: link
|
||||||
}
|
}
|
||||||
|
|
||||||
module.directive("tgPromoteIssueToUsButton", ["$rootScope", "$tgRepo", "$tgConfirm", "$tgQqueue", "$translate"
|
module.directive("tgPromoteIssueToUsButton", ["$rootScope", "$tgRepo", "$tgConfirm", "$translate"
|
||||||
PromoteIssueToUsButtonDirective])
|
PromoteIssueToUsButtonDirective])
|
||||||
|
|
|
@ -49,11 +49,12 @@ class TaskDetailController extends mixOf(taiga.Controller, taiga.PageMixin)
|
||||||
"tgAppMetaService",
|
"tgAppMetaService",
|
||||||
"$tgNavUrls",
|
"$tgNavUrls",
|
||||||
"$tgAnalytics",
|
"$tgAnalytics",
|
||||||
"$translate"
|
"$translate",
|
||||||
|
"$tgQueueModelTransformation"
|
||||||
]
|
]
|
||||||
|
|
||||||
constructor: (@scope, @rootscope, @repo, @confirm, @rs, @params, @q, @location,
|
constructor: (@scope, @rootscope, @repo, @confirm, @rs, @params, @q, @location,
|
||||||
@log, @appMetaService, @navUrls, @analytics, @translate) ->
|
@log, @appMetaService, @navUrls, @analytics, @translate, @modelTransform) ->
|
||||||
bindMethods(@)
|
bindMethods(@)
|
||||||
|
|
||||||
@scope.taskRef = @params.taskref
|
@scope.taskRef = @params.taskref
|
||||||
|
@ -118,6 +119,8 @@ class TaskDetailController extends mixOf(taiga.Controller, taiga.PageMixin)
|
||||||
@scope.taskId = task.id
|
@scope.taskId = task.id
|
||||||
@scope.commentModel = task
|
@scope.commentModel = task
|
||||||
|
|
||||||
|
@modelTransform.setObject(@scope, 'task')
|
||||||
|
|
||||||
if @scope.task.neighbors.previous?.ref?
|
if @scope.task.neighbors.previous?.ref?
|
||||||
ctx = {
|
ctx = {
|
||||||
project: @scope.project.slug
|
project: @scope.project.slug
|
||||||
|
@ -245,7 +248,7 @@ module.directive("tgTaskStatusDisplay", ["$tgTemplate", "$compile", TaskStatusDi
|
||||||
## Task status button directive
|
## Task status button directive
|
||||||
#############################################################################
|
#############################################################################
|
||||||
|
|
||||||
TaskStatusButtonDirective = ($rootScope, $repo, $confirm, $loading, $qqueue, $compile, $translate, $template) ->
|
TaskStatusButtonDirective = ($rootScope, $repo, $confirm, $loading, $modelTransform, $compile, $translate, $template) ->
|
||||||
# Display the status of Task and you can edit it.
|
# Display the status of Task and you can edit it.
|
||||||
#
|
#
|
||||||
# Example:
|
# Example:
|
||||||
|
@ -256,7 +259,7 @@ TaskStatusButtonDirective = ($rootScope, $repo, $confirm, $loading, $qqueue, $co
|
||||||
# - scope.statusById object
|
# - scope.statusById object
|
||||||
# - $scope.project.my_permissions
|
# - $scope.project.my_permissions
|
||||||
|
|
||||||
template = $template.get("us/us-status-button.html", true)
|
template = $template.get("common/components/status-button.html", true)
|
||||||
|
|
||||||
link = ($scope, $el, $attrs, $model) ->
|
link = ($scope, $el, $attrs, $model) ->
|
||||||
isEditable = ->
|
isEditable = ->
|
||||||
|
@ -273,16 +276,17 @@ TaskStatusButtonDirective = ($rootScope, $repo, $confirm, $loading, $qqueue, $co
|
||||||
|
|
||||||
$el.html(html)
|
$el.html(html)
|
||||||
|
|
||||||
save = $qqueue.bindAdd (status) =>
|
save = (status) ->
|
||||||
task = $model.$modelValue.clone()
|
|
||||||
task.status = status
|
|
||||||
|
|
||||||
currentLoading = $loading()
|
currentLoading = $loading()
|
||||||
.target($el)
|
.target($el)
|
||||||
.start()
|
.start()
|
||||||
|
|
||||||
|
transform = $modelTransform.save (task) ->
|
||||||
|
task.status = status
|
||||||
|
|
||||||
|
return task
|
||||||
|
|
||||||
onSuccess = ->
|
onSuccess = ->
|
||||||
$model.$setViewValue(task)
|
|
||||||
$rootScope.$broadcast("object:updated")
|
$rootScope.$broadcast("object:updated")
|
||||||
currentLoading.finish()
|
currentLoading.finish()
|
||||||
|
|
||||||
|
@ -290,7 +294,7 @@ TaskStatusButtonDirective = ($rootScope, $repo, $confirm, $loading, $qqueue, $co
|
||||||
$confirm.notify("error")
|
$confirm.notify("error")
|
||||||
currentLoading.finish()
|
currentLoading.finish()
|
||||||
|
|
||||||
$repo.save(task).then(onSuccess, onError)
|
transform.then(onSuccess, onError)
|
||||||
|
|
||||||
$el.on "click", ".js-edit-status", (event) ->
|
$el.on "click", ".js-edit-status", (event) ->
|
||||||
event.preventDefault()
|
event.preventDefault()
|
||||||
|
@ -310,7 +314,10 @@ TaskStatusButtonDirective = ($rootScope, $repo, $confirm, $loading, $qqueue, $co
|
||||||
|
|
||||||
save(target.data("status-id"))
|
save(target.data("status-id"))
|
||||||
|
|
||||||
$scope.$watch $attrs.ngModel, (task) ->
|
$scope.$watch () ->
|
||||||
|
return $model.$modelValue?.status
|
||||||
|
, () ->
|
||||||
|
task = $model.$modelValue
|
||||||
render(task) if task
|
render(task) if task
|
||||||
|
|
||||||
$scope.$on "$destroy", ->
|
$scope.$on "$destroy", ->
|
||||||
|
@ -322,11 +329,11 @@ TaskStatusButtonDirective = ($rootScope, $repo, $confirm, $loading, $qqueue, $co
|
||||||
require: "ngModel"
|
require: "ngModel"
|
||||||
}
|
}
|
||||||
|
|
||||||
module.directive("tgTaskStatusButton", ["$rootScope", "$tgRepo", "$tgConfirm", "$tgLoading", "$tgQqueue",
|
module.directive("tgTaskStatusButton", ["$rootScope", "$tgRepo", "$tgConfirm", "$tgLoading", "$tgQueueModelTransformation",
|
||||||
"$compile", "$translate", "$tgTemplate", TaskStatusButtonDirective])
|
"$compile", "$translate", "$tgTemplate", TaskStatusButtonDirective])
|
||||||
|
|
||||||
|
|
||||||
TaskIsIocaineButtonDirective = ($rootscope, $tgrepo, $confirm, $loading, $qqueue, $compile, $template) ->
|
TaskIsIocaineButtonDirective = ($rootscope, $tgrepo, $confirm, $loading, $modelTransform, $compile, $template) ->
|
||||||
template = $template.get("issue/iocaine-button.html", true)
|
template = $template.get("issue/iocaine-button.html", true)
|
||||||
|
|
||||||
link = ($scope, $el, $attrs, $model) ->
|
link = ($scope, $el, $attrs, $model) ->
|
||||||
|
@ -345,24 +352,23 @@ TaskIsIocaineButtonDirective = ($rootscope, $tgrepo, $confirm, $loading, $qqueue
|
||||||
html = $compile(template(ctx))($scope)
|
html = $compile(template(ctx))($scope)
|
||||||
$el.html(html)
|
$el.html(html)
|
||||||
|
|
||||||
save = $qqueue.bindAdd (is_iocaine) =>
|
save = (is_iocaine) ->
|
||||||
task = $model.$modelValue.clone()
|
|
||||||
task.is_iocaine = is_iocaine
|
|
||||||
|
|
||||||
currentLoading = $loading()
|
currentLoading = $loading()
|
||||||
.target($el.find('label'))
|
.target($el.find('label'))
|
||||||
.start()
|
.start()
|
||||||
|
|
||||||
promise = $tgrepo.save(task)
|
transform = $modelTransform.save (task) ->
|
||||||
|
task.is_iocaine = is_iocaine
|
||||||
|
|
||||||
promise.then ->
|
return task
|
||||||
$model.$setViewValue(task)
|
|
||||||
|
transform.then ->
|
||||||
$rootscope.$broadcast("object:updated")
|
$rootscope.$broadcast("object:updated")
|
||||||
|
|
||||||
promise.then null, ->
|
transform.then null, ->
|
||||||
$confirm.notify("error")
|
$confirm.notify("error")
|
||||||
|
|
||||||
promise.finally ->
|
transform.finally ->
|
||||||
currentLoading.finish()
|
currentLoading.finish()
|
||||||
|
|
||||||
$el.on "click", ".is-iocaine", (event) ->
|
$el.on "click", ".is-iocaine", (event) ->
|
||||||
|
@ -371,7 +377,10 @@ TaskIsIocaineButtonDirective = ($rootscope, $tgrepo, $confirm, $loading, $qqueue
|
||||||
is_iocaine = not $model.$modelValue.is_iocaine
|
is_iocaine = not $model.$modelValue.is_iocaine
|
||||||
save(is_iocaine)
|
save(is_iocaine)
|
||||||
|
|
||||||
$scope.$watch $attrs.ngModel, (task) ->
|
$scope.$watch () ->
|
||||||
|
return $model.$modelValue?.is_iocaine
|
||||||
|
, () ->
|
||||||
|
task = $model.$modelValue
|
||||||
render(task) if task
|
render(task) if task
|
||||||
|
|
||||||
$scope.$on "$destroy", ->
|
$scope.$on "$destroy", ->
|
||||||
|
@ -383,5 +392,5 @@ TaskIsIocaineButtonDirective = ($rootscope, $tgrepo, $confirm, $loading, $qqueue
|
||||||
require: "ngModel"
|
require: "ngModel"
|
||||||
}
|
}
|
||||||
|
|
||||||
module.directive("tgTaskIsIocaineButton", ["$rootScope", "$tgRepo", "$tgConfirm", "$tgLoading", "$tgQqueue",
|
module.directive("tgTaskIsIocaineButton", ["$rootScope", "$tgRepo", "$tgConfirm", "$tgLoading", "$tgQueueModelTransformation",
|
||||||
"$compile", "$tgTemplate", TaskIsIocaineButtonDirective])
|
"$compile", "$tgTemplate", TaskIsIocaineButtonDirective])
|
||||||
|
|
|
@ -49,11 +49,12 @@ class UserStoryDetailController extends mixOf(taiga.Controller, taiga.PageMixin)
|
||||||
"tgAppMetaService",
|
"tgAppMetaService",
|
||||||
"$tgNavUrls",
|
"$tgNavUrls",
|
||||||
"$tgAnalytics",
|
"$tgAnalytics",
|
||||||
"$translate"
|
"$translate",
|
||||||
|
"$tgQueueModelTransformation"
|
||||||
]
|
]
|
||||||
|
|
||||||
constructor: (@scope, @rootscope, @repo, @confirm, @rs, @params, @q, @location,
|
constructor: (@scope, @rootscope, @repo, @confirm, @rs, @params, @q, @location,
|
||||||
@log, @appMetaService, @navUrls, @analytics, @translate) ->
|
@log, @appMetaService, @navUrls, @analytics, @translate, @modelTransform) ->
|
||||||
bindMethods(@)
|
bindMethods(@)
|
||||||
|
|
||||||
@scope.usRef = @params.usref
|
@scope.usRef = @params.usref
|
||||||
|
@ -159,6 +160,8 @@ class UserStoryDetailController extends mixOf(taiga.Controller, taiga.PageMixin)
|
||||||
@scope.usId = us.id
|
@scope.usId = us.id
|
||||||
@scope.commentModel = us
|
@scope.commentModel = us
|
||||||
|
|
||||||
|
@modelTransform.setObject(@scope, 'us')
|
||||||
|
|
||||||
if @scope.us.neighbors.previous?.ref?
|
if @scope.us.neighbors.previous?.ref?
|
||||||
ctx = {
|
ctx = {
|
||||||
project: @scope.project.slug
|
project: @scope.project.slug
|
||||||
|
@ -285,7 +288,7 @@ module.directive("tgUsStatusDisplay", ["$tgTemplate", "$compile", UsStatusDispla
|
||||||
## User story status button directive
|
## User story status button directive
|
||||||
#############################################################################
|
#############################################################################
|
||||||
|
|
||||||
UsStatusButtonDirective = ($rootScope, $repo, $confirm, $loading, $qqueue, $template) ->
|
UsStatusButtonDirective = ($rootScope, $repo, $confirm, $loading, $modelTransform, $template, $compile) ->
|
||||||
# Display the status of a US and you can edit it.
|
# Display the status of a US and you can edit it.
|
||||||
#
|
#
|
||||||
# Example:
|
# Example:
|
||||||
|
@ -296,7 +299,7 @@ UsStatusButtonDirective = ($rootScope, $repo, $confirm, $loading, $qqueue, $temp
|
||||||
# - scope.statusById object
|
# - scope.statusById object
|
||||||
# - $scope.project.my_permissions
|
# - $scope.project.my_permissions
|
||||||
|
|
||||||
template = $template.get("us/us-status-button.html", true)
|
template = $template.get("common/components/status-button.html", true)
|
||||||
|
|
||||||
link = ($scope, $el, $attrs, $model) ->
|
link = ($scope, $el, $attrs, $model) ->
|
||||||
isEditable = ->
|
isEditable = ->
|
||||||
|
@ -313,19 +316,21 @@ UsStatusButtonDirective = ($rootScope, $repo, $confirm, $loading, $qqueue, $temp
|
||||||
|
|
||||||
$el.html(html)
|
$el.html(html)
|
||||||
|
|
||||||
save = $qqueue.bindAdd (status) =>
|
$compile($el.contents())($scope);
|
||||||
us = $model.$modelValue.clone()
|
|
||||||
|
|
||||||
us.status = status
|
save = (status) =>
|
||||||
|
$el.find(".pop-status").popover().close()
|
||||||
$.fn.popover().closeAll()
|
|
||||||
|
|
||||||
currentLoading = $loading()
|
currentLoading = $loading()
|
||||||
.target($el)
|
.target($el.find('.js-edit-status'))
|
||||||
.start()
|
.start()
|
||||||
|
|
||||||
|
transform = $modelTransform.save (us) ->
|
||||||
|
us.status = status
|
||||||
|
|
||||||
|
return us
|
||||||
|
|
||||||
onSuccess = ->
|
onSuccess = ->
|
||||||
$model.$setViewValue(us)
|
|
||||||
$rootScope.$broadcast("object:updated")
|
$rootScope.$broadcast("object:updated")
|
||||||
currentLoading.finish()
|
currentLoading.finish()
|
||||||
|
|
||||||
|
@ -333,7 +338,7 @@ UsStatusButtonDirective = ($rootScope, $repo, $confirm, $loading, $qqueue, $temp
|
||||||
$confirm.notify("error")
|
$confirm.notify("error")
|
||||||
currentLoading.finish()
|
currentLoading.finish()
|
||||||
|
|
||||||
$repo.save(us).then(onSuccess, onError)
|
transform.then(onSuccess, onError)
|
||||||
|
|
||||||
$el.on "click", ".js-edit-status", (event) ->
|
$el.on "click", ".js-edit-status", (event) ->
|
||||||
event.preventDefault()
|
event.preventDefault()
|
||||||
|
@ -352,7 +357,11 @@ UsStatusButtonDirective = ($rootScope, $repo, $confirm, $loading, $qqueue, $temp
|
||||||
|
|
||||||
save(status)
|
save(status)
|
||||||
|
|
||||||
$scope.$watch $attrs.ngModel, (us) ->
|
$scope.$watch () ->
|
||||||
|
return $model.$modelValue?.status
|
||||||
|
, () ->
|
||||||
|
us = $model.$modelValue
|
||||||
|
|
||||||
render(us) if us
|
render(us) if us
|
||||||
|
|
||||||
$scope.$on "$destroy", ->
|
$scope.$on "$destroy", ->
|
||||||
|
@ -364,7 +373,7 @@ UsStatusButtonDirective = ($rootScope, $repo, $confirm, $loading, $qqueue, $temp
|
||||||
require: "ngModel"
|
require: "ngModel"
|
||||||
}
|
}
|
||||||
|
|
||||||
module.directive("tgUsStatusButton", ["$rootScope", "$tgRepo", "$tgConfirm", "$tgLoading","$tgQqueue", "$tgTemplate",
|
module.directive("tgUsStatusButton", ["$rootScope", "$tgRepo", "$tgConfirm", "$tgLoading","$tgQueueModelTransformation", "$tgTemplate", "$compile",
|
||||||
UsStatusButtonDirective])
|
UsStatusButtonDirective])
|
||||||
|
|
||||||
|
|
||||||
|
@ -372,7 +381,7 @@ module.directive("tgUsStatusButton", ["$rootScope", "$tgRepo", "$tgConfirm", "$t
|
||||||
## User story team requirements button directive
|
## User story team requirements button directive
|
||||||
#############################################################################
|
#############################################################################
|
||||||
|
|
||||||
UsTeamRequirementButtonDirective = ($rootscope, $tgrepo, $confirm, $loading, $qqueue, $template, $compile) ->
|
UsTeamRequirementButtonDirective = ($rootscope, $tgrepo, $confirm, $loading, $modelTransform, $template, $compile) ->
|
||||||
template = $template.get("us/us-team-requirement-button.html", true)
|
template = $template.get("us/us-team-requirement-button.html", true)
|
||||||
|
|
||||||
link = ($scope, $el, $attrs, $model) ->
|
link = ($scope, $el, $attrs, $model) ->
|
||||||
|
@ -389,21 +398,21 @@ UsTeamRequirementButtonDirective = ($rootscope, $tgrepo, $confirm, $loading, $qq
|
||||||
|
|
||||||
$el.html(html)
|
$el.html(html)
|
||||||
|
|
||||||
save = $qqueue.bindAdd (team_requirement) =>
|
save = (team_requirement) ->
|
||||||
us = $model.$modelValue.clone()
|
|
||||||
us.team_requirement = team_requirement
|
|
||||||
|
|
||||||
currentLoading = $loading()
|
currentLoading = $loading()
|
||||||
.target($el.find("label"))
|
.target($el.find("label"))
|
||||||
.start()
|
.start()
|
||||||
|
|
||||||
promise = $tgrepo.save(us)
|
transform = $modelTransform.save (us) ->
|
||||||
promise.then =>
|
us.team_requirement = team_requirement
|
||||||
$model.$setViewValue(us)
|
|
||||||
|
return us
|
||||||
|
|
||||||
|
transform.then =>
|
||||||
currentLoading.finish()
|
currentLoading.finish()
|
||||||
$rootscope.$broadcast("object:updated")
|
$rootscope.$broadcast("object:updated")
|
||||||
|
|
||||||
promise.then null, ->
|
transform.then null, ->
|
||||||
currentLoading.finish()
|
currentLoading.finish()
|
||||||
$confirm.notify("error")
|
$confirm.notify("error")
|
||||||
|
|
||||||
|
@ -414,7 +423,11 @@ UsTeamRequirementButtonDirective = ($rootscope, $tgrepo, $confirm, $loading, $qq
|
||||||
|
|
||||||
save(team_requirement)
|
save(team_requirement)
|
||||||
|
|
||||||
$scope.$watch $attrs.ngModel, (us) ->
|
$scope.$watch () ->
|
||||||
|
return $model.$modelValue?.team_requirement
|
||||||
|
, () ->
|
||||||
|
us = $model.$modelValue
|
||||||
|
|
||||||
render(us) if us
|
render(us) if us
|
||||||
|
|
||||||
$scope.$on "$destroy", ->
|
$scope.$on "$destroy", ->
|
||||||
|
@ -426,13 +439,13 @@ UsTeamRequirementButtonDirective = ($rootscope, $tgrepo, $confirm, $loading, $qq
|
||||||
require: "ngModel"
|
require: "ngModel"
|
||||||
}
|
}
|
||||||
|
|
||||||
module.directive("tgUsTeamRequirementButton", ["$rootScope", "$tgRepo", "$tgConfirm", "$tgLoading", "$tgQqueue", "$tgTemplate", "$compile", UsTeamRequirementButtonDirective])
|
module.directive("tgUsTeamRequirementButton", ["$rootScope", "$tgRepo", "$tgConfirm", "$tgLoading", "$tgQueueModelTransformation", "$tgTemplate", "$compile", UsTeamRequirementButtonDirective])
|
||||||
|
|
||||||
#############################################################################
|
#############################################################################
|
||||||
## User story client requirements button directive
|
## User story client requirements button directive
|
||||||
#############################################################################
|
#############################################################################
|
||||||
|
|
||||||
UsClientRequirementButtonDirective = ($rootscope, $tgrepo, $confirm, $loading, $qqueue, $template, $compile) ->
|
UsClientRequirementButtonDirective = ($rootscope, $tgrepo, $confirm, $loading, $modelTransform, $template, $compile) ->
|
||||||
template = $template.get("us/us-client-requirement-button.html", true)
|
template = $template.get("us/us-client-requirement-button.html", true)
|
||||||
|
|
||||||
link = ($scope, $el, $attrs, $model) ->
|
link = ($scope, $el, $attrs, $model) ->
|
||||||
|
@ -447,21 +460,21 @@ UsClientRequirementButtonDirective = ($rootscope, $tgrepo, $confirm, $loading, $
|
||||||
html = $compile(template(ctx))($scope)
|
html = $compile(template(ctx))($scope)
|
||||||
$el.html(html)
|
$el.html(html)
|
||||||
|
|
||||||
save = $qqueue.bindAdd (client_requirement) =>
|
save = (client_requirement) ->
|
||||||
us = $model.$modelValue.clone()
|
|
||||||
us.client_requirement = client_requirement
|
|
||||||
|
|
||||||
currentLoading = $loading()
|
currentLoading = $loading()
|
||||||
.target($el.find("label"))
|
.target($el.find("label"))
|
||||||
.start()
|
.start()
|
||||||
|
|
||||||
promise = $tgrepo.save(us)
|
transform = $modelTransform.save (us) ->
|
||||||
promise.then =>
|
us.client_requirement = client_requirement
|
||||||
$model.$setViewValue(us)
|
|
||||||
|
return us
|
||||||
|
|
||||||
|
transform.then =>
|
||||||
currentLoading.finish()
|
currentLoading.finish()
|
||||||
$rootscope.$broadcast("object:updated")
|
$rootscope.$broadcast("object:updated")
|
||||||
|
|
||||||
promise.then null, ->
|
transform.then null, ->
|
||||||
$confirm.notify("error")
|
$confirm.notify("error")
|
||||||
|
|
||||||
$el.on "click", ".client-requirement", (event) ->
|
$el.on "click", ".client-requirement", (event) ->
|
||||||
|
@ -470,7 +483,10 @@ UsClientRequirementButtonDirective = ($rootscope, $tgrepo, $confirm, $loading, $
|
||||||
client_requirement = not $model.$modelValue.client_requirement
|
client_requirement = not $model.$modelValue.client_requirement
|
||||||
save(client_requirement)
|
save(client_requirement)
|
||||||
|
|
||||||
$scope.$watch $attrs.ngModel, (us) ->
|
$scope.$watch () ->
|
||||||
|
return $model.$modelValue?.client_requirement
|
||||||
|
, () ->
|
||||||
|
us = $model.$modelValue
|
||||||
render(us) if us
|
render(us) if us
|
||||||
|
|
||||||
$scope.$on "$destroy", ->
|
$scope.$on "$destroy", ->
|
||||||
|
@ -482,5 +498,5 @@ UsClientRequirementButtonDirective = ($rootscope, $tgrepo, $confirm, $loading, $
|
||||||
require: "ngModel"
|
require: "ngModel"
|
||||||
}
|
}
|
||||||
|
|
||||||
module.directive("tgUsClientRequirementButton", ["$rootScope", "$tgRepo", "$tgConfirm", "$tgLoading", "$tgQqueue", "$tgTemplate", "$compile",
|
module.directive("tgUsClientRequirementButton", ["$rootScope", "$tgRepo", "$tgConfirm", "$tgLoading", "$tgQueueModelTransformation", "$tgTemplate", "$compile",
|
||||||
UsClientRequirementButtonDirective])
|
UsClientRequirementButtonDirective])
|
||||||
|
|
|
@ -0,0 +1,19 @@
|
||||||
|
span.detail-status-inner.js-edit-status(
|
||||||
|
class!="<% if(editable){ %>clickable<% }%>"
|
||||||
|
)
|
||||||
|
span(style!="background-color:<%- status.color %>")
|
||||||
|
span.e2e-status <%- status.name %>
|
||||||
|
<% if(editable){ %>
|
||||||
|
tg-svg(svg-icon="icon-arrow-down")
|
||||||
|
<% }%>
|
||||||
|
|
||||||
|
ul.pop-status.popover
|
||||||
|
<% _.each(statuses, function(st) { %>
|
||||||
|
li
|
||||||
|
a.status(
|
||||||
|
href=""
|
||||||
|
title!="<%- st.name %>"
|
||||||
|
data-status-id!="<%- st.id %>"
|
||||||
|
)
|
||||||
|
| <%- st.name %>
|
||||||
|
<% }); %>
|
|
@ -1,20 +0,0 @@
|
||||||
span.detail-status-inner.js-edit-status(
|
|
||||||
class!="<% if(editable){ %>clickable<% }%>"
|
|
||||||
style!="background-color:<%- status.color %>"
|
|
||||||
ng-click="editStatus()"
|
|
||||||
)
|
|
||||||
span <%- status.name %>
|
|
||||||
<% if(editable){ %>
|
|
||||||
tg-svg(svg-icon="icon-arrow-down")
|
|
||||||
<% }%>
|
|
||||||
|
|
||||||
ul.popover.pop-status
|
|
||||||
<% _.each(statuses, function(st) { %>
|
|
||||||
li
|
|
||||||
a.status(
|
|
||||||
href=""
|
|
||||||
title!="<%- st.name %>"
|
|
||||||
data-status-id!="<%- st.id %>"
|
|
||||||
)
|
|
||||||
| <%- st.name %>
|
|
||||||
<% }); %>
|
|
|
@ -1,19 +0,0 @@
|
||||||
span.detail-status-inner.js-edit-status(
|
|
||||||
class!="<% if(editable){ %>clickable<% }%>"
|
|
||||||
style!="background-color:<%- status.color %>"
|
|
||||||
)
|
|
||||||
span <%- status.name %>
|
|
||||||
<% if(editable){ %>
|
|
||||||
tg-svg(svg-icon="icon-arrow-down")
|
|
||||||
<% }%>
|
|
||||||
|
|
||||||
ul.pop-status.popover
|
|
||||||
<% _.each(statuses, function(st) { %>
|
|
||||||
li
|
|
||||||
a.status(
|
|
||||||
href=""
|
|
||||||
title!="<%- st.name %>"
|
|
||||||
data-status-id!="<%- st.id %>"
|
|
||||||
)
|
|
||||||
| <%- st.name %>
|
|
||||||
<% }); %>
|
|
|
@ -22,11 +22,13 @@
|
||||||
}
|
}
|
||||||
.detail-status-inner {
|
.detail-status-inner {
|
||||||
align-items: center;
|
align-items: center;
|
||||||
color: $white;
|
|
||||||
display: flex;
|
display: flex;
|
||||||
justify-content: flex-start;
|
justify-content: flex-start;
|
||||||
padding: .15rem .25rem;
|
> span {
|
||||||
text-transform: uppercase;
|
color: $white;
|
||||||
|
padding: .15rem .25rem;
|
||||||
|
text-transform: uppercase;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
.pop-status {
|
.pop-status {
|
||||||
@include popover(150px, 1.25rem, 0, '', '');
|
@include popover(150px, 1.25rem, 0, '', '');
|
||||||
|
|
|
@ -107,7 +107,7 @@ helper.statusSelector = function() {
|
||||||
return this.getSelectedStatus();
|
return this.getSelectedStatus();
|
||||||
},
|
},
|
||||||
getSelectedStatus: async function(){
|
getSelectedStatus: async function(){
|
||||||
return el.$$('.detail-status-inner span').first().getInnerHtml();
|
return el.$$('.detail-status-inner .e2e-status').first().getInnerHtml();
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue