Some error handling
parent
20bd7a2d6b
commit
4ab0512e22
|
@ -446,11 +446,10 @@ EditableSubjectDirective = ($rootscope, $tgrepo, $confirm, $navurls, $location)
|
||||||
$el.html(editTemplate({item: scope.item}))
|
$el.html(editTemplate({item: scope.item}))
|
||||||
else
|
else
|
||||||
canEdit = $scope.project.my_permissions.indexOf($attrs.requiredPerm) != -1
|
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) ->
|
$scope.$watch $attrs.ngModel, (item) ->
|
||||||
return if not item
|
return if not item
|
||||||
scope.item = item
|
|
||||||
render()
|
render()
|
||||||
|
|
||||||
$scope.$on "$destroy", ->
|
$scope.$on "$destroy", ->
|
||||||
|
@ -459,19 +458,23 @@ EditableSubjectDirective = ($rootscope, $tgrepo, $confirm, $navurls, $location)
|
||||||
$el.click ->
|
$el.click ->
|
||||||
if not editing and $scope.project.my_permissions.indexOf($attrs.requiredPerm) != -1
|
if not editing and $scope.project.my_permissions.indexOf($attrs.requiredPerm) != -1
|
||||||
editing = true
|
editing = true
|
||||||
|
scope.item = {subject: $model.$modelValue.subject}
|
||||||
render()
|
render()
|
||||||
$el.find('input').focus()
|
$el.find('input').focus()
|
||||||
|
|
||||||
$el.on "keyup", "input", ->
|
$el.on "keyup", "input", ->
|
||||||
if event.keyCode == 13
|
if event.keyCode == 13
|
||||||
scope.item.subject = $el.find('input').val()
|
$model.$modelValue.subject = $el.find('input').val()
|
||||||
$tgrepo.save(scope.item).then ->
|
promise = $tgrepo.save($model.$modelValue)
|
||||||
|
promise.then ->
|
||||||
$rootscope.$broadcast("history:reload")
|
$rootscope.$broadcast("history:reload")
|
||||||
editing = false
|
editing = false
|
||||||
render()
|
render()
|
||||||
|
promise.then null, ->
|
||||||
|
$confirm.notify("error")
|
||||||
else if event.keyCode == 27
|
else if event.keyCode == 27
|
||||||
editing = false
|
editing = false
|
||||||
scope.item.revert()
|
$model.$modelValue.revert()
|
||||||
render()
|
render()
|
||||||
|
|
||||||
return {
|
return {
|
||||||
|
@ -510,11 +513,10 @@ EditableDescriptionDirective = ($rootscope, $tgrepo, $confirm, $navurls, $locati
|
||||||
$el.html($compile(editTemplate({item: scope.item}))(scope))
|
$el.html($compile(editTemplate({item: scope.item}))(scope))
|
||||||
else
|
else
|
||||||
canEdit = $scope.project.my_permissions.indexOf($attrs.requiredPerm) != -1
|
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) ->
|
$scope.$watch $attrs.ngModel, (item) ->
|
||||||
return if not item
|
return if not item
|
||||||
scope.item = item
|
|
||||||
render()
|
render()
|
||||||
|
|
||||||
$scope.$on "$destroy", ->
|
$scope.$on "$destroy", ->
|
||||||
|
@ -523,22 +525,26 @@ EditableDescriptionDirective = ($rootscope, $tgrepo, $confirm, $navurls, $locati
|
||||||
$el.click ->
|
$el.click ->
|
||||||
if not editing and $scope.project.my_permissions.indexOf($attrs.requiredPerm) != -1
|
if not editing and $scope.project.my_permissions.indexOf($attrs.requiredPerm) != -1
|
||||||
editing = true
|
editing = true
|
||||||
|
scope.item = {description: $model.$modelValue.description}
|
||||||
render()
|
render()
|
||||||
$el.find('textarea').focus()
|
$el.find('textarea').focus()
|
||||||
|
|
||||||
$el.on "click", ".save", ->
|
$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")
|
$rootscope.$broadcast("history:reload")
|
||||||
editing = false
|
editing = false
|
||||||
render()
|
render()
|
||||||
|
promise.then null, ->
|
||||||
|
$confirm.notify("error")
|
||||||
|
|
||||||
$el.on "keyup", "textarea", ->
|
$el.on "keyup", "textarea", ->
|
||||||
if event.keyCode == 27
|
if event.keyCode == 27
|
||||||
editing = false
|
editing = false
|
||||||
scope.item.revert()
|
$model.$modelValue.revert()
|
||||||
render()
|
render()
|
||||||
|
|
||||||
|
|
||||||
return {
|
return {
|
||||||
link: link
|
link: link
|
||||||
restrict: "EA"
|
restrict: "EA"
|
||||||
|
|
|
@ -91,7 +91,7 @@ module.directive("tgColorizeTags", ColorizeTagsDirective)
|
||||||
## TagLine (possible should be moved as generic directive)
|
## 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)
|
# Main directive template (rendered by angular)
|
||||||
template = """
|
template = """
|
||||||
<div class="tags-container"></div>
|
<div class="tags-container"></div>
|
||||||
|
@ -140,8 +140,11 @@ TagLineDirective = ($rootscope, $log, $rs, $tgrepo) ->
|
||||||
$model.$setViewValue(normalizeTags(tags))
|
$model.$setViewValue(normalizeTags(tags))
|
||||||
autosaveModel = $scope.$eval($attrs.autosaveModel)
|
autosaveModel = $scope.$eval($attrs.autosaveModel)
|
||||||
if autosaveModel
|
if autosaveModel
|
||||||
$tgrepo.save(autosaveModel).then ->
|
promise = $tgrepo.save(autosaveModel)
|
||||||
|
promise.then ->
|
||||||
$rootscope.$broadcast("history:reload")
|
$rootscope.$broadcast("history:reload")
|
||||||
|
promise.then null, ->
|
||||||
|
$confirm.notify("error")
|
||||||
|
|
||||||
saveInputTag = () ->
|
saveInputTag = () ->
|
||||||
input = $el.find('input')
|
input = $el.find('input')
|
||||||
|
@ -213,8 +216,11 @@ TagLineDirective = ($rootscope, $log, $rs, $tgrepo) ->
|
||||||
$model.$setViewValue(normalizeTags(tags))
|
$model.$setViewValue(normalizeTags(tags))
|
||||||
autosaveModel = $scope.$eval($attrs.autosaveModel)
|
autosaveModel = $scope.$eval($attrs.autosaveModel)
|
||||||
if autosaveModel
|
if autosaveModel
|
||||||
$tgrepo.save(autosaveModel).then ->
|
promise = $tgrepo.save(autosaveModel)
|
||||||
|
promise.then ->
|
||||||
$rootscope.$broadcast("history:reload")
|
$rootscope.$broadcast("history:reload")
|
||||||
|
promise.then null, ->
|
||||||
|
$confirm.notify("error")
|
||||||
|
|
||||||
return {
|
return {
|
||||||
link:link,
|
link:link,
|
||||||
|
@ -222,4 +228,4 @@ TagLineDirective = ($rootscope, $log, $rs, $tgrepo) ->
|
||||||
template: template
|
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])
|
module.directive("tgTaskStatusButton", ["$rootScope", "$tgRepo", TaskStatusButtonDirective])
|
||||||
|
|
||||||
|
|
||||||
TaskIsIocaineButtonDirective = ($rootscope, $tgrepo) ->
|
TaskIsIocaineButtonDirective = ($rootscope, $tgrepo, $confirm) ->
|
||||||
template = _.template("""
|
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!">
|
<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>
|
<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 = $model.$modelValue.clone()
|
||||||
us.is_iocaine = not us.is_iocaine
|
us.is_iocaine = not us.is_iocaine
|
||||||
$model.$setViewValue(us)
|
$model.$setViewValue(us)
|
||||||
$tgrepo.save($model.$modelValue).then ->
|
promise = $tgrepo.save($model.$modelValue)
|
||||||
|
promise.then ->
|
||||||
$rootscope.$broadcast("history:reload")
|
$rootscope.$broadcast("history:reload")
|
||||||
|
promise.then null, ->
|
||||||
|
$confirm.notify("error")
|
||||||
|
|
||||||
return {
|
return {
|
||||||
link: link
|
link: link
|
||||||
|
@ -288,4 +290,4 @@ TaskIsIocaineButtonDirective = ($rootscope, $tgrepo) ->
|
||||||
require: "ngModel"
|
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
|
## User story team requirements button directive
|
||||||
#############################################################################
|
#############################################################################
|
||||||
|
|
||||||
UsTeamRequirementButtonDirective = ($rootscope, $tgrepo) ->
|
UsTeamRequirementButtonDirective = ($rootscope, $tgrepo, $confirm) ->
|
||||||
template = _.template("""
|
template = _.template("""
|
||||||
<label for="team-requirement" class="button button-gray team-requirement">Team requirement</label>
|
<label for="team-requirement" class="button button-gray team-requirement">Team requirement</label>
|
||||||
<input type="checkbox" id="team-requirement" name="team-requirement"/>
|
<input type="checkbox" id="team-requirement" name="team-requirement"/>
|
||||||
|
@ -504,8 +504,13 @@ UsTeamRequirementButtonDirective = ($rootscope, $tgrepo) ->
|
||||||
us = $model.$modelValue.clone()
|
us = $model.$modelValue.clone()
|
||||||
us.team_requirement = not us.team_requirement
|
us.team_requirement = not us.team_requirement
|
||||||
$model.$setViewValue(us)
|
$model.$setViewValue(us)
|
||||||
$tgrepo.save($model.$modelValue).then ->
|
promise = $tgrepo.save($model.$modelValue)
|
||||||
|
promise.then ->
|
||||||
$rootscope.$broadcast("history:reload")
|
$rootscope.$broadcast("history:reload")
|
||||||
|
promise.then null, ->
|
||||||
|
$confirm.notify("error")
|
||||||
|
us.revert()
|
||||||
|
$model.$setViewValue(us)
|
||||||
|
|
||||||
return {
|
return {
|
||||||
link: link
|
link: link
|
||||||
|
@ -513,14 +518,14 @@ UsTeamRequirementButtonDirective = ($rootscope, $tgrepo) ->
|
||||||
require: "ngModel"
|
require: "ngModel"
|
||||||
}
|
}
|
||||||
|
|
||||||
module.directive("tgUsTeamRequirementButton", ["$rootScope", "$tgRepo", UsTeamRequirementButtonDirective])
|
module.directive("tgUsTeamRequirementButton", ["$rootScope", "$tgRepo", "$tgConfirm", UsTeamRequirementButtonDirective])
|
||||||
|
|
||||||
|
|
||||||
#############################################################################
|
#############################################################################
|
||||||
## User story client requirements button directive
|
## User story client requirements button directive
|
||||||
#############################################################################
|
#############################################################################
|
||||||
|
|
||||||
UsClientRequirementButtonDirective = ($rootscope, $tgrepo) ->
|
UsClientRequirementButtonDirective = ($rootscope, $tgrepo, $confirm) ->
|
||||||
template = _.template("""
|
template = _.template("""
|
||||||
<label for="client-requirement" class="button button-gray client-requirement">Client requirement</label>
|
<label for="client-requirement" class="button button-gray client-requirement">Client requirement</label>
|
||||||
<input type="checkbox" id="client-requirement" name="client-requirement"/>
|
<input type="checkbox" id="client-requirement" name="client-requirement"/>
|
||||||
|
@ -551,12 +556,17 @@ UsClientRequirementButtonDirective = ($rootscope, $tgrepo) ->
|
||||||
us = $model.$modelValue.clone()
|
us = $model.$modelValue.clone()
|
||||||
us.client_requirement = not us.client_requirement
|
us.client_requirement = not us.client_requirement
|
||||||
$model.$setViewValue(us)
|
$model.$setViewValue(us)
|
||||||
$tgrepo.save($model.$modelValue).then ->
|
promise = $tgrepo.save($model.$modelValue)
|
||||||
|
promise.then ->
|
||||||
$rootscope.$broadcast("history:reload")
|
$rootscope.$broadcast("history:reload")
|
||||||
|
promise.then null, ->
|
||||||
|
$confirm.notify("error")
|
||||||
|
us.revert()
|
||||||
|
$model.$setViewValue(us)
|
||||||
|
|
||||||
return {
|
return {
|
||||||
link: link
|
link: link
|
||||||
restrict: "EA"
|
restrict: "EA"
|
||||||
require: "ngModel"
|
require: "ngModel"
|
||||||
}
|
}
|
||||||
module.directive("tgUsClientRequirementButton", ["$rootScope", "$tgRepo", UsClientRequirementButtonDirective])
|
module.directive("tgUsClientRequirementButton", ["$rootScope", "$tgRepo", "$tgConfirm", UsClientRequirementButtonDirective])
|
||||||
|
|
Loading…
Reference in New Issue