1
0
mirror of https://github.com/ansible/awx.git synced 2024-11-02 09:51:09 +03:00

Reset list radio selection when switching to a new tab

This commit is contained in:
Leigh Johnson 2016-11-04 16:32:35 -04:00
parent 1656ab45f1
commit ce5f95c206
2 changed files with 78 additions and 29 deletions

View File

@ -120,12 +120,29 @@ angular.module('jobTemplates', [surveyMaker.name, jobTemplatesList.name, jobTemp
return html; return html;
}, },
// $scope encapsulated in this controller will be a initialized as child of 'modal' $scope, because of element hierarchy // $scope encapsulated in this controller will be a initialized as child of 'modal' $scope, because of element hierarchy
controller: ['$scope', 'JobTemplateList', 'JobTemplateDataset', controller: ['$scope', 'JobTemplateList', 'JobTemplateDataset', '$log',
function($scope, list, Dataset) { function($scope, list, Dataset, $log) {
$scope.list = list; // name of this tab
$scope[`${list.iterator}_dataset`] = Dataset.data; let tab = 'jobs';
$scope[list.name] = $scope[`${list.iterator}_dataset`].results;
init();
function init() {
$scope.list = list;
$scope[`${list.iterator}_dataset`] = Dataset.data;
$scope[list.name] = $scope[`${list.iterator}_dataset`].results;
}
// resets any selected list items, if this tab is not active
$scope.$on('resetWorkflowList', function(e, active) {
// e.targetScope is a reference to the outer scope if you need to manipulate it!
// a reference to the currently-selected radio is stored in $scope.selection[list.iterator]
// clear it out!
if (active !== tab) {
$scope.selection[list.iterator] = null;
}
});
} }
] ]
}, },
@ -143,10 +160,25 @@ angular.module('jobTemplates', [surveyMaker.name, jobTemplatesList.name, jobTemp
// encapsulated $scope in this controller will be a initialized as child of 'modal' $scope, because of element hierarchy // encapsulated $scope in this controller will be a initialized as child of 'modal' $scope, because of element hierarchy
controller: ['$scope', 'InventorySourcesList', 'InventorySourcesDataset', controller: ['$scope', 'InventorySourcesList', 'InventorySourcesDataset',
function($scope, list, Dataset) { function($scope, list, Dataset) {
$scope.list = list; let tab = 'inventory_sync';
$scope[`${list.iterator}_dataset`] = Dataset.data;
$scope[list.name] = $scope[`${list.iterator}_dataset`].results;
init();
function init() {
$scope.list = list;
$scope[`${list.iterator}_dataset`] = Dataset.data;
$scope[list.name] = $scope[`${list.iterator}_dataset`].results;
}
// resets any selected list items, if this tab is not active
$scope.$on('resetWorkflowList', function(e, active) {
// e.targetScope is a reference to the outer scope if you need to manipulate it!
if (active !== tab) {
$scope.selection[list.iterator] = null;
}
});
} }
] ]
}, },
@ -167,9 +199,24 @@ angular.module('jobTemplates', [surveyMaker.name, jobTemplatesList.name, jobTemp
// encapsulated $scope in this controller will be a initialized as child of 'modal' $scope, because of element hierarchy // encapsulated $scope in this controller will be a initialized as child of 'modal' $scope, because of element hierarchy
controller: ['$scope', 'ProjectList', 'ProjectDataset', controller: ['$scope', 'ProjectList', 'ProjectDataset',
function($scope, list, Dataset) { function($scope, list, Dataset) {
$scope.list = list; let tab = 'project_sync';
$scope[`${list.iterator}_dataset`] = Dataset.data;
$scope[list.name] = $scope[`${list.iterator}_dataset`].results; init();
function init() {
$scope.list = list;
$scope[`${list.iterator}_dataset`] = Dataset.data;
$scope[list.name] = $scope[`${list.iterator}_dataset`].results;
}
// resets any selected list items, if this tab is not active
$scope.$on('resetWorkflowList', function(e, active) {
// e.targetScope is a reference to the outer scope if you need to manipulate it!
if (active !== tab) {
$scope.selection[list.iterator] = null;
}
});
} }
] ]
}, },

View File

@ -540,6 +540,8 @@ export default ['$scope', 'WorkflowHelpService', 'generateList', 'JobTemplateLis
}; };
$scope.toggleFormTab = function(tab) { $scope.toggleFormTab = function(tab) {
// a dictionary of settings required by each encapsulated tab
$scope.$broadcast('resetWorkflowList', tab);
if ($scope.workflowMakerFormConfig.activeTab !== tab) { if ($scope.workflowMakerFormConfig.activeTab !== tab) {
$scope.workflowMakerFormConfig.activeTab = tab; $scope.workflowMakerFormConfig.activeTab = tab;
} }
@ -547,13 +549,13 @@ export default ['$scope', 'WorkflowHelpService', 'generateList', 'JobTemplateLis
$scope.toggle_job_template = function(id) { $scope.toggle_job_template = function(id) {
$scope.workflow_projects.forEach(function(row, i) { // $scope.workflow_projects.forEach(function(row, i) {
$scope.workflow_projects[i].checked = 0; // $scope.workflow_projects[i].checked = 0;
}); // });
$scope.workflow_inventory_sources.forEach(function(row, i) { // $scope.workflow_inventory_sources.forEach(function(row, i) {
$scope.workflow_inventory_sources[i].checked = 0; // $scope.workflow_inventory_sources[i].checked = 0;
}); // });
$scope.workflow_job_templates.forEach(function(row, i) { $scope.workflow_job_templates.forEach(function(row, i) {
if (row.id === id) { if (row.id === id) {
@ -614,13 +616,13 @@ export default ['$scope', 'WorkflowHelpService', 'generateList', 'JobTemplateLis
resetPromptFields(); resetPromptFields();
$scope.workflow_job_templates.forEach(function(row, i) { // $scope.workflow_job_templates.forEach(function(row, i) {
$scope.workflow_job_templates[i].checked = 0; // $scope.workflow_job_templates[i].checked = 0;
}); // });
$scope.workflow_inventory_sources.forEach(function(row, i) { // $scope.workflow_inventory_sources.forEach(function(row, i) {
$scope.workflow_inventory_sources[i].checked = 0; // $scope.workflow_inventory_sources[i].checked = 0;
}); // });
$scope.workflow_projects.forEach(function(row, i) { $scope.workflow_projects.forEach(function(row, i) {
if (row.id === id) { if (row.id === id) {
@ -637,13 +639,13 @@ export default ['$scope', 'WorkflowHelpService', 'generateList', 'JobTemplateLis
resetPromptFields(); resetPromptFields();
$scope.workflow_job_templates.forEach(function(row, i) { // $scope.workflow_job_templates.forEach(function(row, i) {
$scope.workflow_job_templates[i].checked = 0; // $scope.workflow_job_templates[i].checked = 0;
}); // });
$scope.workflow_projects.forEach(function(row, i) { // $scope.workflow_projects.forEach(function(row, i) {
$scope.workflow_projects[i].checked = 0; // $scope.workflow_projects[i].checked = 0;
}); // });
$scope.workflow_inventory_sources.forEach(function(row, i) { $scope.workflow_inventory_sources.forEach(function(row, i) {
if (row.id === id) { if (row.id === id) {