Merge pull request #597 from taigaio/remove-descriptions-from-listin-API

Removing descriptions from list API
stable
Alejandro 2015-08-10 13:55:23 +02:00
commit e2c174e23c
29 changed files with 343 additions and 169 deletions

View File

@ -109,16 +109,18 @@ CreateMembersDirective = ($rs, $rootScope, $confirm, $loading, lightboxService,
submit = debounce 2000, (event) =>
event.preventDefault()
$loading.start(submitButton)
currentLoading = $loading()
.target(submitButton)
.start()
onSuccess = (data) ->
$loading.finish(submitButton)
currentLoading.finish()
lightboxService.close($el)
$confirm.notify("success")
$rootScope.$broadcast("membersform:new:success")
onError = (data) ->
$loading.finish(submitButton)
currentLoading.finish()
lightboxService.close($el)
$confirm.notify("error")
$rootScope.$broadcast("membersform:new:error")

View File

@ -114,11 +114,13 @@ ProjectProfileDirective = ($repo, $confirm, $loading, $navurls, $location, proje
return if not form.validate()
$loading.start(submitButton)
currentLoading = $loading()
.target(submitButton)
.start()
promise = $repo.save($scope.project)
promise.then ->
$loading.finish(submitButton)
currentLoading.finish()
$confirm.notify("success")
newUrl = $navurls.resolve("project-admin-project-profile-details", {
project: $scope.project.slug
@ -131,7 +133,7 @@ ProjectProfileDirective = ($repo, $confirm, $loading, $navurls, $location, proje
currentUserService.loadProjects()
promise.then null, (data) ->
$loading.finish(submitButton)
currentLoading.finish()
form.setErrors(data)
if data._error_message
$confirm.notify("error", data._error_message)
@ -158,15 +160,17 @@ ProjectDefaultValuesDirective = ($repo, $confirm, $loading) ->
return if not form.validate()
$loading.start(submitButton)
currentLoading = $loading()
.target(submitButton)
.start()
promise = $repo.save($scope.project)
promise.then ->
$loading.finish(submitButton)
currentLoading.finish()
$confirm.notify("success")
promise.then null, (data) ->
$loading.finish(target)
currentLoading.finish()
form.setErrors(data)
if data._error_message
$confirm.notify("error", data._error_message)
@ -193,19 +197,21 @@ ProjectModulesDirective = ($repo, $confirm, $loading, projectService) ->
form = $el.find("form").checksley()
return if not form.validate()
target = angular.element(".admin-functionalities a.button-green")
$loading.start(target)
target = angular.element(".admin-functionalities .submit-button")
currentLoading = $loading()
.target(target)
.start()
promise = $repo.save($scope.project)
promise.then ->
$loading.finish(target)
currentLoading.finish()
$confirm.notify("success")
$scope.$emit("project:loaded", $scope.project)
projectService.fetchProject()
promise.then null, (data) ->
$loading.finish(target)
currentLoading.finish()
$confirm.notify("error", data._error_message)
$el.on "submit", "form", (event) ->

View File

@ -454,15 +454,17 @@ GithubWebhooksDirective = ($repo, $confirm, $loading) ->
return if not form.validate()
$loading.start(submitButton)
currentLoading = $loading()
.target(submitButton)
.start()
promise = $repo.saveAttribute($scope.github, "github")
promise.then ->
$loading.finish(submitButton)
currentLoading.finish()
$confirm.notify("success")
promise.then null, (data) ->
$loading.finish(submitButton)
currentLoading.finish()
form.setErrors(data)
if data._error_message
$confirm.notify("error", data._error_message)
@ -488,16 +490,18 @@ GitlabWebhooksDirective = ($repo, $confirm, $loading) ->
return if not form.validate()
$loading.start(submitButton)
currentLoading = $loading()
.target(submitButton)
.start()
promise = $repo.saveAttribute($scope.gitlab, "gitlab")
promise.then ->
$loading.finish(submitButton)
currentLoading.finish()
$confirm.notify("success")
$scope.$emit("project:modules:reload")
promise.then null, (data) ->
$loading.finish(submitButton)
currentLoading.finish()
form.setErrors(data)
if data._error_message
$confirm.notify("error", data._error_message)
@ -523,16 +527,18 @@ BitbucketWebhooksDirective = ($repo, $confirm, $loading) ->
return if not form.validate()
$loading.start(submitButton)
currentLoading = $loading()
.target(submitButton)
.start()
promise = $repo.saveAttribute($scope.bitbucket, "bitbucket")
promise.then ->
$loading.finish(submitButton)
currentLoading.finish()
$confirm.notify("success")
$scope.$emit("project:modules:reload")
promise.then null, (data) ->
$loading.finish(submitButton)
currentLoading.finish()
form.setErrors(data)
if data._error_message
$confirm.notify("error", data._error_message)

View File

@ -71,17 +71,19 @@ CreateEditSprint = ($repo, $confirm, $rs, $rootscope, lightboxService, $loading,
promise = $repo.save(newSprint)
broadcastEvent = "sprintform:edit:success"
$loading.start(submitButton)
currentLoading = $loading()
.target(submitButton)
.start()
promise.then (data) ->
$loading.finish(submitButton)
currentLoading.finish()
$scope.sprintsCounter += 1 if createSprint
$rootscope.$broadcast(broadcastEvent, data)
lightboxService.close($el)
promise.then null, (data) ->
$loading.finish(submitButton)
currentLoading.finish()
form.setErrors(data)
if data._error_message

View File

@ -50,11 +50,12 @@ class BacklogController extends mixOf(taiga.Controller, taiga.PageMixin, taiga.F
"$tgNavUrls",
"$tgEvents",
"$tgAnalytics",
"$translate"
"$translate",
"$tgLoading"
]
constructor: (@scope, @rootscope, @repo, @confirm, @rs, @params, @q,
@location, @appMetaService, @navUrls, @events, @analytics, @translate) ->
@location, @appMetaService, @navUrls, @events, @analytics, @translate, @loading) ->
bindMethods(@)
@scope.sectionName = @translate.instant("BACKLOG.SECTION_NAME")
@ -488,8 +489,19 @@ class BacklogController extends mixOf(taiga.Controller, taiga.PageMixin, taiga.F
@rootscope.$broadcast("filters:update")
@.loadProjectStats()
editUserStory: (us) ->
@rootscope.$broadcast("usform:edit", us)
editUserStory: (projectId, ref, $event) ->
target = $($event.target)
currentLoading = @loading()
.target(target)
.removeClasses("icon-edit")
.timeout(200)
.start()
@rs.userstories.getByRef(projectId, ref).then (us) =>
@rootscope.$broadcast("usform:edit", us)
currentLoading.finish()
deleteUserStory: (us) ->
title = @translate.instant("US.TITLE_DELETE_ACTION")

View File

@ -153,12 +153,16 @@ ToggleExcludeClosedSprintsVisualization = ($rootscope, $loading, $translate) ->
loadingElm = $("<div>")
$el.after(loadingElm)
currentLoading = null
# Event Handlers
$el.on "click", (event) ->
event.preventDefault()
excludeClosedSprints = not excludeClosedSprints
$loading.start(loadingElm)
currentLoading = $loading()
.target(loadingElm)
.start()
if excludeClosedSprints
$rootscope.$broadcast("backlog:unload-closed-sprints")
@ -169,7 +173,7 @@ ToggleExcludeClosedSprintsVisualization = ($rootscope, $loading, $translate) ->
$el.off()
$scope.$on "closed-sprints:reloaded", (ctx, sprints) =>
$loading.finish(loadingElm)
currentLoading.finish()
if sprints.length > 0
key = "BACKLOG.SPRINTS.ACTION_HIDE_CLOSED_SPRINTS"

View File

@ -316,18 +316,20 @@ AssignedToDirective = ($rootscope, $confirm, $repo, $loading, $qqueue, $template
save = $qqueue.bindAdd (userId) =>
$model.$modelValue.assigned_to = userId
$loading.start($el)
currentLoading = $loading()
.target($el)
.start()
promise = $repo.save($model.$modelValue)
promise.then ->
$loading.finish($el)
currentLoading.finish()
$confirm.notify("success")
renderAssignedTo($model.$modelValue)
$rootscope.$broadcast("object:updated")
promise.then null, ->
$model.$modelValue.revert()
$confirm.notify("error")
$loading.finish($el)
currentLoading.finish()
return promise
@ -408,9 +410,12 @@ BlockButtonDirective = ($rootscope, $loading, $template) ->
$el.on "click", ".item-unblock", (event) ->
event.preventDefault()
$loading.start($el.find(".item-unblock"))
currentLoading = $loading()
.target($el.find(".item-unblock"))
.start()
finish = ->
$loading.finish($el.find(".item-unblock"))
currentLoading.finish()
$rootscope.$broadcast("unblock", $model.$modelValue, finish)
@ -486,7 +491,9 @@ EditableSubjectDirective = ($rootscope, $repo, $confirm, $loading, $qqueue, $tem
save = $qqueue.bindAdd (subject) =>
$model.$modelValue.subject = subject
$loading.start($el.find('.save-container'))
currentLoading = $loading()
.target($el.find('.save-container'))
.start()
promise = $repo.save($model.$modelValue)
promise.then ->
@ -497,7 +504,7 @@ EditableSubjectDirective = ($rootscope, $repo, $confirm, $loading, $qqueue, $tem
promise.then null, ->
$confirm.notify("error")
promise.finally ->
$loading.finish($el.find('.save-container'))
currentLoading.finish()
return promise
@ -571,7 +578,10 @@ EditableDescriptionDirective = ($rootscope, $repo, $confirm, $compile, $loading,
save = $qqueue.bindAdd (description) =>
$model.$modelValue.description = description
$loading.start($el.find('.save-container'))
currentLoading = $loading()
.target($el.find('.save-container'))
.start()
promise = $repo.save($model.$modelValue)
promise.then ->
$confirm.notify("success")
@ -581,7 +591,7 @@ EditableDescriptionDirective = ($rootscope, $repo, $confirm, $compile, $loading,
promise.then null, ->
$confirm.notify("error")
promise.finally ->
$loading.finish($el.find('.save-container'))
currentLoading.finish()
$el.on "mouseup", ".view-description", (event) ->
# We want to dettect the a inside the div so we use the target and

View File

@ -64,9 +64,12 @@ class ConfirmService extends taiga.Service
el.on "click.confirm-dialog", "a.button-green", debounce 2000, (event) =>
event.preventDefault()
target = angular.element(event.currentTarget)
@loading.start(target)
currentLoading = @loading()
.target(target)
.start()
defered.resolve (ok=true) =>
@loading.finish(target)
currentLoading.finish()
if ok
@.hide(el)
@ -110,11 +113,13 @@ class ConfirmService extends taiga.Service
el.on "click.confirm-dialog", "a.button-green", debounce 2000, (event) =>
event.preventDefault()
target = angular.element(event.currentTarget)
@loading.start(target)
currentLoading = @loading()
.target(target)
.start()
defered.resolve {
selected: choicesField.val()
finish: =>
@loading.finish(target)
currentLoading.finish()
@.hide(el)
}

View File

@ -347,18 +347,21 @@ HistoryDirective = ($log, $loading, $qqueue, $template, $confirm, $translate, $c
$el.find(".comment-list").addClass("activeanimation")
currentLoading = $loading()
.target(target)
.start()
onSuccess = ->
$rootScope.$broadcast("comment:new")
$ctrl.loadHistory(type, objectId).finally ->
$loading.finish(target)
currentLoading.finish()
onError = ->
$loading.finish(target)
currentLoading.finish()
$confirm.notify("error")
model = $scope.$eval($attrs.ngModel)
$loading.start(target)
$ctrl.repo.save(model).then(onSuccess, onError)
@ -371,7 +374,7 @@ HistoryDirective = ($log, $loading, $qqueue, $template, $confirm, $translate, $c
# Events
$el.on "click", ".add-comment input.button-green", debounce 2000, (event) ->
$el.on "click", ".add-comment button.button-green", debounce 2000, (event) ->
event.preventDefault()
target = angular.element(event.currentTarget)

View File

@ -179,7 +179,9 @@ BlockLightboxDirective = ($rootscope, $tgrepo, $confirm, lightboxService, $loadi
block = $qqueue.bindAdd (item) =>
$model.$setViewValue(item)
$loading.start($el.find(".button-green"))
currentLoading = $loading()
.target($el.find(".button-green"))
.start()
promise = $tgrepo.save($model.$modelValue)
promise.then ->
@ -192,7 +194,7 @@ BlockLightboxDirective = ($rootscope, $tgrepo, $confirm, lightboxService, $loadi
$model.$setViewValue(item)
promise.finally ->
$loading.finish($el.find(".button-green"))
currentLoading.finish()
lightboxService.close($el)
$scope.$on "block", ->
@ -324,7 +326,9 @@ CreateEditUserstoryDirective = ($repo, $model, $rs, $rootScope, lightboxService,
if not form.validate()
return
$loading.start(submitButton)
currentLoading = $loading()
.target(submitButton)
.start()
if $scope.isNew
promise = $repo.create("userstories", $scope.us)
@ -334,12 +338,12 @@ CreateEditUserstoryDirective = ($repo, $model, $rs, $rootScope, lightboxService,
broadcastEvent = "usform:edit:success"
promise.then (data) ->
$loading.finish(submitButton)
currentLoading.finish()
lightboxService.close($el)
$rootScope.$broadcast(broadcastEvent, data)
promise.then null, (data) ->
$loading.finish(submitButton)
currentLoading.finish()
form.setErrors(data)
if data._error_message
$confirm.notify("error", data._error_message)
@ -399,16 +403,18 @@ CreateBulkUserstoriesDirective = ($repo, $rs, $rootscope, lightboxService, $load
if not form.validate()
return
$loading.start(submitButton)
currentLoading = $loading()
.target(submitButton)
.start()
promise = $rs.userstories.bulkCreate($scope.new.projectId, $scope.new.statusId, $scope.new.bulk)
promise.then (result) ->
$loading.finish(submitButton)
currentLoading.finish()
$rootscope.$broadcast("usform:bulk:success", result)
lightboxService.close($el)
promise.then null, (data) ->
$loading.finish(submitButton)
currentLoading.finish()
form.setErrors(data)
if data._error_message
$confirm.notify("error", data._error_message)

View File

@ -21,29 +21,78 @@
module = angular.module("taigaCommon")
class TgLoadingService extends taiga.Service
start: (target) ->
if not target.hasClass('loading')
target.data('loading-old-content', target.html())
target.addClass('loading')
target.html("<img class='loading-spinner' src='/svg/spinner-circle.svg' alt='loading...' />")
TgLoadingService = ->
spinner = "<img class='loading-spinner' src='/svg/spinner-circle.svg' alt='loading...' />"
finish: (target) ->
if target.hasClass('loading')
oldContent = target.data('loading-old-content')
target.data('loading-old-content', null)
target.html(oldContent)
target.removeClass('loading')
return () ->
service = {
settings: {
target: null,
classes: []
timeout: 0
},
target: (target) ->
service.settings.target = target
module.service("$tgLoading", TgLoadingService)
return service
removeClasses: (classess...) ->
service.settings.classes = classess
return service
timeout: (timeout) ->
service.settings.timeout = timeout
return service
start: ->
target = service.settings.target
service.settings.classes.map (className) -> target.removeClass(className)
# The loader is shown after that quantity of milliseconds
timeoutId = setTimeout (->
if not target.hasClass('loading')
service.settings.oldContent = target.html()
target.addClass('loading')
target.html(spinner)
), service.settings.timeout
service.settings.timeoutId = timeoutId
return service
finish: ->
target = service.settings.target
timeoutId = service.settings.timeoutId
if timeoutId
clearTimeout(timeoutId)
removeClasses = service.settings.classes
removeClasses.map (className) -> service.settings.target.addClass(className)
target.html(service.settings.oldContent)
target.removeClass('loading')
return service
}
return service
module.factory("$tgLoading", TgLoadingService)
LoadingDirective = ($loading) ->
link = ($scope, $el, attr) ->
currentLoading = null
$scope.$watch attr.tgLoading, (showLoading) =>
if showLoading
$loading.start($el)
currentLoading = $loading()
.target($el)
.start()
else
$loading.finish($el)
currentLoading.finish()
return {
link:link

View File

@ -39,17 +39,19 @@ FeedbackDirective = ($lightboxService, $repo, $confirm, $loading, feedbackServic
if not form.validate()
return
$loading.start(submitButton)
currentLoading = $loading()
.target(submitButton)
.start()
promise = $repo.create("feedback", $scope.feedback)
promise.then (data) ->
$loading.finish(submitButton)
currentLoading.finish()
$lightboxService.close($el)
$confirm.notify("success", "\\o/ we'll be happy to read your")
promise.then null, ->
$loading.finish(submitButton)
currentLoading.finish()
$confirm.notify("error")
submitButton = $el.find(".submit-button")

View File

@ -239,18 +239,21 @@ IssueStatusButtonDirective = ($rootScope, $repo, $confirm, $loading, $qqueue, $t
issue = $model.$modelValue.clone()
issue.status = statusId
currentLoading = $loading()
.target($el.find(".level-name"))
.start()
onSuccess = ->
$confirm.notify("success")
$model.$setViewValue(issue)
$rootScope.$broadcast("object:updated")
$loading.finish($el.find(".level-name"))
currentLoading.finish()
onError = ->
$confirm.notify("error")
issue.revert()
$model.$setViewValue(issue)
$loading.finish($el.find(".level-name"))
currentLoading.finish()
$loading.start($el.find(".level-name"))
$repo.save(issue).then(onSuccess, onError)
@ -323,18 +326,21 @@ IssueTypeButtonDirective = ($rootScope, $repo, $confirm, $loading, $qqueue, $tem
issue = $model.$modelValue.clone()
issue.type = type
currentLoading = $loading()
.target($el.find(".level-name"))
.start()
onSuccess = ->
$confirm.notify("success")
$model.$setViewValue(issue)
$rootScope.$broadcast("object:updated")
$loading.finish($el.find(".level-name"))
currentLoading.finish()
onError = ->
$confirm.notify("error")
issue.revert()
$model.$setViewValue(issue)
$loading.finish($el.find(".level-name"))
$loading.start($el.find(".level-name"))
currentLoading.finish()
$repo.save(issue).then(onSuccess, onError)
@ -409,18 +415,20 @@ IssueSeverityButtonDirective = ($rootScope, $repo, $confirm, $loading, $qqueue,
issue = $model.$modelValue.clone()
issue.severity = severity
currentLoading = $loading()
.target($el.find(".level-name"))
.start()
onSuccess = ->
$confirm.notify("success")
$model.$setViewValue(issue)
$rootScope.$broadcast("object:updated")
$loading.finish($el.find(".level-name"))
currentLoading.finish()
onError = ->
$confirm.notify("error")
issue.revert()
$model.$setViewValue(issue)
$loading.finish($el.find(".level-name"))
$loading.start($el.find(".level-name"))
currentLoading.finish()
$repo.save(issue).then(onSuccess, onError)
@ -496,18 +504,20 @@ IssuePriorityButtonDirective = ($rootScope, $repo, $confirm, $loading, $qqueue,
issue = $model.$modelValue.clone()
issue.priority = priority
currentLoading = $loading()
.target($el.find(".level-name"))
.start()
onSuccess = ->
$confirm.notify("success")
$model.$setViewValue(issue)
$rootScope.$broadcast("object:updated")
$loading.finish($el.find(".level-name"))
currentLoading.finish()
onError = ->
$confirm.notify("error")
issue.revert()
$model.$setViewValue(issue)
$loading.finish($el.find(".level-name"))
$loading.start($el.find(".level-name"))
currentLoading.finish()
$repo.save(issue).then(onSuccess, onError)

View File

@ -58,17 +58,20 @@ CreateIssueDirective = ($repo, $confirm, $rootscope, lightboxService, $loading)
if not form.validate()
return
$loading.start(submitButton)
currentLoading = $loading()
.target(submitButton)
.start()
promise = $repo.create("issues", $scope.issue)
promise.then (data) ->
$loading.finish(submitButton)
currentLoading.finish()
$rootscope.$broadcast("issueform:new:success", data)
lightboxService.close($el)
$confirm.notify("success")
promise.then null, ->
$loading.finish(submitButton)
currentLoading.finish()
$confirm.notify("error")
@ -103,20 +106,22 @@ CreateBulkIssuesDirective = ($repo, $rs, $confirm, $rootscope, $loading, lightbo
if not form.validate()
return
$loading.start(submitButton)
currentLoading = $loading()
.target(submitButton)
.start()
data = $scope.new.bulk
projectId = $scope.new.projectId
promise = $rs.issues.bulkCreate(projectId, data)
promise.then (result) ->
$loading.finish(submitButton)
currentLoading.finish()
$rootscope.$broadcast("issueform:new:success", result)
lightboxService.close($el)
$confirm.notify("success")
promise.then null, ->
$loading.finish(submitButton)
currentLoading.finish()
$confirm.notify("error")
submitButton = $el.find(".submit-button")

View File

@ -649,12 +649,14 @@ IssuesFiltersDirective = ($q, $log, $location, $rs, $confirm, $loading, $templat
if event.keyCode == 13
target = angular.element(event.currentTarget)
newFilter = target.val()
$loading.start($el.find(".new"))
currentLoading = $loading()
.target($el.find(".new"))
.start()
promise = $ctrl.saveCurrentFiltersTo(newFilter)
promise.then ->
loadPromise = $ctrl.loadMyFilters()
loadPromise.then (filters) ->
$loading.finish($el.find(".new"))
currentLoading.finish()
$scope.filters.myFilters = filters
currentfilterstype = $el.find("h2 a.subfilter span.title").prop('data-type')
@ -665,11 +667,11 @@ IssuesFiltersDirective = ($q, $log, $location, $rs, $confirm, $loading, $templat
$el.find('.save-filters').show()
loadPromise.then null, ->
$loading.finish($el.find(".new"))
currentLoading.finish()
$confirm.notify("error", "Error loading custom filters")
promise.then null, ->
$loading.finish($el.find(".new"))
currentLoading.finish()
$el.find(".my-filter-name").val(newFilter).focus().select()
$confirm.notify("error", "Filter not saved")

View File

@ -404,7 +404,7 @@ module.directive("tgKanbanArchivedStatusIntro", ["$translate", KanbanArchivedSta
## Kanban User Story Directive
#############################################################################
KanbanUserstoryDirective = ($rootscope) ->
KanbanUserstoryDirective = ($rootscope, $loading, $rs) ->
link = ($scope, $el, $attrs, $model) ->
$el.disableSelection()
@ -418,8 +418,18 @@ KanbanUserstoryDirective = ($rootscope) ->
if $el.find(".icon-edit").hasClass("noclick")
return
$scope.$apply ->
$rootscope.$broadcast("usform:edit", $model.$modelValue)
target = $(event.target)
currentLoading = $loading()
.target(target)
.timeout(200)
.removeClasses("icon-edit")
.start()
us = $model.$modelValue
$rs.userstories.getByRef(us.project, us.ref).then (editingUserStory) =>
$rootscope.$broadcast("usform:edit", editingUserStory)
currentLoading.finish()
$scope.$on "$destroy", ->
$el.off()
@ -430,7 +440,7 @@ KanbanUserstoryDirective = ($rootscope) ->
require: "ngModel"
}
module.directive("tgKanbanUserstory", ["$rootScope", KanbanUserstoryDirective])
module.directive("tgKanbanUserstory", ["$rootScope", "$tgLoading", "$tgResources", KanbanUserstoryDirective])
#############################################################################
## Kanban Squish Column Directive

View File

@ -30,6 +30,7 @@ CreateProject = ($rootscope, $repo, $confirm, $location, $navurls, $rs, $project
link = ($scope, $el, attrs) ->
$scope.data = {}
$scope.templates = []
currentLoading = null
form = $el.find("form").checksley({"onlyOneErrorElement": true})
@ -39,7 +40,7 @@ CreateProject = ($rootscope, $repo, $confirm, $location, $navurls, $rs, $project
# than another deleted in the same session
$cacheFactory.get('$http').removeAll()
$loading.finish(submitButton)
currentLoading.finish()
$rootscope.$broadcast("projects:reload")
$confirm.notify("success", $translate.instant("COMMON.SAVE"))
@ -49,7 +50,7 @@ CreateProject = ($rootscope, $repo, $confirm, $location, $navurls, $rs, $project
currentUserService.loadProjects()
onErrorSubmit = (response) ->
$loading.finish(submitButton)
currentLoading.finish()
form.setErrors(response)
selectors = []
for error_field in _.keys(response)
@ -65,7 +66,9 @@ CreateProject = ($rootscope, $repo, $confirm, $location, $navurls, $rs, $project
if not form.validate()
return
$loading.start(submitButton)
currentLoading = $loading()
.target(submitButton)
.start()
promise = $repo.create("projects", $scope.data)
promise.then(onSuccessSubmit, onErrorSubmit)

View File

@ -33,16 +33,18 @@ RelatedTaskRowDirective = ($repo, $compile, $confirm, $rootscope, $loading, $tem
saveTask = debounce 2000, (task) ->
task.subject = $el.find('input').val()
$loading.start($el.find('.task-name'))
currentLoading = $loading()
.target($el.find('.task-name'))
.start()
promise = $repo.save(task)
promise.then =>
$loading.finish($el.find('.task-name'))
currentLoading.finish()
$confirm.notify("success")
$rootscope.$broadcast("related-tasks:update")
promise.then null, =>
$loading.finish($el.find('.task-name'))
currentLoading.finish()
$el.find('input').val(task.subject)
$confirm.notify("error")
return promise
@ -126,17 +128,20 @@ RelatedTaskCreateFormDirective = ($repo, $compile, $confirm, $tgmodel, $loading,
$scope.newTask.status = $scope.project.default_task_status
$scope.newTask.assigned_to = null
$loading.start($el.find('.task-name'))
currentLoading = $loading()
.target($el.find('.task-name'))
.start()
promise = $repo.create("tasks", task)
promise.then ->
$analytics.trackEvent("task", "create", "create task on userstory", 1)
$loading.finish($el.find('.task-name'))
currentLoading.finish()
$scope.$emit("related-tasks:add")
$confirm.notify("success")
promise.then null, ->
$el.find('input').val(task.subject)
$loading.finish($el.find('.task-name'))
currentLoading.finish()
$confirm.notify("error")
return promise

View File

@ -80,11 +80,13 @@ CreateEditTaskDirective = ($repo, $model, $rs, $rootscope, $loading, lightboxSer
promise = $repo.save($scope.task)
broadcastEvent = "taskform:edit:success"
$loading.start(submitButton)
currentLoading = $loading()
.target(submitButton)
.start()
# FIXME: error handling?
promise.then (data) ->
$loading.finish(submitButton)
currentLoading.finish()
lightboxService.close($el)
$rootscope.$broadcast(broadcastEvent, data)
@ -107,7 +109,9 @@ CreateBulkTasksDirective = ($repo, $rs, $rootscope, $loading, lightboxService) -
if not form.validate()
return
$loading.start(submitButton)
currentLoading = $loading()
.target(submitButton)
.start()
data = $scope.form.data
projectId = $scope.projectId
@ -116,13 +120,13 @@ CreateBulkTasksDirective = ($repo, $rs, $rootscope, $loading, lightboxService) -
promise = $rs.tasks.bulkCreate(projectId, sprintId, usId, data)
promise.then (result) ->
$loading.finish(submitButton)
currentLoading.finish()
$rootscope.$broadcast("taskform:bulk:success", result)
lightboxService.close($el)
# TODO: error handling
promise.then null, ->
$loading.finish(submitButton)
currentLoading.finish()
console.log "FAIL"
$scope.$on "taskform:bulk", (ctx, sprintId, usId)->

View File

@ -295,7 +295,7 @@ module.directive("tgTaskboard", ["$rootScope", TaskboardDirective])
## Taskboard Task Directive
#############################################################################
TaskboardTaskDirective = ($rootscope) ->
TaskboardTaskDirective = ($rootscope, $loading, $rs) ->
link = ($scope, $el, $attrs, $model) ->
$el.disableSelection()
@ -309,12 +309,23 @@ TaskboardTaskDirective = ($rootscope) ->
if $el.find('.icon-edit').hasClass('noclick')
return
$scope.$apply ->
$rootscope.$broadcast("taskform:edit", $scope.task)
target = $(event.target)
currentLoading = $loading()
.target(target)
.timeout(200)
.removeClasses("icon-edit")
.start()
task = $scope.task
$rs.tasks.getByRef(task.project, task.ref).then (editingTask) =>
$rootscope.$broadcast("taskform:edit", editingTask)
currentLoading.finish()
return {link:link}
module.directive("tgTaskboardTask", ["$rootScope", TaskboardTaskDirective])
module.directive("tgTaskboardTask", ["$rootScope", "$tgLoading", "$tgResources", TaskboardTaskDirective])
#############################################################################
## Taskboard Squish Column Directive

View File

@ -246,21 +246,21 @@ TaskStatusButtonDirective = ($rootScope, $repo, $confirm, $loading, $qqueue, $co
task = $model.$modelValue.clone()
task.status = status
$model.$setViewValue(task)
currentLoading = $loading()
.target($el.find(".level-name"))
.start()
onSuccess = ->
$model.$setViewValue(task)
$confirm.notify("success")
$rootScope.$broadcast("object:updated")
$loading.finish($el.find(".level-name"))
currentLoading.finish()
onError = ->
$confirm.notify("error")
task.revert()
$model.$setViewValue(task)
$loading.finish($el.find(".level-name"))
currentLoading.finish()
$loading.start($el.find(".level-name"))
$repo.save($model.$modelValue).then(onSuccess, onError)
$repo.save(task).then(onSuccess, onError)
$el.on "click", ".status-data", (event) ->
event.preventDefault()
@ -328,22 +328,22 @@ TaskIsIocaineButtonDirective = ($rootscope, $tgrepo, $confirm, $loading, $qqueue
task = $model.$modelValue.clone()
task.is_iocaine = is_iocaine
$model.$setViewValue(task)
$loading.start($el.find('label'))
currentLoading = $loading()
.target($el.find('label'))
.start()
promise = $tgrepo.save(task)
promise.then ->
$model.$setViewValue(task)
$confirm.notify("success")
$rootscope.$broadcast("object:updated")
promise.then null, ->
task.revert()
$model.$setViewValue(task)
$confirm.notify("error")
promise.finally ->
$loading.finish($el.find('label'))
currentLoading.finish()
$el.on "click", ".is-iocaine", (event) ->
return if not isEditable()

View File

@ -67,15 +67,17 @@ UserChangePasswordDirective = ($rs, $confirm, $loading, $translate) ->
$confirm.notify('error', $translate.instant("CHANGE_PASSWORD.ERROR_PASSWORD_MATCH"))
return
$loading.start(submitButton)
currentLoading = $loading()
.target(submitButton)
.start()
promise = $rs.userSettings.changePassword($scope.currentPassword, $scope.newPassword1)
promise.then =>
$loading.finish(submitButton)
currentLoading.finish()
$confirm.notify('success')
promise.then null, (response) =>
$loading.finish(submitButton)
currentLoading.finish()
$confirm.notify('error', response.data._error_message)
submitButton = $el.find(".submit-button")

View File

@ -304,8 +304,8 @@ UsStatusButtonDirective = ($rootScope, $repo, $confirm, $loading, $qqueue, $temp
statuses: $scope.statusList
editable: isEditable()
})
$el.html(html)
$el.html(html)
save = $qqueue.bindAdd (status) =>
us = $model.$modelValue.clone()
@ -314,22 +314,21 @@ UsStatusButtonDirective = ($rootScope, $repo, $confirm, $loading, $qqueue, $temp
$.fn.popover().closeAll()
$model.$setViewValue(us)
currentLoading = $loading()
.target($el.find(".level-name"))
.start()
onSuccess = ->
$confirm.notify("success")
$model.$setViewValue(us)
$rootScope.$broadcast("object:updated")
$loading.finish($el.find(".level-name"))
currentLoading.finish()
onError = ->
$confirm.notify("error")
us.revert()
$model.$setViewValue(us)
$loading.finish($el.find(".level-name"))
currentLoading.finish()
$loading.start($el.find(".level-name"))
$repo.save($model.$modelValue).then(onSuccess, onError)
$repo.save(us).then(onSuccess, onError)
$el.on "click", ".status-data", (event) ->
event.preventDefault()
@ -393,20 +392,19 @@ UsTeamRequirementButtonDirective = ($rootscope, $tgrepo, $confirm, $loading, $qq
us = $model.$modelValue.clone()
us.team_requirement = team_requirement
$model.$setViewValue(us)
currentLoading = $loading()
.target($el.find("label"))
.start()
$loading.start($el.find("label"))
promise = $tgrepo.save($model.$modelValue)
promise = $tgrepo.save(us)
promise.then =>
$loading.finish($el.find("label"))
$model.$setViewValue(us)
currentLoading.finish()
$rootscope.$broadcast("object:updated")
promise.then null, ->
$loading.finish($el.find("label"))
currentLoading.finish()
$confirm.notify("error")
us.revert()
$model.$setViewValue(us)
$el.on "click", ".team-requirement", (event) ->
return if not canEdit()
@ -456,18 +454,18 @@ UsClientRequirementButtonDirective = ($rootscope, $tgrepo, $confirm, $loading, $
us = $model.$modelValue.clone()
us.client_requirement = client_requirement
$model.$setViewValue(us)
currentLoading = $loading()
.target($el.find("label"))
.start()
$loading.start($el.find("label"))
promise = $tgrepo.save($model.$modelValue)
promise = $tgrepo.save(us)
promise.then =>
$loading.finish($el.find("label"))
$rootscope.$broadcast("object:updated")
promise.then null, ->
$loading.finish($el.find("label"))
$confirm.notify("error")
us.revert()
$model.$setViewValue(us)
currentLoading.finish()
$rootscope.$broadcast("object:updated")
promise.then null, ->
$confirm.notify("error")
$el.on "click", ".client-requirement", (event) ->
return if not canEdit()

View File

@ -233,7 +233,12 @@ EditableWikiContentDirective = ($window, $document, $repo, $confirm, $loading, $
onError = ->
$confirm.notify("error")
$loading.start($el.find('.save-container'))
console.log $el.find('.save-container')
currentLoading = $loading()
.removeClasses("icon-floppy")
.target($el.find('.icon-floppy'))
.start()
if wiki.id?
promise = $repo.save(wiki).then(onSuccess, onError)
@ -241,7 +246,7 @@ EditableWikiContentDirective = ($window, $document, $repo, $confirm, $loading, $
promise = $repo.create("wiki", wiki).then(onSuccess, onError)
promise.finally ->
$loading.finish($el.find('.save-container'))
currentLoading.finish()
$el.on "click", "a", (event) ->
target = angular.element(event.target)

View File

@ -104,27 +104,29 @@ WikiNavDirective = ($tgrepo, $log, $location, $confirm, $navUrls, $analytics, $l
target = angular.element(event.currentTarget)
newLink = target.val()
$loading.start($el.find(".new"))
currentLoading = $loading()
.target($el.find(".new"))
.start()
promise = $tgrepo.create("wiki-links", {project: $scope.projectId, title: newLink, href: slugify(newLink)})
promise.then ->
$analytics.trackEvent("wikilink", "create", "create wiki link", 1)
loadPromise = $ctrl.loadWikiLinks()
loadPromise.then ->
$loading.finish($el.find(".new"))
currentLoading.finish()
$el.find(".new").addClass("hidden")
$el.find(".new input").val('')
$el.find(".add-button").show()
render($scope.wikiLinks)
loadPromise.then null, ->
$loading.finish($el.find(".new"))
currentLoading.finish()
$el.find(".new").addClass("hidden")
$el.find(".new input").val('')
$el.find(".add-button").show()
$confirm.notify("error", "Error loading wiki links")
promise.then null, (error) ->
$loading.finish($el.find(".new"))
currentLoading.finish()
$el.find(".new input").val(newLink)
$el.find(".new input").focus().select()
if error?.__all__?[0]?

View File

@ -16,7 +16,7 @@ section.history
a(class="help-markdown", href="https://taiga.io/support/taiga-markdown-syntax/", target="_blank", title="{{'COMMON.WYSIWYG.MARKDOWN_HELP' | translate}}")
span.icon.icon-help
span(translate="COMMON.WYSIWYG.MARKDOWN_HELP")
input(type="button", ng-disabled!="!<%- ngmodel %>.comment.length" title="{{'COMMENTS.COMMENT' | translate}}", value="{{'COMMENTS.COMMENT' | translate}}", class="button button-green save-comment")
button(type="button", ng-disabled!="!<%- ngmodel %>.comment.length" title="{{'COMMENTS.COMMENT' | translate}}", translate="COMMENTS.COMMENT", class="button button-green save-comment")
<% } %>
section.history-activity.hidden
.changes-list

View File

@ -10,7 +10,7 @@ div.row.us-item-row(ng-repeat="us in userstories track by us.id", tg-bind-scope,
span(ng-bind="us.subject")
div.us-settings
a.icon.icon-edit(tg-check-permission="modify_us", href="",
ng-click="ctrl.editUserStory(us)", title="{{'COMMON.EDIT' | translate}}")
ng-click="ctrl.editUserStory(us.project, us.ref, $event)", title="{{'COMMON.EDIT' | translate}}")
a.icon.icon-delete(tg-check-permission="delete_us", href="",
ng-click="ctrl.deleteUserStory(us)", title="{{'COMMON.DELETE' | translate}}")

View File

@ -87,6 +87,10 @@
.task-name {
@extend %bold;
}
.loading {
bottom: .5rem;
position: absolute;
}
.icon-edit,
.icon-drag-h {
@extend %large;
@ -132,6 +136,7 @@
.task-name {
word-wrap: break-word;
}
.loading,
.icon-edit {
bottom: .2rem;
right: .5rem;

View File

@ -109,6 +109,10 @@
.icon {
transition: color .3s linear, opacity .3s linear;
}
.loading {
bottom: .5rem;
position: absolute;
}
.icon-edit,
.icon-drag-h {
@extend %large;
@ -120,7 +124,8 @@
color: $card-dark;
}
}
.icon-edit {
.icon-edit,
.loading {
right: 1rem;
}
.icon-drag-h {