mirror of
https://github.com/ansible/awx.git
synced 2026-01-15 11:50:42 -03:30
Merge pull request #4530 from mabashian/3901-lookup-radio-selects
Fixed various issues with the lookup modals and lookup lists
This commit is contained in:
commit
b5eb0b9bfb
@ -1328,7 +1328,7 @@ angular.module('FormGenerator', [GeneratorHelpers.name, 'Utilities', listGenerat
|
||||
|
||||
//lookup type fields
|
||||
if (field.type === 'lookup') {
|
||||
let defaultLookupNgClick = `$state.go($state.current.name + '.${field.sourceModel}')`;
|
||||
let defaultLookupNgClick = `$state.go($state.current.name + '.${field.sourceModel}', {selected: ${field.sourceModel}})`;
|
||||
html += label();
|
||||
|
||||
html += "<div ";
|
||||
|
||||
@ -526,8 +526,7 @@ angular.module('GeneratorHelpers', [systemStatus.name])
|
||||
}
|
||||
html += "\" ";
|
||||
html += field.columnNgClass ? " ng-class=\"" + field.columnNgClass + "\"": "";
|
||||
html += (options.mode === 'lookup' || options.mode === 'select') ? " ng-click=\"toggle_" + list.iterator +
|
||||
"(" + list.iterator + ".id)\"" : "";
|
||||
html += (options.mode === 'lookup' || options.mode === 'select') ? " ng-click=\"toggle_row(" + list.iterator + ".id)\"" : "";
|
||||
html += (field.columnShow) ? Attr(field, 'columnShow') : "";
|
||||
html += (field.ngBindHtml) ? "ng-bind-html=\"" + field.ngBindHtml + "\" " : "";
|
||||
html += (field.columnClick) ? "ng-click=\"" + field.columnClick + "\" " : "";
|
||||
|
||||
@ -317,7 +317,7 @@ export default ['$location', '$compile', '$rootScope', 'Attr', 'Icon',
|
||||
// Change layout if a lookup list, place radio buttons before labels
|
||||
if (options.mode === 'lookup') {
|
||||
if (options.input_type === "radio") { //added by JT so that lookup forms can be either radio inputs or check box inputs
|
||||
innerTable += `<td class="List-tableCell"> <input type="radio" ng-model="selection.${list.iterator}" ng-value="{id: ${list.iterator}.id, name: ${list.iterator}.name}"/></td>`;
|
||||
innerTable += `<td class="List-tableCell"> <input type="radio" ng-model="${list.iterator}.checked" ng-value="1" ng-false-value="0" name="check_${list.iterator}_{{${list.iterator}.id}}" ng-click="toggle_row(${list.iterator}.id)"></td>`;
|
||||
} else { // its assumed that options.input_type = checkbox
|
||||
innerTable += "<td class=\"List-tableCell select-column List-staticColumn--smallStatus\"><input type=\"checkbox\" ng-model=\"" + list.iterator + ".checked\" name=\"check_{{" +
|
||||
list.iterator + ".id }}\" ng-click=\"toggle_" + list.iterator + "(" + list.iterator + ".id, true)\" ng-true-value=\"1\" " +
|
||||
|
||||
@ -19,19 +19,75 @@ export default ['templateUrl', function(templateUrl) {
|
||||
|
||||
element.find('.modal-body').append(clone);
|
||||
|
||||
scope.init();
|
||||
|
||||
});
|
||||
$('#form-modal').modal('show');
|
||||
},
|
||||
controller: ['$scope', '$state', function($scope, $state) {
|
||||
|
||||
$scope.init = function() {
|
||||
let list = $scope.list;
|
||||
if($state.params.selected) {
|
||||
$scope.currentSelection = {
|
||||
name: null,
|
||||
id: parseInt($state.params.selected)
|
||||
};
|
||||
}
|
||||
$scope.$watch(list.name, function(){
|
||||
selectRowIfPresent();
|
||||
});
|
||||
};
|
||||
|
||||
function selectRowIfPresent(){
|
||||
let list = $scope.list;
|
||||
if($scope.currentSelection && $scope.currentSelection.id) {
|
||||
$scope[list.name].forEach(function(row) {
|
||||
if (row.id === $scope.currentSelection.id) {
|
||||
row.checked = true;
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
$scope.saveForm = function() {
|
||||
let list = $scope.list;
|
||||
$scope.$parent[`${list.iterator}_name`] = $scope.selection[list.iterator].name;
|
||||
$scope.$parent[list.iterator] = $scope.selection[list.iterator].id;
|
||||
if($scope.currentSelection.name !== null) {
|
||||
$scope.$parent[`${list.iterator}_name`] = $scope.currentSelection.name;
|
||||
}
|
||||
$scope.$parent[list.iterator] = $scope.currentSelection.id;
|
||||
$state.go('^');
|
||||
};
|
||||
|
||||
$scope.cancelForm = function() {
|
||||
$state.go('^');
|
||||
};
|
||||
|
||||
$scope.toggle_row = function(rowId) {
|
||||
let list = $scope.list;
|
||||
let count = 0;
|
||||
$scope[list.name].forEach(function(row) {
|
||||
if (row.id === rowId) {
|
||||
if (row.checked) {
|
||||
row.success_class = 'success';
|
||||
} else {
|
||||
row.checked = true;
|
||||
row.success_class = '';
|
||||
}
|
||||
$scope.currentSelection = {
|
||||
name: row.name,
|
||||
id: row.id
|
||||
};
|
||||
} else {
|
||||
row.checked = 0;
|
||||
row.success_class = '';
|
||||
}
|
||||
if (row.checked) {
|
||||
count++;
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
}]
|
||||
};
|
||||
}];
|
||||
|
||||
@ -17,7 +17,7 @@
|
||||
</div>
|
||||
<div class="modal-footer">
|
||||
<button ng-click="cancelForm()" class="Lookup-cancel btn btn-default">Cancel</button>
|
||||
<button ng-click="saveForm()" class="Lookup-save btn btn-primary" ng-bind="list.lookupConfirmText ? list.lookupConfirmText : 'Save'"></button>
|
||||
<button ng-click="saveForm()" class="Lookup-save btn btn-primary" ng-disabled="!currentSelection || !currentSelection.id" ng-bind="list.lookupConfirmText ? list.lookupConfirmText : 'Save'"></button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@ -628,7 +628,7 @@ export default ['$injector', '$stateExtender', '$log', function($injector, $stat
|
||||
searchPrefix: field.sourceModel,
|
||||
//squashSearchUrl: true, @issue enable
|
||||
name: `${formStateDefinition.name}.${field.sourceModel}`,
|
||||
url: `/${field.sourceModel}`,
|
||||
url: `/${field.sourceModel}?selected`,
|
||||
// a lookup field's basePath takes precedence over generic list definition's basePath, if supplied
|
||||
data: {
|
||||
basePath: field.basePath || null,
|
||||
@ -639,6 +639,9 @@ export default ['$injector', '$stateExtender', '$log', function($injector, $stat
|
||||
value: { page_size: '5' }
|
||||
}
|
||||
},
|
||||
ncyBreadcrumb: {
|
||||
skip: true
|
||||
},
|
||||
views: {
|
||||
'modal': {
|
||||
templateProvider: function(ListDefinition, generateList) {
|
||||
|
||||
@ -133,9 +133,22 @@ angular.module('templates', [surveyMaker.name, templatesList.name, jobTemplatesA
|
||||
$scope.list = list;
|
||||
$scope[`${list.iterator}_dataset`] = Dataset.data;
|
||||
$scope[list.name] = $scope[`${list.iterator}_dataset`].results;
|
||||
|
||||
$scope.$watch('job_templates', function(){
|
||||
if($scope.selectedTemplate){
|
||||
$scope.job_templates.forEach(function(row, i) {
|
||||
if(row.id === $scope.selectedTemplate.id) {
|
||||
$scope.job_templates[i].checked = 1;
|
||||
}
|
||||
else {
|
||||
$scope.job_templates[i].checked = 0;
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
$scope.toggle_job_template = function(id) {
|
||||
$scope.toggle_row = function(id) {
|
||||
|
||||
$scope.job_templates.forEach(function(row, i) {
|
||||
if (row.id === id) {
|
||||
@ -153,7 +166,21 @@ angular.module('templates', [surveyMaker.name, templatesList.name, jobTemplatesA
|
||||
|
||||
$scope.$on('templateSelected', function(e, options) {
|
||||
if(options.activeTab !== 'jobs') {
|
||||
// Clear out any selected job
|
||||
$scope.job_templates.forEach(function(row, i) {
|
||||
$scope.job_templates[i].checked = 0;
|
||||
});
|
||||
}
|
||||
else {
|
||||
if($scope.selectedTemplate){
|
||||
$scope.job_templates.forEach(function(row, i) {
|
||||
if(row.id === $scope.selectedTemplate.id) {
|
||||
$scope.job_templates[i].checked = 1;
|
||||
}
|
||||
else {
|
||||
$scope.job_templates[i].checked = 0;
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
@ -181,9 +208,21 @@ angular.module('templates', [surveyMaker.name, templatesList.name, jobTemplatesA
|
||||
$scope[`${list.iterator}_dataset`] = Dataset.data;
|
||||
$scope[list.name] = $scope[`${list.iterator}_dataset`].results;
|
||||
|
||||
$scope.$watch('workflow_inventory_sources', function(){
|
||||
if($scope.selectedTemplate){
|
||||
$scope.workflow_inventory_sources.forEach(function(row, i) {
|
||||
if(row.id === $scope.selectedTemplate.id) {
|
||||
$scope.workflow_inventory_sources[i].checked = 1;
|
||||
}
|
||||
else {
|
||||
$scope.workflow_inventory_sources[i].checked = 0;
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
$scope.toggle_inventory_source = function(id) {
|
||||
$scope.toggle_row = function(id) {
|
||||
|
||||
$scope.workflow_inventory_sources.forEach(function(row, i) {
|
||||
if (row.id === id) {
|
||||
@ -200,8 +239,22 @@ angular.module('templates', [surveyMaker.name, templatesList.name, jobTemplatesA
|
||||
};
|
||||
|
||||
$scope.$on('templateSelected', function(e, options) {
|
||||
if(options.activeTab !== 'project_sync') {
|
||||
|
||||
if(options.activeTab !== 'inventory_sync') {
|
||||
$scope.workflow_inventory_sources.forEach(function(row, i) {
|
||||
$scope.workflow_inventory_sources[i].checked = 0;
|
||||
});
|
||||
}
|
||||
else {
|
||||
if($scope.selectedTemplate){
|
||||
$scope.workflow_inventory_sources.forEach(function(row, i) {
|
||||
if(row.id === $scope.selectedTemplate.id) {
|
||||
$scope.workflow_inventory_sources[i].checked = 1;
|
||||
}
|
||||
else {
|
||||
$scope.workflow_inventory_sources[i].checked = 0;
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
@ -227,9 +280,21 @@ angular.module('templates', [surveyMaker.name, templatesList.name, jobTemplatesA
|
||||
$scope[`${list.iterator}_dataset`] = Dataset.data;
|
||||
$scope[list.name] = $scope[`${list.iterator}_dataset`].results;
|
||||
|
||||
$scope.$watch('projects', function(){
|
||||
if($scope.selectedTemplate){
|
||||
$scope.projects.forEach(function(row, i) {
|
||||
if(row.id === $scope.selectedTemplate.id) {
|
||||
$scope.projects[i].checked = 1;
|
||||
}
|
||||
else {
|
||||
$scope.projects[i].checked = 0;
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
$scope.toggle_project = function(id) {
|
||||
$scope.toggle_row = function(id) {
|
||||
|
||||
$scope.projects.forEach(function(row, i) {
|
||||
if (row.id === id) {
|
||||
@ -246,8 +311,22 @@ angular.module('templates', [surveyMaker.name, templatesList.name, jobTemplatesA
|
||||
};
|
||||
|
||||
$scope.$on('templateSelected', function(e, options) {
|
||||
if(options.activeTab !== 'inventory_sync') {
|
||||
|
||||
if(options.activeTab !== 'project_sync') {
|
||||
$scope.projects.forEach(function(row, i) {
|
||||
$scope.projects[i].checked = 0;
|
||||
});
|
||||
}
|
||||
else {
|
||||
if($scope.selectedTemplate){
|
||||
$scope.projects.forEach(function(row, i) {
|
||||
if(row.id === $scope.selectedTemplate.id) {
|
||||
$scope.projects[i].checked = 1;
|
||||
}
|
||||
else {
|
||||
$scope.projects[i].checked = 0;
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
@ -294,6 +373,7 @@ angular.module('templates', [surveyMaker.name, templatesList.name, jobTemplatesA
|
||||
};
|
||||
|
||||
$scope.$on('templateSelected', function(e, options) {
|
||||
|
||||
resetPromptFields();
|
||||
// Loop across the preset values and attach them to scope
|
||||
_.forOwn(options.presetValues, function(value, key) {
|
||||
@ -387,6 +467,9 @@ angular.module('templates', [surveyMaker.name, templatesList.name, jobTemplatesA
|
||||
dynamic: true
|
||||
}
|
||||
},
|
||||
ncyBreadcrumb: {
|
||||
skip: true
|
||||
},
|
||||
views: {
|
||||
'related': {
|
||||
templateProvider: function(ListDefinition, generateList) {
|
||||
@ -439,6 +522,9 @@ angular.module('templates', [surveyMaker.name, templatesList.name, jobTemplatesA
|
||||
dynamic: true
|
||||
}
|
||||
},
|
||||
ncyBreadcrumb: {
|
||||
skip: true
|
||||
},
|
||||
views: {
|
||||
'related': {
|
||||
templateProvider: function(ListDefinition, generateList) {
|
||||
|
||||
@ -560,17 +560,33 @@ export default ['$scope', 'WorkflowService', 'generateList', 'TemplateList', 'Pr
|
||||
|
||||
$scope.selectedTemplate = $scope.nodeBeingEdited.unifiedJobTemplate;
|
||||
|
||||
switch ($scope.nodeBeingEdited.unifiedJobTemplate.type) {
|
||||
case "job_template":
|
||||
$scope.workflowMakerFormConfig.activeTab = "jobs";
|
||||
break;
|
||||
case "project":
|
||||
$scope.workflowMakerFormConfig.activeTab = "project_sync";
|
||||
break;
|
||||
case "inventory_source":
|
||||
$scope.workflowMakerFormConfig.activeTab = "inventory_sync";
|
||||
break;
|
||||
if($scope.selectedTemplate.unified_job_type) {
|
||||
switch ($scope.selectedTemplate.unified_job_type) {
|
||||
case "job":
|
||||
$scope.workflowMakerFormConfig.activeTab = "jobs";
|
||||
break;
|
||||
case "project_update":
|
||||
$scope.workflowMakerFormConfig.activeTab = "project_sync";
|
||||
break;
|
||||
case "inventory_update":
|
||||
$scope.workflowMakerFormConfig.activeTab = "inventory_sync";
|
||||
break;
|
||||
}
|
||||
}
|
||||
else if($scope.selectedTemplate.type) {
|
||||
switch ($scope.selectedTemplate.type) {
|
||||
case "job_template":
|
||||
$scope.workflowMakerFormConfig.activeTab = "jobs";
|
||||
break;
|
||||
case "project":
|
||||
$scope.workflowMakerFormConfig.activeTab = "project_sync";
|
||||
break;
|
||||
case "inventory_source":
|
||||
$scope.workflowMakerFormConfig.activeTab = "inventory_sync";
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
let siblingConnectionTypes = WorkflowService.getSiblingConnectionTypes({
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user