1
0
mirror of https://github.com/ansible/awx.git synced 2024-11-02 01:21:21 +03:00

populate org and description on app detail view

This commit is contained in:
John Mitchell 2018-04-27 13:05:34 -04:00
parent 6ab64590d7
commit 11560ab7bb
No known key found for this signature in database
GPG Key ID: FE6A9B5BD4EB5C94
3 changed files with 15 additions and 23 deletions

View File

@ -42,7 +42,7 @@ function AddApplicationsController (models, $state, strings) {
vm.form.organization._resource = 'organization';
vm.form.organization._route = 'applications.add.organization';
vm.form.organization._model = organization;
vm.form.organization._placeholder = strings.get('SELECT AN ORGANIZATION');
vm.form.organization._placeholder = strings.get('inputs.ORGANIZATION_PLACEHOLDER');
vm.form.name.required = true;
vm.form.organization.required = true;

View File

@ -25,6 +25,10 @@ function ApplicationsStrings (BaseString) {
ROW_ITEM_LABEL_ORGANIZATION: t.s('ORG'),
ROW_ITEM_LABEL_MODIFIED: t.s('LAST MODIFIED')
};
ns.inputs = {
ORGANIZATION_PLACEHOLDER: t.s('SELECT AN ORGANIZATION')
};
}
ApplicationsStrings.$inject = ['BaseStringService'];

View File

@ -52,37 +52,25 @@ function EditApplicationsController (models, $state, strings, $scope) {
vm.form.disabled = !isEditable;
vm.form.name.required = true;
vm.form.redirect_uris.required = true;
const isOrgAdmin = _.some(me.get('related.admin_of_organizations.results'), (org) => org.id === organization.get('id'));
const isSuperuser = me.get('is_superuser');
const isCurrentAuthor = Boolean(application.get('summary_fields.created_by.id') === me.get('id'));
vm.form.organization = {
type: 'field',
label: 'Organization',
id: 'organization'
};
vm.form.description = {
type: 'String',
label: 'Description',
id: 'description'
};
vm.form.organization._resource = 'organization';
vm.form.organization._route = 'applications.edit.organization';
vm.form.organization._model = organization;
vm.form.organization._placeholder = strings.get('SELECT AN ORGANIZATION');
// TODO: org not returned via api endpoint, check on this
vm.form.organization._value = application.get('organization');
vm.form.organization._disabled = true;
if (isSuperuser || isOrgAdmin || (application.get('organization') === null && isCurrentAuthor)) {
vm.form.organization._disabled = false;
}
vm.form.name.required = true;
vm.form.organization._resource = 'organization';
vm.form.organization._model = organization;
vm.form.organization._route = 'applications.edit.organization';
vm.form.organization._value = application.get('summary_fields.organization.id');
vm.form.organization._displayValue = application.get('summary_fields.organization.name');
vm.form.organization._placeholder = strings.get('inputs.ORGANIZATION_PLACEHOLDER');
vm.form.organization.required = true;
vm.form.redirect_uris.required = true;
delete vm.form.name.help_text;