3 if (typeof (console) === 'undefined') console = { debug: function() {} }; // mock console.debug
5 function Work($resource){
10 authors:[ { name:'', surname:'', inst:'', email:'' } ],
11 symposium: { authors: [ {name:'', surname:'', inst:'', email:'' } ], work_nr: 1, },
13 this.Work = $resource( '/data/conference/Work/:_id', { _id:'' } );
15 this.$watch('$location.hashPath', this.hash_change);
17 Work.$inject=['$resource'];
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 })
29 console.debug( this.Work );
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 )
37 this.work = new this.Work( this.master );
39 this.work.symposium = symposium;
40 this.work.type = 'symposium';
42 console.debug( 'reset', symposium, this.work, this.$location.hashPath );
43 this.$location.hashPath = '';
46 var l = this.$location;
47 this.work.$save(function(work){
48 l.hashPath = work._id;
58 <div ng:controller="Work" ng:init="$window.$root = this">
61 <input type="radio" name="work.type" value="symposium"> Simpozij
63 <div ng:show="work.type == 'symposium'" style="background:#f0f0f0">
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>
70 Tema simpozija: <input name="work.symposium.title" size="60"><br/>
73 <textarea name="work.symposium.abstract" cols="50" rows="5"></textarea> <br/>
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>
83 [<a href="" ng:click="work.symposium.authors.$add()">Add another organizer</a>]
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/>
95 <h2>Autori <span ng:show="work.type == 'symposium'">{{work.symposium.work_nr}}. </span>rada</h2>
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>
104 [<a href="" ng:click="work.authors.$add()">Add another author</a>]
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>
124 <td>[<a href="" ng:click="work.authors.$add()">Add another author</a>]</td>
136 Naslov: <input name="work.title" size="60"><br/>
139 <textarea name="work.abstract" cols="50" rows="5"></textarea> <br/>
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">
146 <b ng:show="$invalidWidgets.visible() > 0" style="color:#800">{{$invalidWidgets.visible()}} errors to fix in submission form</b>
148 <div ng:show="work._id">
149 <a href="#{{work._id}}">permalink to {{work.title}}</a>
154 {{$window.location.href}}
155 <pre>work = {{work}}</pre>
156 <pre>master = {{master}}</pre>
160 work.$id={{work.$id}}
161 work._id={{work._id}}