mirror of
https://github.com/ansible/awx.git
synced 2026-01-12 18:40:01 -03:30
Add more generalized legacy Lookup integration
This commit is contained in:
parent
dc1bff9048
commit
b7982bf202
@ -1,12 +1,11 @@
|
||||
const DEFAULT_ORGANIZATION_PLACEHOLDER = 'SELECT AN ORGANIZATION';
|
||||
|
||||
function AddCredentialsController (models, organizationList, $state) {
|
||||
function AddCredentialsController (models, $state) {
|
||||
let vm = this || {};
|
||||
|
||||
let me = models.me;
|
||||
let credential = models.credential;
|
||||
let credentialType = models.credentialType;
|
||||
let organization = models.organization;
|
||||
|
||||
vm.panelTitle = 'NEW CREDENTIAL';
|
||||
|
||||
@ -23,8 +22,8 @@ function AddCredentialsController (models, organizationList, $state) {
|
||||
omit: ['user', 'team', 'inputs']
|
||||
});
|
||||
|
||||
vm.form.organization._model = organization;
|
||||
vm.form.organization._placeholder = DEFAULT_ORGANIZATION_PLACEHOLDER;
|
||||
vm.form.organization._resource = 'organization';
|
||||
vm.form.organization._route = 'credentials.add.organization';
|
||||
|
||||
vm.form.credential_type._data = credentialType.get('results');
|
||||
vm.form.credential_type._placeholder = 'SELECT A TYPE';
|
||||
@ -53,7 +52,6 @@ function AddCredentialsController (models, organizationList, $state) {
|
||||
|
||||
AddCredentialsController.$inject = [
|
||||
'resolvedModels',
|
||||
'OrganizationList',
|
||||
'$state'
|
||||
];
|
||||
|
||||
|
||||
@ -3,13 +3,12 @@ import AddController from './add-credentials.controller.js';
|
||||
import EditController from './edit-credentials.controller.js';
|
||||
import { N_ } from '../../src/i18n';
|
||||
|
||||
function CredentialsResolve ($q, $stateParams, Me, Credential, CredentialType, Organization) {
|
||||
function CredentialsResolve ($q, $stateParams, Me, Credential, CredentialType) {
|
||||
let id = $stateParams.credential_id;
|
||||
|
||||
let promises = {
|
||||
me: new Me('get'),
|
||||
credentialType: new CredentialType('get'),
|
||||
organization: new Organization('get')
|
||||
credentialType: new CredentialType('get')
|
||||
};
|
||||
|
||||
if (id) {
|
||||
@ -26,8 +25,7 @@ CredentialsResolve.$inject = [
|
||||
'$stateParams',
|
||||
'MeModel',
|
||||
'CredentialModel',
|
||||
'CredentialTypeModel',
|
||||
'OrganizationModel'
|
||||
'CredentialTypeModel'
|
||||
];
|
||||
|
||||
function CredentialsConfig ($stateExtenderProvider, legacyProvider, pathProvider) {
|
||||
|
||||
@ -2,9 +2,6 @@ function atInputLookupLink (scope, element, attrs, controllers) {
|
||||
let formController = controllers[0];
|
||||
let inputController = controllers[1];
|
||||
|
||||
scope.ns = 'lookup';
|
||||
scope[scope.ns] = { modal: {} };
|
||||
|
||||
if (scope.tab === '1') {
|
||||
element.find('input')[0].focus();
|
||||
}
|
||||
@ -16,27 +13,30 @@ function AtInputLookupController (baseInputController, $state) {
|
||||
let vm = this || {};
|
||||
|
||||
let scope;
|
||||
let modal;
|
||||
|
||||
vm.init = (_scope_, element, form) => {
|
||||
baseInputController.call(vm, 'input', _scope_, element, form);
|
||||
|
||||
scope = _scope_;
|
||||
|
||||
scope.$watch('organization', () => {
|
||||
if (scope.organization) {
|
||||
scope.state._value = scope.organization;
|
||||
scope.state._displayValue = scope.organization_name;
|
||||
scope.$watch(scope.state._resource, () => {
|
||||
if (scope[scope.state._resource]) {
|
||||
scope.state._value = scope[scope.state._resource];
|
||||
scope.state._displayValue = scope[`${scope.state._resource}_name`];
|
||||
}
|
||||
});
|
||||
|
||||
modal = scope.lookup.modal;
|
||||
|
||||
vm.check();
|
||||
};
|
||||
|
||||
vm.search = () => {
|
||||
$state.go('credentials.add.organization');
|
||||
let params = {};
|
||||
|
||||
if (scope.state._value) {
|
||||
params.selected = scope.state._value;
|
||||
}
|
||||
|
||||
$state.go(scope.state._route, params);
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
@ -23,5 +23,5 @@
|
||||
<at-input-message></at-input-message>
|
||||
</div>
|
||||
|
||||
<div ui-view="organization"></div>
|
||||
<div ui-view="{{ state._resource }}"></div>
|
||||
</div>
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user