@@ -42,46 +42,81 @@ <h1>Java EE - Angular Application</h1>
4242
4343< br >
4444
45- < div class ="grid ">
46- <!-- Specify a JavaScript controller script that binds Javascript variables to the HTML.-->
47- < div ng-controller ="personsListController ">
48- <!-- Binds the grid component to be displayed. -->
49- < div class ="gridStyle " ng-grid ="gridOptions "> </ div >
50-
51- <!-- Bind the pagination component to be displayed. -->
52- < pagination direction-links ="true " boundary-links ="true "
53- total-items ="persons.totalResults " items-per-page ="persons.pageSize "
54- ng-model ="persons.currentPage " ng-change ="refreshGrid() ">
55- </ pagination >
45+ <!-- Specify a JavaScript controller script that binds Javascript variables to the HTML.-->
46+ < div class ="grid " ng-controller ="personsListController ">
47+ < div >
48+ < h3 > List Persons</ h3 >
5649 </ div >
50+
51+ <!-- Binds the grid component to be displayed. -->
52+ < div class ="gridStyle " ng-grid ="gridOptions "> </ div >
53+
54+ <!-- Bind the pagination component to be displayed. -->
55+ < pagination direction-links ="true " boundary-links ="true "
56+ total-items ="persons.totalResults " items-per-page ="persons.pageSize "
57+ ng-model ="persons.currentPage " ng-change ="refreshGrid() ">
58+ </ pagination >
5759</ div >
5860
59- < div class ="form ">
61+
62+
63+ < div class ="form " ng-controller ="personsFormController ">
64+ < div ng-if ="person.id == null ">
65+ < h3 > Add Person</ h3 >
66+ </ div >
67+
68+ < div ng-if ="person.id != null ">
69+ < h3 > Edit Person</ h3 >
70+ </ div >
71+
6072 < div >
61- < form name ="personForm " ng-controller ="personsFormController " ng-submit ="updatePerson() ">
62- < div class ="form-group ">
73+ < form name ="personForm " ng-submit ="updatePerson() " novalidate >
74+
75+ < div class ="form-group " ng-class ="{'has-error' : personForm.name.$invalid && personForm.name.$dirty} ">
6376 < label for ="name "> Name:</ label >
64- < input id ="name " name ="name " type ="text " class ="form-control " ng-model ="person.name " required />
77+ < span ng-class ="{'glyphicon glyphicon-ok' : personForm.name.$valid && personForm.name.$dirty} "> </ span >
78+
79+ < input id ="name " name ="name " type ="text " class ="form-control " maxlength ="50 "
80+ ng-model ="person.name "
81+ required ng-minlength ="2 " ng-maxlength ="50 "/>
82+
83+ < p class ="help-block " ng-show ="personForm.name.$error.required "> Add Name.</ p >
84+ < p class ="help-block " ng-show ="personForm.name.$error.minlength "> Name must be at least 2 characters long.</ p >
85+ < p class ="help-block " ng-show ="personForm.name.$error.maxlength "> Name cannot be longer than 50 characters.</ p >
6586 </ div >
6687
67- < div class ="form-group ">
88+ < div class ="form-group " ng-class =" {'has-error' : personForm.description.$invalid && personForm.description.$dirty} " >
6889 < label for ="description "> Description:</ label >
69- < input id ="description " name ="description " type ="text " class ="form-control " ng-model ="person.description "/>
90+ < span ng-class ="{'glyphicon glyphicon-ok' : personForm.description.$valid && personForm.description.$dirty} "> </ span >
91+
92+ < input id ="description " name ="description " type ="text " class ="form-control " maxlength ="100 "
93+ ng-model ="person.description "
94+ required ng-minlength ="5 " ng-maxlength ="100 "/>
95+
96+ < p class ="help-block " ng-show ="personForm.description.$error.required "> Add Description.</ p >
97+ < p class ="help-block " ng-show ="personForm.description.$error.minlength "> Description must be at least 5 characters long.</ p >
98+ < p class ="help-block " ng-show ="personForm.description.$error.maxlength "> Description cannot be longer than 100 characters.</ p >
7099 </ div >
71100
72- < div class ="form-group ">
101+ < div class ="form-group " ng-class =" {'has-error' : personForm.link.$invalid && personForm.link.$dirty} " >
73102 < label for ="link "> Link:</ label >
74- < input id ="link " name ="link " type ="url " class ="form-control " ng-model ="person.link "/>
103+ < span ng-class ="{'glyphicon glyphicon-ok' : personForm.link.$valid && personForm.link.$dirty} "> </ span >
104+
105+ < input id ="link " name ="link " type ="url " class ="form-control " maxlength ="500 "
106+ ng-model ="person.link "
107+ required />
108+
109+ < p class ="help-block " ng-show ="personForm.link.$error.required "> Add Link.</ p >
110+ < p class ="help-block " ng-show ="personForm.link.$invalid && personForm.link.$dirty "> Invalid Link.</ p >
75111 </ div >
76112
77113 < div class ="avatar " ng-if ="person.link ">
78- < img src ="{{person.link}} "/>
114+ < img ng- src ="{{person.link}} " width =" 400 " height =" 250 "/>
79115 </ div >
80116
81117 < div class ="buttons ">
82118 < button type ="button " class ="btn btn-primary " ng-click ="clearForm() "> Clear</ button >
83- < button type ="button " class ="btn btn-primary " ng-click ="deletePerson() "> Delete</ button >
84- < button type ="submit " class ="btn btn-primary "> Save</ button >
119+ < button type ="submit " class ="btn btn-primary " ng-disabled ="personForm.$invalid "> Save</ button >
85120 </ div >
86121 </ form >
87122 </ div >
0 commit comments