From fa2a64e09da2f2844e8e54e60fe951b6c558818f Mon Sep 17 00:00:00 2001 From: Dobrica Pavlinusic Date: Sat, 12 Jan 2013 18:31:35 +0100 Subject: [PATCH] implement registration state track drafs, each state has it's own partial template --- app/js/app.js | 2 +- app/js/controllers.js | 10 +++++---- app/partials/draft.html.ep | 34 +++++++++++++++++++++++++++++++ app/partials/registration.html.ep | 4 ++-- app/registration/view.html.ep | 4 ++-- 5 files changed, 45 insertions(+), 9 deletions(-) create mode 100644 app/partials/draft.html.ep diff --git a/app/js/app.js b/app/js/app.js index 2533351..88eed4b 100644 --- a/app/js/app.js +++ b/app/js/app.js @@ -6,7 +6,7 @@ angular.module('myApp', ['myApp.filters', 'myApp.services', 'myApp.directives' ] config(['$routeProvider', function($routeProvider) { $routeProvider.when('/registration/:registrationId', {templateUrl: 'partials/registration.html', controller: RegistrationCtrl}); $routeProvider.when('/confirmation/:registrationId', {templateUrl: 'partials/confirmation.html', controller: RegistrationCtrl}); + $routeProvider.when('/draft/:registrationId', {templateUrl: 'partials/draft.html', controller: RegistrationCtrl}); $routeProvider.when('/list', {templateUrl: 'partials/list.html', controller: ListCtrl}); - $routeProvider.when('/view2', {templateUrl: 'partials/partial2.html', controller: MyCtrl2}); $routeProvider.otherwise({redirectTo: '/registration/'}); }]); diff --git a/app/js/controllers.js b/app/js/controllers.js index 919e7e0..9454ff9 100644 --- a/app/js/controllers.js +++ b/app/js/controllers.js @@ -9,7 +9,9 @@ function RegistrationCtrl($scope, $log, Registration, $routeParams, $location, $ $scope.$location = $location; $scope.organizations = []; - $scope.update = function(registration) { + $scope.update = function(registration, state) { + + registration.state = state; if ( ! $scope.has_work && registration.work ) { delete( registration.work ); @@ -18,9 +20,9 @@ function RegistrationCtrl($scope, $log, Registration, $routeParams, $location, $ registration.$save( function(registration) { $log.info("saved", registration); - $log.info('id =', registration.id); - if ( registration.id ) { - $location.path( '/confirmation/' + registration.id ); + $log.info('id =', registration.id, 'state = ', registration.state); + if ( registration.id && registration.state ) { + $location.path( '/' + registration.state + '/' + registration.id ); } else { $log.error("can't find id in ", registration); } diff --git a/app/partials/draft.html.ep b/app/partials/draft.html.ep new file mode 100644 index 0000000..8a85904 --- /dev/null +++ b/app/partials/draft.html.ep @@ -0,0 +1,34 @@ +

Registracija i prijavljivanje izlaganja

+ + +
+ +
+<%= locale +en => 'Your draft of registration is saved. Bookmark this page to access it later.', +hr => 'Registracija privremeno spremljena. Dodajte stranicu u bookmark da bi je mogli kasnije mijenjati.' %> +
+ +
+%= include 'registration/view' +
+ +
+ +% if ( $lang =~ m/-dev/ ) { +
+user={{user}}
+
+$routeParams={{$routeParams}}
+
+{{RegistrationForm.$valid}}
+{{RegistrationForm.$error}}
+
+location={{$location}}
+
+
+% } + + + + diff --git a/app/partials/registration.html.ep b/app/partials/registration.html.ep index 2800929..985babd 100644 --- a/app/partials/registration.html.ep +++ b/app/partials/registration.html.ep @@ -241,14 +241,14 @@ hr => 'Dodaj još jedan rad na simpoziju' %> - +

<%= locale en => 'Please fill all required fields correctly. Fields with red border call for your attention.', hr => 'Molimo ispunite sva obavezna polja označena crvenim okvirom.' %> - +

diff --git a/app/registration/view.html.ep b/app/registration/view.html.ep index 44c5ac5..c614d9d 100644 --- a/app/registration/view.html.ep +++ b/app/registration/view.html.ep @@ -2,8 +2,8 @@ edit {{registration.user.registration_type}} {{registration._id | registration_date_time}} - {{registration.id}} - {{registration.status}} + {{registration.id}} + {{registration.state}} % if ( $lang =~ m/-dev/ ) { couchdb % } -- 2.20.1