Advertisement
Guest User

Untitled

a guest
Jan 18th, 2017
79
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.57 KB | None | 0 0
  1. $scope.changePassword = function(item){
  2. ngDialog.open({
  3. template: 'changePasswordModal',
  4. scope: $scope,
  5. className: 'ngdialog-theme-default',
  6. controller: ['$scope', function ($scope) {
  7. $scope.close = function(){
  8. var novaSenha = $('#newPassword').val();
  9. var confirmaNovaSenha = $('#confirmNewPassword').val();
  10. if(!novaSenha || !confirmaNovaSenha || novaSenha !== confirmaNovaSenha){
  11.  
  12. $scope.$parent.erros = [ { descricaoerro : 'Nova senha e Confirmar nova senha precisam ser iguais.' } ];
  13. ngDialog.close();
  14. return;
  15. }
  16.  
  17. var data = item;
  18. data.idUsuario = item.id;
  19. data.novaSenha = novaSenha;
  20. delete item.id;
  21.  
  22. API.User.alterarSenhaAdmin(data, function(result){
  23. item = result;
  24. // ngDialog.closeAll();
  25. Utils.openConfirmModal('Senha alterada com sucesso.', '');
  26. // Utils.showMessage({ type : 'success', message : 'Senha alterada com sucesso.' }, function(){
  27. // $state.go('app.users');
  28. // });
  29. }, function(result){
  30. var erros = result.data ? result.data.erros : [ { descricaoerro : 'Ocorreu um erro no sistema, entre em contato com o suporte técnico para correção do problema.' } ];
  31.  
  32. Utils.openConfirmModal(validaErro(erros), '');
  33. // Utils.showMessage({ type : 'error', message : validaErro(erros) });
  34. // ngDialog.closeAll();
  35. });
  36.  
  37. }
  38. }],
  39. });
  40. };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement