hashPath now tracks work._id
[angular-mojolicious.git] / templates / conference / Work.html.ep
1 <script>
2 angular.service('conference', function($resource){
3  this.Work = $resource( '/data/conference/Work/:_id', { _id:'' } );
4 }, {$inject:['$resource'],$creation:'eager'});
5
6 function WorkForm(){
7         this.master = {
8                 type: '',
9                 title: '',
10                 abstract: '',
11                 authors:[ { name:'', surname:'', inst:'', email:'' } ],
12         };
13         this.reset();
14         this.$watch('$location.hashPath', this.hash_change);
15 }
16
17 WorkForm.prototype = {
18         hash_change: function() {
19                 var id = this.$location.hashPath;
20                 if ( id ) {
21                         this.work = this.Work.get({ _id: id });
22                 }
23         },
24         reset: function() {
25                 this.work = new this.Work( this.master );
26         },
27         save: function(){
28                 var l = this.$location;
29                 this.work.$save(function(work){
30                         l.hashPath = work._id;
31                 });
32         }
33 };
34 </script>
35
36 <div ng:controller="WorkForm">
37
38 <div ng:show="work._id">
39 <a href="#{{work._id}}">permalink to this work</a>
40 </div>
41         <label>Vrsta rada:</label><br/>
42         <input type="radio" name="work.type" value="simp"> Simpozij <br/>
43         <input type="radio" name="work.type" value="pred"> Predavanje <br/>
44         <input type="radio" name="work.type" value="poster"> Poster <br/>
45         <input type="radio" name="work.type" value="round"> Okrugli stol <br/>
46
47 <div ng:repeat="author in work.authors">
48 [<a href="" ng:click="work.authors.$remove(author)">X</a>]
49 <input name="author.name" ng:required>
50 <input name="author.surname" ng:required>
51 <input name="author.inst" >
52 <input name="author.email" ng:required>
53 </div>
54 [<a href="" ng:click="work.authors.$add()">Add another author</a>]
55 <!--
56
57     <table>
58       <tr>
59         <th> </th>
60         <th>Ime</th>
61         <th>Prezime</th>
62         <th>Ustanova</th>
63         <th>email</th>
64       </tr>
65       <tr ng:repeat="author in work.authors">
66         <td>[<a href="" ng:click="work.authors.$remove(author)">X</a>]</td>
67         <td><input name="author.name" ng:required></td>
68         <td><input name="author.surname" ng:required></td>
69         <td><input name="author.inst" ></td>
70         <td><input name="author.email" ng:required></td>
71       </tr>
72       <tr>
73         <td> </td>
74         <td>[<a href="" ng:click="work.authors.$add()">Add another author</a>]</td>
75         <td> </td>
76         <td> </td>
77         <td> </td>
78       </tr>
79     </table>
80
81 -->
82
83 <hr>    
84
85
86    Naslov: <input name="work.title" size="60"><br/>
87    
88    Sazetak: <br/>
89     <textarea name="work.abstract" cols="50" rows="5"></textarea> <br/>
90     <input type="submit" value="Save" ng:click="save();" disabled="{{$invalidWidgets}}">
91     <input type="reset" value="Reset" ng:click="reset()">
92         <a href="Work">Novi rad</a>
93
94 <hr>
95 Debug Information:
96 {{$window.location.href}}
97 <pre>work = {{work}}</pre>
98 <pre>master = {{master}}</pre>
99
100 <pre>
101 $id={{$id}}
102 work.$id={{work.$id}}
103 work._id={{work._id}}
104 </pre>
105
106 </div>