Fix bug with workflow maker templates pagination and smart search

This commit is contained in:
Marliana Lara
2018-11-05 14:00:22 -05:00
parent 2ae8583a86
commit a3d5705cea
2 changed files with 59 additions and 54 deletions

View File

@@ -1,4 +1,4 @@
<div class="List-infoCell" ng-if="template.type === 'job_template'"> <div class="List-infoCell" ng-if="wf_maker_template.type === 'job_template'">
<span class="Key-icon Key-icon--circle Key-icon--default" aw-pop-over="<dl><dt>{{ 'INVENTORY' | translate }}</dt><dd>{{(template.summary_fields.inventory.name | sanitize) || ('NONE SELECTED' | translate)}}</dd></dl><dl><dt>{{ 'PROJECT' | translate }}</dt><dd>{{template.summary_fields.project.name | sanitize}}</dd></dl><dl><dt>{{ 'PLAYBOOK' | translate }}</dt><dd>{{template.playbook| sanitize}}</dd></dl><dl><dt>{{ 'CREDENTIAL' | translate }}</dt> <dd>{{(template.summary_fields.credential.name | sanitize) || ('NONE SELECTED' | translate)}}</dd></dl>" <span class="Key-icon Key-icon--circle Key-icon--default" aw-pop-over="<dl><dt>{{ 'INVENTORY' | translate }}</dt><dd>{{(wf_maker_template.summary_fields.inventory.name | sanitize) || ('NONE SELECTED' | translate)}}</dd></dl><dl><dt>{{ 'PROJECT' | translate }}</dt><dd>{{wf_maker_template.summary_fields.project.name | sanitize}}</dd></dl><dl><dt>{{ 'PLAYBOOK' | translate }}</dt><dd>{{wf_maker_template.playbook| sanitize}}</dd></dl><dl><dt>{{ 'CREDENTIAL' | translate }}</dt> <dd>{{(wf_maker_template.summary_fields.credential.name | sanitize) || ('NONE SELECTED' | translate)}}</dd></dl>"
data-popover-title="{{template.name| sanitize}}">?</span> data-popover-title="{{wf_maker_template.name| sanitize}}">?</span>
</div> </div>

View File

@@ -413,28 +413,29 @@ angular.module('templates', [surveyMaker.name, jobTemplates.name, labels.name, p
formChildState: true formChildState: true
}, },
params: { params: {
job_template_search: { wf_maker_template_search: {
value: { value: {
page_size: '5',
order_by: 'name', order_by: 'name',
role_level: 'execute_role' page_size: '10',
role_level: 'execute_role',
type: 'workflow_job_template,job_template'
}, },
squash: false, squash: false,
dynamic: true dynamic: true
}, },
project_search: { wf_maker_project_search: {
value: { value: {
page_size: '5', order_by: 'name',
order_by: 'name' page_size: '10'
}, },
squash: true, squash: true,
dynamic: true dynamic: true
}, },
inventory_source_search: { wf_maker_inventory_source_search: {
value: { value: {
page_size: '5',
not__source: '', not__source: '',
order_by: 'name' order_by: 'name',
page_size: '10'
}, },
squash: true, squash: true,
dynamic: true dynamic: true
@@ -465,14 +466,14 @@ angular.module('templates', [surveyMaker.name, jobTemplates.name, labels.name, p
$scope[`${list.iterator}_dataset`] = Dataset.data; $scope[`${list.iterator}_dataset`] = Dataset.data;
$scope[list.name] = $scope[`${list.iterator}_dataset`].results; $scope[list.name] = $scope[`${list.iterator}_dataset`].results;
$scope.$watch('templates', function(){ $scope.$watch('wf_maker_templates', function(){
if($scope.selectedTemplate){ if($scope.selectedTemplate){
$scope.templates.forEach(function(row, i) { $scope.wf_maker_templates.forEach(function(row, i) {
if(row.id === $scope.selectedTemplate.id) { if(row.id === $scope.selectedTemplate.id) {
$scope.templates[i].checked = 1; $scope.wf_maker_templates[i].checked = 1;
} }
else { else {
$scope.templates[i].checked = 0; $scope.wf_maker_templates[i].checked = 0;
} }
}); });
} }
@@ -481,9 +482,9 @@ angular.module('templates', [surveyMaker.name, jobTemplates.name, labels.name, p
$scope.toggle_row = function(selectedRow) { $scope.toggle_row = function(selectedRow) {
if ($scope.workflowJobTemplateObj.summary_fields.user_capabilities.edit) { if ($scope.workflowJobTemplateObj.summary_fields.user_capabilities.edit) {
$scope.templates.forEach(function(row, i) { $scope.wf_maker_templates.forEach(function(row, i) {
if (row.id === selectedRow.id) { if (row.id === selectedRow.id) {
$scope.templates[i].checked = 1; $scope.wf_maker_templates[i].checked = 1;
$scope.selection[list.iterator] = { $scope.selection[list.iterator] = {
id: row.id, id: row.id,
name: row.name name: row.name
@@ -496,27 +497,27 @@ angular.module('templates', [surveyMaker.name, jobTemplates.name, labels.name, p
}; };
$scope.$watch('selectedTemplate', () => { $scope.$watch('selectedTemplate', () => {
$scope.templates.forEach(function(row, i) { $scope.wf_maker_templates.forEach(function(row, i) {
if(_.has($scope, 'selectedTemplate.id') && row.id === $scope.selectedTemplate.id) { if(_.has($scope, 'selectedTemplate.id') && row.id === $scope.selectedTemplate.id) {
$scope.templates[i].checked = 1; $scope.wf_maker_templates[i].checked = 1;
} }
else { else {
$scope.templates[i].checked = 0; $scope.wf_maker_templates[i].checked = 0;
} }
}); });
}); });
$scope.$watch('activeTab', () => { $scope.$watch('activeTab', () => {
if(!$scope.activeTab || $scope.activeTab !== "jobs") { if(!$scope.activeTab || $scope.activeTab !== "jobs") {
$scope.templates.forEach(function(row, i) { $scope.wf_maker_templates.forEach(function(row, i) {
$scope.templates[i].checked = 0; $scope.wf_maker_templates[i].checked = 0;
}); });
} }
}); });
$scope.$on('clearWorkflowLists', function() { $scope.$on('clearWorkflowLists', function() {
$scope.templates.forEach(function(row, i) { $scope.wf_maker_templates.forEach(function(row, i) {
$scope.templates[i].checked = 0; $scope.wf_maker_templates[i].checked = 0;
}); });
}); });
} }
@@ -542,14 +543,14 @@ angular.module('templates', [surveyMaker.name, jobTemplates.name, labels.name, p
$scope[`${list.iterator}_dataset`] = Dataset.data; $scope[`${list.iterator}_dataset`] = Dataset.data;
$scope[list.name] = $scope[`${list.iterator}_dataset`].results; $scope[list.name] = $scope[`${list.iterator}_dataset`].results;
$scope.$watch('workflow_inventory_sources', function(){ $scope.$watch('wf_maker_inventory_sources', function(){
if($scope.selectedTemplate){ if($scope.selectedTemplate){
$scope.workflow_inventory_sources.forEach(function(row, i) { $scope.wf_maker_inventory_sources.forEach(function(row, i) {
if(row.id === $scope.selectedTemplate.id) { if(row.id === $scope.selectedTemplate.id) {
$scope.workflow_inventory_sources[i].checked = 1; $scope.wf_maker_inventory_sources[i].checked = 1;
} }
else { else {
$scope.workflow_inventory_sources[i].checked = 0; $scope.wf_maker_inventory_sources[i].checked = 0;
} }
}); });
} }
@@ -558,9 +559,9 @@ angular.module('templates', [surveyMaker.name, jobTemplates.name, labels.name, p
$scope.toggle_row = function(selectedRow) { $scope.toggle_row = function(selectedRow) {
if ($scope.workflowJobTemplateObj.summary_fields.user_capabilities.edit) { if ($scope.workflowJobTemplateObj.summary_fields.user_capabilities.edit) {
$scope.workflow_inventory_sources.forEach(function(row, i) { $scope.wf_maker_inventory_sources.forEach(function(row, i) {
if (row.id === selectedRow.id) { if (row.id === selectedRow.id) {
$scope.workflow_inventory_sources[i].checked = 1; $scope.wf_maker_inventory_sources[i].checked = 1;
$scope.selection[list.iterator] = { $scope.selection[list.iterator] = {
id: row.id, id: row.id,
name: row.name name: row.name
@@ -573,27 +574,27 @@ angular.module('templates', [surveyMaker.name, jobTemplates.name, labels.name, p
}; };
$scope.$watch('selectedTemplate', () => { $scope.$watch('selectedTemplate', () => {
$scope.workflow_inventory_sources.forEach(function(row, i) { $scope.wf_maker_inventory_sources.forEach(function(row, i) {
if(_.hasIn($scope, 'selectedTemplate.id') && row.id === $scope.selectedTemplate.id) { if(_.hasIn($scope, 'selectedTemplate.id') && row.id === $scope.selectedTemplate.id) {
$scope.workflow_inventory_sources[i].checked = 1; $scope.wf_maker_inventory_sources[i].checked = 1;
} }
else { else {
$scope.workflow_inventory_sources[i].checked = 0; $scope.wf_maker_inventory_sources[i].checked = 0;
} }
}); });
}); });
$scope.$watch('activeTab', () => { $scope.$watch('activeTab', () => {
if(!$scope.activeTab || $scope.activeTab !== "inventory_sync") { if(!$scope.activeTab || $scope.activeTab !== "inventory_sync") {
$scope.workflow_inventory_sources.forEach(function(row, i) { $scope.wf_maker_inventory_sources.forEach(function(row, i) {
$scope.workflow_inventory_sources[i].checked = 0; $scope.wf_maker_inventory_sources[i].checked = 0;
}); });
} }
}); });
$scope.$on('clearWorkflowLists', function() { $scope.$on('clearWorkflowLists', function() {
$scope.workflow_inventory_sources.forEach(function(row, i) { $scope.wf_maker_inventory_sources.forEach(function(row, i) {
$scope.workflow_inventory_sources[i].checked = 0; $scope.wf_maker_inventory_sources[i].checked = 0;
}); });
}); });
} }
@@ -619,14 +620,14 @@ angular.module('templates', [surveyMaker.name, jobTemplates.name, labels.name, p
$scope[`${list.iterator}_dataset`] = Dataset.data; $scope[`${list.iterator}_dataset`] = Dataset.data;
$scope[list.name] = $scope[`${list.iterator}_dataset`].results; $scope[list.name] = $scope[`${list.iterator}_dataset`].results;
$scope.$watch('projects', function(){ $scope.$watch('wf_maker_projects', function(){
if($scope.selectedTemplate){ if($scope.selectedTemplate){
$scope.projects.forEach(function(row, i) { $scope.wf_maker_projects.forEach(function(row, i) {
if(row.id === $scope.selectedTemplate.id) { if(row.id === $scope.selectedTemplate.id) {
$scope.projects[i].checked = 1; $scope.wf_maker_projects[i].checked = 1;
} }
else { else {
$scope.projects[i].checked = 0; $scope.wf_maker_projects[i].checked = 0;
} }
}); });
} }
@@ -635,9 +636,9 @@ angular.module('templates', [surveyMaker.name, jobTemplates.name, labels.name, p
$scope.toggle_row = function(selectedRow) { $scope.toggle_row = function(selectedRow) {
if ($scope.workflowJobTemplateObj.summary_fields.user_capabilities.edit) { if ($scope.workflowJobTemplateObj.summary_fields.user_capabilities.edit) {
$scope.projects.forEach(function(row, i) { $scope.wf_maker_projects.forEach(function(row, i) {
if (row.id === selectedRow.id) { if (row.id === selectedRow.id) {
$scope.projects[i].checked = 1; $scope.wf_maker_projects[i].checked = 1;
$scope.selection[list.iterator] = { $scope.selection[list.iterator] = {
id: row.id, id: row.id,
name: row.name name: row.name
@@ -650,27 +651,27 @@ angular.module('templates', [surveyMaker.name, jobTemplates.name, labels.name, p
}; };
$scope.$watch('selectedTemplate', () => { $scope.$watch('selectedTemplate', () => {
$scope.projects.forEach(function(row, i) { $scope.wf_maker_projects.forEach(function(row, i) {
if(_.hasIn($scope, 'selectedTemplate.id') && row.id === $scope.selectedTemplate.id) { if(_.hasIn($scope, 'selectedTemplate.id') && row.id === $scope.selectedTemplate.id) {
$scope.projects[i].checked = 1; $scope.wf_maker_projects[i].checked = 1;
} }
else { else {
$scope.projects[i].checked = 0; $scope.wf_maker_projects[i].checked = 0;
} }
}); });
}); });
$scope.$watch('activeTab', () => { $scope.$watch('activeTab', () => {
if(!$scope.activeTab || $scope.activeTab !== "project_sync") { if(!$scope.activeTab || $scope.activeTab !== "project_sync") {
$scope.projects.forEach(function(row, i) { $scope.wf_maker_projects.forEach(function(row, i) {
$scope.projects[i].checked = 0; $scope.wf_maker_projects[i].checked = 0;
}); });
} }
}); });
$scope.$on('clearWorkflowLists', function() { $scope.$on('clearWorkflowLists', function() {
$scope.projects.forEach(function(row, i) { $scope.wf_maker_projects.forEach(function(row, i) {
$scope.projects[i].checked = 0; $scope.wf_maker_projects[i].checked = 0;
}); });
}); });
} }
@@ -705,13 +706,13 @@ angular.module('templates', [surveyMaker.name, jobTemplates.name, labels.name, p
delete list.fields.smart_status; delete list.fields.smart_status;
delete list.fields.labels; delete list.fields.labels;
delete list.fieldActions; delete list.fieldActions;
list.name = 'wf_maker_templates';
list.iterator = 'wf_maker_template';
list.fields.name.columnClass = "col-md-8"; list.fields.name.columnClass = "col-md-8";
list.fields.name.tag = i18n._('WORKFLOW'); list.fields.name.tag = i18n._('WORKFLOW');
list.fields.name.showTag = "{{template.type === 'workflow_job_template'}}"; list.fields.name.showTag = "{{wf_maker_template.type === 'workflow_job_template'}}";
list.disableRow = "{{ !workflowJobTemplateObj.summary_fields.user_capabilities.edit }}"; list.disableRow = "{{ !workflowJobTemplateObj.summary_fields.user_capabilities.edit }}";
list.disableRowValue = '!workflowJobTemplateObj.summary_fields.user_capabilities.edit'; list.disableRowValue = '!workflowJobTemplateObj.summary_fields.user_capabilities.edit';
list.iterator = 'template';
list.name = 'templates';
list.basePath = 'unified_job_templates'; list.basePath = 'unified_job_templates';
list.fields.info = { list.fields.info = {
ngInclude: "'/static/partials/job-template-details.html'", ngInclude: "'/static/partials/job-template-details.html'",
@@ -733,6 +734,8 @@ angular.module('templates', [surveyMaker.name, jobTemplates.name, labels.name, p
delete list.fields.status; delete list.fields.status;
delete list.fields.scm_type; delete list.fields.scm_type;
delete list.fields.last_updated; delete list.fields.last_updated;
list.name = 'wf_maker_projects';
list.iterator = 'wf_maker_project';
list.fields.name.columnClass = "col-md-11"; list.fields.name.columnClass = "col-md-11";
list.maxVisiblePages = 5; list.maxVisiblePages = 5;
list.searchBarFullWidth = true; list.searchBarFullWidth = true;
@@ -745,6 +748,8 @@ angular.module('templates', [surveyMaker.name, jobTemplates.name, labels.name, p
WorkflowInventorySourcesList: ['InventorySourcesList', WorkflowInventorySourcesList: ['InventorySourcesList',
(InventorySourcesList) => { (InventorySourcesList) => {
let list = _.cloneDeep(InventorySourcesList); let list = _.cloneDeep(InventorySourcesList);
list.name = 'wf_maker_inventory_sources';
list.iterator = 'wf_maker_inventory_source';
list.maxVisiblePages = 5; list.maxVisiblePages = 5;
list.searchBarFullWidth = true; list.searchBarFullWidth = true;
list.disableRow = "{{ !workflowJobTemplateObj.summary_fields.user_capabilities.edit }}"; list.disableRow = "{{ !workflowJobTemplateObj.summary_fields.user_capabilities.edit }}";