change the dynamic compile to a normal angular compile template

stable
Juanfran 2016-04-28 09:42:26 +02:00
parent 00b78eb65d
commit e4315246a1
5 changed files with 59 additions and 43 deletions

View File

@ -51,7 +51,12 @@ class LightboxService extends taiga.Service
@animationFrame.add ->
$el.addClass("open")
$el.one "transitionend", =>
$el.find('input,textarea').first().focus()
firstField = $el.find('input,textarea').first()
if firstField.length
$el.find('input,textarea').first().focus()
else if document.activeElement
$(document.activeElement).blur()
@animationFrame.add =>
lightboxContent.show()

View File

@ -158,6 +158,10 @@ RelatedTaskStatusDirective = ($repo, $template) ->
$scope.$eval($attrs.onUpdate)
$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) ->
$el.append(selectionTemplate({ 'statuses': project.task_statuses }))
updateTaskStatus($el, task, $scope.taskStatusById)

View File

@ -117,16 +117,14 @@ module.directive("tgRelatedTaskRow", ["$tgRepo", "$compile", "$tgConfirm", "$roo
"$tgTemplate", "$translate", RelatedTaskRowDirective])
RelatedTaskCreateFormDirective = ($repo, $compile, $confirm, $tgmodel, $loading, $analytics, $template) ->
template = $template.get("task/related-task-create-form.html", true)
RelatedTaskCreateFormDirective = ($repo, $compile, $confirm, $tgmodel, $loading, $analytics) ->
newTask = {
subject: ""
assigned_to: null
}
link = ($scope, $el, $attrs) ->
createTask = debounce 2000, (task) ->
createTask = (task) ->
task.subject = $el.find('input').val()
task.assigned_to = $scope.newTask.assigned_to
task.status = $scope.newTask.status
@ -151,50 +149,54 @@ RelatedTaskCreateFormDirective = ($repo, $compile, $confirm, $tgmodel, $loading,
return promise
close = () ->
$el.removeClass('active')
$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 = ->
$scope.newRelatedTaskFormOpen = true
$el.html($compile(template())($scope))
$el.find('input').focus().select()
$el.addClass('active')
$scope.openNewRelatedTask = true
$el.on "keyup", "input", (event)->
if event.keyCode == 13
createTask(newTask).then ->
render()
reset()
$el.find('input').focus()
else if event.keyCode == 27
$scope.$apply () -> close()
$el.on "click", ".icon-close", (event)->
$scope.$apply () -> close()
$scope.save = () ->
createTask(newTask).then ->
close()
$el.on "click", ".save-task", (event)->
createTask(newTask).then ->
close()
taiga.bindOnce $scope, "us", (val) ->
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("")
taiga.bindOnce $scope, "us", reset
$scope.$on "related-tasks:show-form", ->
render()
$scope.$apply(render)
$scope.$on "$destroy", ->
$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",
"$tgAnalytics", "$tgTemplate", RelatedTaskCreateFormDirective])
"$tgAnalytics", RelatedTaskCreateFormDirective])
RelatedTaskCreateButtonDirective = ($repo, $compile, $confirm, $tgmodel, $template) ->
@ -288,6 +290,10 @@ RelatedTaskAssignedToInlineEditionDirective = ($repo, $rootscope, $translate) ->
notAutoSave = $scope.$eval($attrs.notAutoSave)
autoSave = !notAutoSave
$scope.$watch $attrs.tgRelatedTaskAssignedToInlineEdition, () ->
task = $scope.$eval($attrs.tgRelatedTaskAssignedToInlineEdition)
updateRelatedTask(task)
updateRelatedTask(task)
$el.on "click", ".task-assignedto", (event) ->

View File

@ -12,4 +12,4 @@ section.related-tasks(
tg-related-task-row
ng-model="task"
)
.row.single-related-task.related-task-create-form(tg-related-task-create-form)
div(tg-related-task-create-form)

View File

@ -1,15 +1,16 @@
.task-name
input(type='text', placeholder="{{'TASK.PLACEHOLDER_SUBJECT' | translate}}")
.task-settings
a.save-task(title="{{'COMMON.SAVE' | translate}}")
tg-svg(svg-icon="icon-save")
.row.single-related-task.related-task-create-form.active(ng-if="openNewRelatedTask")
.task-name
input(type='text', autofocus, placeholder="{{'TASK.PLACEHOLDER_SUBJECT' | translate}}")
.task-settings
a.save-task(ng-click="save()" title="{{'COMMON.SAVE' | translate}}")
tg-svg(svg-icon="icon-save")
.status(tg-related-task-status='newTask', ng-model='newTask', not-auto-save='true')
a.task-status(href='', title="{{'TASK.TITLE_SELECT_STATUS' | translate}}")
span.task-status-bind
tg-svg(svg-icon="icon-arrow-down")
.status(tg-related-task-status='newTask', ng-model='newTask', not-auto-save='true')
a.task-status(href='', title="{{'TASK.TITLE_SELECT_STATUS' | translate}}")
span.task-status-bind
tg-svg(svg-icon="icon-arrow-down")
.assigned-to(tg-related-task-assigned-to-inline-edition='newTask', not-auto-save='true')
.task-assignedto(title="{{'COMMON.FIELDS.ASSIGNED_TO' | translate}}")
figure.avatar
tg-svg(svg-icon="icon-arrow-down")
.assigned-to(tg-related-task-assigned-to-inline-edition='newTask', not-auto-save='true')
.task-assignedto(title="{{'COMMON.FIELDS.ASSIGNED_TO' | translate}}")
figure.avatar
tg-svg(svg-icon="icon-arrow-down")