From 3f5d2c7d2fe0cba785815bbe15490761c9dd3cf4 Mon Sep 17 00:00:00 2001 From: Dobrica Pavlinusic Date: Thu, 24 Jan 2013 16:02:09 +0100 Subject: [PATCH] change state of registration with div alert --- app/js/controllers.js | 17 ++++++++++++++--- app/partials/verified.html.ep | 10 ++++++++-- 2 files changed, 22 insertions(+), 5 deletions(-) diff --git a/app/js/controllers.js b/app/js/controllers.js index 8b9cf1d..c3f74b7 100644 --- a/app/js/controllers.js +++ b/app/js/controllers.js @@ -13,7 +13,9 @@ function RegistrationCtrl($scope, $log, Registration, $routeParams, $location, $ }); $scope.RegistrationState = RegistrationState; - $scope.update = function(registration, state) { + $scope.info = { message: '', css_class: '' } ; // alert box + + $scope.update = function(registration, state, info_message) { registration.state = state; @@ -23,10 +25,13 @@ function RegistrationCtrl($scope, $log, Registration, $routeParams, $location, $ } registration.$save( function(registration) { - $log.info("saved", registration); $log.info('id =', registration.id, 'state = ', registration.state); if ( registration.id && registration.state ) { - $location.path( '/' + registration.state + '/' + registration.id ); + if ( ! info_message ) { + $location.path( '/' + registration.state + '/' + registration.id ); + } else { + $scope.info = { message: info_message, css_class: 'alert-success' }; + } } else { $log.error("can't find id in ", registration); } @@ -146,6 +151,12 @@ function RegistrationCtrl($scope, $log, Registration, $routeParams, $location, $ return abstract.length <= 2000 ? abstract.length : 2000 - abstract.length; } + $scope.change_state = function(new_state) { + if ( new_state == $scope.registration.state ) return; + $scope.info = { css_class: 'alert-warning', message: 'Changed state from "'+$scope.registration.state+'" to "'+new_state+'"' }; + $scope.registration.state = new_state; + } + $scope.reset(); } RegistrationCtrl.$inject = [ '$scope', '$log', 'Registration', '$routeParams', '$location', '$route', 'Organizations', 'RegistrationState' ]; diff --git a/app/partials/verified.html.ep b/app/partials/verified.html.ep index fb0e033..77d04cd 100644 --- a/app/partials/verified.html.ep +++ b/app/partials/verified.html.ep @@ -2,6 +2,10 @@
+
+{{info.message}} +
+
<%= locale en => 'Registration', hr => 'Registracija' %> @@ -10,7 +14,7 @@ @@ -48,7 +52,9 @@
- + %= $lang =~ m/-dev/ ? '{{registration.payment}} {{registration.state}}' : '' -- 2.20.1