mirror of
https://github.com/ansible/awx.git
synced 2026-05-10 10:57:35 -02:30
Inventory refactor: lists now uniformly set tool tips placement to 'top'. Fixed an ugly scope bug when using modals that call LookupInit. The callbacks inside search were being left in the inventory scope and fired everytime the host view refreshed. Added a cleanup method in search to remove its callbacks. Calling the cleanup method on modal close fixes.
This commit is contained in:
@@ -450,8 +450,8 @@ angular.module('GroupsHelper', [ 'RestServices', 'Utilities', 'ListGenerator', '
|
||||
|
||||
var inventory_id = params.inventory_id;
|
||||
var group_id = (params.group_id !== undefined) ? params.group_id : null;
|
||||
var inventory_scope = params.scope;
|
||||
|
||||
var parent_scope = params.scope;
|
||||
|
||||
// Inject dynamic view
|
||||
var defaultUrl = (group_id !== null) ? GetBasePath('groups') + group_id + '/children/' :
|
||||
GetBasePath('inventory') + inventory_id + '/groups/';
|
||||
@@ -459,14 +459,14 @@ angular.module('GroupsHelper', [ 'RestServices', 'Utilities', 'ListGenerator', '
|
||||
var generator = GenerateForm;
|
||||
var scope = generator.inject(form, { mode: 'add', modal: true, related: false, show_modal: false });
|
||||
var groupCreated = false;
|
||||
|
||||
|
||||
$('#form-modal .btn-none').removeClass('btn-none').addClass('btn-success');
|
||||
|
||||
scope.formModalActionLabel = 'Save';
|
||||
scope.formModalCancelShow = true;
|
||||
scope.parseType = 'yaml';
|
||||
scope.source = null;
|
||||
ParseTypeChange(scope);
|
||||
|
||||
$('#form-modal .btn-none').removeClass('btn-none').addClass('btn-success');
|
||||
|
||||
generator.reset();
|
||||
var master={};
|
||||
@@ -475,24 +475,28 @@ angular.module('GroupsHelper', [ 'RestServices', 'Utilities', 'ListGenerator', '
|
||||
scope.removeAddTreeRefreshed();
|
||||
}
|
||||
scope.removeAddTreeRefreshed = scope.$on('GroupTreeRefreshed', function(e) {
|
||||
$rootScope.formModalHeader = null;
|
||||
$rootScope.formModalCancleShow= null;
|
||||
$rootScope.formModalActionLabel = null;
|
||||
Wait('stop');
|
||||
$('#form-modal').modal('hide');
|
||||
scope.removeAddTreeRefreshed();
|
||||
});
|
||||
|
||||
if (scope.removeSaveComplete) {
|
||||
scope.removeSaveComplete();
|
||||
scope.removeSaveComplete();
|
||||
}
|
||||
scope.removeSaveComplete = scope.$on('SaveComplete', function(e, group_id, error) {
|
||||
if (!error) {
|
||||
scope.searchCleanup();
|
||||
scope.formModalActionDisabled = false;
|
||||
scope.showGroupHelp = false; //get rid of the Hint
|
||||
BuildTree({ scope: inventory_scope, inventory_id: inventory_id, refresh: true, new_group_id: group_id });
|
||||
BuildTree({ scope: parent_scope, inventory_id: inventory_id, refresh: true, new_group_id: group_id });
|
||||
}
|
||||
});
|
||||
|
||||
if (scope.removeFormSaveSuccess) {
|
||||
scope.removeFormSaveSuccess();
|
||||
scope.removeFormSaveSuccess();
|
||||
}
|
||||
scope.removeFormSaveSuccess = scope.$on('formSaveSuccess', function(e, group_id, url) {
|
||||
|
||||
@@ -574,7 +578,13 @@ angular.module('GroupsHelper', [ 'RestServices', 'Utilities', 'ListGenerator', '
|
||||
scope.$emit('SaveComplete', group_id, false);
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
// Cancel
|
||||
scope.cancelModal = function() {
|
||||
if (scope.searchCleanup) {
|
||||
scope.searchCleanup();
|
||||
}
|
||||
}
|
||||
|
||||
// Save
|
||||
scope.formModalAction = function() {
|
||||
@@ -637,12 +647,6 @@ angular.module('GroupsHelper', [ 'RestServices', 'Utilities', 'ListGenerator', '
|
||||
});
|
||||
}
|
||||
|
||||
// Cancel
|
||||
scope.formReset = function() {
|
||||
// Defaults
|
||||
generator.reset();
|
||||
};
|
||||
|
||||
var choicesReady = 0;
|
||||
|
||||
if (scope.removeChoicesReady) {
|
||||
@@ -699,7 +703,6 @@ angular.module('GroupsHelper', [ 'RestServices', 'Utilities', 'ListGenerator', '
|
||||
var form = GroupForm;
|
||||
var defaultUrl = GetBasePath('groups') + group_id + '/';
|
||||
var master = {};
|
||||
var relatedSets = {};
|
||||
|
||||
// Load the modal form
|
||||
var scope = generator.inject(form, { mode: 'edit', modal: true, related: false, show_modal: false });
|
||||
@@ -726,10 +729,6 @@ angular.module('GroupsHelper', [ 'RestServices', 'Utilities', 'ListGenerator', '
|
||||
scope.groupLoadedRemove();
|
||||
}
|
||||
scope.groupLoadedRemove = scope.$on('groupLoaded', function() {
|
||||
for (var set in relatedSets) {
|
||||
scope.search(relatedSets[set].iterator);
|
||||
}
|
||||
|
||||
if (scope.variable_url) {
|
||||
// get group variables
|
||||
Rest.setUrl(scope.variable_url);
|
||||
@@ -871,12 +870,6 @@ angular.module('GroupsHelper', [ 'RestServices', 'Utilities', 'ListGenerator', '
|
||||
master[fld] = scope[fld];
|
||||
}
|
||||
}
|
||||
var related = data.related;
|
||||
for (var set in form.related) {
|
||||
if (related[set]) {
|
||||
relatedSets[set] = { url: related[set], iterator: form.related[set].iterator };
|
||||
}
|
||||
}
|
||||
scope.variable_url = data.related.variable_data;
|
||||
scope.source_url = data.related.inventory_source;
|
||||
$('#form-modal').modal('show');
|
||||
@@ -926,6 +919,7 @@ angular.module('GroupsHelper', [ 'RestServices', 'Utilities', 'ListGenerator', '
|
||||
}
|
||||
scope.removeSaveComplete = scope.$on('SaveComplete', function(e, error) {
|
||||
if (!error) {
|
||||
// Update the view with any changes
|
||||
UpdateGroup({
|
||||
scope: parent_scope,
|
||||
group_id: group_id,
|
||||
@@ -935,6 +929,8 @@ angular.module('GroupsHelper', [ 'RestServices', 'Utilities', 'ListGenerator', '
|
||||
has_inventory_sources: (scope.source) ? true : false
|
||||
}
|
||||
});
|
||||
//Clean up
|
||||
scope.searchCleanup();
|
||||
scope.formModalActionDisabled = false;
|
||||
scope.showGroupHelp = false; //get rid of the Hint
|
||||
Wait('stop');
|
||||
@@ -1025,6 +1021,13 @@ angular.module('GroupsHelper', [ 'RestServices', 'Utilities', 'ListGenerator', '
|
||||
}
|
||||
});
|
||||
|
||||
// Cancel
|
||||
scope.cancelModal = function() {
|
||||
if (scope.searchCleanup) {
|
||||
scope.searchCleanup();
|
||||
}
|
||||
}
|
||||
|
||||
// Save
|
||||
scope.formModalAction = function() {
|
||||
Wait('start');
|
||||
@@ -1120,17 +1123,7 @@ angular.module('GroupsHelper', [ 'RestServices', 'Utilities', 'ListGenerator', '
|
||||
form: GroupForm
|
||||
});
|
||||
}
|
||||
|
||||
// Cancel
|
||||
scope.formReset = function() {
|
||||
generator.reset();
|
||||
for (var fld in master) {
|
||||
scope[fld] = master[fld];
|
||||
}
|
||||
scope.parseType = 'yaml';
|
||||
$('#s2id_group_source_regions').select2('data', master['source_regions']);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}])
|
||||
|
||||
|
||||
@@ -38,6 +38,7 @@ angular.module('HostsHelper', [ 'RestServices', 'Utilities', 'ListGenerator', 'H
|
||||
|
||||
SearchInit({ scope: scope, set: 'hosts', list: InventoryHosts, url: url });
|
||||
PaginateInit({ scope: scope, list: InventoryHosts, url: url });
|
||||
console.log('before call to hosts search')
|
||||
scope.search(InventoryHosts.iterator);
|
||||
}
|
||||
}])
|
||||
|
||||
@@ -27,11 +27,11 @@ angular.module('LookUpHelper', [ 'RestServices', 'Utilities', 'SearchHelper', 'P
|
||||
|
||||
var defaultUrl;
|
||||
if (params.url) {
|
||||
// pass in a url value to override the default
|
||||
defaultUrl = params.url;
|
||||
// pass in a url value to override the default
|
||||
defaultUrl = params.url;
|
||||
}
|
||||
else {
|
||||
defaultUrl = (list.name == 'inventories') ? GetBasePath('inventory') : GetBasePath(list.name);
|
||||
defaultUrl = (list.name == 'inventories') ? GetBasePath('inventory') : GetBasePath(list.name);
|
||||
}
|
||||
|
||||
// Show pop-up
|
||||
@@ -67,15 +67,15 @@ angular.module('LookUpHelper', [ 'RestServices', 'Utilities', 'SearchHelper', 'P
|
||||
found = true;
|
||||
scope[field] = listScope[list.name][i].id;
|
||||
if (scope[form.name + '_form'] && form.fields[field] && form.fields[field].sourceModel) {
|
||||
scope[form.fields[field].sourceModel + '_' + form.fields[field].sourceField] =
|
||||
listScope[list.name][i][form.fields[field].sourceField];
|
||||
scope[form.fields[field].sourceModel + '_' + form.fields[field].sourceField] =
|
||||
listScope[list.name][i][form.fields[field].sourceField];
|
||||
if (scope[form.name + '_form'][form.fields[field].sourceModel + '_' + form.fields[field].sourceField]) {
|
||||
scope[form.name + '_form'][form.fields[field].sourceModel + '_' + form.fields[field].sourceField]
|
||||
.$setValidity('awlookup',true);
|
||||
scope[form.name + '_form'][form.fields[field].sourceModel + '_' + form.fields[field].sourceField]
|
||||
.$setValidity('awlookup',true);
|
||||
}
|
||||
}
|
||||
if (scope[form.name + '_form']) {
|
||||
scope[form.name + '_form'].$setDirty();
|
||||
scope[form.name + '_form'].$setDirty();
|
||||
}
|
||||
listGenerator.hide();
|
||||
}
|
||||
@@ -94,12 +94,12 @@ angular.module('LookUpHelper', [ 'RestServices', 'Utilities', 'SearchHelper', 'P
|
||||
listScope['toggle_' + list.iterator] = function(id) {
|
||||
for (var i=0; i < scope[list.name].length; i++) {
|
||||
if (listScope[list.name][i]['id'] == id) {
|
||||
listScope[list.name][i]['checked'] = '1';
|
||||
listScope[list.name][i]['success_class'] = 'success';
|
||||
listScope[list.name][i]['checked'] = '1';
|
||||
listScope[list.name][i]['success_class'] = 'success';
|
||||
}
|
||||
else {
|
||||
listScope[list.name][i]['checked'] = '0';
|
||||
listScope[list.name][i]['success_class'] = '';
|
||||
listScope[list.name][i]['checked'] = '0';
|
||||
listScope[list.name][i]['success_class'] = '';
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -114,10 +114,10 @@ angular.module('LookUpHelper', [ 'RestServices', 'Utilities', 'SearchHelper', 'P
|
||||
listScope.lookupPostRefreshRemove = scope.$on('PostRefresh', function() {
|
||||
for (var fld in list.fields) {
|
||||
if (list.fields[fld].type && list.fields[fld].type == 'date') {
|
||||
//convert dates to our standard format
|
||||
for (var i=0; i < scope[list.name].length; i++) {
|
||||
scope[list.name][i][fld] = FormatDate(new Date(scope[list.name][i][fld]));
|
||||
}
|
||||
//convert dates to our standard format
|
||||
for (var i=0; i < scope[list.name].length; i++) {
|
||||
scope[list.name][i][fld] = FormatDate(new Date(scope[list.name][i][fld]));
|
||||
}
|
||||
}
|
||||
}
|
||||
// List generator creates the form, resetting it and losing the previously selected value.
|
||||
|
||||
@@ -22,7 +22,8 @@ angular.module('RefreshHelper', ['RestServices', 'Utilities'])
|
||||
var set = params.set;
|
||||
var iterator = params.iterator;
|
||||
var url = params.url;
|
||||
|
||||
console.log('Inside refresh');
|
||||
console.log(url);
|
||||
scope.current_url = url;
|
||||
Rest.setUrl(url);
|
||||
Rest.get()
|
||||
|
||||
@@ -525,5 +525,15 @@ angular.module('SearchHelper', ['RestServices', 'Utilities', 'RefreshHelper'])
|
||||
scope.search(list.iterator);
|
||||
}
|
||||
|
||||
// Call after modal dialogs to remove any lingering callbacks
|
||||
scope.searchCleanup = function() {
|
||||
console.log('search cleanup!');
|
||||
scope.removeDoSearch();
|
||||
scope.removeFoundObject();
|
||||
scope.removeResultWarning();
|
||||
scope.removePrepareSearch();
|
||||
scope.removePrepareSearch2();
|
||||
}
|
||||
|
||||
}
|
||||
}]);
|
||||
|
||||
Reference in New Issue
Block a user