simple Symposium CRUD
authorDobrica Pavlinusic <dpavlin@rot13.org>
Sun, 7 Nov 2010 22:14:05 +0000 (23:14 +0100)
committerDobrica Pavlinusic <dpavlin@rot13.org>
Sun, 7 Nov 2010 22:14:05 +0000 (23:14 +0100)
templates/conference/Symposium.html.ep

index b51a39b..2c35f0f 100644 (file)
@@ -1,7 +1,57 @@
-<script src="/controller/conference/Symposium.js"></script>
+<script>
+
+function Symposium($resource){
+       this.master = {
+               type: '',
+               title: '',
+               abstract: '',
+               authors:[ { name:'', surname:'', inst:'', email:'' } ],
+       };
+       this.Symposium = $resource( '/data/conference/Symposium/:id', { id:'' } );
+       this.reset();
+       this.$watch('$location.hashPath', this.hash_change);
+}
+Symposium.$inject=['$resource'];
+
+Symposium.prototype = {
+       hash_change: function() {
+               var id = this.$location.hashPath;
+               if ( id ) {
+                       this.symposium = this.Symposium.get({ id: id });
+               }
+       },
+       reset: function() {
+               console.debug( this.Symposium );
+               this.symposium = new this.Symposium( this.master );
+       },
+       save: function(){
+               var l = this.$location;
+               this.symposium.$save(function(symposium){
+                       l.hashPath = symposium.$id;
+               });
+       },
+       $all: function() {
+               if ( this.all ) return this.all;
+               this.all = this.Symposium.query();
+               console.log('$all', this.all);
+               return this.all;
+       },
+};
+
+</script>
 
 <div ng:controller="Symposium">
 
+<input type=checkbox name=debug>
+
+<ul>
+<li ng:repeat="s in $all()">
+<a href="#{{s.$id}}">{{s.title}}</a>
+<br><small>{{s.abstract}}</small>
+<pre ng:show="debug">{{s}}</pre>
+</li>
+</ul>
+
 <h1>Prijava simpozija</h1>
 
 <div ng:show="symposium._id">