mirror of
https://github.com/ZwareBear/awx.git
synced 2026-04-29 11:21:49 -05:00
Update project structure
This commit is contained in:
1
awx/ui/client/lib/components/form/_index.less
Normal file
1
awx/ui/client/lib/components/form/_index.less
Normal file
@@ -0,0 +1 @@
|
||||
|
||||
90
awx/ui/client/lib/components/form/form.directive.js
Normal file
90
awx/ui/client/lib/components/form/form.directive.js
Normal file
@@ -0,0 +1,90 @@
|
||||
function use (type, componentScope, componentElement) {
|
||||
let vm = this;
|
||||
|
||||
let component;
|
||||
|
||||
switch (type) {
|
||||
case 'input':
|
||||
component = vm.trackInput(componentElement);
|
||||
break;
|
||||
case 'action':
|
||||
component = vm.trackAction(componentElement);
|
||||
break;
|
||||
default:
|
||||
throw new Error('An at-form cannot use component type:', type);
|
||||
}
|
||||
|
||||
componentScope.meta = component;
|
||||
}
|
||||
|
||||
function trackInput (componentElement) {
|
||||
let vm = this;
|
||||
|
||||
let input = {
|
||||
el: componentElement,
|
||||
tabindex: vm.inputs.length + 1
|
||||
};
|
||||
|
||||
if (vm.inputs.length === 0) {
|
||||
input.autofocus = true;
|
||||
componentElement.find('input').focus();
|
||||
}
|
||||
|
||||
vm.inputs.push(input)
|
||||
|
||||
return input;
|
||||
}
|
||||
|
||||
function trackAction (componentElement) {
|
||||
let vm = this;
|
||||
|
||||
let action = {
|
||||
el: componentElement
|
||||
};
|
||||
|
||||
vm.actions.push(action);
|
||||
|
||||
return action;
|
||||
}
|
||||
|
||||
function update () {
|
||||
let vm = this;
|
||||
|
||||
vm.inputs.forEach(input => console.log(input));
|
||||
}
|
||||
|
||||
function remove (id) {
|
||||
let vm = this;
|
||||
|
||||
delete inputs[id];
|
||||
}
|
||||
|
||||
function AtFormController () {
|
||||
let vm = this;
|
||||
|
||||
vm.inputs = [];
|
||||
vm.actions = [];
|
||||
|
||||
vm.use = use;
|
||||
vm.trackInput = trackInput;
|
||||
vm.trackAction = trackAction;
|
||||
vm.update = update;
|
||||
vm.remove = remove;
|
||||
}
|
||||
|
||||
function atForm (pathService) {
|
||||
return {
|
||||
restrict: 'E',
|
||||
transclude: true,
|
||||
templateUrl: pathService.getPartialPath('components/form/form'),
|
||||
controller: AtFormController,
|
||||
controllerAs: 'vm',
|
||||
scope: {
|
||||
config: '='
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
atForm.$inject = ['PathService'];
|
||||
|
||||
export default atForm;
|
||||
5
awx/ui/client/lib/components/form/form.partial.html
Normal file
5
awx/ui/client/lib/components/form/form.partial.html
Normal file
@@ -0,0 +1,5 @@
|
||||
<form>
|
||||
<div class="row">
|
||||
<ng-transclude></ng-transclude>
|
||||
</div>
|
||||
</form>
|
||||
Reference in New Issue
Block a user