mirror of
https://github.com/ZwareBear/awx.git
synced 2026-05-13 02:08:37 -05:00
Latest UI Inventory updates
This commit is contained in:
@@ -34,6 +34,9 @@ angular.module('FormGenerator', ['GeneratorHelpers'])
|
||||
case 'falseValue':
|
||||
result = "ng-false-value=\"" + obj[key] + "\" ";
|
||||
break;
|
||||
case 'awToolTip':
|
||||
result = "aw-tool-tip=\"" + obj[key] + "\" ";
|
||||
break;
|
||||
default:
|
||||
result = key + "=\"" + obj[key] + "\" ";
|
||||
}
|
||||
@@ -53,14 +56,21 @@ angular.module('FormGenerator', ['GeneratorHelpers'])
|
||||
// Use to inject the form as html into the view. View MUST have an ng-bind for 'htmlTemplate'.
|
||||
// Returns scope of form.
|
||||
//
|
||||
var element = angular.element(document.getElementById('htmlTemplate'));
|
||||
var element;
|
||||
if (options.modal) {
|
||||
element = angular.element(document.getElementById('form-modal-body'));
|
||||
}
|
||||
else {
|
||||
var element = angular.element(document.getElementById('htmlTemplate'));
|
||||
}
|
||||
|
||||
this.setForm(form);
|
||||
element.html(this.build(options)); // Inject the html
|
||||
this.scope = element.scope(); // Set scope specific to the element we're compiling, avoids circular reference
|
||||
// From here use 'scope' to manipulate the form, as the form is not in '$scope'
|
||||
$compile(element)(this.scope);
|
||||
|
||||
if (options.related) {
|
||||
if ((!options.modal) && options.related) {
|
||||
this.addListeners();
|
||||
}
|
||||
|
||||
@@ -68,7 +78,13 @@ angular.module('FormGenerator', ['GeneratorHelpers'])
|
||||
this.applyDefaults();
|
||||
}
|
||||
|
||||
if (options.modal) {
|
||||
(options.mode == 'add') ? scope.formHeader = form.addTitle : form.editTitle;
|
||||
$('#form-modal').modal();
|
||||
}
|
||||
|
||||
this.mode = options.mode;
|
||||
this.modal = (options.modal) ? true : false;
|
||||
|
||||
return this.scope;
|
||||
},
|
||||
@@ -130,20 +146,22 @@ angular.module('FormGenerator', ['GeneratorHelpers'])
|
||||
//
|
||||
var html = '';
|
||||
|
||||
//Breadcrumbs
|
||||
html += "<div class=\"nav-path\">\n";
|
||||
html += "<ul class=\"breadcrumb\">\n";
|
||||
html += "<li ng-repeat=\"crumb in breadcrumbs\"><a href=\"{{ '#' + crumb.path }}\">{{ crumb.title | capitalize }}</a> " +
|
||||
"<span class=\"divider\">/</span></li>\n";
|
||||
html += "<li class=\"active\">";
|
||||
if (options.mode == 'edit') {
|
||||
html += this.form.editTitle;
|
||||
if (!this.modal) {
|
||||
//Breadcrumbs
|
||||
html += "<div class=\"nav-path\">\n";
|
||||
html += "<ul class=\"breadcrumb\">\n";
|
||||
html += "<li ng-repeat=\"crumb in breadcrumbs\"><a href=\"{{ '#' + crumb.path }}\">{{ crumb.title | capitalize }}</a> " +
|
||||
"<span class=\"divider\">/</span></li>\n";
|
||||
html += "<li class=\"active\">";
|
||||
if (options.mode == 'edit') {
|
||||
html += this.form.editTitle;
|
||||
}
|
||||
else {
|
||||
html += this.form.addTitle;
|
||||
}
|
||||
html += "</li>\n</ul>\n</div>\n";
|
||||
}
|
||||
else {
|
||||
html += this.form.addTitle;
|
||||
}
|
||||
html += "</li>\n</ul>\n</div>\n";
|
||||
|
||||
|
||||
// Start the well
|
||||
if ( this.has('well') ) {
|
||||
html += "<div class=\"well\">\n";
|
||||
@@ -269,6 +287,13 @@ angular.module('FormGenerator', ['GeneratorHelpers'])
|
||||
}
|
||||
}
|
||||
|
||||
if (field.type == 'hidden') {
|
||||
if ( (options.mode == 'edit' && field.includeOnEdit) ||
|
||||
(options.mode == 'add' && field.includeOnAdd) ) {
|
||||
html += "<input type=\"hidden\" ng-model=\"" + fld + "\" name=\"" + fld + "\" />";
|
||||
}
|
||||
}
|
||||
|
||||
//lookup type fields
|
||||
if (field.type == 'lookup') {
|
||||
html += "<div class=\"control-group\""
|
||||
@@ -300,50 +325,51 @@ angular.module('FormGenerator', ['GeneratorHelpers'])
|
||||
}
|
||||
|
||||
//buttons
|
||||
if (this.has('buttons')) {
|
||||
html += "<div class=\"control-group\">\n";
|
||||
html += "<div class=\"controls buttons\">\n";
|
||||
}
|
||||
for (var btn in this.form.buttons) {
|
||||
var button = this.form.buttons[btn];
|
||||
//button
|
||||
html += "<button ";
|
||||
if (button.class) {
|
||||
html += this.attr(button,'class');
|
||||
}
|
||||
if (button.ngClick) {
|
||||
html += this.attr(button,'ngClick');
|
||||
}
|
||||
if (button.ngDisabled) {
|
||||
if (btn !== 'reset') {
|
||||
html += "ng-disabled=\"" + this.form.name + "_form.$pristine || " + this.form.name + "_form.$invalid\" ";
|
||||
if (!this.modal) {
|
||||
if (this.has('buttons')) {
|
||||
html += "<div class=\"control-group\">\n";
|
||||
html += "<div class=\"controls buttons\">\n";
|
||||
}
|
||||
for (var btn in this.form.buttons) {
|
||||
var button = this.form.buttons[btn];
|
||||
//button
|
||||
html += "<button ";
|
||||
if (button.class) {
|
||||
html += this.attr(button,'class');
|
||||
}
|
||||
else {
|
||||
html += "ng-disabled=\"" + this.form.name + "_form.$pristine\" ";
|
||||
if (button.ngClick) {
|
||||
html += this.attr(button,'ngClick');
|
||||
}
|
||||
if (button.ngDisabled) {
|
||||
if (btn !== 'reset') {
|
||||
html += "ng-disabled=\"" + this.form.name + "_form.$pristine || " + this.form.name + "_form.$invalid\" ";
|
||||
}
|
||||
else {
|
||||
html += "ng-disabled=\"" + this.form.name + "_form.$pristine\" ";
|
||||
}
|
||||
}
|
||||
html += ">";
|
||||
if (button.icon) {
|
||||
html += this.icon(button.icon);
|
||||
}
|
||||
html += button.label + "</button>\n";
|
||||
}
|
||||
html += ">";
|
||||
if (button.icon) {
|
||||
html += this.icon(button.icon);
|
||||
if (this.has('buttons')) {
|
||||
html += "</div>\n";
|
||||
html += "</div>\n";
|
||||
}
|
||||
html += button.label + "</button>\n";
|
||||
}
|
||||
if (this.has('buttons')) {
|
||||
html += "</div>\n";
|
||||
html += "</div>\n";
|
||||
}
|
||||
|
||||
html += "</form>\n";
|
||||
|
||||
if ( this.has('well') ) {
|
||||
html += "</div>\n";
|
||||
}
|
||||
|
||||
if (options.related && this.form.related) {
|
||||
if ((!this.modal) && options.related && this.form.related) {
|
||||
html += this.buildCollections();
|
||||
}
|
||||
|
||||
console.log(html);
|
||||
//console.log(html);
|
||||
|
||||
return html;
|
||||
|
||||
@@ -371,9 +397,30 @@ angular.module('FormGenerator', ['GeneratorHelpers'])
|
||||
}
|
||||
html += "\">\n";
|
||||
html += "<div class=\"accordion-inner\">\n";
|
||||
|
||||
|
||||
if (form.related[itm].instructions) {
|
||||
html += "<div class=\"alert alert-info alert-block\">\n";
|
||||
html += "<button type=\"button\" class=\"close\" data-dismiss=\"alert\">×</button>\n";
|
||||
html += "<strong>Hint: </strong>" + form.related[itm].instructions + "\n";
|
||||
html += "</div>\n"
|
||||
}
|
||||
|
||||
if (form.related[itm].type == 'tree') {
|
||||
html += "<div id=\"tree-view\"></div>\n";
|
||||
html += "<div>\n";
|
||||
// Add actions(s)
|
||||
if (form.related[itm].actions && form.related[itm].actions.length > 0) {
|
||||
html += "<div class=\"text-right actions\">\n";
|
||||
for (var act in form.related[itm].actions) {
|
||||
var action = form.related[itm].actions[act];
|
||||
html += "<button class=\"btn btn-mini btn-success\" ";
|
||||
html += this.attr(action,'ngClick');
|
||||
html += (action.awToolTip) ? this.attr(action,'awToolTip') : "";
|
||||
html += ">" + this.icon(action.icon) + "</button>\n";
|
||||
}
|
||||
html += "</div>\n";
|
||||
}
|
||||
html += "<div id=\"tree-view\"></div>\n";
|
||||
html += "</div>\n";
|
||||
}
|
||||
else {
|
||||
html += "<div class=\"well\">\n";
|
||||
|
||||
@@ -129,7 +129,6 @@ angular.module('ListGenerator', ['GeneratorHelpers',])
|
||||
if (options.mode != 'lookup') {
|
||||
//actions
|
||||
base = $location.path().replace(/^\//,'').split('/')[0];
|
||||
console.log('base: ' + base);
|
||||
html += "<div class=\"text-right\">\n";
|
||||
for (action in list.actions) {
|
||||
if (list.actions[action].mode == 'all' || list.actions[action].mode == options.mode) {
|
||||
@@ -227,7 +226,6 @@ angular.module('ListGenerator', ['GeneratorHelpers',])
|
||||
else {
|
||||
html += PaginateWidget({ set: list.name, iterator: list.iterator, mini: true });
|
||||
}
|
||||
|
||||
return html;
|
||||
|
||||
}
|
||||
|
||||
@@ -26,8 +26,8 @@ angular.module('PromptDialog', [])
|
||||
var cls = (params.class == null || params.class == undefined) ? 'btn-danger' : params.class;
|
||||
$('#prompt-action-btn').addClass(cls); //Use jquery because django template engine conflicts with Angular's
|
||||
// use of {{...}}
|
||||
scope.id = params.id;
|
||||
scope.url = params.url;
|
||||
//scope.id = params.id;
|
||||
//scope.url = params.url;
|
||||
scope.promptAction = params.action;
|
||||
$(dialog).modal({
|
||||
backdrop: 'static',
|
||||
|
||||
@@ -30,12 +30,12 @@ angular.module('RestServices',['ngCookies','AuthService'])
|
||||
|
||||
get: function(args) {
|
||||
args = (args) ? args : {};
|
||||
this.params = (args.params != null || args.params != undefined) ? args.params : null;
|
||||
this.params = (args.params) ? args.params : null;
|
||||
this.pReplace();
|
||||
return $http({method: 'GET',
|
||||
url: this.url,
|
||||
headers: this.auth,
|
||||
params: this.params,
|
||||
params: this.params
|
||||
});
|
||||
},
|
||||
post: function(data) {
|
||||
|
||||
Reference in New Issue
Block a user