|
3 | 3 | 'use strict'; |
4 | 4 |
|
5 | 5 | angular.module('dhib.quickstart.service.modal', ['ui.bootstrap']) |
| 6 | + .filter('GetByFieldAndValue', GetByFieldAndValue) |
6 | 7 | .service('ModalService', ModalService) |
7 | 8 | .controller('loadDataModalController', LoadDataModalController) |
8 | 9 | .controller('entityModalController', EntityModalController) |
9 | 10 | .controller('flowModalController', FlowModalController); |
| 11 | + |
| 12 | + function GetByFieldAndValue() { |
| 13 | + return function(field, value, collection) { |
| 14 | + var i=0, len=collection.length; |
| 15 | + for (; i<len; i++) { |
| 16 | + if (String(collection[i]['Field']) === String(field) && String(collection[i]['Value']) === String(value)) { |
| 17 | + return collection[i]; |
| 18 | + } |
| 19 | + } |
| 20 | + return null; |
| 21 | + } |
| 22 | + } |
10 | 23 |
|
11 | 24 | function ModalService($uibModal) { |
12 | 25 | var self = this; |
|
76 | 89 | } |
77 | 90 | } |
78 | 91 |
|
79 | | - function LoadDataModalController($scope, $uibModalInstance, DataHub, entityName, flowName) { |
| 92 | + function LoadDataModalController($scope, $uibModalInstance, $filter, DataHub, entityName, flowName) { |
80 | 93 | $scope.loadDataForm = { |
81 | 94 | inputPath: '.', |
82 | 95 | inputFileType: 'documents', |
|
223 | 236 | }; |
224 | 237 |
|
225 | 238 | $scope.showBasedOnCategoryAndInputFileType = function(category, inputFileType) { |
226 | | - if(category === 'Delimited text options' && $scope.loadDataForm.inputFileType !== 'delimited_text') { |
227 | | - return false; |
228 | | - } else if(category === 'Aggregate XML options' && $scope.loadDataForm.inputFileType !== 'aggregates') { |
229 | | - return false; |
| 239 | + return showBasedOnCategoryAndInputFileType(category, inputFileType); |
| 240 | + }; |
| 241 | + |
| 242 | + $scope.showIfHasNoFilterFieldOrWithSpecifiedValue = function(field,value,collection) { |
| 243 | + if(angular.isUndefined(field) || $filter('GetByFieldAndValue')(field,value,collection)) { |
| 244 | + return true; |
230 | 245 | } |
231 | | - return true; |
| 246 | + return false; |
232 | 247 | }; |
233 | 248 |
|
234 | 249 | } |
235 | 250 |
|
| 251 | + function showBasedOnCategoryAndInputFileType(category, inputFileType) { |
| 252 | + if(category === 'Delimited text options' && inputFileType !== 'delimited_text') { |
| 253 | + return false; |
| 254 | + } else if(category === 'Aggregate XML options' && inputFileType !== 'aggregates') { |
| 255 | + return false; |
| 256 | + } |
| 257 | + return true; |
| 258 | + }; |
| 259 | + |
236 | 260 | function constructInitialMlcpCommand(DataHub) { |
237 | 261 | var mlcpCommand = 'mlcp'; |
238 | 262 |
|
|
258 | 282 |
|
259 | 283 | var otherOptions = []; |
260 | 284 | $.each(groups, function(i, group) { |
261 | | - $.each(group.settings, function(i, setting) { |
262 | | - if(setting['Value']) { |
263 | | - var key = setting['Field']; |
264 | | - var value = '"' + setting['Value'] + '"'; |
265 | | - mlcpCommand += ' ' + key + ' ' + value; |
266 | | - var option = {}; |
267 | | - option[key] = value; |
268 | | - otherOptions.push(option); |
| 285 | + if(showBasedOnCategoryAndInputFileType(group.category, loadDataForm.inputFileType)) { |
| 286 | + $.each(group.settings, function(i, setting) { |
| 287 | + if(setting['Value']) { |
| 288 | + var key = setting['Field']; |
| 289 | + var value = '"' + setting['Value'] + '"'; |
| 290 | + mlcpCommand += ' ' + key + ' ' + value; |
| 291 | + var option = {}; |
| 292 | + option[key] = value; |
| 293 | + otherOptions.push(option); |
269 | 294 | } |
270 | | - }); |
| 295 | + }); |
| 296 | + } |
271 | 297 | }); |
272 | 298 |
|
273 | 299 | loadDataForm.otherOptions = otherOptions.length > 0 ? JSON.stringify(otherOptions) : ''; |
|
0 commit comments