[sidebar] Using model-driven form instead of data-driven form
[u/erikhf/frm.git] / src / components / sidebar / sidebar.html
1 <div>
2     <div [hidden]="!active" class="form-background">
3         <form *ng-if="editmode" [(ng-form-model)]="form" (ng-submit)="onSubmit()" #of="form">
4             <h3>{{newObject?"Add new Organizational Unit":"Update Organizational Unit"}}</h3>
5
6             <div class="form-group">
7                 <label>Name</label>
8                 <input class="form-control" type="text" ng-control="name">
9
10
11             </div>
12             <div class="form-group">
13                 <label>Short Name</label>
14                 <input class="form-control" type="text" ng-control="shortName" #shortname="form">
15
16                 <p [hidden]="shortname.valid || shortname.untouched" class="alert alert-danger">
17                     Short name is required
18                 </p>
19             </div>
20
21             <div class="form-group">
22                 <label>Description</label>
23                 <textarea class="form-control" ng-control="description" rows="3"></textarea>
24             </div>
25             <div class="form-group">
26                 <label>Code</label>
27                 <input class="form-control" type="text" ng-control="code">
28             </div>
29
30             <div class="form-group">
31                 <label>Opening Date</label>
32                 <input class="form-control" type="date" ng-control="openingDate" #openingDate="form">
33
34                 <p [hidden]="openingdate.valid" class="alert alert-danger">Opening date is required</p>
35             </div>
36             <div class="form-group">
37                 <label>Closed Date</label>
38                 <input class="form-control" type="date" ng-control="closedDate">
39             </div>
40             <div class="form-group">
41                 <label>URL</label>
42                 <input class="form-control" type="url" ng-control="url" #url="form">
43
44                 <p [hidden]="url.valid" class="alert alert-danger">The specified URL is not valid</p>
45             </div>
46             <fieldset class="form-group">
47                 <Legend>Coordinates</Legend>
48                 <div class="form-group">
49                     <label>lat</label>
50                     <input class="form-control" type="number" ng-control="lat" #lat="form"/>
51                     <label>long</label>
52                     <input class="form-control" type="number" ng-control="lng" #lng="form"/>
53                 </div>
54                 <p>{{lat.valid}}</p>
55
56                 <p>{{lng.valid}}</p>
57             </fieldset>
58
59
60             <fieldset class="form-group">
61                 <legend>Contact information</legend>
62                 <label>Contact person</label>
63                 <input class="form-control" type="text" ng-control="contactPerson"/>
64                 <label>Address</label>
65                 <input class="form-control" type="text" ng-control="address"/>
66                 <label>E-mail</label>
67                 <input class="form-control" type="email" ng-control="email"/>
68                 <label>Phone number</label>
69                 <input class="form-control" type="text" ng-control="phoneNumber"/>
70             </fieldset>
71             <button type="button" (click)="cancel()" class="btn btn-default">Cancel</button>
72             <button type="submit" [disabled]="!of.form.valid" class="btn btn-default">{{newObject? "Add":"Update"}}
73             </button>
74
75         </form>
76
77
78         <section *ng-if="!editmode">
79             <label for="actOrgUnitName">Name</label>
80
81             <p id="actOrgUnitName">{{(form.controls.name.value) || "[None]"}}</p>
82
83             <label for="actOrgUnitShortName">Short Name</label>
84
85             <p id="actOrgUnitShortName">{{(form.controls.shortName.value)||["None"]}}</p>
86
87             <label for="actOrgUnitDescription">Description</label>
88
89             <p id="actOrgUnitDescription">{{(form.controls.description.value)||"None"}}</p>
90
91             <label for="actOrgUnitCode">Code</label>
92
93             <p id="actOrgUnitCode">{{(form.controls.code.value)||["None"]}}</p>
94
95             <label for="actOrgUnitOpeningDate">Opening Date</label>
96
97             <p id="actOrgUnitOpeningDate">{{form.controls.openingDate.value||["None"]}}</p>
98
99             <label for="actOrgUnitClosingDate">Closed Date</label>
100
101             <p id="actOrgUnitClosingDate">{{form.controls.closedDate.value||["None"]}}</p>
102
103             <label for="actOrgUnitURL">Url</label>
104
105             <p id="actOrgUnitURL">{{(form.controls.url.value) ||["None"]}}</p>
106
107             <button class="btn btn-default" (click)="editmode = !editmode">Edit</button>
108         </section>
109
110     </div>
111 </div>