});
$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;
}
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);
}
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' ];
<form ng-controller="RegistrationCtrl" name="RegistrationForm" class="form-horizontal">
+<div class="alert" ng-class="info.css_class" ng-show="info.message">
+{{info.message}}
+</div>
+
<fieldset>
<legend>
<%= locale en => 'Registration', hr => 'Registracija' %>
<input
type="checkbox"
ng-model="registration.verified"
- ng-change="registration.state = 'verified'"
+ ng-change="change_state('verified')"
class="my-label-input"
label="<%= locale en => 'Verified', hr => 'Provjerena' %>"
>
</fieldset>
-<button class="btn btn-primary" ng-click="update(registration, registration.state)" ng-show="RegistrationForm.$dirty">Save changes</button>
+<button class="btn btn-primary" ng-click="update(registration, registration.state, '<%= locale en => 'Registration saved', hr => 'Registracija spremljena' %>')" ng-show="RegistrationForm.$dirty">
+<%= locale en => 'Save changes', hr => 'Spremi promjene' %>
+</button>
%= $lang =~ m/-dev/ ? '{{registration.payment}} {{registration.state}}' : ''