add Symposium
[angular-mojolicious.git] / public / controller / conference / Symposium.js
1 function Symposium($resource){
2         this.master = {
3                 type: '',
4                 title: '',
5                 abstract: '',
6                 authors:[ { name:'', surname:'', inst:'', email:'' } ],
7         };
8         this.Symposium = $resource( '/data/conference/Symposium/:_id', { _id:'' } );
9         this.reset();
10         this.$watch('$location.hashPath', this.hash_change);
11 }
12 Symposium.$inject=['$resource'];
13
14 Symposium.prototype = {
15         hash_change: function() {
16                 var id = this.$location.hashPath;
17                 if ( id ) {
18                         this.symposium = this.Symposium.get({ _id: id });
19                 }
20         },
21         reset: function() {
22                 console.debug( this.Symposium );
23                 this.symposium = new this.Symposium( this.master );
24         },
25         save: function(){
26                 var l = this.$location;
27                 this.symposium.$save(function(symposium){
28                         l.hashPath = symposium._id;
29                 });
30         }
31 };