mirror of
https://github.com/ansible/awx.git
synced 2026-02-12 07:04:45 -03:30
Merge pull request #5873 from mabashian/5850-job-launch-multi-select
Add validation to the multi-select questions in survey
This commit is contained in:
@@ -1371,4 +1371,33 @@ function(ConfigurationUtils, i18n, $rootScope) {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
}])
|
||||||
|
|
||||||
|
.directive('awRequireMultiple', [function() {
|
||||||
|
return {
|
||||||
|
require: 'ngModel',
|
||||||
|
link: function postLink(scope, element, attrs, ngModel) {
|
||||||
|
// Watch for changes to the required attribute
|
||||||
|
attrs.$observe('required', function(value) {
|
||||||
|
if(value) {
|
||||||
|
ngModel.$validators.required = function (value) {
|
||||||
|
if(angular.isArray(value)) {
|
||||||
|
if(value.length === 0) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
return (!value[0] || value[0] === "") ? false : true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
delete ngModel.$validators.required;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
};
|
||||||
}]);
|
}]);
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
<div>
|
<div>
|
||||||
<select class="form-control SurveyMaker-previewSelect" ng-model="selectedValue" multi-select ng-required="isRequired" ng-disabled="isDisabled">
|
<select class="form-control SurveyMaker-previewSelect" ng-model="selectedValue" multi-select ng-required="isRequired" ng-disabled="isDisabled" aw-require-multiple>
|
||||||
<option ng-repeat="choice in choices" value="{{choice}}">{{choice}}</option>
|
<option ng-repeat="choice in choices" value="{{choice}}">{{choice}}</option>
|
||||||
</select>
|
</select>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
Reference in New Issue
Block a user