Merge pull request #983 from taigaio/issue/3983/angular-translate-expression-in-related-tasks
change the dynamic compile to a normal angular compile templatestable
commit
dd6a2a8084
|
@ -51,7 +51,12 @@ class LightboxService extends taiga.Service
|
||||||
@animationFrame.add ->
|
@animationFrame.add ->
|
||||||
$el.addClass("open")
|
$el.addClass("open")
|
||||||
$el.one "transitionend", =>
|
$el.one "transitionend", =>
|
||||||
|
firstField = $el.find('input,textarea').first()
|
||||||
|
|
||||||
|
if firstField.length
|
||||||
$el.find('input,textarea').first().focus()
|
$el.find('input,textarea').first().focus()
|
||||||
|
else if document.activeElement
|
||||||
|
$(document.activeElement).blur()
|
||||||
|
|
||||||
@animationFrame.add =>
|
@animationFrame.add =>
|
||||||
lightboxContent.show()
|
lightboxContent.show()
|
||||||
|
|
|
@ -158,6 +158,10 @@ RelatedTaskStatusDirective = ($repo, $template) ->
|
||||||
$scope.$eval($attrs.onUpdate)
|
$scope.$eval($attrs.onUpdate)
|
||||||
$scope.$emit("related-tasks:status-changed")
|
$scope.$emit("related-tasks:status-changed")
|
||||||
|
|
||||||
|
$scope.$watch $attrs.tgRelatedTaskStatus, () ->
|
||||||
|
task = $scope.$eval($attrs.tgRelatedTaskStatus)
|
||||||
|
updateTaskStatus($el, task, $scope.taskStatusById)
|
||||||
|
|
||||||
taiga.bindOnce $scope, "project", (project) ->
|
taiga.bindOnce $scope, "project", (project) ->
|
||||||
$el.append(selectionTemplate({ 'statuses': project.task_statuses }))
|
$el.append(selectionTemplate({ 'statuses': project.task_statuses }))
|
||||||
updateTaskStatus($el, task, $scope.taskStatusById)
|
updateTaskStatus($el, task, $scope.taskStatusById)
|
||||||
|
|
|
@ -117,16 +117,14 @@ module.directive("tgRelatedTaskRow", ["$tgRepo", "$compile", "$tgConfirm", "$roo
|
||||||
"$tgTemplate", "$translate", RelatedTaskRowDirective])
|
"$tgTemplate", "$translate", RelatedTaskRowDirective])
|
||||||
|
|
||||||
|
|
||||||
RelatedTaskCreateFormDirective = ($repo, $compile, $confirm, $tgmodel, $loading, $analytics, $template) ->
|
RelatedTaskCreateFormDirective = ($repo, $compile, $confirm, $tgmodel, $loading, $analytics) ->
|
||||||
template = $template.get("task/related-task-create-form.html", true)
|
|
||||||
|
|
||||||
newTask = {
|
newTask = {
|
||||||
subject: ""
|
subject: ""
|
||||||
assigned_to: null
|
assigned_to: null
|
||||||
}
|
}
|
||||||
|
|
||||||
link = ($scope, $el, $attrs) ->
|
link = ($scope, $el, $attrs) ->
|
||||||
createTask = debounce 2000, (task) ->
|
createTask = (task) ->
|
||||||
task.subject = $el.find('input').val()
|
task.subject = $el.find('input').val()
|
||||||
task.assigned_to = $scope.newTask.assigned_to
|
task.assigned_to = $scope.newTask.assigned_to
|
||||||
task.status = $scope.newTask.status
|
task.status = $scope.newTask.status
|
||||||
|
@ -151,50 +149,54 @@ RelatedTaskCreateFormDirective = ($repo, $compile, $confirm, $tgmodel, $loading,
|
||||||
return promise
|
return promise
|
||||||
|
|
||||||
close = () ->
|
close = () ->
|
||||||
$el.removeClass('active')
|
|
||||||
$el.off()
|
$el.off()
|
||||||
$el.html("")
|
|
||||||
|
|
||||||
$scope.newRelatedTaskFormOpen = false
|
$scope.openNewRelatedTask = false
|
||||||
|
|
||||||
|
reset = () ->
|
||||||
|
newTask = {
|
||||||
|
subject: ""
|
||||||
|
assigned_to: null
|
||||||
|
}
|
||||||
|
|
||||||
|
newTask["status"] = $scope.project.default_task_status
|
||||||
|
newTask["project"] = $scope.project.id
|
||||||
|
newTask["user_story"] = $scope.us.id
|
||||||
|
|
||||||
|
$scope.newTask = $tgmodel.make_model("tasks", newTask)
|
||||||
|
|
||||||
render = ->
|
render = ->
|
||||||
$scope.newRelatedTaskFormOpen = true
|
$scope.openNewRelatedTask = true
|
||||||
|
|
||||||
$el.html($compile(template())($scope))
|
|
||||||
$el.find('input').focus().select()
|
|
||||||
$el.addClass('active')
|
|
||||||
|
|
||||||
$el.on "keyup", "input", (event)->
|
$el.on "keyup", "input", (event)->
|
||||||
if event.keyCode == 13
|
if event.keyCode == 13
|
||||||
createTask(newTask).then ->
|
createTask(newTask).then ->
|
||||||
render()
|
reset()
|
||||||
|
$el.find('input').focus()
|
||||||
|
|
||||||
else if event.keyCode == 27
|
else if event.keyCode == 27
|
||||||
$scope.$apply () -> close()
|
$scope.$apply () -> close()
|
||||||
|
|
||||||
$el.on "click", ".icon-close", (event)->
|
$scope.save = () ->
|
||||||
$scope.$apply () -> close()
|
|
||||||
|
|
||||||
$el.on "click", ".save-task", (event)->
|
|
||||||
createTask(newTask).then ->
|
createTask(newTask).then ->
|
||||||
close()
|
close()
|
||||||
|
|
||||||
taiga.bindOnce $scope, "us", (val) ->
|
taiga.bindOnce $scope, "us", reset
|
||||||
newTask["status"] = $scope.project.default_task_status
|
|
||||||
newTask["project"] = $scope.project.id
|
|
||||||
newTask["user_story"] = $scope.us.id
|
|
||||||
$scope.newTask = $tgmodel.make_model("tasks", newTask)
|
|
||||||
$el.html("")
|
|
||||||
|
|
||||||
$scope.$on "related-tasks:show-form", ->
|
$scope.$on "related-tasks:show-form", ->
|
||||||
render()
|
$scope.$apply(render)
|
||||||
|
|
||||||
$scope.$on "$destroy", ->
|
$scope.$on "$destroy", ->
|
||||||
$el.off()
|
$el.off()
|
||||||
|
|
||||||
return {link: link}
|
return {
|
||||||
|
scope: true,
|
||||||
|
link: link,
|
||||||
|
templateUrl: 'task/related-task-create-form.html'
|
||||||
|
}
|
||||||
|
|
||||||
module.directive("tgRelatedTaskCreateForm", ["$tgRepo", "$compile", "$tgConfirm", "$tgModel", "$tgLoading",
|
module.directive("tgRelatedTaskCreateForm", ["$tgRepo", "$compile", "$tgConfirm", "$tgModel", "$tgLoading",
|
||||||
"$tgAnalytics", "$tgTemplate", RelatedTaskCreateFormDirective])
|
"$tgAnalytics", RelatedTaskCreateFormDirective])
|
||||||
|
|
||||||
|
|
||||||
RelatedTaskCreateButtonDirective = ($repo, $compile, $confirm, $tgmodel, $template) ->
|
RelatedTaskCreateButtonDirective = ($repo, $compile, $confirm, $tgmodel, $template) ->
|
||||||
|
@ -288,6 +290,10 @@ RelatedTaskAssignedToInlineEditionDirective = ($repo, $rootscope, $translate) ->
|
||||||
notAutoSave = $scope.$eval($attrs.notAutoSave)
|
notAutoSave = $scope.$eval($attrs.notAutoSave)
|
||||||
autoSave = !notAutoSave
|
autoSave = !notAutoSave
|
||||||
|
|
||||||
|
$scope.$watch $attrs.tgRelatedTaskAssignedToInlineEdition, () ->
|
||||||
|
task = $scope.$eval($attrs.tgRelatedTaskAssignedToInlineEdition)
|
||||||
|
updateRelatedTask(task)
|
||||||
|
|
||||||
updateRelatedTask(task)
|
updateRelatedTask(task)
|
||||||
|
|
||||||
$el.on "click", ".task-assignedto", (event) ->
|
$el.on "click", ".task-assignedto", (event) ->
|
||||||
|
|
|
@ -12,4 +12,4 @@ section.related-tasks(
|
||||||
tg-related-task-row
|
tg-related-task-row
|
||||||
ng-model="task"
|
ng-model="task"
|
||||||
)
|
)
|
||||||
.row.single-related-task.related-task-create-form(tg-related-task-create-form)
|
div(tg-related-task-create-form)
|
||||||
|
|
|
@ -1,15 +1,16 @@
|
||||||
.task-name
|
.row.single-related-task.related-task-create-form.active(ng-if="openNewRelatedTask")
|
||||||
input(type='text', placeholder="{{'TASK.PLACEHOLDER_SUBJECT' | translate}}")
|
.task-name
|
||||||
.task-settings
|
input(type='text', autofocus, placeholder="{{'TASK.PLACEHOLDER_SUBJECT' | translate}}")
|
||||||
a.save-task(title="{{'COMMON.SAVE' | translate}}")
|
.task-settings
|
||||||
|
a.save-task(ng-click="save()" title="{{'COMMON.SAVE' | translate}}")
|
||||||
tg-svg(svg-icon="icon-save")
|
tg-svg(svg-icon="icon-save")
|
||||||
|
|
||||||
.status(tg-related-task-status='newTask', ng-model='newTask', not-auto-save='true')
|
.status(tg-related-task-status='newTask', ng-model='newTask', not-auto-save='true')
|
||||||
a.task-status(href='', title="{{'TASK.TITLE_SELECT_STATUS' | translate}}")
|
a.task-status(href='', title="{{'TASK.TITLE_SELECT_STATUS' | translate}}")
|
||||||
span.task-status-bind
|
span.task-status-bind
|
||||||
tg-svg(svg-icon="icon-arrow-down")
|
tg-svg(svg-icon="icon-arrow-down")
|
||||||
|
|
||||||
.assigned-to(tg-related-task-assigned-to-inline-edition='newTask', not-auto-save='true')
|
.assigned-to(tg-related-task-assigned-to-inline-edition='newTask', not-auto-save='true')
|
||||||
.task-assignedto(title="{{'COMMON.FIELDS.ASSIGNED_TO' | translate}}")
|
.task-assignedto(title="{{'COMMON.FIELDS.ASSIGNED_TO' | translate}}")
|
||||||
figure.avatar
|
figure.avatar
|
||||||
tg-svg(svg-icon="icon-arrow-down")
|
tg-svg(svg-icon="icon-arrow-down")
|
||||||
|
|
Loading…
Reference in New Issue