AC-411 Asterisk displayed left of label on all required fields. Inventory tweaks.

This commit is contained in:
chouseknecht 2013-09-09 00:31:31 -04:00
parent f9a1614730
commit a7d1c3faf0
6 changed files with 29 additions and 17 deletions

View File

@ -50,8 +50,6 @@ angular.module('InventoryFormDefinition', [])
type: 'lookup',
sourceModel: 'organization',
sourceField: 'name',
addRequired: true,
editRequired: true,
ngClick: 'lookUpOrganization()',
awRequiredWhen: {variable: "organizationrequired", init: "true" }
},

View File

@ -54,21 +54,21 @@ angular.module('InventoryHostsFormDefinition', [])
actions: {
add: {
label: 'Add Existing Host',
label: 'Copy',
ngClick: "addHost()",
ngHide: "hostAddHide",
awToolTip: "Select from a list of existing hosts",
awToolTip: "Copy an existing host to the selected group",
dataPlacement: 'bottom',
'class': 'btn-xs btn-primary',
'class': 'btn-sm btn-primary',
icon: 'icon-check'
},
create: {
label: 'Create New Host',
label: 'Create New',
ngClick: 'createHost()',
ngHide: 'hostCreateHide',
awToolTip: 'Create a new host',
awToolTip: 'Create a new host and add it to the selected group',
dataPlacement: 'bottom',
'class': 'btn-xs btn-success',
'class': 'btn-sm btn-success',
icon: 'icon-plus'
}
},

View File

@ -38,8 +38,6 @@ angular.module('TeamFormDefinition', [])
type: 'lookup',
sourceModel: 'organization',
sourceField: 'name',
addRequired: true,
editRequired: true,
ngClick: 'lookUpOrganization()',
awRequiredWhen: {variable: "teamrequired", init: "true" }
}

View File

@ -25,6 +25,7 @@ body {
/* Helper Classes */
.pad-right-sm { padding-right: 10px; }
.pad-left-lg { padding-left: 50px; }
.spinny {
display: none;
@ -633,6 +634,7 @@ select.field-mini-height {
.title {
display: inline-block;
padding-top: 7px;
color: #555;
font-size: 14px;
font-weight: normal;

View File

@ -110,9 +110,18 @@ angular.module('AWDirectives', ['RestServices', 'Utilities', 'AuthService', 'Hos
validity = true;
if ( scope[attrs.awRequiredWhen] && (elm.attr('required') == null || elm.attr('required') == undefined) ) {
$(elm).attr('required','required');
console.log('here');
if ($(elm).hasClass('lookup')) {
console.log('adding!');
$(elm).parent().parent().parent().find('label').prepend('* ');
}
}
else if (!scope[attrs.awRequiredWhen]) {
elm.removeAttr('required');
elm.removeAttr('required');
if ($(elm).hasClass('lookup')) {
var txt = $(elm).parent().parent().parent().find('label').text();
$(elm).parent().parent().parent().find('label').text(txt.replace(/^*/,''));
}
}
if (scope[attrs.awRequiredWhen] && (viewValue == undefined || viewValue == null || viewValue == '')) {
validity = false;

View File

@ -88,6 +88,11 @@ angular.module('FormGenerator', ['GeneratorHelpers', 'ngCookies'])
$(this).remove();
});
// Prepend an asterisk to required field label
$('.form-control[required]').each(function() {
var txt = $(this).parent().parent().find('label').prepend('* ');
});
if (options.modal) {
this.scope.formModalActionDisabled = false;
this.scope.formModalInfo = false //Disable info button for default modal
@ -680,7 +685,7 @@ angular.module('FormGenerator', ['GeneratorHelpers', 'ngCookies'])
html += "<span class=\"input-group-btn\">\n";
html += "<button type=\"button\" class=\"lookup-btn btn btn-default\" " + this.attr(field,'ngClick') + "><i class=\"icon-search\"></i></button>\n";
html += "</span>\n";
html += "<input type=\"text\" class=\"form-control input-medium\" ";
html += "<input type=\"text\" class=\"form-control input-medium lookup\" ";
html += "ng-model=\"" + field.sourceModel + '_' + field.sourceField + "\" ";
html += "name=\"" + field.sourceModel + '_' + field.sourceField + "\" ";
html += "class=\"form-control\" ";
@ -1047,16 +1052,16 @@ angular.module('FormGenerator', ['GeneratorHelpers', 'ngCookies'])
//html += "<button type=\"button\" class=\"btn btn-default btn-xs\" ng-click=\"editInventory()\" ng-hide=\"inventoryEditHide\" " +
// "aw-tool-tip=\"Edit inventory properties\" data-placement=\"bottom\"><i class=\"icon-edit\"></i> " +
// "Inventory Properties</button>\n";
html += "<button type=\"button\" class=\"btn btn-default btn-xs\" ng-click=\"editGroup()\" ng-hide=\"groupEditHide\" " +
html += "<button type=\"button\" class=\"btn btn-default btn-sm\" ng-click=\"editGroup()\" ng-hide=\"groupEditHide\" " +
"aw-tool-tip=\"Edit the selected group's properties\" data-placement=\"bottom\"><i class=\"icon-edit\"></i> " +
"Properties</button>\n";
//html += "<button type=\"button\" class=\"btn btn-default btn-xs\" ng-click=\"editHosts()\" ng-hide=\"showGroupHelp\" " +
// "aw-tool-tip=\"Modify and create inventory hosts\" data-placement=\"bottom\"><i class=\"icon-laptop\"></i> Hosts</button>\n";
html += "<button type=\"button\" class=\"btn btn-success btn-xs\" ng-click=\"addGroup()\" ng-hide=\"groupAddHide\" " +
html += "<button type=\"button\" class=\"btn btn-success btn-sm\" ng-click=\"addGroup()\" ng-hide=\"groupAddHide\" " +
"aw-tool-tip=\"Copy existing groups to the selected group\" data-placement=\"bottom\"><i class=\"icon-check\"></i> Copy</button>\n";
html += "<button type=\"button\" class=\"btn btn-success btn-xs\" ng-click=\"createGroup()\" ng-hide=\"groupCreateHide\" " +
html += "<button type=\"button\" class=\"btn btn-success btn-sm\" ng-click=\"createGroup()\" ng-hide=\"groupCreateHide\" " +
"aw-tool-tip=\"Create a brand new group and add it to the selected group\" data-placement=\"bottom\"><i class=\"icon-plus\"></i> Create New</button>\n";
html += "<button type=\"button\" class=\"btn btn-danger btn-xs\" ng-click=\"deleteGroup()\" ng-hide=\"groupDeleteHide\" " +
html += "<button type=\"button\" class=\"btn btn-danger btn-sm\" ng-click=\"deleteGroup()\" ng-hide=\"groupDeleteHide\" " +
"aw-tool-tip=\"Permanently delete the selected group. Any hosts in the group will still be available in All Hosts.\" " +
"data-placement=\"bottom\"><i class=\"icon-trash\"></i> Delete</button>\n";
html += "</div><!-- tree controls -->\n";
@ -1095,7 +1100,7 @@ angular.module('FormGenerator', ['GeneratorHelpers', 'ngCookies'])
html += "<div class=\"hosts-well well\">\n";
html += SearchWidget({ iterator: form.iterator, template: form, mini: true, size: 'col-md-6 col-lg-6'});
html += "<div class=\"col-md-6 col-lg-6\">\n"
html += "<div class=\"col-md-5 col-lg-5\">\n"
html += "<div class=\"pull-right\">\n";
// Add actions(s)
for (var action in form.actions) {