Some error handling
parent
20bd7a2d6b
commit
4ab0512e22
|
@ -446,11 +446,10 @@ EditableSubjectDirective = ($rootscope, $tgrepo, $confirm, $navurls, $location)
|
|||
$el.html(editTemplate({item: scope.item}))
|
||||
else
|
||||
canEdit = $scope.project.my_permissions.indexOf($attrs.requiredPerm) != -1
|
||||
$el.html(viewTemplate({item: scope.item, canEdit: canEdit}))
|
||||
$el.html(viewTemplate({item: $model.$modelValue, canEdit: canEdit}))
|
||||
|
||||
$scope.$watch $attrs.ngModel, (item) ->
|
||||
return if not item
|
||||
scope.item = item
|
||||
render()
|
||||
|
||||
$scope.$on "$destroy", ->
|
||||
|
@ -459,19 +458,23 @@ EditableSubjectDirective = ($rootscope, $tgrepo, $confirm, $navurls, $location)
|
|||
$el.click ->
|
||||
if not editing and $scope.project.my_permissions.indexOf($attrs.requiredPerm) != -1
|
||||
editing = true
|
||||
scope.item = {subject: $model.$modelValue.subject}
|
||||
render()
|
||||
$el.find('input').focus()
|
||||
|
||||
$el.on "keyup", "input", ->
|
||||
if event.keyCode == 13
|
||||
scope.item.subject = $el.find('input').val()
|
||||
$tgrepo.save(scope.item).then ->
|
||||
$model.$modelValue.subject = $el.find('input').val()
|
||||
promise = $tgrepo.save($model.$modelValue)
|
||||
promise.then ->
|
||||
$rootscope.$broadcast("history:reload")
|
||||
editing = false
|
||||
render()
|
||||
promise.then null, ->
|
||||
$confirm.notify("error")
|
||||
else if event.keyCode == 27
|
||||
editing = false
|
||||
scope.item.revert()
|
||||
$model.$modelValue.revert()
|
||||
render()
|
||||
|
||||
return {
|
||||
|
@ -510,11 +513,10 @@ EditableDescriptionDirective = ($rootscope, $tgrepo, $confirm, $navurls, $locati
|
|||
$el.html($compile(editTemplate({item: scope.item}))(scope))
|
||||
else
|
||||
canEdit = $scope.project.my_permissions.indexOf($attrs.requiredPerm) != -1
|
||||
$el.html(viewTemplate({descriptionHtml: scope.item.description_html, canEdit: canEdit}))
|
||||
$el.html(viewTemplate({descriptionHtml: $model.$modelValue.description_html, canEdit: canEdit}))
|
||||
|
||||
$scope.$watch $attrs.ngModel, (item) ->
|
||||
return if not item
|
||||
scope.item = item
|
||||
render()
|
||||
|
||||
$scope.$on "$destroy", ->
|
||||
|
@ -523,22 +525,26 @@ EditableDescriptionDirective = ($rootscope, $tgrepo, $confirm, $navurls, $locati
|
|||
$el.click ->
|
||||
if not editing and $scope.project.my_permissions.indexOf($attrs.requiredPerm) != -1
|
||||
editing = true
|
||||
scope.item = {description: $model.$modelValue.description}
|
||||
render()
|
||||
$el.find('textarea').focus()
|
||||
|
||||
$el.on "click", ".save", ->
|
||||
$tgrepo.save(scope.item).then ->
|
||||
$model.$modelValue.description = scope.item.description
|
||||
promise = $tgrepo.save($model.$modelValue)
|
||||
promise.then ->
|
||||
$rootscope.$broadcast("history:reload")
|
||||
editing = false
|
||||
render()
|
||||
promise.then null, ->
|
||||
$confirm.notify("error")
|
||||
|
||||
$el.on "keyup", "textarea", ->
|
||||
if event.keyCode == 27
|
||||
editing = false
|
||||
scope.item.revert()
|
||||
$model.$modelValue.revert()
|
||||
render()
|
||||
|
||||
|
||||
return {
|
||||
link: link
|
||||
restrict: "EA"
|
||||
|
|
|
@ -91,7 +91,7 @@ module.directive("tgColorizeTags", ColorizeTagsDirective)
|
|||
## TagLine (possible should be moved as generic directive)
|
||||
#############################################################################
|
||||
|
||||
TagLineDirective = ($rootscope, $log, $rs, $tgrepo) ->
|
||||
TagLineDirective = ($rootscope, $log, $rs, $tgrepo, $confirm) ->
|
||||
# Main directive template (rendered by angular)
|
||||
template = """
|
||||
<div class="tags-container"></div>
|
||||
|
@ -140,8 +140,11 @@ TagLineDirective = ($rootscope, $log, $rs, $tgrepo) ->
|
|||
$model.$setViewValue(normalizeTags(tags))
|
||||
autosaveModel = $scope.$eval($attrs.autosaveModel)
|
||||
if autosaveModel
|
||||
$tgrepo.save(autosaveModel).then ->
|
||||
promise = $tgrepo.save(autosaveModel)
|
||||
promise.then ->
|
||||
$rootscope.$broadcast("history:reload")
|
||||
promise.then null, ->
|
||||
$confirm.notify("error")
|
||||
|
||||
saveInputTag = () ->
|
||||
input = $el.find('input')
|
||||
|
@ -213,8 +216,11 @@ TagLineDirective = ($rootscope, $log, $rs, $tgrepo) ->
|
|||
$model.$setViewValue(normalizeTags(tags))
|
||||
autosaveModel = $scope.$eval($attrs.autosaveModel)
|
||||
if autosaveModel
|
||||
$tgrepo.save(autosaveModel).then ->
|
||||
promise = $tgrepo.save(autosaveModel)
|
||||
promise.then ->
|
||||
$rootscope.$broadcast("history:reload")
|
||||
promise.then null, ->
|
||||
$confirm.notify("error")
|
||||
|
||||
return {
|
||||
link:link,
|
||||
|
@ -222,4 +228,4 @@ TagLineDirective = ($rootscope, $log, $rs, $tgrepo) ->
|
|||
template: template
|
||||
}
|
||||
|
||||
module.directive("tgTagLine", ["$rootScope", "$log", "$tgResources", "$tgRepo", TagLineDirective])
|
||||
module.directive("tgTagLine", ["$rootScope", "$log", "$tgResources", "$tgRepo", "$tgConfirm", TagLineDirective])
|
||||
|
|
|
@ -248,7 +248,7 @@ TaskStatusButtonDirective = ($rootScope, $repo) ->
|
|||
module.directive("tgTaskStatusButton", ["$rootScope", "$tgRepo", TaskStatusButtonDirective])
|
||||
|
||||
|
||||
TaskIsIocaineButtonDirective = ($rootscope, $tgrepo) ->
|
||||
TaskIsIocaineButtonDirective = ($rootscope, $tgrepo, $confirm) ->
|
||||
template = _.template("""
|
||||
<fieldset title="Feeling a bit overwhelmed by a task? Make sure others know about it by clicking on Iocaine when editing a task. It's possible to become immune to this (fictional) deadly poison by consuming small amounts over time just as it's possible to get better at what you do by occasionally taking on extra challenges!">
|
||||
<label for="is-iocaine" class="clickable button button-gray is-iocaine">Iocaine</label>
|
||||
|
@ -278,9 +278,11 @@ TaskIsIocaineButtonDirective = ($rootscope, $tgrepo) ->
|
|||
us = $model.$modelValue.clone()
|
||||
us.is_iocaine = not us.is_iocaine
|
||||
$model.$setViewValue(us)
|
||||
$tgrepo.save($model.$modelValue).then ->
|
||||
promise = $tgrepo.save($model.$modelValue)
|
||||
promise.then ->
|
||||
$rootscope.$broadcast("history:reload")
|
||||
|
||||
promise.then null, ->
|
||||
$confirm.notify("error")
|
||||
|
||||
return {
|
||||
link: link
|
||||
|
@ -288,4 +290,4 @@ TaskIsIocaineButtonDirective = ($rootscope, $tgrepo) ->
|
|||
require: "ngModel"
|
||||
}
|
||||
|
||||
module.directive("tgTaskIsIocaineButton", ["$rootScope", "$tgRepo", TaskIsIocaineButtonDirective])
|
||||
module.directive("tgTaskIsIocaineButton", ["$rootScope", "$tgRepo", "$tgConfirm", TaskIsIocaineButtonDirective])
|
||||
|
|
|
@ -473,7 +473,7 @@ module.directive("tgUsStatusButton", ["$rootScope", "$tgRepo", UsStatusButtonDir
|
|||
## User story team requirements button directive
|
||||
#############################################################################
|
||||
|
||||
UsTeamRequirementButtonDirective = ($rootscope, $tgrepo) ->
|
||||
UsTeamRequirementButtonDirective = ($rootscope, $tgrepo, $confirm) ->
|
||||
template = _.template("""
|
||||
<label for="team-requirement" class="button button-gray team-requirement">Team requirement</label>
|
||||
<input type="checkbox" id="team-requirement" name="team-requirement"/>
|
||||
|
@ -504,8 +504,13 @@ UsTeamRequirementButtonDirective = ($rootscope, $tgrepo) ->
|
|||
us = $model.$modelValue.clone()
|
||||
us.team_requirement = not us.team_requirement
|
||||
$model.$setViewValue(us)
|
||||
$tgrepo.save($model.$modelValue).then ->
|
||||
promise = $tgrepo.save($model.$modelValue)
|
||||
promise.then ->
|
||||
$rootscope.$broadcast("history:reload")
|
||||
promise.then null, ->
|
||||
$confirm.notify("error")
|
||||
us.revert()
|
||||
$model.$setViewValue(us)
|
||||
|
||||
return {
|
||||
link: link
|
||||
|
@ -513,14 +518,14 @@ UsTeamRequirementButtonDirective = ($rootscope, $tgrepo) ->
|
|||
require: "ngModel"
|
||||
}
|
||||
|
||||
module.directive("tgUsTeamRequirementButton", ["$rootScope", "$tgRepo", UsTeamRequirementButtonDirective])
|
||||
module.directive("tgUsTeamRequirementButton", ["$rootScope", "$tgRepo", "$tgConfirm", UsTeamRequirementButtonDirective])
|
||||
|
||||
|
||||
#############################################################################
|
||||
## User story client requirements button directive
|
||||
#############################################################################
|
||||
|
||||
UsClientRequirementButtonDirective = ($rootscope, $tgrepo) ->
|
||||
UsClientRequirementButtonDirective = ($rootscope, $tgrepo, $confirm) ->
|
||||
template = _.template("""
|
||||
<label for="client-requirement" class="button button-gray client-requirement">Client requirement</label>
|
||||
<input type="checkbox" id="client-requirement" name="client-requirement"/>
|
||||
|
@ -551,12 +556,17 @@ UsClientRequirementButtonDirective = ($rootscope, $tgrepo) ->
|
|||
us = $model.$modelValue.clone()
|
||||
us.client_requirement = not us.client_requirement
|
||||
$model.$setViewValue(us)
|
||||
$tgrepo.save($model.$modelValue).then ->
|
||||
promise = $tgrepo.save($model.$modelValue)
|
||||
promise.then ->
|
||||
$rootscope.$broadcast("history:reload")
|
||||
promise.then null, ->
|
||||
$confirm.notify("error")
|
||||
us.revert()
|
||||
$model.$setViewValue(us)
|
||||
|
||||
return {
|
||||
link: link
|
||||
restrict: "EA"
|
||||
require: "ngModel"
|
||||
}
|
||||
module.directive("tgUsClientRequirementButton", ["$rootScope", "$tgRepo", UsClientRequirementButtonDirective])
|
||||
module.directive("tgUsClientRequirementButton", ["$rootScope", "$tgRepo", "$tgConfirm", UsClientRequirementButtonDirective])
|
||||
|
|
Loading…
Reference in New Issue