implement registration state
authorDobrica Pavlinusic <dpavlin@rot13.org>
Sat, 12 Jan 2013 17:31:35 +0000 (18:31 +0100)
committerDobrica Pavlinusic <dpavlin@rot13.org>
Sat, 12 Jan 2013 17:32:58 +0000 (18:32 +0100)
track drafs, each state has it's own partial template

app/js/app.js
app/js/controllers.js
app/partials/draft.html.ep [new file with mode: 0644]
app/partials/registration.html.ep
app/registration/view.html.ep

index 2533351..88eed4b 100644 (file)
@@ -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/'});
   }]);
index 919e7e0..9454ff9 100644 (file)
@@ -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 (file)
index 0000000..8a85904
--- /dev/null
@@ -0,0 +1,34 @@
+<h1> Registracija i prijavljivanje izlaganja</h1>
+
+
+<div ng-controller="RegistrationCtrl" name="RegistrationForm">
+
+<div class="alert alert-success">
+<%= 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.' %>
+</div>
+
+<div class="well">
+%= include 'registration/view'
+</div>
+
+</div>
+
+% if ( $lang =~ m/-dev/ ) {
+<pre>
+user={{user}}
+
+$routeParams={{$routeParams}}
+
+{{RegistrationForm.$valid}}
+{{RegistrationForm.$error}}
+
+location={{$location}}
+
+</pre>
+% }
+
+</div>
+
+
index 2800929..985babd 100644 (file)
@@ -241,14 +241,14 @@ hr => 'Dodaj još jedan rad na simpoziju' %>
 
 </div><!-- user.registration_type == 'symposium' -->
 
-<button class="controls-row btn btn-primary" ng-click="update(registration)" ng-show="RegistrationForm.$valid"><%= locale en=>'Submit',hr=>'Pošalji' %></button>
+<button class="controls-row btn btn-primary" ng-click="update(registration,'confirmation')" ng-show="RegistrationForm.$valid"><%= locale en=>'Submit',hr=>'Pošalji' %></button>
 
 <p class="well" style="color: red" ng-show="! RegistrationForm.$valid">
 <%= 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.'
 %>
-<button class="controls-row btn btn-info" ng-click="update(registration)" ng-show="RegistrationForm.$dirty"><%= locale en=>'Save draft',hr=>'Spremi privremeno' %></button>
+<button class="controls-row btn btn-info" ng-click="update(registration,'draft')" ng-show="RegistrationForm.$dirty"><%= locale en=>'Save draft',hr=>'Spremi privremeno' %></button>
 </p>
 
 <input style="float:right" title="validation errors" type=checkbox name=debug ng-click="debug = ! debug">
index 44c5ac5..c614d9d 100644 (file)
@@ -2,8 +2,8 @@
  <a class="btn" href="#/registration/{{registration.id}}">edit</a>
  {{registration.user.registration_type}}
  {{registration._id | registration_date_time}}
- <a class="btn" href="#/{{registration.status}}/{{registration.id}}" title="{{registration.status}}"><tt>{{registration.id}}</tt></a>
- {{registration.status}}
+ <a class="btn" href="#/{{registration.state}}/{{registration.id}}" title="{{registration.state}}" ng-show="registration.state"><tt>{{registration.id}}</tt></a>
+ {{registration.state}}
 % if ( $lang =~ m/-dev/ ) {
  <a class="btn" href="<%= $couchdb_view %>/{{registration._id}}" target="couchdb">couchdb</a>
 % }