Skip to content

Commit

Permalink
fix(component): fix component validation triggering
Browse files Browse the repository at this point in the history
  • Loading branch information
DedrickEnc committed Aug 10, 2017
1 parent 096ca26 commit 56055f8
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 8 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -39,3 +39,4 @@ nbproject/

# ignore istanbul generated folders
.nyc_output/

3 changes: 2 additions & 1 deletion client/src/js/components/bhDepotSelect.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@ angular.module('bhima.components')
bindings : {
depotUuid : '<',
onSelectCallback : '&',
required : '<?',
required : '<?',
validateTrigger : '<?',
},
});

Expand Down
3 changes: 2 additions & 1 deletion client/src/js/components/bhInventorySelect.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@ angular.module('bhima.components')
bindings : {
inventoryUuid : '<',
onSelectCallback : '&',
required : '<?',
required : '<?',
validateTrigger : '<?',
},
});

Expand Down
6 changes: 3 additions & 3 deletions client/src/modules/templates/bhDepotSelect.tmpl.html
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<div ng-form="DepotForm" bh-depot-select ng-model-options="{ updateOn: 'default' }">
<div
class="form-group"
ng-class="{ 'has-error' : DepotForm.$$parent.$submitted && DepotForm.depot_uuid.$invalid }">
ng-class="{ 'has-error' : $ctrl.validateTrigger && DepotForm.depot_uuid.$invalid }">

<label class="control-label" translate>
STOCK.DEPOT
Expand All @@ -19,9 +19,9 @@
<ui-select-choices ui-select-focus-patch repeat="depot.uuid as depot in $ctrl.depots | filter: { 'text': $select.search }">
<span ng-bind-html="depot.text | highlight:$select.search"></span>
</ui-select-choices>
</ui-select>
</ui-select>

<div class="help-block" ng-messages="DepotForm.depot_uuid.$error" ng-show="DepotForm.$$parent.$submitted">
<div class="help-block" ng-messages="DepotForm.depot_uuid.$error" ng-show="$ctrl.validateTrigger">
<div ng-messages-include="modules/templates/messages.tmpl.html"></div>
</div>
</div>
Expand Down
7 changes: 4 additions & 3 deletions client/src/modules/templates/bhInventorySelect.tmpl.html
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<div ng-form="InventoryForm" bh-inventory-select ng-model-options="{ updateOn: 'default' }">
<div
class="form-group"
ng-class="{ 'has-error' : InventoryForm.$$parent.$submitted && InventoryForm.inventory_uuid.$invalid }">
ng-class="{ 'has-error' : $ctrl.validateTrigger && InventoryForm.inventory_uuid.$invalid }">

<label class="control-label" translate>
FORM.LABELS.INVENTORY
Expand All @@ -11,7 +11,8 @@
<ui-select
name="inventory_uuid"
ng-model="$ctrl.inventoryUuid"
on-select="$ctrl.onSelect($item, $model)">
on-select="$ctrl.onSelect($item, $model)"
ng-required="$ctrl.required">
<ui-select-match placeholder="{{ 'FORM.SELECT.INVENTORY' | translate }}">
<span>{{$select.selected.label}}</span>
</ui-select-match>
Expand All @@ -20,7 +21,7 @@
</ui-select-choices>
</ui-select>

<div class="help-block" ng-messages="InventoryForm.inventory_uuid.$error" ng-show="InventoryForm.$$parent.$submitted">
<div class="help-block" ng-messages="InventoryForm.inventory_uuid.$error" ng-show="$ctrl.validateTrigger">
<div ng-messages-include="modules/templates/messages.tmpl.html"></div>
</div>
</div>
Expand Down

0 comments on commit 56055f8

Please sign in to comment.