mirror of
https://github.com/ansible/awx.git
synced 2026-04-14 06:29:25 -02:30
Add dynamic input group
This commit is contained in:
@@ -16,18 +16,15 @@ function AddCredentialsController (models) {
|
|||||||
options: credential.getPostOptions('description')
|
options: credential.getPostOptions('description')
|
||||||
};
|
};
|
||||||
|
|
||||||
vm.dynamic = {
|
|
||||||
update: type => {
|
|
||||||
this.inputs = type ? type.inputs.fields : null;
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
vm.kind = {
|
vm.kind = {
|
||||||
options: credential.getPostOptions('credential_type'),
|
options: credential.getPostOptions('credential_type'),
|
||||||
data: credentialType.categorizeByKind(),
|
data: credentialType.categorizeByKind(),
|
||||||
notify: vm.dynamic.update,
|
|
||||||
placeholder: 'Select a Type'
|
placeholder: 'Select a Type'
|
||||||
};
|
};
|
||||||
|
|
||||||
|
vm.dynamic = {
|
||||||
|
model: credential
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
AddCredentialsController.$inject = [
|
AddCredentialsController.$inject = [
|
||||||
|
|||||||
@@ -8,15 +8,16 @@
|
|||||||
|
|
||||||
<at-panel-body>
|
<at-panel-body>
|
||||||
<at-form>
|
<at-form>
|
||||||
<at-input-text tab="1" col="4" config="vm.name"></at-input-text>
|
<at-input-text col="4" config="vm.name"></at-input-text>
|
||||||
<at-input-text tab="2" col="4" config="vm.description"></at-input-text>
|
<at-input-text col="4" config="vm.description"></at-input-text>
|
||||||
<at-input-select tab="3" col="4" config="vm.kind"></at-input-select>
|
<at-input-select col="4" config="vm.kind"></at-input-select>
|
||||||
|
|
||||||
<at-dynamic-input-list config="vm.dynamic"></at-dynamic-input-list>
|
<at-dynamic-input-group col="4" config="vm.dynamic" watch="vm.kind">
|
||||||
|
</at-dynamic-input-group>
|
||||||
|
|
||||||
<at-action-group col="12" pos="right">
|
<at-action-group col="12" pos="right">
|
||||||
<at-action tab="4" type="cancel"></at-action>
|
<at-form-action type="cancel"></at-form-action>
|
||||||
<at-action tab="5" type="save"></at-action>
|
<at-form-action type="save"></at-form-action>
|
||||||
</at-action-group>
|
</at-action-group>
|
||||||
</at-form>
|
</at-form>
|
||||||
</at-panel-body>
|
</at-panel-body>
|
||||||
|
|||||||
@@ -0,0 +1,40 @@
|
|||||||
|
function link (scope, el, attrs, controllers) {
|
||||||
|
let dynamicController = controllers[0];
|
||||||
|
|
||||||
|
dynamicController.init(scope);
|
||||||
|
}
|
||||||
|
|
||||||
|
function atDynamicInputGroupController () {
|
||||||
|
let vm = this || {};
|
||||||
|
|
||||||
|
let state;
|
||||||
|
let scope;
|
||||||
|
let input;
|
||||||
|
let form;
|
||||||
|
|
||||||
|
vm.init = (_scope_) => {
|
||||||
|
scope = _scope_;
|
||||||
|
console.log(scope.watch);
|
||||||
|
// scope.form = form.use('input', state);
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
function atDynamicInputGroup (pathService) {
|
||||||
|
return {
|
||||||
|
restrict: 'E',
|
||||||
|
replace: true,
|
||||||
|
require: ['atDynamicInputGroup'],
|
||||||
|
templateUrl: pathService.getPartialPath('components/dynamic/input-group'),
|
||||||
|
controller: atDynamicInputGroupController,
|
||||||
|
controllerAs: 'vm',
|
||||||
|
link,
|
||||||
|
scope: {
|
||||||
|
config: '=',
|
||||||
|
watch: '='
|
||||||
|
}
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
atDynamicInputGroup.$inject = ['PathService'];
|
||||||
|
|
||||||
|
export default atDynamicInputGroup;
|
||||||
@@ -0,0 +1,4 @@
|
|||||||
|
<div>
|
||||||
|
{{ watch.state.value }}
|
||||||
|
{{ watch.data[watch.state.value] }}
|
||||||
|
</div>
|
||||||
@@ -5,7 +5,7 @@ function link (scope, el, attrs, controllers) {
|
|||||||
actionController.init(formController, scope);
|
actionController.init(formController, scope);
|
||||||
}
|
}
|
||||||
|
|
||||||
function atActionController ($state) {
|
function atFormActionController ($state) {
|
||||||
let vm = this || {};
|
let vm = this || {};
|
||||||
|
|
||||||
let form;
|
let form;
|
||||||
@@ -50,16 +50,16 @@ function atActionController ($state) {
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
atActionController.$inject = ['$state'];
|
atFormAction.$inject = ['$state'];
|
||||||
|
|
||||||
function atAction (pathService) {
|
function atFormAction (pathService) {
|
||||||
return {
|
return {
|
||||||
restrict: 'E',
|
restrict: 'E',
|
||||||
transclude: true,
|
transclude: true,
|
||||||
replace: true,
|
replace: true,
|
||||||
require: ['^^atForm', 'atAction'],
|
require: ['^^atForm', 'atFormAction'],
|
||||||
templateUrl: pathService.getPartialPath('components/action/action'),
|
templateUrl: pathService.getPartialPath('components/form/action'),
|
||||||
controller: atActionController,
|
controller: atFormActionController,
|
||||||
controllerAs: 'vm',
|
controllerAs: 'vm',
|
||||||
link,
|
link,
|
||||||
scope: {
|
scope: {
|
||||||
@@ -68,6 +68,6 @@ function atAction (pathService) {
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
atAction.$inject = ['PathService'];
|
atFormAction.$inject = ['PathService'];
|
||||||
|
|
||||||
export default atAction;
|
export default atFormAction;
|
||||||
@@ -24,24 +24,24 @@ function AtFormController () {
|
|||||||
return state;
|
return state;
|
||||||
};
|
};
|
||||||
|
|
||||||
vm.trackInput = (component, el) => {
|
vm.trackInput = (input, el) => {
|
||||||
let form = {
|
let form = {
|
||||||
state: vm.state,
|
state: vm.state,
|
||||||
disabled: false
|
disabled: false
|
||||||
};
|
};
|
||||||
|
|
||||||
vm.inputs.push(component)
|
vm.inputs.push(input)
|
||||||
|
|
||||||
return form;
|
return form;
|
||||||
};
|
};
|
||||||
|
|
||||||
vm.trackAction = component => {
|
vm.trackAction = action => {
|
||||||
let form = {
|
let form = {
|
||||||
state: vm.state,
|
state: vm.state,
|
||||||
disabled: false
|
disabled: false
|
||||||
};
|
};
|
||||||
|
|
||||||
vm.actions.push(component);
|
vm.actions.push(action);
|
||||||
|
|
||||||
return form;
|
return form;
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -1,7 +1,8 @@
|
|||||||
import action from './action/action.directive';
|
|
||||||
import actionGroup from './action/action-group.directive';
|
import actionGroup from './action/action-group.directive';
|
||||||
import badge from './badge/badge.directive';
|
import badge from './badge/badge.directive';
|
||||||
|
import dynamicInputGroup from './dynamic/input-group.directive';
|
||||||
import form from './form/form.directive';
|
import form from './form/form.directive';
|
||||||
|
import formAction from './form/action.directive';
|
||||||
import inputLabel from './input/label.directive';
|
import inputLabel from './input/label.directive';
|
||||||
import inputSearch from './input/search.directive';
|
import inputSearch from './input/search.directive';
|
||||||
import inputSelect from './input/select.directive';
|
import inputSelect from './input/select.directive';
|
||||||
@@ -15,10 +16,11 @@ import toggleContent from './toggle/content.directive';
|
|||||||
|
|
||||||
angular
|
angular
|
||||||
.module('at.lib.components', [])
|
.module('at.lib.components', [])
|
||||||
.directive('atAction', action)
|
|
||||||
.directive('atActionGroup', actionGroup)
|
.directive('atActionGroup', actionGroup)
|
||||||
.directive('atBadge', badge)
|
.directive('atBadge', badge)
|
||||||
|
.directive('atDynamicInputGroup', dynamicInputGroup)
|
||||||
.directive('atForm', form)
|
.directive('atForm', form)
|
||||||
|
.directive('atFormAction', formAction)
|
||||||
.directive('atInputLabel', inputLabel)
|
.directive('atInputLabel', inputLabel)
|
||||||
.directive('atInputSearch', inputSearch)
|
.directive('atInputSearch', inputSearch)
|
||||||
.directive('atInputSelect', inputSelect)
|
.directive('atInputSelect', inputSelect)
|
||||||
|
|||||||
@@ -24,7 +24,6 @@ function AtInputSelectController (eventService) {
|
|||||||
|
|
||||||
scope.config.state = scope.config.state || {};
|
scope.config.state = scope.config.state || {};
|
||||||
state = scope.config.state;
|
state = scope.config.state;
|
||||||
state.required = scope.config.options.required;
|
|
||||||
|
|
||||||
if (scope.tab === 1) {
|
if (scope.tab === 1) {
|
||||||
select.focus();
|
select.focus();
|
||||||
@@ -32,7 +31,7 @@ function AtInputSelectController (eventService) {
|
|||||||
|
|
||||||
state.isValid = state.isValid || false;
|
state.isValid = state.isValid || false;
|
||||||
state.message = state.message || '';
|
state.message = state.message || '';
|
||||||
state.required = state.required || false;
|
state.required = scope.config.options.required || false;
|
||||||
|
|
||||||
scope.form = form.use('input', state);
|
scope.form = form.use('input', state);
|
||||||
|
|
||||||
@@ -77,10 +76,6 @@ function AtInputSelectController (eventService) {
|
|||||||
state.isValid = isValid;
|
state.isValid = isValid;
|
||||||
form.check();
|
form.check();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (scope.config.notify) {
|
|
||||||
scope.config.notify(state.value);
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user