mirror of
https://github.com/ansible/awx.git
synced 2026-02-22 05:30:18 -03:30
Finished security around user->permissions and team->permissions. Found bugs in permission controller that appeared as though some development had not been finished. User was denied access to edit/view when clicking button but not when entering URL directly in browser. Now non-privileged user can view permssions for Users and Teams to which access is granted. Add and Delete buttons are now hidden where access is disallowed and navigating directly to add page throws an error when Save button clicked.
Fixed issue where new CSS for adding asterisk to required fields caused login dialog fields to display multiple asterisks. Modified form generator to show help icon to the left of * on required fields.
This commit is contained in:
1
.gitignore
vendored
1
.gitignore
vendored
@@ -20,3 +20,4 @@ coverage.xml
|
|||||||
pep8.txt
|
pep8.txt
|
||||||
.vagrant*
|
.vagrant*
|
||||||
.tox
|
.tox
|
||||||
|
nohup.out
|
||||||
|
|||||||
@@ -15,6 +15,8 @@ function PermissionsList ($scope, $rootScope, $location, $log, $routeParams, Res
|
|||||||
var scope = view.inject(list, { mode: 'edit' }); // Inject our view
|
var scope = view.inject(list, { mode: 'edit' }); // Inject our view
|
||||||
scope.selected = [];
|
scope.selected = [];
|
||||||
|
|
||||||
|
CheckAccess({ scope: scope });
|
||||||
|
|
||||||
SearchInit({ scope: scope, set: 'permissions', list: list, url: defaultUrl });
|
SearchInit({ scope: scope, set: 'permissions', list: list, url: defaultUrl });
|
||||||
PaginateInit({ scope: scope, list: list, url: defaultUrl });
|
PaginateInit({ scope: scope, list: list, url: defaultUrl });
|
||||||
scope.search(list.iterator);
|
scope.search(list.iterator);
|
||||||
@@ -22,15 +24,13 @@ function PermissionsList ($scope, $rootScope, $location, $log, $routeParams, Res
|
|||||||
LoadBreadCrumbs();
|
LoadBreadCrumbs();
|
||||||
|
|
||||||
scope.addPermission = function() {
|
scope.addPermission = function() {
|
||||||
if (CheckAccess()) {
|
if (scope.PermissionAddAllowed) {
|
||||||
$location.path($location.path() + '/add');
|
$location.path($location.path() + '/add');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
scope.editPermission = function(id) {
|
scope.editPermission = function(id) {
|
||||||
if (CheckAccess()) {
|
$location.path($location.path() + '/' + id);
|
||||||
$location.path($location.path() + '/' + id);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
scope.deletePermission = function(id, name) {
|
scope.deletePermission = function(id, name) {
|
||||||
@@ -45,11 +45,11 @@ function PermissionsList ($scope, $rootScope, $location, $log, $routeParams, Res
|
|||||||
.error( function(data, status, headers, config) {
|
.error( function(data, status, headers, config) {
|
||||||
$('#prompt-modal').modal('hide');
|
$('#prompt-modal').modal('hide');
|
||||||
ProcessErrors(scope, data, status, null,
|
ProcessErrors(scope, data, status, null,
|
||||||
{ hdr: 'Error!', msg: 'Call to ' + url + ' failed. DELETE returned status: ' + status });
|
{ hdr: 'Error!', msg: 'Call to ' + url + ' failed. DELETE returned status: ' + status });
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
if (checkAccess()) {
|
if (scope.PermissionAddAllowed) {
|
||||||
Prompt({ hdr: 'Delete',
|
Prompt({ hdr: 'Delete',
|
||||||
body: 'Are you sure you want to delete ' + name + '?',
|
body: 'Are you sure you want to delete ' + name + '?',
|
||||||
action: action
|
action: action
|
||||||
@@ -66,7 +66,7 @@ PermissionsList.$inject = [ '$scope', '$rootScope', '$location', '$log', '$route
|
|||||||
|
|
||||||
function PermissionsAdd ($scope, $rootScope, $compile, $location, $log, $routeParams, PermissionsForm,
|
function PermissionsAdd ($scope, $rootScope, $compile, $location, $log, $routeParams, PermissionsForm,
|
||||||
GenerateForm, Rest, Alert, ProcessErrors, LoadBreadCrumbs, ClearScope,
|
GenerateForm, Rest, Alert, ProcessErrors, LoadBreadCrumbs, ClearScope,
|
||||||
GetBasePath, ReturnToCaller, InventoryList, ProjectList, LookUpInit)
|
GetBasePath, ReturnToCaller, InventoryList, ProjectList, LookUpInit, CheckAccess)
|
||||||
{
|
{
|
||||||
ClearScope('htmlTemplate'); //Garbage collection. Don't leave behind any listeners/watchers from the prior
|
ClearScope('htmlTemplate'); //Garbage collection. Don't leave behind any listeners/watchers from the prior
|
||||||
//scope.
|
//scope.
|
||||||
@@ -80,6 +80,7 @@ function PermissionsAdd ($scope, $rootScope, $compile, $location, $log, $routePa
|
|||||||
var scope = generator.inject(form, {mode: 'add', related: false});
|
var scope = generator.inject(form, {mode: 'add', related: false});
|
||||||
var master = {};
|
var master = {};
|
||||||
|
|
||||||
|
CheckAccess({ scope: scope })
|
||||||
generator.reset();
|
generator.reset();
|
||||||
LoadBreadCrumbs();
|
LoadBreadCrumbs();
|
||||||
|
|
||||||
@@ -108,20 +109,25 @@ function PermissionsAdd ($scope, $rootScope, $compile, $location, $log, $routePa
|
|||||||
|
|
||||||
// Save
|
// Save
|
||||||
scope.formSave = function() {
|
scope.formSave = function() {
|
||||||
var data = {};
|
if (scope.PermissionAddAllowed) {
|
||||||
for (var fld in form.fields) {
|
var data = {};
|
||||||
data[fld] = scope[fld];
|
for (var fld in form.fields) {
|
||||||
|
data[fld] = scope[fld];
|
||||||
|
}
|
||||||
|
var url = (base == 'teams') ? GetBasePath('teams') + id + '/permissions/' : GetBasePath('users') + id + '/permissions/';
|
||||||
|
Rest.setUrl(url);
|
||||||
|
Rest.post(data)
|
||||||
|
.success( function(data, status, headers, config) {
|
||||||
|
ReturnToCaller(1);
|
||||||
|
})
|
||||||
|
.error( function(data, status, headers, config) {
|
||||||
|
ProcessErrors(scope, data, status, PermissionsForm,
|
||||||
|
{ hdr: 'Error!', msg: 'Failed to create new permission. Post returned status: ' + status });
|
||||||
|
});
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
Alert('Access Denied', 'You do not have access to create new permission objects. Please contact a system administrator.', 'alert-danger');
|
||||||
}
|
}
|
||||||
var url = (base == 'teams') ? GetBasePath('teams') + id + '/permissions/' : GetBasePath('users') + id + '/permissions/';
|
|
||||||
Rest.setUrl(url);
|
|
||||||
Rest.post(data)
|
|
||||||
.success( function(data, status, headers, config) {
|
|
||||||
ReturnToCaller(1);
|
|
||||||
})
|
|
||||||
.error( function(data, status, headers, config) {
|
|
||||||
ProcessErrors(scope, data, status, PermissionsForm,
|
|
||||||
{ hdr: 'Error!', msg: 'Failed to create new permission. Post returned status: ' + status });
|
|
||||||
});
|
|
||||||
};
|
};
|
||||||
|
|
||||||
// Cancel
|
// Cancel
|
||||||
@@ -146,13 +152,13 @@ function PermissionsAdd ($scope, $rootScope, $compile, $location, $log, $routePa
|
|||||||
|
|
||||||
PermissionsAdd.$inject = [ '$scope', '$rootScope', '$compile', '$location', '$log', '$routeParams', 'PermissionsForm',
|
PermissionsAdd.$inject = [ '$scope', '$rootScope', '$compile', '$location', '$log', '$routeParams', 'PermissionsForm',
|
||||||
'GenerateForm', 'Rest', 'Alert', 'ProcessErrors', 'LoadBreadCrumbs', 'ClearScope', 'GetBasePath',
|
'GenerateForm', 'Rest', 'Alert', 'ProcessErrors', 'LoadBreadCrumbs', 'ClearScope', 'GetBasePath',
|
||||||
'ReturnToCaller', 'InventoryList', 'ProjectList', 'LookUpInit'
|
'ReturnToCaller', 'InventoryList', 'ProjectList', 'LookUpInit', 'CheckAccess'
|
||||||
];
|
];
|
||||||
|
|
||||||
|
|
||||||
function PermissionsEdit ($scope, $rootScope, $compile, $location, $log, $routeParams, PermissionsForm,
|
function PermissionsEdit ($scope, $rootScope, $compile, $location, $log, $routeParams, PermissionsForm,
|
||||||
GenerateForm, Rest, Alert, ProcessErrors, LoadBreadCrumbs, ReturnToCaller,
|
GenerateForm, Rest, Alert, ProcessErrors, LoadBreadCrumbs, ReturnToCaller,
|
||||||
ClearScope, Prompt, GetBasePath, InventoryList, ProjectList, LookUpInit)
|
ClearScope, Prompt, GetBasePath, InventoryList, ProjectList, LookUpInit, CheckAccess)
|
||||||
{
|
{
|
||||||
ClearScope('htmlTemplate'); //Garbage collection. Don't leave behind any listeners/watchers from the prior
|
ClearScope('htmlTemplate'); //Garbage collection. Don't leave behind any listeners/watchers from the prior
|
||||||
//scope.
|
//scope.
|
||||||
@@ -169,6 +175,7 @@ function PermissionsEdit ($scope, $rootScope, $compile, $location, $log, $routeP
|
|||||||
var master = {};
|
var master = {};
|
||||||
var relatedSets = {};
|
var relatedSets = {};
|
||||||
|
|
||||||
|
CheckAccess({ scope: scope })
|
||||||
|
|
||||||
// Retrieve detail record and prepopulate the form
|
// Retrieve detail record and prepopulate the form
|
||||||
Rest.setUrl(defaultUrl);
|
Rest.setUrl(defaultUrl);
|
||||||
@@ -215,6 +222,20 @@ function PermissionsEdit ($scope, $rootScope, $compile, $location, $log, $routeP
|
|||||||
list: ProjectList,
|
list: ProjectList,
|
||||||
field: 'project'
|
field: 'project'
|
||||||
});
|
});
|
||||||
|
|
||||||
|
if (!scope.PermissionAddAllowed) {
|
||||||
|
// If not a privileged user, disable access
|
||||||
|
$('form[name="permission_form"]').find('select, input, button').each(function(index){
|
||||||
|
if ($(this).is('input') || $(this).is('select')) {
|
||||||
|
$(this).attr('readonly','readonly');
|
||||||
|
}
|
||||||
|
if ( $(this).is('input[type="checkbox"]') ||
|
||||||
|
$(this).is('input[type="radio"]') ||
|
||||||
|
$(this).is('button') ) {
|
||||||
|
$(this).attr('disabled','disabled');
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
})
|
})
|
||||||
.error( function(data, status, headers, config) {
|
.error( function(data, status, headers, config) {
|
||||||
ProcessErrors(scope, data, status, form,
|
ProcessErrors(scope, data, status, form,
|
||||||
@@ -263,6 +284,6 @@ function PermissionsEdit ($scope, $rootScope, $compile, $location, $log, $routeP
|
|||||||
|
|
||||||
PermissionsEdit.$inject = [ '$scope', '$rootScope', '$compile', '$location', '$log', '$routeParams', 'PermissionsForm',
|
PermissionsEdit.$inject = [ '$scope', '$rootScope', '$compile', '$location', '$log', '$routeParams', 'PermissionsForm',
|
||||||
'GenerateForm', 'Rest', 'Alert', 'ProcessErrors', 'LoadBreadCrumbs', 'ReturnToCaller',
|
'GenerateForm', 'Rest', 'Alert', 'ProcessErrors', 'LoadBreadCrumbs', 'ReturnToCaller',
|
||||||
'ClearScope', 'Prompt', 'GetBasePath', 'InventoryList', 'ProjectList', 'LookUpInit'
|
'ClearScope', 'Prompt', 'GetBasePath', 'InventoryList', 'ProjectList', 'LookUpInit', 'CheckAccess'
|
||||||
];
|
];
|
||||||
|
|
||||||
|
|||||||
@@ -274,12 +274,7 @@ function TeamsEdit ($scope, $rootScope, $compile, $location, $log, $routeParams,
|
|||||||
scope.edit = function(set, id, name) {
|
scope.edit = function(set, id, name) {
|
||||||
$rootScope.flashMessage = null;
|
$rootScope.flashMessage = null;
|
||||||
if (set == 'permissions') {
|
if (set == 'permissions') {
|
||||||
if (scope.PermissionAddAllowed) {
|
$location.path('/' + base + '/' + $routeParams.team_id + '/' + set + '/' + id);
|
||||||
$location.path('/' + base + '/' + $routeParams.team_id + '/' + set + '/' + id);
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
Alert('Access Denied', 'You do not have access to this function. Please contact your system administrator.');
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
$location.path('/' + set + '/' + id);
|
$location.path('/' + set + '/' + id);
|
||||||
|
|||||||
@@ -201,11 +201,14 @@ function UsersEdit ($scope, $rootScope, $compile, $location, $log, $routeParams,
|
|||||||
scope.PermissionAddAllowed = false;
|
scope.PermissionAddAllowed = false;
|
||||||
|
|
||||||
// After the Organization is loaded, retrieve each related set
|
// After the Organization is loaded, retrieve each related set
|
||||||
scope.$on('userLoaded', function() {
|
if (scope.removeUserLoaded) {
|
||||||
|
scope.removeUserLoaded();
|
||||||
|
}
|
||||||
|
scope.removeUserLoaded = scope.$on('userLoaded', function() {
|
||||||
for (var set in relatedSets) {
|
for (var set in relatedSets) {
|
||||||
scope.search(relatedSets[set].iterator);
|
scope.search(relatedSets[set].iterator);
|
||||||
}
|
}
|
||||||
CheckAccess({ scope: scope }); //Does the user have access add Permissions?
|
CheckAccess({ scope: scope }); //Does the user have access to add/edit Permissions?
|
||||||
});
|
});
|
||||||
|
|
||||||
// Retrieve detail record and prepopulate the form
|
// Retrieve detail record and prepopulate the form
|
||||||
@@ -311,12 +314,7 @@ function UsersEdit ($scope, $rootScope, $compile, $location, $log, $routeParams,
|
|||||||
scope.edit = function(set, id, name) {
|
scope.edit = function(set, id, name) {
|
||||||
$rootScope.flashMessage = null;
|
$rootScope.flashMessage = null;
|
||||||
if (set == 'permissions') {
|
if (set == 'permissions') {
|
||||||
if (scope.PermissionAddAllowed) {
|
$location.path('/users/' + $routeParams.user_id + '/permissions/' + id);
|
||||||
$location.path('/users/' + $routeParams.user_id + '/permissions/' + id);
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
Alert('Access Denied', 'You do not have access to this function. Please contact your system administrator.');
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
$location.path('/' + set + '/' + id);
|
$location.path('/' + set + '/' + id);
|
||||||
|
|||||||
@@ -85,10 +85,10 @@ angular.module('JobTemplateFormDefinition', [])
|
|||||||
forks: {
|
forks: {
|
||||||
label: 'Forks',
|
label: 'Forks',
|
||||||
id: 'forks-number',
|
id: 'forks-number',
|
||||||
type: 'number',
|
type: 'text',
|
||||||
integer: true,
|
/*integer: true,
|
||||||
min: 0,
|
min: 0,
|
||||||
spinner: true,
|
spinner: true,*/
|
||||||
"default": '0',
|
"default": '0',
|
||||||
addRequired: false,
|
addRequired: false,
|
||||||
editRequired: false,
|
editRequired: false,
|
||||||
|
|||||||
@@ -116,7 +116,8 @@ angular.module('TeamFormDefinition', [])
|
|||||||
ngClick: "add('permissions')",
|
ngClick: "add('permissions')",
|
||||||
icon: 'icon-plus',
|
icon: 'icon-plus',
|
||||||
label: 'Add',
|
label: 'Add',
|
||||||
awToolTip: 'Add a permission for this user'
|
awToolTip: 'Add a permission for this user',
|
||||||
|
ngShow: 'PermissionAddAllowed'
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
@@ -157,7 +158,8 @@ angular.module('TeamFormDefinition', [])
|
|||||||
ngClick: "delete('permissions', \{\{ permission.id \}\}, '\{\{ permission.name \}\}', 'permissions')",
|
ngClick: "delete('permissions', \{\{ permission.id \}\}, '\{\{ permission.name \}\}', 'permissions')",
|
||||||
icon: 'icon-trash',
|
icon: 'icon-trash',
|
||||||
"class": 'btn-danger',
|
"class": 'btn-danger',
|
||||||
awToolTip: 'Delete the permission'
|
awToolTip: 'Delete the permission',
|
||||||
|
ngShow: 'PermissionAddAllowed'
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -164,7 +164,7 @@ angular.module('UserFormDefinition', [])
|
|||||||
icon: 'icon-plus',
|
icon: 'icon-plus',
|
||||||
label: 'Add',
|
label: 'Add',
|
||||||
awToolTip: 'Add a permission for this user',
|
awToolTip: 'Add a permission for this user',
|
||||||
ngShow: 'PermissionAddAllowed == true'
|
ngShow: 'PermissionAddAllowed'
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
@@ -206,7 +206,8 @@ angular.module('UserFormDefinition', [])
|
|||||||
ngClick: "delete('permissions', \{\{ permission.id \}\}, '\{\{ permission.name \}\}', 'permissions')",
|
ngClick: "delete('permissions', \{\{ permission.id \}\}, '\{\{ permission.name \}\}', 'permissions')",
|
||||||
icon: 'icon-trash',
|
icon: 'icon-trash',
|
||||||
"class": 'btn-danger',
|
"class": 'btn-danger',
|
||||||
awToolTip: 'Delete the permission'
|
awToolTip: 'Delete the permission',
|
||||||
|
ngShow: 'PermissionAddAllowed'
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -48,7 +48,8 @@ angular.module('PermissionListDefinition', [])
|
|||||||
mode: 'all', // One of: edit, select, all
|
mode: 'all', // One of: edit, select, all
|
||||||
ngClick: 'addPermission()',
|
ngClick: 'addPermission()',
|
||||||
"class": 'btn-success btn-sm',
|
"class": 'btn-success btn-sm',
|
||||||
awToolTip: 'Add a new permission'
|
awToolTip: 'Add a new permission',
|
||||||
|
ngShow: 'PermissionAddAllowed'
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
@@ -66,7 +67,8 @@ angular.module('PermissionListDefinition', [])
|
|||||||
ngClick: "deletePermission(\{\{ permission.id \}\},'\{\{ permission.name \}\}')",
|
ngClick: "deletePermission(\{\{ permission.id \}\},'\{\{ permission.name \}\}')",
|
||||||
icon: 'icon-trash',
|
icon: 'icon-trash',
|
||||||
"class": 'btn-xs btn-danger',
|
"class": 'btn-xs btn-danger',
|
||||||
awToolTip: 'Delete permission'
|
awToolTip: 'Delete permission',
|
||||||
|
ngShow: 'PermissionAddAllowed'
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -49,7 +49,7 @@ body {
|
|||||||
}
|
}
|
||||||
|
|
||||||
.prepend-asterisk:before {
|
.prepend-asterisk:before {
|
||||||
content: "\002A";
|
content: "\002A\00A0";
|
||||||
}
|
}
|
||||||
|
|
||||||
.subtitle {
|
.subtitle {
|
||||||
@@ -82,6 +82,10 @@ hr {
|
|||||||
border-color: #e3e3e3;
|
border-color: #e3e3e3;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.help {
|
||||||
|
display: inline-block;
|
||||||
|
}
|
||||||
|
|
||||||
.nowrap {
|
.nowrap {
|
||||||
white-space: nowrap;
|
white-space: nowrap;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -93,7 +93,6 @@ angular.module('FormGenerator', ['GeneratorHelpers', 'ngCookies'])
|
|||||||
$('.form-control[required]').each(function() {
|
$('.form-control[required]').each(function() {
|
||||||
var label = $(this).parent().parent().find('label');
|
var label = $(this).parent().parent().find('label');
|
||||||
if (label && !label.hasClass('prepend-asterisk')) {
|
if (label && !label.hasClass('prepend-asterisk')) {
|
||||||
console.log('adding prepend');
|
|
||||||
label.addClass('prepend-asterisk');
|
label.addClass('prepend-asterisk');
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@@ -377,21 +376,24 @@ angular.module('FormGenerator', ['GeneratorHelpers', 'ngCookies'])
|
|||||||
|
|
||||||
//text fields
|
//text fields
|
||||||
if (field.type == 'text' || field.type == 'password' || field.type == 'email') {
|
if (field.type == 'text' || field.type == 'password' || field.type == 'email') {
|
||||||
html += "<label ";
|
html += "<div class=\"text-right " + getLabelWidth();
|
||||||
html += (field.labelNGClass) ? "ng-class=\"" + field.labelNGClass + "\" " : "";
|
|
||||||
html += "class=\"control-label " + getLabelWidth();
|
|
||||||
html += (field.labelClass) ? " " + field.labelClass : "";
|
html += (field.labelClass) ? " " + field.labelClass : "";
|
||||||
html += "\" ";
|
html += "\" ";
|
||||||
|
html += (field.labelNGClass) ? "ng-class=\"" + field.labelNGClass + "\" " : "";
|
||||||
|
html += ">\n";
|
||||||
|
html += (field.awPopOver) ? this.attr(field, 'awPopOver', fld) : "";
|
||||||
|
html += "<label ";
|
||||||
|
html += "class=\"control-label";
|
||||||
|
html += "\" ";
|
||||||
html += (field.labelBind) ? "ng-bind=\"" + field.labelBind + "\" " : "";
|
html += (field.labelBind) ? "ng-bind=\"" + field.labelBind + "\" " : "";
|
||||||
html += "for=\"" + fld + '">';
|
html += "for=\"" + fld + '">';
|
||||||
html += (field.awPopOver) ? this.attr(field, 'awPopOver', fld) : "";
|
|
||||||
html += (field.icon) ? this.icon(field.icon) : "";
|
html += (field.icon) ? this.icon(field.icon) : "";
|
||||||
html += field.label + '</label>' + "\n";
|
html += field.label + '</label>' + "\n";
|
||||||
|
html += "</div>\n";
|
||||||
html += "<div ";
|
html += "<div ";
|
||||||
html += (field.controlNGClass) ? "ng-class=\"" + field.controlNGClass + "\" " : "";
|
html += (field.controlNGClass) ? "ng-class=\"" + field.controlNGClass + "\" " : "";
|
||||||
html += "class=\"" + getFieldWidth() + "\">\n";
|
html += "class=\"" + getFieldWidth() + "\">\n";
|
||||||
html += (field.clear || field.genMD5) ? "<div class=\"input-group\">\n" : "";
|
html += (field.clear || field.genMD5) ? "<div class=\"input-group\">\n" : "";
|
||||||
|
|
||||||
if (field.control === null || field.control === undefined || field.control) {
|
if (field.control === null || field.control === undefined || field.control) {
|
||||||
html += "<input ";
|
html += "<input ";
|
||||||
html += this.attr(field,'type');
|
html += this.attr(field,'type');
|
||||||
@@ -491,9 +493,15 @@ angular.module('FormGenerator', ['GeneratorHelpers', 'ngCookies'])
|
|||||||
if (field.type == 'textarea') {
|
if (field.type == 'textarea') {
|
||||||
|
|
||||||
if (field.label !== false) {
|
if (field.label !== false) {
|
||||||
html += "<label class=\"control-label " + getLabelWidth() + "\" for=\"" + fld + '">';
|
html += "<div class=\"text-right " + getLabelWidth();
|
||||||
|
html += (field.labelClass) ? " " + field.labelClass : "";
|
||||||
|
html += "\" ";
|
||||||
|
html += (field.labelNGClass) ? "ng-class=\"" + field.labelNGClass + "\" " : "";
|
||||||
|
html += ">\n";
|
||||||
html += (field.awPopOver) ? this.attr(field, 'awPopOver', fld) : "";
|
html += (field.awPopOver) ? this.attr(field, 'awPopOver', fld) : "";
|
||||||
|
html += "<label class=\"control-label\" for=\"" + fld + '">';
|
||||||
html += field.label + '</label>' + "\n";
|
html += field.label + '</label>' + "\n";
|
||||||
|
html += "</div>\n";
|
||||||
html += "<div ";
|
html += "<div ";
|
||||||
html += (field.controlNGClass) ? "ng-class=\"" + field.controlNGClass + "\" " : "";
|
html += (field.controlNGClass) ? "ng-class=\"" + field.controlNGClass + "\" " : "";
|
||||||
html += "class=\"" + getFieldWidth() + "\">\n";
|
html += "class=\"" + getFieldWidth() + "\">\n";
|
||||||
@@ -537,9 +545,15 @@ angular.module('FormGenerator', ['GeneratorHelpers', 'ngCookies'])
|
|||||||
|
|
||||||
//select field
|
//select field
|
||||||
if (field.type == 'select') {
|
if (field.type == 'select') {
|
||||||
html += "<label class=\"control-label " + getLabelWidth() + "\" for=\"" + fld + '">';
|
html += "<div class=\"text-right " + getLabelWidth();
|
||||||
|
html += (field.labelClass) ? " " + field.labelClass : "";
|
||||||
|
html += "\" ";
|
||||||
|
html += (field.labelNGClass) ? "ng-class=\"" + field.labelNGClass + "\" " : "";
|
||||||
|
html += ">\n";
|
||||||
html += (field.awPopOver) ? this.attr(field, 'awPopOver', fld) : "";
|
html += (field.awPopOver) ? this.attr(field, 'awPopOver', fld) : "";
|
||||||
|
html += "<label class=\"control-label\" for=\"" + fld + '">';
|
||||||
html += field.label + '</label>' + "\n";
|
html += field.label + '</label>' + "\n";
|
||||||
|
html += "</div>\n";
|
||||||
html += "<div ";
|
html += "<div ";
|
||||||
html += (field.controlNGClass) ? "ng-class=\"" + field.controlNGClass + "\" " : "";
|
html += (field.controlNGClass) ? "ng-class=\"" + field.controlNGClass + "\" " : "";
|
||||||
html += "class=\"" + getFieldWidth() + "\">\n";
|
html += "class=\"" + getFieldWidth() + "\">\n";
|
||||||
@@ -563,7 +577,8 @@ angular.module('FormGenerator', ['GeneratorHelpers', 'ngCookies'])
|
|||||||
html += "</option>\n";
|
html += "</option>\n";
|
||||||
html += "</select>\n";
|
html += "</select>\n";
|
||||||
// Add error messages
|
// Add error messages
|
||||||
if ( (options.mode == 'add' && field.addRequired) || (options.mode == 'edit' && field.editRequired) ) {
|
if ( (options.mode == 'add' && field.addRequired) || (options.mode == 'edit' && field.editRequired) ||
|
||||||
|
field.awRequiredWhen ) {
|
||||||
html += "<div class=\"error\" ng-show=\"" + this.form.name + '_form.' + fld + ".$dirty && " +
|
html += "<div class=\"error\" ng-show=\"" + this.form.name + '_form.' + fld + ".$dirty && " +
|
||||||
this.form.name + '_form.' + fld + ".$error.required\">A value is required!</div>\n";
|
this.form.name + '_form.' + fld + ".$error.required\">A value is required!</div>\n";
|
||||||
}
|
}
|
||||||
@@ -686,9 +701,15 @@ angular.module('FormGenerator', ['GeneratorHelpers', 'ngCookies'])
|
|||||||
|
|
||||||
//lookup type fields
|
//lookup type fields
|
||||||
if (field.type == 'lookup' && (field.excludeMode == undefined || field.excludeMode != options.mode)) {
|
if (field.type == 'lookup' && (field.excludeMode == undefined || field.excludeMode != options.mode)) {
|
||||||
html += "<label class=\"control-label " + getLabelWidth() + "\" for=\"" + fld + '">';
|
html += "<div class=\"text-right " + getLabelWidth();
|
||||||
|
html += (field.labelClass) ? " " + field.labelClass : "";
|
||||||
|
html += "\" ";
|
||||||
|
html += (field.labelNGClass) ? "ng-class=\"" + field.labelNGClass + "\" " : "";
|
||||||
|
html += ">\n";
|
||||||
html += (field.awPopOver) ? this.attr(field, 'awPopOver', fld) : "";
|
html += (field.awPopOver) ? this.attr(field, 'awPopOver', fld) : "";
|
||||||
|
html += "<label class=\"control-label\" for=\"" + fld + '">';
|
||||||
html += field.label + '</label>' + "\n";
|
html += field.label + '</label>' + "\n";
|
||||||
|
html += "</div>\n";
|
||||||
html += "<div ";
|
html += "<div ";
|
||||||
html += (field.controlNGClass) ? "ng-class=\"" + field.controlNGClass + "\" " : "";
|
html += (field.controlNGClass) ? "ng-class=\"" + field.controlNGClass + "\" " : "";
|
||||||
html += "class=\"" + getFieldWidth() + "\">\n";
|
html += "class=\"" + getFieldWidth() + "\">\n";
|
||||||
@@ -727,13 +748,18 @@ angular.module('FormGenerator', ['GeneratorHelpers', 'ngCookies'])
|
|||||||
|
|
||||||
//custom fields
|
//custom fields
|
||||||
if (field.type == 'custom') {
|
if (field.type == 'custom') {
|
||||||
html += "<label class=\"control-label " + getLabelWidth();
|
html += "<div class=\"text-right " + getLabelWidth();
|
||||||
html += (field.labelClass) ? " " + field.labelClass : "";
|
html += (field.labelClass) ? " " + field.labelClass : "";
|
||||||
html += "\" for=\"" + fld + '">';
|
html += "\" ";
|
||||||
|
html += (field.labelNGClass) ? "ng-class=\"" + field.labelNGClass + "\" " : "";
|
||||||
|
html += ">\n";
|
||||||
html += (field.awPopOver) ? this.attr(field, 'awPopOver', fld) : "";
|
html += (field.awPopOver) ? this.attr(field, 'awPopOver', fld) : "";
|
||||||
|
|
||||||
|
html += "<label class=\"control-label\" for=\"" + fld + '">';
|
||||||
html += (field.icon) ? this.icon(field.icon) : "";
|
html += (field.icon) ? this.icon(field.icon) : "";
|
||||||
html += (field.label) ? field.label : '';
|
html += (field.label) ? field.label : '';
|
||||||
html += '</label>' + "\n";
|
html += '</label>' + "\n";
|
||||||
|
html += "</div>\n";
|
||||||
html += "<div ";
|
html += "<div ";
|
||||||
html += (field.controlNGClass) ? "ng-class=\"" + field.controlNGClass + "\" " : "";
|
html += (field.controlNGClass) ? "ng-class=\"" + field.controlNGClass + "\" " : "";
|
||||||
html += "class=\"" + getFieldWidth() + "\">\n";
|
html += "class=\"" + getFieldWidth() + "\">\n";
|
||||||
@@ -1362,7 +1388,9 @@ angular.module('FormGenerator', ['GeneratorHelpers', 'ngCookies'])
|
|||||||
var action = form.related[itm].fieldActions[act];
|
var action = form.related[itm].fieldActions[act];
|
||||||
html += "<button type=\"button\" class=\"btn btn-xs";
|
html += "<button type=\"button\" class=\"btn btn-xs";
|
||||||
html += (action['class']) ? " " + action['class'] : "";
|
html += (action['class']) ? " " + action['class'] : "";
|
||||||
html += "\" " + this.attr(action,'ngClick');
|
html += "\" ";
|
||||||
|
html += this.attr(action,'ngClick');
|
||||||
|
html += this.attr(action, 'ngShow');
|
||||||
html += (action.awToolTip) ? this.attr(action,'awToolTip') : "";
|
html += (action.awToolTip) ? this.attr(action,'awToolTip') : "";
|
||||||
html += (action.awToolTip) ? "data-placement=\"top\" " : "";
|
html += (action.awToolTip) ? "data-placement=\"top\" " : "";
|
||||||
html += ">" + this.icon(action.icon);
|
html += ">" + this.icon(action.icon);
|
||||||
|
|||||||
@@ -167,7 +167,7 @@
|
|||||||
<div class="login-alert" ng-show="(sessionExpired == true)">Your session timed out due to inactivity. Please sign in.</div>
|
<div class="login-alert" ng-show="(sessionExpired == true)">Your session timed out due to inactivity. Please sign in.</div>
|
||||||
<form id="login-form" name="loginForm" class="form-horizontal" autocomplete="off" novalidate >
|
<form id="login-form" name="loginForm" class="form-horizontal" autocomplete="off" novalidate >
|
||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
<label class="control-label col-lg-3">* Username</label>
|
<label class="control-label col-lg-3 prepend-asterisk">Username</label>
|
||||||
<div class="col-lg-8">
|
<div class="col-lg-8">
|
||||||
<input type="text" name="login_username" class="form-control" ng-model="login_username"
|
<input type="text" name="login_username" class="form-control" ng-model="login_username"
|
||||||
id="login-username" autocomplete="off" required>
|
id="login-username" autocomplete="off" required>
|
||||||
@@ -178,7 +178,7 @@
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
<label class="control-label col-lg-3">* Password</label>
|
<label class="control-label col-lg-3 prepend-asterisk">Password</label>
|
||||||
<div class="col-lg-8">
|
<div class="col-lg-8">
|
||||||
<input type="password" name="login_password" id="login-password" class="form-control"
|
<input type="password" name="login_password" id="login-password" class="form-control"
|
||||||
ng-model="login_password" required autocomplete="off">
|
ng-model="login_password" required autocomplete="off">
|
||||||
@@ -303,7 +303,7 @@
|
|||||||
<div class="alert" ng-class="alertClass" ng-bind-html-unsafe="alertBody"></div>
|
<div class="alert" ng-class="alertClass" ng-bind-html-unsafe="alertBody"></div>
|
||||||
</div>
|
</div>
|
||||||
<div class="modal-footer">
|
<div class="modal-footer">
|
||||||
<a href="#" ng-hide="disableButtons" data-target="#form-modal" data-dismiss="modal" class="btn btn-default">OK</a>
|
<a href="#" ng-hide="disableButtons" data-target="#form-modal" data-dismiss="modal" class="btn btn-primary">OK</a>
|
||||||
</div>
|
</div>
|
||||||
</div><!-- modal-content -->
|
</div><!-- modal-content -->
|
||||||
</div><!-- modal-dialog -->
|
</div><!-- modal-dialog -->
|
||||||
@@ -321,7 +321,7 @@
|
|||||||
<div class="alert" ng-class="alertClass2" ng-bind-html-unsafe="alertBody2"></div>
|
<div class="alert" ng-class="alertClass2" ng-bind-html-unsafe="alertBody2"></div>
|
||||||
</div>
|
</div>
|
||||||
<div class="modal-footer">
|
<div class="modal-footer">
|
||||||
<a href="#" ng-hide="disableButtons2" data-target="#form-modal2" data-dismiss="modal" class="btn btn-default">OK</a>
|
<a href="#" ng-hide="disableButtons2" data-target="#form-modal2" data-dismiss="modal" class="btn btn-primary">OK</a>
|
||||||
</div>
|
</div>
|
||||||
</div><!-- modal-content -->
|
</div><!-- modal-content -->
|
||||||
</div><!-- modal-dialog -->
|
</div><!-- modal-dialog -->
|
||||||
|
|||||||
Reference in New Issue
Block a user