fix database name in view
[angular-mojolicious.git] / templates / conference / User.html.ep
1 <script>
2 angular.service('conference', function($resource){
3  this.User = $resource( '/data/conference/User/' );
4 }, {$inject:['$resource'],$creation:'eager'});
5
6 function UserForm(){
7   this.master = {
8     name: 'John Smith', 
9     address:{
10       line1: '123 Main St.', 
11       city:'Anytown', 
12       state:'AA', 
13       zip:'12345'
14     }, 
15     contacts:[
16       {type:'phone', value:'1(234) 555-1212'}
17     ]
18   };
19   this.cancel();
20 }
21
22 UserForm.prototype = {
23   cancel: function(){
24     this.form = angular.copy(this.master);
25   },
26
27   save: function(){
28         this.saved = new this.User( this.form );
29         this.saved.$save();
30         console.debug( 'saved', this.saved );
31     this.form = this.saved;
32   }
33 };
34 </script>
35 <div ng:controller="UserForm">
36
37   <label>Name:</label><br/>
38   <input type="text" name="form.name" ng:required/> <br/><br/>
39
40   <label>Address:</label><br/>
41   <input type="text" name="form.address.line1" size="33" ng:required/> <br/>
42   <input type="text" name="form.address.city" size="12" ng:required/>,
43   <input type="text" name="form.address.state" size="2" ng:required ng:validate="regexp:/^\w\w$/"/>
44   <input type="text" name="form.address.zip" size="5" ng:required ng:validate="regexp:/^\d\d\d\d\d$/"/><br/><br/>
45
46   <label>Phone:</label>
47   [ <a href="" ng:click="form.contacts.$add()">add</a> ]
48   <div ng:repeat="contact in form.contacts">
49     <select name="contact.type">
50       <option>email</option>
51       <option>phone</option>
52       <option>pager</option>
53       <option>IM</option>
54     </select>
55     <input type="text" name="contact.value" ng:required/> 
56      [ <a href="" ng:click="form.contacts.$remove(contact)">X</a> ]
57   </div>
58 <button ng:click="cancel()" disabled="{{master.$equals(form)}}">Cancel</button>
59 <button ng:click="save()" disabled="{{$invalidWidgets.visible() || master.$equals(form)}}">Save</button>
60
61 <hr/>
62 Debug View:
63 <pre>form={{form}}
64 master={{master}}</pre>
65 </div>