unify form submit

stable
Juanfran 2014-11-27 13:55:14 +01:00
parent bb5eaa8633
commit 33c427b072
40 changed files with 312 additions and 221 deletions

View File

@ -30,7 +30,7 @@ MAX_MEMBERSHIP_FIELDSETS = 4
## Create Members Lightbox Directive
#############################################################################
CreateMembersDirective = ($rs, $rootScope, $confirm, lightboxService) ->
CreateMembersDirective = ($rs, $rootScope, $confirm, $loading ,lightboxService) ->
extraTextTemplate = """
<fieldset class="extra-text">
<textarea placeholder="(Optional) Add a personalized text to the invitation. Tell something lovely to your new members ;-)"></textarea>
@ -103,15 +103,19 @@ CreateMembersDirective = ($rs, $rootScope, $confirm, lightboxService) ->
$el.find(".add-member-wrapper fieldset:last > a").removeClass("icon-plus add-fieldset")
.addClass("icon-delete delete-fieldset")
$el.on "click", ".button-green", debounce 2000, (event) ->
submit = debounce 2000, (event) =>
event.preventDefault()
$loading.start(submitButton)
onSuccess = (data) ->
$loading.finish(submitButton)
lightboxService.close($el)
$confirm.notify("success")
$rootScope.$broadcast("membersform:new:success")
onError = (data) ->
$loading.finish(submitButton)
lightboxService.close($el)
$confirm.notify("error")
$rootScope.$broadcast("membersform:new:error")
@ -143,7 +147,12 @@ CreateMembersDirective = ($rs, $rootScope, $confirm, lightboxService) ->
$rs.memberships.bulkCreateMemberships($scope.project.id, invitations, invitation_extra_text).then(onSuccess, onError)
submitButton = $el.find(".submit-button")
$el.on "submit", "form", submit
$el.on "click", ".submit-button", submit
return {link: link}
module.directive("tgLbCreateMembers", ["$tgResources", "$rootScope", "$tgConfirm", "lightboxService",
module.directive("tgLbCreateMembers", ["$tgResources", "$rootScope", "$tgConfirm", "$tgLoading", "lightboxService",
CreateMembersDirective])

View File

@ -27,6 +27,7 @@ toString = @.taiga.toString
joinStr = @.taiga.joinStr
groupBy = @.taiga.groupBy
bindOnce = @.taiga.bindOnce
debounce = @.taiga.debounce
module = angular.module("taigaAdmin")
@ -95,14 +96,16 @@ module.controller("ProjectProfileController", ProjectProfileController)
ProjectProfileDirective = ($repo, $confirm, $loading, $navurls, $location) ->
link = ($scope, $el, $attrs) ->
form = $el.find("form").checksley({"onlyOneErrorElement": true})
submit = (target) =>
submit = debounce 2000, (event) =>
event.preventDefault()
return if not form.validate()
$loading.start(target)
$loading.start(submitButton)
promise = $repo.save($scope.project)
promise.then ->
$loading.finish(target)
$loading.finish(submitButton)
$confirm.notify("success")
newUrl = $navurls.resolve("project-admin-project-profile-details", {project: $scope.project.slug})
$location.path(newUrl)
@ -114,24 +117,51 @@ ProjectProfileDirective = ($repo, $confirm, $loading, $navurls, $location) ->
if data._error_message
$confirm.notify("error", data._error_message)
$el.on "submit", "form", (event) ->
event.preventDefault()
submit()
submitButton = $el.find(".submit-button");
$el.on "click", ".default-values a.button-green", (event) ->
event.preventDefault()
target = angular.element(event.currentTarget)
submit(target)
$el.on "click", ".project-details a.button-green", (event) ->
event.preventDefault()
target = angular.element(event.currentTarget)
submit(target)
$el.on "submit", "form", submit
$el.on "click", ".submit-button", submit
return {link:link}
module.directive("tgProjectProfile", ["$tgRepo", "$tgConfirm", "$tgLoading", "$tgNavUrls", "$tgLocation", ProjectProfileDirective])
#############################################################################
## Project Default Values Directive
#############################################################################
ProjectDefaultValuesDirective = ($repo, $confirm, $loading) ->
link = ($scope, $el, $attrs) ->
form = $el.find("form").checksley({"onlyOneErrorElement": true})
submit = debounce 2000, (event) =>
event.preventDefault()
return if not form.validate()
$loading.start(submitButton)
promise = $repo.save($scope.project)
promise.then ->
$loading.finish(submitButton)
$confirm.notify("success")
promise.then null, (data) ->
$loading.finish(target)
form.setErrors(data)
if data._error_message
$confirm.notify("error", data._error_message)
submitButton = $el.find(".submit-button")
$el.on "submit", "form", submit
$el.on "click", ".submit-button", submit
$scope.$on "$destroy", ->
$el.off()
return {link:link}
module.directive("tgProjectDefaultValues", ["$tgRepo", "$tgConfirm", "$tgLoading", ProjectDefaultValuesDirective])
#############################################################################
## Project Modules Directive

View File

@ -208,7 +208,7 @@ ProjectValuesDirective = ($log, $repo, $confirm, $location, animationFrame) ->
animationFrame.add () ->
goToBottomList()
$el.find(".new-value").hide()
$el.find(".new-value").addClass("hidden")
initializeNewValue()
promise.then null, (data) ->

View File

@ -23,6 +23,7 @@ taiga = @.taiga
mixOf = @.taiga.mixOf
bindMethods = @.taiga.bindMethods
debounce = @.taiga.debounce
module = angular.module("taigaAdmin")
@ -94,30 +95,28 @@ module.directive("tgSelectInputText", SelectInputText)
GithubWebhooksDirective = ($repo, $confirm, $loading) ->
link = ($scope, $el, $attrs) ->
form = $el.find("form").checksley({"onlyOneErrorElement": true})
submit = (target) =>
submit = debounce 2000, (event) =>
event.preventDefault()
return if not form.validate()
$loading.start(target)
$loading.start(submitButton)
promise = $repo.saveAttribute($scope.github, "github")
promise.then ->
$loading.finish(target)
$loading.finish(submitButton)
$confirm.notify("success")
promise.then null, (data) ->
$loading.finish(target)
$loading.finish(submitButton)
form.setErrors(data)
if data._error_message
$confirm.notify("error", data._error_message)
$el.on "click", "a.button-green", (event) ->
event.preventDefault()
target = angular.element(event.currentTarget)
submit(target)
submitButton = $el.find(".submit-button")
$el.on "submit", "form", (event) ->
event.preventDefault()
submit()
$el.on "submit", "form", submit
$el.on "click", ".submit-button", submit
return {link:link}

View File

@ -189,7 +189,9 @@ LoginDirective = ($auth, $confirm, $location, $config, $routeParams, $navUrls, $
onError = (response) ->
$confirm.notify("light-error", "According to our Oompa Loompas, your username/email
or password are incorrect.") #TODO: i18n
submit = ->
submit = debounce 2000, (event) =>
event.preventDefault()
form = new checksley.Form($el.find("form.login-form"))
if not form.validate()
return
@ -202,13 +204,8 @@ LoginDirective = ($auth, $confirm, $location, $config, $routeParams, $navUrls, $
promise = $auth.login(data)
return promise.then(onSuccess, onError)
$el.on "click", "a.button-login", (event) ->
event.preventDefault()
submit()
$el.on "submit", "form", (event) ->
event.preventDefault()
submit()
$el.on "submit", "form", submit
$el.on "click", ".submit-button", submit
return {link:link}
@ -239,20 +236,17 @@ RegisterDirective = ($auth, $confirm, $location, $navUrls, $config, $analytics)
form.setErrors(response.data)
submit = debounce 2000, =>
submit = debounce 2000, (event) =>
event.preventDefault()
if not form.validate()
return
promise = $auth.register($scope.data)
promise.then(onSuccessSubmit, onErrorSubmit)
$el.on "submit", (event) ->
event.preventDefault()
submit()
$el.on "click", "a.button-register", (event) ->
event.preventDefault()
submit()
$el.on "submit", "form", submit
$el.on "click", ".submit-button", submit
return {link:link}
@ -279,20 +273,17 @@ ForgotPasswordDirective = ($auth, $confirm, $location, $navUrls) ->
$confirm.notify("light-error", "According to our Oompa Loompas,
your are not registered yet.") #TODO: i18n
submit = debounce 2000, =>
submit = debounce 2000, (event) =>
event.preventDefault()
if not form.validate()
return
promise = $auth.forgotPassword($scope.data)
promise.then(onSuccessSubmit, onErrorSubmit)
$el.on "submit", (event) ->
event.preventDefault()
submit()
$el.on "click", "a.button-forgot", (event) ->
event.preventDefault()
submit()
$el.on "submit", "form", submit
$el.on "click", ".submit-button", submit
return {link:link}
@ -324,20 +315,17 @@ ChangePasswordFromRecoveryDirective = ($auth, $confirm, $location, $params, $nav
$confirm.notify("light-error", "One of our Oompa Loompas say
'#{response.data._error_message}'.") #TODO: i18n
submit = debounce 2000, =>
submit = debounce 2000, (event) =>
event.preventDefault()
if not form.validate()
return
promise = $auth.changePasswordFromRecovery($scope.data)
promise.then(onSuccessSubmit, onErrorSubmit)
$el.on "submit", (event) ->
event.preventDefault()
submit()
$el.on "click", "a.button-change-password", (event) ->
event.preventDefault()
submit()
$el.on "submit", "form", submit
$el.on "click", ".submit-button", submit
return {link:link}
@ -375,20 +363,17 @@ InvitationDirective = ($auth, $confirm, $location, $params, $navUrls, $analytics
$confirm.notify("light-error", "According to our Oompa Loompas, your are not registered yet or
typed an invalid password.") #TODO: i18n
submitLogin = debounce 2000, =>
submitLogin = debounce 2000, (event) =>
event.preventDefault()
if not loginForm.validate()
return
promise = $auth.acceptInvitiationWithExistingUser($scope.dataLogin)
promise.then(onSuccessSubmitLogin, onErrorSubmitLogin)
$el.on "submit", "form.login-form", (event) ->
event.preventDefault()
submitLogin()
$el.on "click", "a.button-login", (event) ->
event.preventDefault()
submitLogin()
$el.on "submit", "form.login-form", submitLogin
$el.on "click", ".button-login", submitLogin
# Register form
$scope.dataRegister = {token: token}
@ -404,20 +389,17 @@ InvitationDirective = ($auth, $confirm, $location, $params, $navUrls, $analytics
$confirm.notify("light-error", "According to our Oompa Loompas, that
username or email is already in use.") #TODO: i18n
submitRegister = debounce 2000, =>
submitRegister = debounce 2000, (event) =>
event.preventDefault()
if not registerForm.validate()
return
promise = $auth.acceptInvitiationWithNewUser($scope.dataRegister)
promise.then(onSuccessSubmitRegister, onErrorSubmitRegister)
$el.on "submit", "form.register-form", (event) ->
event.preventDefault()
submitRegister
$el.on "click", "a.button-register", (event) ->
event.preventDefault()
submitRegister()
$el.on "submit", "form.register-form", submitRegister
$el.on "click", ".button-register", submitRegister
return {link:link}
@ -483,20 +465,17 @@ CancelAccountDirective = ($repo, $model, $auth, $confirm, $location, $params, $n
$confirm.notify("error", "One of our Oompa Loompas says
'#{response.data._error_message}'.") #TODO: i18n
submit = ->
submit = debounce 2000, (event) =>
event.preventDefault()
if not form.validate()
return
promise = $auth.cancelAccount($scope.data)
promise.then(onSuccessSubmit, onErrorSubmit)
$el.on "submit", (event) ->
event.preventDefault()
submit()
$el.on "click", "a.button-cancel-account", (event) ->
event.preventDefault()
submit()
$el.on "submit", "form", submit
$el.on "click", ".submit-button", submit
return {link:link}

View File

@ -41,7 +41,9 @@ CreateEditSprint = ($repo, $confirm, $rs, $rootscope, lightboxService, $loading)
estimated_finish: null
}
submit = (event) ->
submit = debounce 2000, (event) =>
event.preventDefault()
target = angular.element(event.currentTarget)
form = $el.find("form").checksley()
@ -65,17 +67,17 @@ CreateEditSprint = ($repo, $confirm, $rs, $rootscope, lightboxService, $loading)
promise = $repo.save(newSprint)
broadcastEvent = "sprintform:edit:success"
$loading.start(target)
$loading.start(submitButton)
promise.then (data) ->
$loading.finish(target)
$loading.finish(submitButton)
$scope.sprintsCounter += 1 if createSprint
$rootscope.$broadcast(broadcastEvent, data)
lightboxService.close($el)
promise.then null, (data) ->
$loading.finish(target)
$loading.finish(submitButton)
form.setErrors(data)
if data._error_message
@ -152,9 +154,10 @@ CreateEditSprint = ($repo, $confirm, $rs, $rootscope, lightboxService, $loading)
else
$el.find(".last-sprint-name").removeClass("disappear")
$el.on "click", ".button-green", debounce 2000, (event) ->
event.preventDefault()
submit(event)
submitButton = $el.find(".submit-button")
$el.on "submit", "form", submit
$el.on "click", ".submit-button", submit
$el.on "click", ".delete-sprint .icon-delete", (event) ->
event.preventDefault()

View File

@ -285,15 +285,14 @@ CreateEditUserstoryDirective = ($repo, $model, $rs, $rootScope, lightboxService,
lightboxService.open($el)
$el.on "click", ".button-green", debounce 2000, (event) ->
submit = debounce 2000, (event) =>
event.preventDefault()
form = $el.find("form").checksley()
target = angular.element(event.currentTarget)
form = $el.find("form").checksley()
if not form.validate()
return
$loading.start(target)
$loading.start(submitButton)
if $scope.isNew
promise = $repo.create("userstories", $scope.us)
@ -303,16 +302,21 @@ CreateEditUserstoryDirective = ($repo, $model, $rs, $rootScope, lightboxService,
broadcastEvent = "usform:edit:success"
promise.then (data) ->
$loading.finish(target)
$loading.finish(submitButton)
lightboxService.close($el)
$rootScope.$broadcast(broadcastEvent, data)
promise.then null, (data) ->
$loading.finish(target)
$loading.finish(submitButton)
form.setErrors(data)
if data._error_message
$confirm.notify("error", data._error_message)
submitButton = $el.find(".submit-button")
$el.on "submit", "form", submit
$el.on "click", ".submit-button", submit
$el.on "click", ".close", (event) ->
event.preventDefault()
$scope.$apply ->
@ -356,28 +360,32 @@ CreateBulkUserstoriesDirective = ($repo, $rs, $rootscope, lightboxService, $load
}
lightboxService.open($el)
$el.on "click", ".button-green", debounce 2000, (event) ->
submit = debounce 2000, (event) =>
event.preventDefault()
target = angular.element(event.currentTarget)
form = $el.find("form").checksley({onlyOneErrorElement: true})
if not form.validate()
return
$loading.start(target)
$loading.start(submitButton)
promise = $rs.userstories.bulkCreate($scope.new.projectId, $scope.new.statusId, $scope.new.bulk)
promise.then (result) ->
$loading.finish(target)
$loading.finish(submitButton)
$rootscope.$broadcast("usform:bulk:success", result)
lightboxService.close($el)
promise.then null, (data) ->
$loading.finish(target)
$loading.finish(submitButton)
form.setErrors(data)
if data._error_message
$confirm.notify("error", data._error_message)
submitButton = $el.find(".submit-button")
$el.on "submit", "form", submit
$el.on "click", ".submit-button", submit
$scope.$on "$destroy", ->
$el.off()

View File

@ -29,29 +29,33 @@ trim = @.taiga.trim
module = angular.module("taigaFeedback", [])
FeedbackDirective = ($lightboxService, $repo, $confirm)->
FeedbackDirective = ($lightboxService, $repo, $confirm, $loading)->
link = ($scope, $el, $attrs) ->
form = $el.find("form").checksley()
submit = debounce 2000, ->
submit = debounce 2000, (event) =>
event.preventDefault()
if not form.validate()
return
$loading.start(submitButton)
promise = $repo.create("feedback", $scope.feedback)
promise.then (data) ->
$loading.finish(submitButton)
$lightboxService.close($el)
$confirm.notify("success", "\\o/ we'll be happy to read your")
promise.then null, ->
$loading.finish(submitButton)
$confirm.notify("error")
$el.on "submit", (event) ->
submit()
submitButton = $el.find(".submit-button")
$el.on "click", ".button-green", (event) ->
event.preventDefault()
submit()
$el.on "submit", "form", submit
$el.on "click", ".submit-button", submit
$scope.$on "feedback:show", ->
$scope.$apply ->
@ -65,4 +69,4 @@ FeedbackDirective = ($lightboxService, $repo, $confirm)->
return {link:link}
module.directive("tgLbFeedback", ["lightboxService", "$tgRepo", "$tgConfirm", FeedbackDirective])
module.directive("tgLbFeedback", ["lightboxService", "$tgRepo", "$tgConfirm", "$tgLoading", FeedbackDirective])

View File

@ -29,7 +29,7 @@ module = angular.module("taigaIssues")
## Issue Create Lightbox Directive
#############################################################################
CreateIssueDirective = ($repo, $confirm, $rootscope, lightboxService) ->
CreateIssueDirective = ($repo, $confirm, $rootscope, lightboxService, $loading) ->
link = ($scope, $el, $attrs) ->
form = $el.find("form").checksley()
$scope.issue = {}
@ -50,31 +50,35 @@ CreateIssueDirective = ($repo, $confirm, $rootscope, lightboxService) ->
$scope.$on "$destroy", ->
$el.off()
submit = debounce 2000, ->
submit = debounce 2000, (event) =>
event.preventDefault()
if not form.validate()
return
$loading.start(submitButton)
promise = $repo.create("issues", $scope.issue)
promise.then (data) ->
$loading.finish(submitButton)
$rootscope.$broadcast("issueform:new:success", data)
lightboxService.close($el)
$confirm.notify("success")
promise.then null, ->
$loading.finish(submitButton)
$confirm.notify("error")
$el.on "click", ".button-green", (event) ->
event.preventDefault()
submit()
$el.on "submit", "form", (event) ->
event.preventDefault()
submit()
submitButton = $el.find(".submit-button")
$el.on "submit", "form", submit
$el.on "click", ".submit-button", submit
return {link:link}
module.directive("tgLbCreateIssue", ["$tgRepo", "$tgConfirm", "$rootScope", "lightboxService",
module.directive("tgLbCreateIssue", ["$tgRepo", "$tgConfirm", "$rootScope", "lightboxService", "$tgLoading",
CreateIssueDirective])
@ -82,7 +86,7 @@ module.directive("tgLbCreateIssue", ["$tgRepo", "$tgConfirm", "$rootScope", "lig
## Issue Bulk Create Lightbox Directive
#############################################################################
CreateBulkIssuesDirective = ($repo, $rs, $confirm, $rootscope, lightboxService) ->
CreateBulkIssuesDirective = ($repo, $rs, $confirm, $rootscope, $loading, lightboxService) ->
link = ($scope, $el, attrs) ->
$scope.$on "issueform:bulk", (ctx, projectId, status)->
lightboxService.open($el)
@ -91,29 +95,38 @@ CreateBulkIssuesDirective = ($repo, $rs, $confirm, $rootscope, lightboxService)
bulk: ""
}
$el.on "click", ".button-green", debounce 2000, (event) ->
submit = debounce 2000, (event) =>
event.preventDefault()
form = $el.find("form").checksley()
if not form.validate()
return
$loading.start(submitButton)
data = $scope.new.bulk
projectId = $scope.new.projectId
promise = $rs.issues.bulkCreate(projectId, data)
promise.then (result) ->
$loading.finish(submitButton)
$rootscope.$broadcast("issueform:new:success", result)
lightboxService.close($el)
$confirm.notify("success")
promise.then null, ->
$loading.finish(submitButton)
$confirm.notify("error")
submitButton = $el.find(".submit-button")
$el.on "submit", "form", submit
$el.on "click", ".submit-button", submit
$scope.$on "$destroy", ->
$el.off()
return {link: link}
module.directive("tgLbCreateBulkIssues", ["$tgRepo", "$tgResources", "$tgConfirm", "$rootScope",
module.directive("tgLbCreateBulkIssues", ["$tgRepo", "$tgResources", "$tgConfirm", "$rootScope", "$tgLoading",
"lightboxService", CreateBulkIssuesDirective])

View File

@ -26,7 +26,7 @@ debounce = @.taiga.debounce
module = angular.module("taigaProject")
CreateProject = ($rootscope, $repo, $confirm, $location, $navurls, $rs, $projectUrl, lightboxService, $cacheFactory) ->
CreateProject = ($rootscope, $repo, $confirm, $location, $navurls, $rs, $projectUrl, $loading, lightboxService, $cacheFactory) ->
link = ($scope, $el, attrs) ->
$scope.data = {}
$scope.templates = []
@ -39,12 +39,14 @@ CreateProject = ($rootscope, $repo, $confirm, $location, $navurls, $rs, $project
# than another deleted in the same session
$cacheFactory.get('$http').removeAll()
$loading.finish(submitButton)
$rootscope.$broadcast("projects:reload")
$confirm.notify("success", "Success") #TODO: i18n
$location.url($projectUrl.get(response))
lightboxService.close($el)
onErrorSubmit = (response) ->
$loading.finish(submitButton)
form.setErrors(response)
selectors = []
for error_field in _.keys(response)
@ -54,10 +56,14 @@ CreateProject = ($rootscope, $repo, $confirm, $location, $navurls, $rs, $project
error_step.addClass("active")
$el.find('.progress-bar').removeClass().addClass('progress-bar').addClass(error_step.data("step"))
submit = ->
submit = (event) =>
event.preventDefault()
if not form.validate()
return
$loading.start(submitButton)
promise = $repo.create("projects", $scope.data)
promise.then(onSuccessSubmit, onErrorSubmit)
@ -109,10 +115,10 @@ CreateProject = ($rootscope, $repo, $confirm, $location, $navurls, $rs, $project
step = prev.data('step')
$el.find('.progress-bar').removeClass().addClass('progress-bar').addClass(step)
submitButton = $el.find(".submit-button")
$el.on "click", ".button-submit", debounce 2000, (event) ->
event.preventDefault()
submit()
$el.on "submit", "form", submit
$el.on "click", ".submit-button", submit
$el.on "click", ".close", (event) ->
event.preventDefault()
@ -121,7 +127,7 @@ CreateProject = ($rootscope, $repo, $confirm, $location, $navurls, $rs, $project
return {link:link}
module.directive("tgLbCreateProject", ["$rootScope", "$tgRepo", "$tgConfirm", "$location", "$tgNavUrls",
"$tgResources", "$projectUrl", "lightboxService", "$cacheFactory", CreateProject])
"$tgResources", "$projectUrl", "$tgLoading", "lightboxService", "$cacheFactory", CreateProject])
#############################################################################

View File

@ -26,6 +26,7 @@ bindOnce = @.taiga.bindOnce
mixOf = @.taiga.mixOf
debounceLeading = @.taiga.debounceLeading
trim = @.taiga.trim
debounce = @.taiga.debounce
module = angular.module("taigaSearch", [])
@ -111,7 +112,9 @@ SearchBoxDirective = ($lightboxService, $navurls, $location, $route)->
link = ($scope, $el, $attrs) ->
project = null
submit = ->
submit = debounce 2000, (event) =>
event.preventDefault()
form = $el.find("form").checksley()
if not form.validate()
return
@ -131,12 +134,8 @@ SearchBoxDirective = ($lightboxService, $navurls, $location, $route)->
$lightboxService.open($el)
$el.find("#search-text").val("")
$el.on "submit", (event) ->
submit()
$el.on "click", ".button-green", (event) ->
event.preventDefault()
submit()
$el.on "submit", "form", submit
$el.on "click", ".submit-button", submit
return {link:link}

View File

@ -23,7 +23,7 @@ taiga = @.taiga
bindOnce = @.taiga.bindOnce
debounce = @.taiga.debounce
CreateEditTaskDirective = ($repo, $model, $rs, $rootscope, lightboxService) ->
CreateEditTaskDirective = ($repo, $model, $rs, $rootscope, $loading, lightboxService) ->
link = ($scope, $el, attrs) ->
$scope.isNew = true
@ -53,16 +53,10 @@ CreateEditTaskDirective = ($repo, $model, $rs, $rootscope, lightboxService) ->
$el.find(".title").html("Edit task ") #TODO: i18n
lightboxService.open($el)
$el.on "click", ".button-green", debounce 2000, (event) ->
formSubmitted event
$el.on "submit", "form", debounce 2000, (event) ->
formSubmitted event
submitButton = $el.find(".submit-button")
$scope.$on "$destroy", ->
$el.off()
formSubmitted = (event) ->
submit = debounce 2000, (event) =>
event.preventDefault()
form = $el.find("form").checksley()
@ -76,29 +70,36 @@ CreateEditTaskDirective = ($repo, $model, $rs, $rootscope, lightboxService) ->
promise = $repo.save($scope.task)
broadcastEvent = "taskform:edit:success"
$loading.start(submitButton)
# FIXME: error handling?
promise.then (data) ->
$loading.finish(submitButton)
lightboxService.close($el)
$rootscope.$broadcast(broadcastEvent, data)
$el.on "submit", "form", submit
$el.on "click", ".submit-button", submit
$scope.$on "$destroy", ->
$el.off()
return {link: link}
CreateBulkTasksDirective = ($repo, $rs, $rootscope, lightboxService) ->
CreateBulkTasksDirective = ($repo, $rs, $rootscope, $loading, lightboxService) ->
link = ($scope, $el, attrs) ->
$scope.form = {data: "", usId: null}
$scope.$on "taskform:bulk", (ctx, sprintId, usId)->
lightboxService.open($el)
$scope.form = {data: "", sprintId: sprintId, usId: usId}
$el.on "click", ".button-green", debounce 2000, (event) ->
submit = debounce 2000, (event) =>
event.preventDefault()
form = $el.find("form").checksley()
if not form.validate()
return
$loading.start(submitButton)
data = $scope.form.data
projectId = $scope.projectId
sprintId = $scope.form.sprintId
@ -106,13 +107,24 @@ CreateBulkTasksDirective = ($repo, $rs, $rootscope, lightboxService) ->
promise = $rs.tasks.bulkCreate(projectId, sprintId, usId, data)
promise.then (result) ->
$loading.finish(submitButton)
$rootscope.$broadcast("taskform:bulk:success", result)
lightboxService.close($el)
# TODO: error handling
promise.then null, ->
$loading.finish(submitButton)
console.log "FAIL"
$scope.$on "taskform:bulk", (ctx, sprintId, usId)->
lightboxService.open($el)
$scope.form = {data: "", sprintId: sprintId, usId: usId}
submitButton = $el.find(".submit-button")
$el.on "submit", "form", submit
$el.on "click", ".submit-button", submit
$scope.$on "$destroy", ->
$el.off()
@ -126,6 +138,7 @@ module.directive("tgLbCreateEditTask", [
"$tgModel",
"$tgResources",
"$rootScope",
"$tgLoading",
"lightboxService",
CreateEditTaskDirective
])
@ -134,6 +147,7 @@ module.directive("tgLbCreateBulkTasks", [
"$tgRepo",
"$tgResources",
"$rootScope",
"$tgLoading",
"lightboxService",
CreateBulkTasksDirective
])

View File

@ -22,6 +22,7 @@
taiga = @.taiga
mixOf = @.taiga.mixOf
debounce = @.taiga.debounce
module = angular.module("taigaUserSettings")
@ -66,18 +67,6 @@ class UserChangePasswordController extends mixOf(taiga.Controller, taiga.PageMix
return promise.then(=> @.loadProject())
save: ->
if @scope.newPassword1 != @scope.newPassword2
@confirm.notify('error', "The passwords dosn't match")
return
promise = @rs.userSettings.changePassword(@scope.currentPassword, @scope.newPassword1)
promise.then =>
@confirm.notify('success')
promise.then null, (response) =>
@confirm.notify('error', response.data._error_message)
module.controller("UserChangePasswordController", UserChangePasswordController)
@ -85,11 +74,36 @@ module.controller("UserChangePasswordController", UserChangePasswordController)
## User ChangePassword Directive
#############################################################################
UserChangePasswordDirective = () ->
link = ($scope, $el, $attrs) ->
UserChangePasswordDirective = ($rs, $confirm, $loading) ->
link = ($scope, $el, $attrs, ctrl) ->
submit = debounce 2000, (event) =>
event.preventDefault()
if $scope.newPassword1 != $scope.newPassword2
$confirm.notify('error', "The passwords dosn't match")
return
$loading.start(submitButton)
promise = $rs.userSettings.changePassword($scope.currentPassword, $scope.newPassword1)
promise.then =>
$loading.finish(submitButton)
$confirm.notify('success')
promise.then null, (response) =>
$loading.finish(submitButton)
$confirm.notify('error', response.data._error_message)
submitButton = $el.find(".submit-button")
$el.on "submit", "form", submit
$el.on "click", ".submit-button", submit
$scope.$on "$destroy", ->
$el.off()
return {link:link}
return {
link:link
}
module.directive("tgUserChangePassword", UserChangePasswordDirective)
module.directive("tgUserChangePassword", ["$tgResources", "$tgConfirm", "$tgLoading", UserChangePasswordDirective])

View File

@ -23,7 +23,7 @@ taiga = @.taiga
mixOf = @.taiga.mixOf
sizeFormat = @.taiga.sizeFormat
module = angular.module("taigaUserSettings")
debounce = @.taiga.debounce
#############################################################################
## User settings Controller
@ -82,7 +82,9 @@ module.controller("UserSettingsController", UserSettingsController)
UserProfileDirective = ($confirm, $auth, $repo) ->
link = ($scope, $el, $attrs) ->
$el.on "click", ".user-profile form .save-profile", (event) ->
submit = debounce 2000, (event) =>
event.preventDefault()
form = $el.find("form").checksley()
return if not form.validate()
@ -103,6 +105,10 @@ UserProfileDirective = ($confirm, $auth, $repo) ->
$repo.save($scope.user).then(onSuccess, onError)
$el.on "submit", "form", submit
$el.on "click", ".submit-button", submit
$scope.$on "$destroy", ->
$el.off()

View File

@ -4,7 +4,7 @@ block head
title Taiga Your agile, free, and open source project management tool
block content
div.wrapper(tg-project-profile, ng-controller="ProjectProfileController as ctrl",
div.wrapper(tg-project-default-values, ng-controller="ProjectProfileController as ctrl",
ng-init="section='admin'; sectionName='Default values'")
sidebar.menu-secondary.sidebar(tg-admin-navigation="project-profile")
include views/modules/admin-menu

View File

@ -93,5 +93,5 @@ block content
option(value="") Select a videoconference system
input(type="text", ng-model="project.videoconferences_salt",
placeholder="If you want you can append a salt code to the name of the chat room")
input(type="submit", class="hidden")
a.button.button-green(href="") Save
button(type="submit", class="hidden")
a.button.button-green.submit-button(href="", title="Save") Save

View File

@ -54,8 +54,8 @@ block content
p All projects are private during Taiga's beta period.
input(type="submit", class="hidden")
a.button.button-green(href="") Save
button(type="submit", class="hidden")
a.button.button-green.submit-button(href="", title="Save") Save
a.delete-project(href="", title="Delete this project", ng-click="ctrl.openDeleteLightbox()") Delete this project
div.lightbox.lightbox-delete-project(tg-lb-delete-project)

View File

@ -27,8 +27,8 @@ block content
.icon.icon-copy
.help-copy Copy to clipboard: Ctrl+C
input(type="submit", class="hidden")
a.button.button-green(href="") Save
button(type="submit", class="hidden")
a.button.button-green.submit-button(href="", title="Save") Save
.help

View File

@ -25,5 +25,5 @@ block content
label(for="retype-password") Retype Password
input(type="password", placeholder="Retype Password", id="retype-password", ng-model="newPassword2")
fieldset
input(type="submit", class="hidden")
a.button.button-green(href="", ng-click="ctrl.save()") Save
button(type="submit", class="hidden")
a.button.button-green.submit-button(href="", title="Save") Save

View File

@ -55,8 +55,8 @@ block content
ng-model="user.bio")
fieldset.submit
input(type="submit", class="hidden")
a.button.button-green.save-profile(href="") Save
button(type="submit", title="Save", class="hidden")
a.button.button-green.save-profile.submit-button(href="") Save
a.delete-account(href="", title="Delete Taiga account",
ng-click="ctrl.openDeleteLightbox()") Delete Taiga account

View File

@ -36,5 +36,5 @@ section.default-values
ng-options="s.id as s.name for s in issueStatusList")
fieldset
input(type="submit", class="hidden")
a.button.button-green(href="", title="Save") Save
button(type="submit", class="hidden")
a.button.button-green.submit-button(href="", title="Save") Save

View File

@ -3,10 +3,10 @@ div.change-email-form-container(tg-cancel-account)
strong Cancel your account <br />
span We're sorry you are leaving the taiga, we hope you enjoyed your stay :)
form(ng-submit="ctrl.submit()")
form
fieldset
input(type="hidden", name="cancel_token", ng-model="data.cancel_token", data-required="true",
placeholder="cancel account token")
a.button.button-cancel-account.button-gray(href="", title="Yes, I'm leaving") Yes, I'm leaving!
input(type="submit", style="display:none")
button(type="submit", class="hidden")

View File

@ -3,10 +3,10 @@ div.change-email-form-container(tg-change-email)
strong Change your email <br />
span One click more and your email will be updated!
form(ng-submit="ctrl.submit()")
form
fieldset
input(type="hidden", name="email_token", ng-model="data.email_token", data-required="true",
placeholder="change email token")
a.button.button-change-email.button-gray(href="", title="Change email") Change email
input(type="submit", style="display:none")
button(type="submit", class="hidden")

View File

@ -3,7 +3,7 @@ div.change-password-form-container(tg-change-password-from-recovery)
strong Create a new Taiga pass <br />
span And hey, you may want to eat some more iron-rich food, it's good for your brain :P
form(ng-submit="ctrl.submit()")
form
fieldset.token-change-password(ng-hide="tokenInParams")
input(type="text", name="token", ng-model="data.token", data-required="true",
placeholder="Recover password token")
@ -16,5 +16,5 @@ div.change-password-form-container(tg-change-password-from-recovery)
input(type="password", name="password2", id="password2", ng-model="data.password2",
data-required="true", data-equalto="#password", placeholder="Re-type new password")
fieldset
a.button.button-change-password.button-gray(href="", title="Reset Password") Reset Password
input(type="submit", style="display:none")
a.button.button-change-password.button-gray.submit-button(href="", title="Reset Password") Reset Password
button(type="submit", class="hidden")

View File

@ -10,7 +10,7 @@ div.forgot-form-container(tg-forgot-password)
input(type="text", name="username", ng-model="data.username", data-required="true",
placeholder="Username or email")
fieldset
a.button.button-forgot.button-gray(href="", title="Reset Password") Reset Password
input(type="submit", style="display:none")
button(type="submit", class="hidden")
a.button.button-gray.submit-button.button-forgot(href="", title="Reset Password") Reset Password
a(href="", title="Login", tg-nav="login") Nah, take me back. I think I remember it.

View File

@ -8,7 +8,7 @@ form.login-form
placeholder="Password")
a.forgot-pass(href="", tg-nav="forgot-password", title="Did you forgot your password?") Forgot it?
fieldset
a.button.button-login.button-gray(href="", title="Log in") Enter
input(type="submit", style="display:none")
a.button.button-login.button-gray.submit-button(href="", title="Log in") Enter
button(type="submit", class="hidden")
fieldset(tg-github-login-button)

View File

@ -20,7 +20,7 @@ form.register-form
placeholder="Set a password")
fieldset
a.button.button-register.button-gray(href="", title="Sign up") Sign up
input(type="submit", style="display:none")
button(type="submit", class="hidden")
a.button.button-register.button-gray.submit-button(href="", title="Sign up") Sign up
tg-terms-notice

View File

@ -6,7 +6,9 @@ form
//- Form is set in a directive
.add-member-forms
a.button.button-green(href="", title="Save")
span Create
button(type="submit", class="hidden")
a.button.button-green.submit-button(href="", title="Create")
span Create
p.help-text If users are already registered on Taiga, they will be added automatically. Otherwise they will receive an invitation.

View File

@ -20,6 +20,6 @@ form
textarea.description(placeholder="Description", ng-model="issue.description")
// include lightbox-attachments
input(type="submit", style="display:none")
a.button.button-green(href="", title="Save")
button(type="submit", class="hidden")
a.button.button-green.submit-button(href="", title="Save")
span Create

View File

@ -6,6 +6,6 @@ form
textarea(ng-model="feedback.comment", data-required="true",
placeholder="...a bug, some suggestions, something cool... or even your worst nightmare with Taiga")
fieldset
input.hidden(type="submit")
a.button.button-green(href="", title="Send feedback")
button(type="submit", class="hidden")
a.button.button-green.submit-button(href="", title="Send feedback")
span Send feedback

View File

@ -4,5 +4,6 @@ form
h2.title(tr="common.new-bulk")
fieldset
textarea(cols="200", wrap="off", tg-limit-line-length, tr="placeholder:common.one-item-line", ng-model="new.bulk", data-required="true", data-linewidth="200")
a.button.button-green(href="", tr="title:common.save")
span(tr="common.save")
button(type="submit", class="hidden")
a.button.button-green.submit-button(href="", title="Save") Save

View File

@ -5,6 +5,5 @@ form
fieldset
input(type="text", name="text", id="search-text", placeholder="What are you looking for?", data-required="true")
fieldset
input.hidden(type="submit")
a.button.button-green(href="", title="Accept")
span Search
button(type="submit", class="hidden")
a.button.button-green.submit-button(href="", title="Search") Search

View File

@ -15,7 +15,8 @@ form
input.date-end(type="text", name="estimated_finish", placeholder="Estimated End",
ng-model="sprint.estimated_finish", data-required="true", tg-date-selector)
a.button.button-green(href="", title="Save")
button(type="submit", class="hidden")
a.button.button-green.submit-button(href="", title="Create")
span Create
div(tg-check-permission="delete_milestone")

View File

@ -4,5 +4,6 @@ form
h2.title(tr="common.new-bulk")
fieldset
textarea(cols="200", wrap="off", tg-limit-line-length, tr="placeholder:common.one-item-line", ng-model="form.data", data-required="true")
a.button.button-green(href="", tr="title:common.save")
span(tr="common.save")
button(type="submit", class="hidden")
a.button.button-green.submit-button(href="", title="Save") Save

View File

@ -34,6 +34,6 @@ form
tg-blocking-message-input(watch="task.is_blocked", ng-model="task.blocked_note")
button(title="Save" style="display: none;")
a.button.button-green(href="", title="Save")
button(type="submit", class="hidden")
a.button.button-green.submit-button(href="", title="Save")
span Create

View File

@ -4,5 +4,6 @@ form
h2.title(tr="common.new-bulk")
fieldset
textarea(cols="200", wrap="off", tg-limit-line-length, tr="placeholder:common.one-item-line", ng-model="new.bulk", data-required="true", data-linewidth="200")
a.button.button-green(href="", tr="title:common.save")
span(tr="common.save")
button(type="submit", class="hidden")
a.button.button-green.submit-button(href="", title="Save") Save

View File

@ -36,5 +36,5 @@ form
tg-blocking-message-input(watch="us.is_blocked", ng-model="us.blocked_note")
a.button.button-green(href="", title="Save")
span Create
button(type="submit", class="hidden")
a.button.button-green.submit-button(href="", title="Submit") Create

View File

@ -10,8 +10,8 @@ div.login-form-container(tg-login)
a.forgot-pass(href="", tg-nav="forgot-password", title="Did you forgot your password?") Forgot it?
fieldset
a.button.button-login.button-gray(href="", title="Sign in") Sign in
input(type="submit", style="display:none")
button(type="submit", class="hidden")
a.button.button-login.button-gray.submit-button(href="", title="Sign in") Sign in
fieldset(tg-github-login-button)

View File

@ -21,8 +21,8 @@ div.register-form-container(tg-register)
placeholder="Set a password (case sensitive)")
fieldset
a.button.button-register.button-gray(href="", title="Sign up") Sign up
input(type="submit", class="hidden")
button(type="submit", class="hidden")
a.button.button-register.button-gray.submit-button(href="", title="Sign up") Sign up
fieldset(tg-github-login-button)

View File

@ -28,7 +28,9 @@ form
fieldset.wizard-action
div
a.button-prev.button.button-gray(href="", title="Prev") Prev
a.button-submit.button.button-green(href="", title="Create") Create
a.submit-button.button.button-green(href="", title="Create") Create
button(type="submit", class="hidden")
div.progress-bar
div.progress-state