Minor fixes: clean code
parent
98fd32e3b4
commit
5f68c09533
|
@ -78,13 +78,13 @@ class UserChangePasswordController extends mixOf(taiga.Controller, taiga.PageMix
|
||||||
|
|
||||||
module.controller("UserChangePasswordController", UserChangePasswordController)
|
module.controller("UserChangePasswordController", UserChangePasswordController)
|
||||||
|
|
||||||
|
|
||||||
#############################################################################
|
#############################################################################
|
||||||
## User ChangePassword Directive
|
## User ChangePassword Directive
|
||||||
#############################################################################
|
#############################################################################
|
||||||
|
|
||||||
UserChangePasswordDirective = () ->
|
UserChangePasswordDirective = () ->
|
||||||
link = ($scope, $el, $attrs) ->
|
link = ($scope, $el, $attrs) ->
|
||||||
|
|
||||||
$scope.$on "$destroy", ->
|
$scope.$on "$destroy", ->
|
||||||
$el.off()
|
$el.off()
|
||||||
|
|
||||||
|
|
|
@ -20,9 +20,7 @@
|
||||||
###
|
###
|
||||||
|
|
||||||
taiga = @.taiga
|
taiga = @.taiga
|
||||||
|
|
||||||
mixOf = @.taiga.mixOf
|
mixOf = @.taiga.mixOf
|
||||||
|
|
||||||
module = angular.module("taigaUserSettings")
|
module = angular.module("taigaUserSettings")
|
||||||
|
|
||||||
|
|
||||||
|
@ -66,7 +64,6 @@ class UserSettingsController extends mixOf(taiga.Controller, taiga.PageMixin)
|
||||||
return promise.then(=> @.loadProject())
|
return promise.then(=> @.loadProject())
|
||||||
|
|
||||||
saveUserProfile: ->
|
saveUserProfile: ->
|
||||||
|
|
||||||
updatingEmail = @scope.user.isAttributeModified("email")
|
updatingEmail = @scope.user.isAttributeModified("email")
|
||||||
promise = @repo.save(@scope.user)
|
promise = @repo.save(@scope.user)
|
||||||
promise.then =>
|
promise.then =>
|
||||||
|
@ -75,7 +72,6 @@ class UserSettingsController extends mixOf(taiga.Controller, taiga.PageMixin)
|
||||||
@confirm.success("<strong>Check your inbox!</strong><br />
|
@confirm.success("<strong>Check your inbox!</strong><br />
|
||||||
We have sent a mail to your account<br />
|
We have sent a mail to your account<br />
|
||||||
with the instructions to set your new address") #TODO: i18n
|
with the instructions to set your new address") #TODO: i18n
|
||||||
|
|
||||||
else
|
else
|
||||||
@confirm.notify('success')
|
@confirm.notify('success')
|
||||||
|
|
||||||
|
@ -86,9 +82,9 @@ class UserSettingsController extends mixOf(taiga.Controller, taiga.PageMixin)
|
||||||
openDeleteLightbox: ->
|
openDeleteLightbox: ->
|
||||||
@rootscope.$broadcast("deletelightbox:new", @scope.user)
|
@rootscope.$broadcast("deletelightbox:new", @scope.user)
|
||||||
|
|
||||||
|
|
||||||
module.controller("UserSettingsController", UserSettingsController)
|
module.controller("UserSettingsController", UserSettingsController)
|
||||||
|
|
||||||
|
|
||||||
#############################################################################
|
#############################################################################
|
||||||
## User Profile Directive
|
## User Profile Directive
|
||||||
#############################################################################
|
#############################################################################
|
||||||
|
@ -117,10 +113,6 @@ module.directive("tgUserProfile", UserProfileDirective)
|
||||||
|
|
||||||
UserAvatarDirective = ($auth, $model, $rs, $confirm) ->
|
UserAvatarDirective = ($auth, $model, $rs, $confirm) ->
|
||||||
link = ($scope, $el, $attrs) ->
|
link = ($scope, $el, $attrs) ->
|
||||||
|
|
||||||
$scope.$on "$destroy", ->
|
|
||||||
$el.off()
|
|
||||||
|
|
||||||
$el.on "click", ".button.change", ->
|
$el.on "click", ".button.change", ->
|
||||||
$el.find("#avatar-field").click()
|
$el.find("#avatar-field").click()
|
||||||
|
|
||||||
|
@ -128,22 +120,28 @@ UserAvatarDirective = ($auth, $model, $rs, $confirm) ->
|
||||||
target = angular.element(event.currentTarget)
|
target = angular.element(event.currentTarget)
|
||||||
|
|
||||||
promise = $rs.userSettings.changeAvatar($scope.avatarAttachment)
|
promise = $rs.userSettings.changeAvatar($scope.avatarAttachment)
|
||||||
$el.find('.overlay').show();
|
$el.find('.overlay').show()
|
||||||
|
|
||||||
promise.then (response) ->
|
promise.then (response) ->
|
||||||
user = $model.make_model("users", response.data)
|
user = $model.make_model("users", response.data)
|
||||||
$auth.setUser(user)
|
$auth.setUser(user)
|
||||||
$scope.user = user
|
$scope.user = user
|
||||||
$el.find('.overlay').hide();
|
|
||||||
|
$el.find('.overlay').hide()
|
||||||
$confirm.notify('success')
|
$confirm.notify('success')
|
||||||
|
|
||||||
promise.then null, (response) ->
|
promise.then null, (response) ->
|
||||||
console.log response
|
$el.find('.overlay').hide()
|
||||||
$el.find('.overlay').hide();
|
|
||||||
$confirm.notify('error', response.data._error_message)
|
$confirm.notify('error', response.data._error_message)
|
||||||
|
|
||||||
|
$scope.$on "$destroy", ->
|
||||||
|
$el.off()
|
||||||
|
|
||||||
return {link:link}
|
return {link:link}
|
||||||
|
|
||||||
module.directive("tgUserAvatar", ["$tgAuth", "$tgModel", "$tgResources", "$tgConfirm", UserAvatarDirective])
|
module.directive("tgUserAvatar", ["$tgAuth", "$tgModel", "$tgResources", "$tgConfirm", UserAvatarDirective])
|
||||||
|
|
||||||
|
|
||||||
#############################################################################
|
#############################################################################
|
||||||
## User Avatar Model Directive
|
## User Avatar Model Directive
|
||||||
#############################################################################
|
#############################################################################
|
||||||
|
|
Loading…
Reference in New Issue