File tree 2 files changed +29
-14
lines changed 2 files changed +29
-14
lines changed Original file line number Diff line number Diff line change @@ -104,18 +104,25 @@ angular.module('bsis')
104
104
$scope . getOpenTestBatches ( ) ;
105
105
$scope . getTestBatchFormFields ( ) ;
106
106
107
- $scope . addTestBatch = function ( donationBatches ) {
107
+ $scope . addTestBatch = function ( donationBatches , valid ) {
108
+ if ( valid ) {
108
109
109
- TestingService . addTestBatch ( donationBatches , function ( response ) {
110
- if ( response === true ) {
111
- $scope . selectedDonationBatches = { } ;
112
- $scope . getOpenTestBatches ( ) ;
113
- $scope . getTestBatchFormFields ( ) ;
114
- }
115
- else {
116
- // TODO: handle case where response == false
117
- }
118
- } ) ;
110
+ TestingService . addTestBatch ( donationBatches , function ( response ) {
111
+ if ( response === true ) {
112
+ $scope . selectedDonationBatches = { } ;
113
+ $scope . getOpenTestBatches ( ) ;
114
+ $scope . getTestBatchFormFields ( ) ;
115
+ $scope . submitted = '' ;
116
+ }
117
+ else {
118
+ // TODO: handle case where response == false
119
+ }
120
+ } ) ;
121
+ }
122
+ else {
123
+ $scope . submitted = true ;
124
+ console . log ( "FORM NOT VALID" ) ;
125
+ }
119
126
} ;
120
127
121
128
$scope . testBatchTableParams = new ngTableParams ( {
Original file line number Diff line number Diff line change @@ -46,12 +46,12 @@ <h4>New Test Batch</h4>
46
46
< p > < em > There are no current donations to test</ em > </ p >
47
47
</ div >
48
48
< div ng-switch-default >
49
- < form class ="form-horizontal col-sm-12 " role ="form " ng-submit ="addTestBatch(selectedDonationBatches.ids) ">
49
+ < form name =" addTestBatchForm " novalidate class ="form-horizontal col-sm-12 " role ="form " ng-submit ="addTestBatch(selectedDonationBatches.ids, addTestBatchForm.$valid ) ">
50
50
< div class ="form-group ">
51
51
< label for ="name " class ="col-sm-2 control-label "> Donation Batches</ label >
52
52
< div class ="row col-sm-10 ">
53
53
< div class ="form-inline " style ="padding-left:5px; ">
54
- < ui-select multiple ng-model ="selectedDonationBatches.ids " theme ="bootstrap " ng-disabled ="disabled " style ="width: 800px; ">
54
+ < ui-select name =" donationBatches " required multiple ng-model ="selectedDonationBatches.ids " theme ="bootstrap " ng-disabled ="disabled " style ="width: 800px; " >
55
55
< ui-select-match placeholder ="Select: "> {{$item.collectionCenter.name}} ({{$item.createdDate}})</ ui-select-match >
56
56
< ui-select-choices repeat ="donationBatch.id as donationBatch in donationBatches | filter:$select.search ">
57
57
< div ng-bind-html ="donationBatch.collectionCenter.name "> </ div >
@@ -61,14 +61,22 @@ <h4>New Test Batch</h4>
61
61
</ small >
62
62
</ ui-select-choices >
63
63
</ ui-select >
64
+ < div >
65
+ < small class ="error "
66
+ ng-show ="
67
+ (addTestBatchForm.donationBatches.$invalid && (addTestBatchForm.donationBatches.$dirty || submitted))
68
+ ">
69
+ Select one or more donation batches
70
+ </ small >
71
+ </ div >
64
72
</ div >
65
73
</ div >
66
74
</ div >
67
75
68
76
< div class ="form-group ">
69
77
< div class ="col-sm-offset-2 col-sm-4 ">
70
78
< button class ="btn btn-primary " type ="submit "> Add Test Batch</ button >
71
- < button class ="btn btn-primary " type ="button " ng-click ="clear() "> Clear</ button >
79
+ < button class ="btn btn-primary " type ="button " ng-click ="clearForm(addTestBatchForm); clear() "> Clear</ button >
72
80
</ div >
73
81
</ div >
74
82
You can’t perform that action at this time.
0 commit comments