Skip to content

Commit 4bfa3c5

Browse files
committed
tweaking the form validation
1 parent 9eede67 commit 4bfa3c5

File tree

2 files changed

+11
-32
lines changed

2 files changed

+11
-32
lines changed

quick-start/src/main/resources/static/app/mlcp/mlcp.controller.js

Lines changed: 7 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -29,28 +29,13 @@
2929
}
3030
});
3131

32-
$scope.errorMessage = null;
33-
$scope.hasError = false;
34-
3532
$scope.mlcp = angular.extend({
3633
input_file_type: 'documents',
3734
}, mlcpOptions);
38-
39-
35+
4036
function ok() {
41-
if(isValidInputFilePath) {
42-
$uibModalInstance.close($scope.mlcp);
43-
}
44-
}
45-
46-
function isValidInputFilePath() {
4737
if($scope.mlcp.input_file_path) {
48-
$scope.hasError = false;
49-
$scope.errorMessage = null;
50-
return true;
51-
} else {
52-
$scope.hasError = true;
53-
$scope.errorMessage = 'The Location of Files to Load is required.';
38+
$uibModalInstance.close($scope.mlcp);
5439
}
5540
}
5641

@@ -88,7 +73,8 @@
8873
function isGroupVisible(category) {
8974
if(category === 'Delimited Text Options' && $scope.mlcp.input_file_type !== 'delimited_text') {
9075
return false;
91-
} else if(category === 'Aggregate XML Options' && $scope.mlcp.input_file_type !== 'aggregates') {
76+
}
77+
else if(category === 'Aggregate XML Options' && $scope.mlcp.input_file_type !== 'aggregates') {
9278
return false;
9379
}
9480
return true;
@@ -138,7 +124,7 @@
138124
addMlcpOption(options, 'input_file_path', inputFilePath, true);
139125
addMlcpOption(options, 'input_file_type', input_file_type, true);
140126
addMlcpOption(options, 'output_uri_replace', '"' + inputFilePath + ',\'\'"', true);
141-
127+
142128
angular.forEach(self.groups, function(group) {
143129
if (isGroupVisible(group.category)) {
144130
$.each(group.settings, function(i, setting) {
@@ -155,7 +141,7 @@
155141
});
156142
return options;
157143
}
158-
144+
159145
function addMlcpOption(options, key, value, isOtherOption) {
160146
options.push('-' + key);
161147
if(value) {
@@ -177,7 +163,7 @@
177163
}
178164

179165
$scope.$watch('mlcp.input_file_path', function(value) {
180-
if(isValidInputFilePath(value)) {
166+
if(value) {
181167
searchPath(value);
182168
}
183169
});

quick-start/src/main/resources/static/app/mlcp/mlcp.html

Lines changed: 4 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -3,21 +3,14 @@
33
<span aria-hidden="true">&times;</span><span class="sr-only">Close</span></button>
44
<h4 class="modal-title" id="myModalLabel">Load Data</h4>
55
</div>
6-
<div class="modal-body" id="myModalBody">
7-
<div class="row" ng-show="hasError">
8-
<div class="col-xs-12 col-md-12">
9-
<div class="alert alert-danger">
10-
{{ errorMessage }}
11-
</div>
12-
</div>
13-
</div>
6+
<div class="modal-body" id="myModalBody" ng-cloak>
147
<div class="row">
158
<div id="details" class="col-xs-12 col-md-12">
16-
<form ng-submit="ctrl.ok()">
17-
<div class="form-group">
9+
<form name="loadDataForm" ng-submit="ctrl.ok()">
10+
<div class="form-group" ng-class="{ 'has-error' : !loadDataForm.ifp.$valid }">
1811
<label for="ifp" popover-trigger="mouseenter" uib-popover="The location of a folder containing the files you wish to load.">Location of Files to Load</label>
1912
<input id="ifp" class="form-control" name="ifp" type="text" ng-model="mlcp.input_file_path"
20-
placeHolder="Enter Path" required="required" ng-focus="showInputPathTreeBrowser = true">
13+
placeHolder="Enter Path (required)" required="required" ng-focus="showInputPathTreeBrowser = true">
2114
<div id="inputPathTreeBrowser" class="panel panel-primary tree-scroller-cust1" ng-show="showInputPathTreeBrowser">
2215
<div class="panel-body">
2316
<treecontrol class="tree-classic" tree-model="ctrl.dataForTheTree"

0 commit comments

Comments
 (0)