Merge pull request #368 from mabashian/7549-auto-pop

Removed prepend-asterisk in favor of an injected span
This commit is contained in:
Michael Abashian 2017-09-01 11:30:18 -04:00 committed by GitHub
commit f314367bc8
14 changed files with 88 additions and 75 deletions

View File

@ -342,16 +342,6 @@ textarea.allowresize {
}
}
.prepend-asterisk:before {
content: "\002A\00A0";
color: @red;
margin-right: -5px;
}
.prepend-asterisk.user-password:before {
margin-right: 0;
}
.subtitle {
font-size: 16px;
}

View File

@ -700,6 +700,10 @@ input[type='radio']:checked:before {
width: 30px;
}
.Form-requiredAsterisk {
color: @red;
}
@media only screen and (max-width: 650px) {
.Form-formGroup {
flex: 1 0 auto;

View File

@ -56,7 +56,7 @@
$state.go('inventories.edit.groups.edit', {inventory_id: $scope.inventory_id, group_id: id});
};
$scope.goToGroupGroups = function(id){console.log();
$scope.goToGroupGroups = function(id){
$state.go('inventories.edit.groups.edit.nested_groups', {inventory_id: $scope.inventory_id, group_id: id});
};

View File

@ -41,10 +41,7 @@ export default ['i18n', function(i18n) {
type: 'lookup',
list: 'OrganizationList',
basePath: 'organizations',
awRequiredWhen: {
reqExpression: "orgrequired",
init: true
},
required: true,
sourceModel: 'organization',
sourceField: 'name',
ngDisabled: '!(inventory_script_obj.summary_fields.user_capabilities.edit || canAdd)'

View File

@ -12,7 +12,7 @@ export default
.success(function (data) {
credentialTypesLookup()
.then(kinds => {
if(data.credential_type === kinds.Machine && data.inputs){console.log(data.inputs);
if(data.credential_type === kinds.Machine && data.inputs){
if(data.inputs.password === "ASK" ){
passwords.push("ssh_password");
}

View File

@ -17,8 +17,11 @@ export default
field = form.fields[password];
fld = password;
scope[fld] = '';
html += "<div class=\"form-group prepend-asterisk\">\n";
html += "<label for=\"" + fld + "\">" + field.label + "</label>\n";
html += "<div class=\"form-group\">\n";
html += "<label for=\"" + fld + "\">";
html += '<span class="Form-requiredAsterisk">*</span>';
html += '<span>' + field.label + '</span>';
html += "</label>\n";
html += "<input type=\"password\" ";
html += "ng-model=\"" + fld + '" ';
html += 'name="' + fld + '" ';
@ -37,8 +40,9 @@ export default
fld = field.associated;
field = form.fields[field.associated];
scope[fld] = '';
html += "<div class=\"form-group prepend-asterisk\">\n";
html += "<div class=\"form-group\">\n";
html += "<label for=\"" + fld + "\"> " + field.label + "</label>\n";
html += '<span class="Form-requiredAsterisk">*</span>';
html += "<input type=\"password\" ";
html += "ng-model=\"" + fld + '" ';
html += 'name="' + fld + '" ';

View File

@ -99,7 +99,8 @@
<div class="JobSubmission-instructions" translate>Launching this job requires the passwords listed below. Enter and confirm each password before continuing.</div>
<form name="forms.credentialpasswords" autocomplete="off" novalidate>
<div class="form-group Form-formGroup Form-formGroup--singleColumn" ng-if="ssh_password_required">
<label for="ssh_password" class="prepend-asterisk Form-inputLabelContainer">
<label for="ssh_password" class="Form-inputLabelContainer">
<span class="Form-requiredAsterisk">*</span>
<span class="Form-inputLabel" translate> Password</span>
</label>
<div class="input-group">
@ -112,7 +113,8 @@
<div class="error api-error" ng-bind="ssh_password_api_error"></div>
</div>
<div class="form-group Form-formGroup Form-formGroup--singleColumn" ng-if="ssh_key_unlock_required">
<label for="ssh_key_unlock" class="prepend-asterisk Form-inputLabelContainer">
<label for="ssh_key_unlock" class="Form-inputLabelContainer">
<span class="Form-requiredAsterisk">*</span>
<span class="Form-inputLabel" translate> Private Key Passphrase</span>
</label>
<div class="input-group">
@ -125,7 +127,8 @@
<div class="error api-error" ng-bind="ssh_key_unlock_api_error"></div>
</div>
<div class="form-group Form-formGroup Form-formGroup--singleColumn" ng-if="become_password_required">
<label for="become_password" class="prepend-asterisk Form-inputLabelContainer">
<label for="become_password" class="Form-inputLabelContainer">
<span class="Form-requiredAsterisk">*</span>
<span class="Form-inputLabel" translate> Privilege Escalation Password</span>
</label>
<div class="input-group">
@ -138,7 +141,8 @@
<div class="error api-error" ng-bind="become_password_api_error"></div>
</div>
<div class="form-group Form-formGroup Form-formGroup--singleColumn" ng-if="vault_password_required">
<label for="vault_password" class="prepend-asterisk Form-inputLabelContainer">
<label for="vault_password" class="Form-inputLabelContainer">
<span class="Form-requiredAsterisk">*</span>
<span class="Form-inputLabel" translate> Vault Password</span>
</label>
<div class="input-group">
@ -174,7 +178,8 @@
</div>
</div>
<div class="form-group Form-formGroup Form-formGroup--singleColumn" ng-if="ask_verbosity_on_launch">
<label for="verbosity" class="prepend-asterisk Form-inputLabelContainer">
<label for="verbosity" class="Form-inputLabelContainer">
<span class="Form-requiredAsterisk">*</span>
<span class="Form-inputLabel" translate> Verbosity</span>
</label>
<div>
@ -192,7 +197,8 @@
</div>
</div>
<div class="form-group Form-formGroup Form-formGroup--singleColumn" ng-if="ask_job_type_on_launch">
<label for="job_type" class="prepend-asterisk Form-inputLabelContainer">
<label for="job_type" class="Form-inputLabelContainer">
<span class="Form-requiredAsterisk">*</span>
<span class="Form-inputLabel" translate> Job Type</span>
</label>
<div>
@ -269,7 +275,8 @@
<div ng-if="survey_enabled" ng-show="step === 'survey'" class="JobSubmission-form">
<form name="forms.survey" autocomplete="off" novalidate>
<div ng-repeat="question in survey_questions" id="taker_'+question.index+'" class="form-group Form-formGroup Form-formGroup--singleColumn">
<label ng-attr-for="{{question.variable}}" class="Form-inputLabelContainer" ng-class="{'prepend-asterisk': question.required===true}">
<label ng-attr-for="{{question.variable}}" class="Form-inputLabelContainer">
<span ng-show="question.required===true" class="Form-requiredAsterisk">*</span>
<span class="label-text Form-inputLabel"> {{question.question_name}}</span>
</label>

View File

@ -99,13 +99,18 @@
</div>
<form id="License-form" name="uploadlicense">
<div class="License-subTitleText prepend-asterisk"> <translate>License File</translate></div>
<div class="License-subTitleText">
<span class="Form-requiredAsterisk">*</span>
<translate>License File</translate>
</div>
<div class="input-group License-file--container">
<span class="btn btn-primary" ng-click="fakeClick()" ng-disabled="!user_is_superuser" translate>Browse</span>
<span class="License-fileName" ng-class="{'License-helperText' : fileName == 'No file selected.'}">{{fileName|translate}}</span>
<input id="License-file" class="form-control" type="file" file-on-change="getKey"/>
</div>
<div class="License-subTitleText prepend-asterisk"> <translate>End User License Agreement</translate>
<div class="License-subTitleText">
<span class="Form-requiredAsterisk">*</span>
<translate>End User License Agreement</translate>
</div>
<div id="eula_notice"
class="License-eulaNotice">{{ license.eula }}</div>

View File

@ -48,7 +48,8 @@
<dnd-nodrag>
<div>
<label class="SurveyMaker-previewLabel" for="question.variable">
<span class="label-text" ng-class="{'prepend-asterisk': question.required}"> {{question.question_name}}</span>
<span ng-show="question.required===true" class="Form-requiredAsterisk">*</span>
<span class="label-text"> {{question.question_name}}</span>
</label>
</div>

View File

@ -421,43 +421,47 @@ function(ConfigurationUtils, i18n, $rootScope) {
return {
require: 'ngModel',
compile: function(tElem) {
let label = $(tElem).closest('.form-group').find('label').first();
$(label).addClass('prepend-asterisk');
},
link: function(scope, elm, attrs, ctrl) {
return {
pre: function preLink() {
let label = $(tElem).closest('.form-group').find('label').first();
$(label).prepend('<span class="Form-requiredAsterisk">*</span>');
},
post: function postLink( scope, elm, attrs, ctrl ) {
function updateRequired() {
var isRequired = scope.$eval(attrs.awRequiredWhen);
function updateRequired() {
var isRequired = scope.$eval(attrs.awRequiredWhen);
var viewValue = elm.val(),
label, validity = true;
label = $(elm).closest('.form-group').find('label').first();
var viewValue = elm.val(),
label, validity = true;
label = $(elm).closest('.form-group').find('label').first();
if (isRequired && (elm.attr('required') === null || elm.attr('required') === undefined)) {
$(elm).attr('required', 'required');
if(!$(label).find('span.Form-requiredAsterisk').length){
$(label).prepend('<span class="Form-requiredAsterisk">*</span>');
}
} else if (!isRequired) {
elm.removeAttr('required');
if (!attrs.awrequiredAlwaysShowAsterisk) {
$(label).find('span.Form-requiredAsterisk')[0].remove();
}
}
if (isRequired && (viewValue === undefined || viewValue === null || viewValue === '')) {
validity = false;
}
ctrl.$setValidity('required', validity);
}
if (isRequired && (elm.attr('required') === null || elm.attr('required') === undefined)) {
$(elm).attr('required', 'required');
$(label).removeClass('prepend-asterisk').addClass('prepend-asterisk');
} else if (!isRequired) {
elm.removeAttr('required');
if (!attrs.awrequiredAlwaysShowAsterisk) {
$(label).removeClass('prepend-asterisk');
scope.$watchGroup([attrs.awRequiredWhen, $(elm).attr('name')], function() {
// watch for the aw-required-when expression to change value
updateRequired();
});
if (attrs.awrequiredInit !== undefined && attrs.awrequiredInit !== null) {
// We already set a watcher on the attribute above so no need to call updateRequired() in here
scope[attrs.awRequiredWhen] = attrs.awrequiredInit;
}
}
if (isRequired && (viewValue === undefined || viewValue === null || viewValue === '')) {
validity = false;
}
ctrl.$setValidity('required', validity);
}
scope.$watchGroup([attrs.awRequiredWhen, $(elm).attr('name')], function() {
// watch for the aw-required-when expression to change value
updateRequired();
});
if (attrs.awrequiredInit !== undefined && attrs.awrequiredInit !== null) {
// We already set a watcher on the attribute above so no need to call updateRequired() in here
scope[attrs.awRequiredWhen] = attrs.awrequiredInit;
}
};
}
};
})

View File

@ -633,15 +633,17 @@ angular.module('FormGenerator', [GeneratorHelpers.name, 'Utilities', listGenerat
if (field.label || field.labelBind) {
html += "<label class=\"";
html += (field.labelClass) ? field.labelClass : "";
html += `${field.required ? ' prepend-asterisk ' : ''}`;
html += (horizontal) ? " " + getLabelWidth() : "Form-inputLabelContainer ";
html += (field.showParseTypeToggle) ? "Form-inputLabelContainer--codeMirror " : "";
html += "\" ";
html += (field.labelNGClass) ? "ng-class=\"" + field.labelNGClass + "\" " : "";
html += "for=\"" + fld + '">\n';
html += `${field.required ? '<span class="Form-requiredAsterisk">*</span>' : ''}`;
html += (field.icon) ? Icon(field.icon) : "";
if (field.labelBind) {
html += "\t\t<span ng-class=class=\"Form-inputLabel\" ng-bind=\"" + field.labelBind + "\" translate>\n\t\t</span>";
html += "\t\t<span class=\"Form-inputLabel\" ng-bind=\"" + field.labelBind + "\" translate>\n\t\t</span>";
} else {
html += "\t\t<span class=\"Form-inputLabel\" translate>\n\t\t\t" + field.label + "\n\t\t</span>";
}

View File

@ -94,10 +94,7 @@ function(NotificationsList, CompletedJobsList, i18n) {
basePath: 'projects',
sourceModel: 'project',
sourceField: 'name',
awRequiredWhen: {
reqExpression: "projectrequired",
init: "true"
},
required: true,
column: 1,
awPopOver: "<p>" + i18n._("Select the project containing the playbook you want this job to execute.") + "</p>",
dataTitle: i18n._('Project'),
@ -111,10 +108,7 @@ function(NotificationsList, CompletedJobsList, i18n) {
ngOptions: 'book for book in playbook_options track by book',
ngDisabled: "!(job_template_obj.summary_fields.user_capabilities.edit || canAddJobTemplate) || disablePlaybookBecausePermissionDenied",
id: 'playbook-select',
awRequiredWhen: {
reqExpression: "playbookrequired",
init: "true"
},
required: true,
column: 1,
awPopOver: "<p>" + i18n._("Select the playbook to be executed by this job.") + "</p>",
dataTitle: i18n._('Playbook'),

View File

@ -28,6 +28,7 @@ export default ['$scope', '$rootScope', 'UserForm', 'GenerateForm', 'Rest',
// apply form definition's default field values
GenerateForm.applyDefaults(form, $scope);
$scope.isAddForm = true;
$scope.ldap_user = false;
$scope.not_ldap_user = !$scope.ldap_user;
$scope.ldap_dn = null;

View File

@ -69,8 +69,10 @@ export default ['i18n', function(i18n) {
type: 'sensitive',
hasShowInputButton: true,
ngShow: 'ldap_user == false && socialAuthUser === false && external_account === null',
ngRequired: "$state.match('add')",
labelNGClass: "{'prepend-asterisk user-password' : $state.matches('add')}",
awRequiredWhen: {
reqExpression: "isAddForm",
init: false
},
ngChange: "clearPWConfirm('password_confirm')",
autocomplete: false,
ngDisabled: '!(user_obj.summary_fields.user_capabilities.edit || canAdd)'
@ -80,8 +82,10 @@ export default ['i18n', function(i18n) {
type: 'sensitive',
hasShowInputButton: true,
ngShow: 'ldap_user == false && socialAuthUser === false && external_account === null',
ngRequired: "$state.match('add')",
labelNGClass: "{'prepend-asterisk user-password' : $state.matches('add')}",
awRequiredWhen: {
reqExpression: "isAddForm",
init: false
},
awPassMatch: true,
associated: 'password',
autocomplete: false,