extract Work controller
authorDobrica Pavlinusic <dpavlin@rot13.org>
Tue, 2 Nov 2010 17:35:57 +0000 (18:35 +0100)
committerDobrica Pavlinusic <dpavlin@rot13.org>
Tue, 2 Nov 2010 17:35:57 +0000 (18:35 +0100)
public/data/conference/Work.js [new file with mode: 0644]
templates/conference/Work.html.ep

diff --git a/public/data/conference/Work.js b/public/data/conference/Work.js
new file mode 100644 (file)
index 0000000..4f33038
--- /dev/null
@@ -0,0 +1,32 @@
+angular.service('conference', function($resource){
+ this.Work = $resource( '/data/conference/Work/:_id', { _id:'' } );
+}, {$inject:['$resource'],$creation:'eager'});
+
+function Work(){
+       this.master = {
+               type: '',
+               title: '',
+               abstract: '',
+               authors:[ { name:'', surname:'', inst:'', email:'' } ],
+       };
+       this.reset();
+       this.$watch('$location.hashPath', this.hash_change);
+}
+
+Work.prototype = {
+       hash_change: function() {
+               var id = this.$location.hashPath;
+               if ( id ) {
+                       this.work = this.Work.get({ _id: id });
+               }
+       },
+       reset: function() {
+               this.work = new this.Work( this.master );
+       },
+       save: function(){
+               var l = this.$location;
+               this.work.$save(function(work){
+                       l.hashPath = work._id;
+               });
+       }
+};
index 710862f..94aff86 100644 (file)
@@ -1,43 +1,11 @@
-<script>
-angular.service('conference', function($resource){
- this.Work = $resource( '/data/conference/Work/:_id', { _id:'' } );
-}, {$inject:['$resource'],$creation:'eager'});
+<script src="/data/Work.js"></script>
 
-function WorkForm(){
-       this.master = {
-               type: '',
-               title: '',
-               abstract: '',
-               authors:[ { name:'', surname:'', inst:'', email:'' } ],
-       };
-       this.reset();
-       this.$watch('$location.hashPath', this.hash_change);
-}
-
-WorkForm.prototype = {
-       hash_change: function() {
-               var id = this.$location.hashPath;
-               if ( id ) {
-                       this.work = this.Work.get({ _id: id });
-               }
-       },
-       reset: function() {
-               this.work = new this.Work( this.master );
-       },
-       save: function(){
-               var l = this.$location;
-               this.work.$save(function(work){
-                       l.hashPath = work._id;
-               });
-       }
-};
-</script>
-
-<div ng:controller="WorkForm">
+<div ng:controller="Work">
 
 <div ng:show="work._id">
-<a href="#{{work._id}}">permalink to this work</a>
+<a href="#{{work._id}}">permalink to {{work.title}}</a>
 </div>
+
        <label>Vrsta rada:</label><br/>
        <input type="radio" name="work.type" value="simp"> Simpozij <br/>
        <input type="radio" name="work.type" value="pred"> Predavanje <br/>