mirror of
https://github.com/ZwareBear/awx.git
synced 2026-05-01 12:21:48 -05:00
Add component controller inheritance and new inputs
This commit is contained in:
@@ -6,54 +6,21 @@ function atInputTextLink (scope, el, attrs, controllers) {
|
||||
el.find('input')[0].focus();
|
||||
}
|
||||
|
||||
inputController.init(formController, scope);
|
||||
inputController.init(scope, formController);
|
||||
}
|
||||
|
||||
function AtInputTextController () {
|
||||
function AtInputTextController (baseInputController) {
|
||||
let vm = this || {};
|
||||
|
||||
let scope;
|
||||
let state;
|
||||
let form;
|
||||
|
||||
vm.init = (_form_, _scope_) => {
|
||||
form = _form_;
|
||||
scope = _scope_;
|
||||
state = scope.state || {};
|
||||
|
||||
state.required = state.required || false;
|
||||
state.isValid = state.isValid || false;
|
||||
state.disabled = state.disabled || false;
|
||||
|
||||
form.use('input', scope);
|
||||
vm.init = (scope, form) => {
|
||||
baseInputController.call(vm, 'input', scope, form);
|
||||
|
||||
vm.check();
|
||||
};
|
||||
|
||||
vm.validate = () => {
|
||||
let isValid = true;
|
||||
|
||||
if (state.required && !state.value) {
|
||||
isValid = false;
|
||||
}
|
||||
|
||||
if (state.validate && !state.validate(state.value)) {
|
||||
isValid = false;
|
||||
}
|
||||
|
||||
return isValid;
|
||||
};
|
||||
|
||||
vm.check = () => {
|
||||
let isValid = vm.validate();
|
||||
|
||||
if (isValid !== state.isValid) {
|
||||
state.isValid = isValid;
|
||||
form.check();
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
AtInputTextController.$inject = ['BaseInputController'];
|
||||
|
||||
function atInputText (pathService) {
|
||||
return {
|
||||
restrict: 'E',
|
||||
|
||||
Reference in New Issue
Block a user