count number of works within symposium
[angular-mojolicious.git] / templates / conference / Work.html.ep
1 <script>
2
3 if (typeof (console) === 'undefined') console = { debug: function() {} }; // mock console.debug
4
5 function Work($resource){
6         this.master = {
7                 type: '',
8                 title: '',
9                 abstract: '',
10                 authors:[ { name:'', surname:'', inst:'', email:'' } ],
11                 symposium: { authors: [ {name:'', surname:'', inst:'', email:'' } ], work_nr: 1, },
12         };
13         this.Work = $resource( '/data/conference/Work/:_id', { _id:'' } );
14         this.reset();
15         this.$watch('$location.hashPath', this.hash_change);
16 }
17 Work.$inject=['$resource'];
18
19 Work.prototype = {
20         hash_change: function() {
21                 var id = this.$location.hashPath;
22 console.debug( 'hash_change', id, this.work._id );
23                 if ( id != this.work._id ) {
24                         if (id) this.work = this.Work.get({ _id: id })
25                         else this.reset();
26                 }
27         },
28         reset: function() {
29                 console.debug( this.Work );
30                 var symposium = null;
31                 if ( this.work && this.work.type == 'symposium' ) {
32                         symposium = this.work.symposium;
33                         if ( this.work._id ) symposium.work_nr++;
34                         // if is required because reset is called twice -- once with saved records and once with new empty one
35 console.debug( 'symposium', symposium, this.work )
36                 }
37                 this.work = new this.Work( this.master );
38                 if ( symposium ) {
39                         this.work.symposium = symposium;
40                         this.work.type = 'symposium';
41                 }
42 console.debug( 'reset', symposium, this.work, this.$location.hashPath );
43                 this.$location.hashPath = '';
44         },
45         save: function(){
46                 var l = this.$location;
47                 this.work.$save(function(work){
48                         l.hashPath = work._id;
49                 });
50         }
51 };
52
53
54 </script>
55
56 <h1>Prijava rada</h1>
57
58 <div ng:controller="Work" ng:init="$window.$root = this">
59
60 <h2>Vrsta rada:</h2>
61 <input type="radio" name="work.type" value="symposium"> Simpozij
62
63 <div ng:show="work.type == 'symposium'" style="background:#f0f0f0">
64 <!--
65 <select name="work.symposium_id" ng:show="work.type == 'symposium'" ng:controller="Symposium">
66 <option ng:repeat="s in symposiums" value="{{s._id}}">{{s.title}}</option>
67 </select>
68 -->
69
70 Tema simpozija: <input name="work.symposium.title" size="60"><br/>
71    
72 Sažetak: <br/>
73 <textarea name="work.symposium.abstract" cols="50" rows="5"></textarea> <br/>
74
75 Organizator:
76 <div ng:repeat="author in work.symposium.authors">
77 [<a href="" ng:click="work.symposium.authors.$remove(author)">X</a>]
78 <input name="author.name" ng:required>
79 <input name="author.surname" ng:required>
80 <input name="author.inst" >
81 <input name="author.email" ng:required>
82 </div>
83 [<a href="" ng:click="work.symposium.authors.$add()">Add another organizer</a>]
84
85 </div>
86
87 <br/>
88
89         <input type="radio" name="work.type" value="lecture"> Predavanje <br/>
90         <input type="radio" name="work.type" value="poster"> Poster <br/>
91         <input type="radio" name="work.type" value="round"> Okrugli stol <br/>
92
93 <hr>
94
95 <h2>Autori <span ng:show="work.type == 'symposium'">{{work.symposium.work_nr}}. </span>rada</h2>
96
97 <div ng:repeat="author in work.authors">
98 [<a href="" ng:click="work.authors.$remove(author)">X</a>]
99 <input name="author.name" ng:required>
100 <input name="author.surname" ng:required>
101 <input name="author.inst" >
102 <input name="author.email" ng:required>
103 </div>
104 [<a href="" ng:click="work.authors.$add()">Add another author</a>]
105 <!--
106
107     <table>
108       <tr>
109         <th> </th>
110         <th>Ime</th>
111         <th>Prezime</th>
112         <th>Ustanova</th>
113         <th>email</th>
114       </tr>
115       <tr ng:repeat="author in work.authors">
116         <td>[<a href="" ng:click="work.authors.$remove(author)">X</a>]</td>
117         <td><input name="author.name" ng:required></td>
118         <td><input name="author.surname" ng:required></td>
119         <td><input name="author.inst" ></td>
120         <td><input name="author.email" ng:required></td>
121       </tr>
122       <tr>
123         <td> </td>
124         <td>[<a href="" ng:click="work.authors.$add()">Add another author</a>]</td>
125         <td> </td>
126         <td> </td>
127         <td> </td>
128       </tr>
129     </table>
130
131 -->
132
133 <hr>    
134
135
136    Naslov: <input name="work.title" size="60"><br/>
137
138    Sazetak: <br/>
139     <textarea name="work.abstract" cols="50" rows="5"></textarea> <br/>
140
141         <span ng:show="$invalidWidgets.visible() == 0">
142     <input type="submit" value="Save" ng:click="work.symposium_id=symposium._id; save();">
143     <input type="reset" value="Novi rad" ng:click="reset()" ng:show="work && work._id">
144         </span>
145
146         <b ng:show="$invalidWidgets.visible() &gt; 0" style="color:#800">{{$invalidWidgets.visible()}} errors to fix in submission form</b>
147
148         <div ng:show="work._id">
149         <a href="#{{work._id}}">permalink to {{work.title}}</a>
150         </div>
151
152 <hr>
153 Debug Information:
154 {{$window.location.href}}
155 <pre>work = {{work}}</pre>
156 <pre>master = {{master}}</pre>
157
158 <pre>
159 $id={{$id}}
160 work.$id={{work.$id}}
161 work._id={{work._id}}
162 </pre>
163
164 </div>