Attached sub form work to source control form in projects.js, added title plus some styling

Added some breathing room at the bottom of the sub form
This commit is contained in:
Ken Hoes
2016-02-24 10:11:09 -05:00
parent 7dbb69dd6d
commit c69534de14
4 changed files with 99 additions and 21 deletions

View File

@@ -141,6 +141,28 @@
padding-right: 50px; padding-right: 50px;
} }
.Form-subForm {
width: 100%;
border-left: 5px solid @default-border;
margin-left: -20px;
padding-left: 15px;
margin-bottom: 15px;
.Form-formGroup {
float: left;
}
}
.Form-subForm--title {
font-weight: bold;
text-transform: uppercase;
color: @default-interface-txt;
font-size: small;
width: 100%;
float: left;
margin-bottom: 10px;
}
.Form-textAreaLabel{ .Form-textAreaLabel{
width:100%; width:100%;
} }

View File

@@ -18,6 +18,9 @@ export default
editTitle: '{{ name }}', //Legend in edit mode editTitle: '{{ name }}', //Legend in edit mode
name: 'credential', name: 'credential',
forceListeners: true, forceListeners: true,
subFormTitles: {
credentialSubForm: 'Type Details',
},
actions: { actions: {
@@ -103,7 +106,8 @@ export default
'</dl>\n', '</dl>\n',
dataTitle: 'Type', dataTitle: 'Type',
dataPlacement: 'right', dataPlacement: 'right',
dataContainer: "body" dataContainer: "body",
hasSubForm: true,
// helpCollapse: [{ // helpCollapse: [{
// hdr: 'Select a Credential Type', // hdr: 'Select a Credential Type',
// content: '<dl>\n' + // content: '<dl>\n' +
@@ -131,7 +135,8 @@ export default
init: false init: false
}, },
autocomplete: false, autocomplete: false,
apiField: 'username' apiField: 'username',
subForm: 'credentialSubForm',
}, },
secret_key: { secret_key: {
label: 'Secret Key', label: 'Secret Key',
@@ -145,7 +150,8 @@ export default
ask: false, ask: false,
clear: false, clear: false,
hasShowInputButton: true, hasShowInputButton: true,
apiField: 'passwowrd' apiField: 'passwowrd',
subForm: 'credentialSubForm'
}, },
security_token: { security_token: {
label: 'STS Token', label: 'STS Token',
@@ -157,7 +163,8 @@ export default
hasShowInputButton: true, hasShowInputButton: true,
dataTitle: 'STS Token', dataTitle: 'STS Token',
dataPlacement: 'right', dataPlacement: 'right',
dataContainer: "body" dataContainer: "body",
subForm: 'credentialSubForm'
}, },
"host": { "host": {
labelBind: 'hostLabel', labelBind: 'hostLabel',
@@ -172,7 +179,8 @@ export default
awRequiredWhen: { awRequiredWhen: {
variable: 'host_required', variable: 'host_required',
init: false init: false
} },
subForm: 'credentialSubForm'
}, },
"username": { "username": {
labelBind: 'usernameLabel', labelBind: 'usernameLabel',
@@ -183,7 +191,8 @@ export default
variable: 'username_required', variable: 'username_required',
init: false init: false
}, },
autocomplete: false autocomplete: false,
subForm: "credentialSubForm"
}, },
"email_address": { "email_address": {
labelBind: 'usernameLabel', labelBind: 'usernameLabel',
@@ -197,7 +206,8 @@ export default
awPopOver: '<p>The email address assigned to the Google Compute Engine <b><i>service account.</b></i></p>', awPopOver: '<p>The email address assigned to the Google Compute Engine <b><i>service account.</b></i></p>',
dataTitle: 'Email', dataTitle: 'Email',
dataPlacement: 'right', dataPlacement: 'right',
dataContainer: "body" dataContainer: "body",
subForm: 'credentialSubForm'
}, },
"subscription_id": { "subscription_id": {
labelBind: "usernameLabel", labelBind: "usernameLabel",
@@ -213,8 +223,8 @@ export default
awPopOver: '<p>Subscription ID is an Azure construct, which is mapped to a username.</p>', awPopOver: '<p>Subscription ID is an Azure construct, which is mapped to a username.</p>',
dataTitle: 'Subscription ID', dataTitle: 'Subscription ID',
dataPlacement: 'right', dataPlacement: 'right',
dataContainer: "body" dataContainer: "body",
subForm: 'credentialSubForm'
}, },
"api_key": { "api_key": {
label: 'API Key', label: 'API Key',
@@ -228,6 +238,7 @@ export default
ask: false, ask: false,
hasShowInputButton: true, hasShowInputButton: true,
clear: false, clear: false,
subForm: 'credentialSubForm'
}, },
"password": { "password": {
labelBind: 'passwordLabel', labelBind: 'passwordLabel',
@@ -242,7 +253,8 @@ export default
awRequiredWhen: { awRequiredWhen: {
variable: "password_required", variable: "password_required",
init: false init: false
} },
subForm: "credentialSubForm"
}, },
"ssh_password": { "ssh_password": {
label: 'Password', // formally 'SSH Password' label: 'Password', // formally 'SSH Password'
@@ -252,7 +264,8 @@ export default
editRequired: false, editRequired: false,
ask: true, ask: true,
hasShowInputButton: true, hasShowInputButton: true,
autocomplete: false autocomplete: false,
subForm: 'credentialSubForm'
}, },
"ssh_key_data": { "ssh_key_data": {
labelBind: 'sshKeyDataLabel', labelBind: 'sshKeyDataLabel',
@@ -273,7 +286,8 @@ export default
awPopOverWatch: "key_description", awPopOverWatch: "key_description",
dataTitle: 'Help', dataTitle: 'Help',
dataPlacement: 'right', dataPlacement: 'right',
dataContainer: "body" dataContainer: "body",
subForm: "credentialSubForm"
}, },
"ssh_key_unlock": { "ssh_key_unlock": {
label: 'Private Key Passphrase', label: 'Private Key Passphrase',
@@ -285,6 +299,7 @@ export default
ask: true, ask: true,
hasShowInputButton: true, hasShowInputButton: true,
askShow: "kind.value == 'ssh'", // Only allow ask for machine credentials askShow: "kind.value == 'ssh'", // Only allow ask for machine credentials
subForm: 'credentialSubForm'
}, },
"become_method": { "become_method": {
label: "Privilege Escalation", label: "Privilege Escalation",
@@ -297,7 +312,8 @@ export default
"This is equivalent to specifying the <code>--become-method=BECOME_METHOD</code> parameter, where <code>BECOME_METHOD</code> could be "+ "This is equivalent to specifying the <code>--become-method=BECOME_METHOD</code> parameter, where <code>BECOME_METHOD</code> could be "+
"<code>sudo | su | pbrun | pfexec | runas</code> <br>(defaults to <code>sudo</code>)</p>", "<code>sudo | su | pbrun | pfexec | runas</code> <br>(defaults to <code>sudo</code>)</p>",
dataPlacement: 'right', dataPlacement: 'right',
dataContainer: "body" dataContainer: "body",
subForm: 'credentialSubForm'
}, },
"become_username": { "become_username": {
label: 'Privilege Escalation Username', label: 'Privilege Escalation Username',
@@ -305,7 +321,8 @@ export default
ngShow: "kind.value == 'ssh' && (become_method && become_method.value)", ngShow: "kind.value == 'ssh' && (become_method && become_method.value)",
addRequired: false, addRequired: false,
editRequired: false, editRequired: false,
autocomplete: false autocomplete: false,
subForm: 'credentialSubForm'
}, },
"become_password": { "become_password": {
label: 'Privilege Escalation Password', label: 'Privilege Escalation Password',
@@ -315,7 +332,8 @@ export default
editRequired: false, editRequired: false,
ask: true, ask: true,
hasShowInputButton: true, hasShowInputButton: true,
autocomplete: false autocomplete: false,
subForm: 'credentialSubForm'
}, },
"project": { "project": {
labelBind: 'projectLabel', labelBind: 'projectLabel',
@@ -331,7 +349,8 @@ export default
awRequiredWhen: { awRequiredWhen: {
variable: 'project_required', variable: 'project_required',
init: false init: false
} },
subForm: 'credentialSubForm'
}, },
"vault_password": { "vault_password": {
label: "Vault Password", label: "Vault Password",
@@ -341,7 +360,8 @@ export default
editRequired: false, editRequired: false,
ask: true, ask: true,
hasShowInputButton: true, hasShowInputButton: true,
autocomplete: false autocomplete: false,
subForm: 'credentialSubForm'
} }
}, },

View File

@@ -19,6 +19,10 @@ angular.module('ProjectFormDefinition', ['SchedulesListDefinition'])
name: 'project', name: 'project',
forceListeners: true, forceListeners: true,
tabs: true, tabs: true,
subFormTitles: {
sourceSubForm: 'Source Details',
},
fields: { fields: {
name: { name: {
@@ -62,7 +66,8 @@ angular.module('ProjectFormDefinition', ['SchedulesListDefinition'])
ngOptions: 'type.label for type in scm_type_options track by type.value', ngOptions: 'type.label for type in scm_type_options track by type.value',
ngChange: 'scmChange()', ngChange: 'scmChange()',
addRequired: true, addRequired: true,
editRequired: true editRequired: true,
hasSubForm: true
}, },
missing_path_alert: { missing_path_alert: {
type: 'alertblock', type: 'alertblock',
@@ -112,6 +117,7 @@ angular.module('ProjectFormDefinition', ['SchedulesListDefinition'])
variable: "scmRequired", variable: "scmRequired",
init: false init: false
}, },
subForm: 'sourceSubForm',
helpCollapse: [{ helpCollapse: [{
hdr: 'GIT URLs', hdr: 'GIT URLs',
content: '<p>Example URLs for GIT SCM include:</p><ul class=\"no-bullets\"><li>https://github.com/ansible/ansible.git</li>' + content: '<p>Example URLs for GIT SCM include:</p><ul class=\"no-bullets\"><li>https://github.com/ansible/ansible.git</li>' +
@@ -135,14 +141,15 @@ angular.module('ProjectFormDefinition', ['SchedulesListDefinition'])
'Do not put the username and key in the URL. ' + 'Do not put the username and key in the URL. ' +
'If using Bitbucket and SSH, do not supply your Bitbucket username.', 'If using Bitbucket and SSH, do not supply your Bitbucket username.',
show: "scm_type.value == 'hg'" show: "scm_type.value == 'hg'"
}] }],
}, },
scm_branch: { scm_branch: {
labelBind: "scmBranchLabel", labelBind: "scmBranchLabel",
type: 'text', type: 'text',
ngShow: "scm_type && scm_type.value !== 'manual'", ngShow: "scm_type && scm_type.value !== 'manual'",
addRequired: false, addRequired: false,
editRequired: false editRequired: false,
subForm: 'sourceSubForm'
}, },
credential: { credential: {
label: 'SCM Credential', label: 'SCM Credential',
@@ -152,12 +159,14 @@ angular.module('ProjectFormDefinition', ['SchedulesListDefinition'])
sourceField: 'name', sourceField: 'name',
ngClick: 'lookUpCredential()', ngClick: 'lookUpCredential()',
addRequired: false, addRequired: false,
editRequired: false editRequired: false,
subForm: 'sourceSubForm'
}, },
checkbox_group: { checkbox_group: {
label: 'SCM Update Options', label: 'SCM Update Options',
type: 'checkbox_group', type: 'checkbox_group',
ngShow: "scm_type && scm_type.value !== 'manual'", ngShow: "scm_type && scm_type.value !== 'manual'",
subForm: 'sourceSubForm',
fields: [{ fields: [{
name: 'scm_clean', name: 'scm_clean',
label: 'Clean', label: 'Clean',

View File

@@ -1476,6 +1476,9 @@ angular.module('FormGenerator', [GeneratorHelpers.name, 'Utilities', listGenerat
} }
html += "</div>\n"; html += "</div>\n";
} else { } else {
var inSubForm = false;
var currentSubForm = undefined;
var hasSubFormField;
// original, single-column form // original, single-column form
section = ''; section = '';
group = ''; group = '';
@@ -1502,9 +1505,33 @@ angular.module('FormGenerator', [GeneratorHelpers.name, 'Utilities', listGenerat
html += "<div" + sectionShow + ">\n"; html += "<div" + sectionShow + ">\n";
section = field.section; section = field.section;
} }
// To hide/show the subform when the value changes on parent
if (field.hasSubForm === true) {
hasSubFormField = fld;
}
// Add a subform container
if(field.subForm && currentSubForm === undefined) {
currentSubForm = field.subForm;
var subFormTitle = this.form.subFormTitles[field.subForm];
html += '<div class="Form-subForm '+ currentSubForm + '" ng-hide="'+ hasSubFormField + '.value === undefined"> ';
html += '<span class="Form-subForm--title">'+ subFormTitle +'</span>';
}
else if (!field.subForm && currentSubForm !== undefined) {
currentSubForm = undefined;
html += '</div></div> ';
}
html += this.buildField(fld, field, options, this.form); html += this.buildField(fld, field, options, this.form);
} }
} }
if (currentSubForm) {
currentSubForm = undefined;
html += '</div>';
}
if (section !== '') { if (section !== '') {
html += "</div>\n</div>\n"; html += "</div>\n</div>\n";
} }