From f7dda124b1427a254b3eb731c23e794b74100531 Mon Sep 17 00:00:00 2001 From: mabashian Date: Fri, 13 Jul 2018 15:59:31 -0400 Subject: [PATCH] Remove updateDataset from templates list --- .../templates/templatesList.controller.js | 27 +++++++------------ .../templates/templatesList.view.html | 18 ++++++------- 2 files changed, 18 insertions(+), 27 deletions(-) diff --git a/awx/ui/client/features/templates/templatesList.controller.js b/awx/ui/client/features/templates/templatesList.controller.js index db90072cd9..b29ba33a96 100644 --- a/awx/ui/client/features/templates/templatesList.controller.js +++ b/awx/ui/client/features/templates/templatesList.controller.js @@ -51,17 +51,16 @@ function ListTemplatesController( $scope.canAdd = ($scope.canAddJobTemplate || $scope.canAddWorkflowJobTemplate); // smart-search - $scope.list = { + vm.list = { iterator: 'template', name: 'templates' }; - $scope.collection = { - iterator: 'template', - basePath: 'unified_job_templates' - }; - $scope.template_dataset = Dataset.data; - $scope.templates = Dataset.data.results; - $scope.$emit('updateCount', Dataset.data.count, 'templates'); + vm.dataset = Dataset.data; + vm.templates = Dataset.data.results; + + $scope.$watch('vm.dataset.count', () => { + $scope.$emit('updateCount', vm.dataset.count, 'templates'); + }); $scope.$watch('$state.params', function(newValue, oldValue) { const job_template_id = _.get($state.params, 'job_template_id'); @@ -72,12 +71,6 @@ function ListTemplatesController( } }, true); - $scope.$on('updateDataset', (e, dataset) => { - $scope.template_dataset = dataset; - $scope.templates = dataset.results; - $scope.$emit('updateCount', dataset.count, 'templates'); - }); - $scope.$on(`ws-jobs`, () => { if (!launchModalOpen) { refreshTemplates(); @@ -188,8 +181,8 @@ function ListTemplatesController( let path = GetBasePath('unified_job_templates'); qs.search(path, $state.params.template_search) .then(function(searchResponse) { - $scope.template_dataset = searchResponse.data; - $scope.templates = $scope.template_dataset.results; + vm.dataset = searchResponse.data; + vm.templates = vm.dataset.results; }); } @@ -254,7 +247,7 @@ function ListTemplatesController( const { page } = _.get($state.params, 'template_search'); let reloadListStateParams = null; - if ($scope.templates.length === 1 && page && page !== '1') { + if (vm.templates.length === 1 && page && page !== '1') { reloadListStateParams = _.cloneDeep($state.params); const pageNumber = (parseInt(reloadListStateParams.template_search.page, 0) - 1); reloadListStateParams.template_search.page = pageNumber.toString(); diff --git a/awx/ui/client/features/templates/templatesList.view.html b/awx/ui/client/features/templates/templatesList.view.html index 0c7783d18f..5b520237a2 100644 --- a/awx/ui/client/features/templates/templatesList.view.html +++ b/awx/ui/client/features/templates/templatesList.view.html @@ -5,11 +5,10 @@ django-model="templates" base-path="unified_job_templates" iterator="template" - list="list" - dataset="template_dataset" - collection="collection" - search-tags="searchTags" - query-set="querySet" + list="vm.list" + collection="vm.templates" + dataset="vm.dataset" + search-tags="vm.searchTags" search-bar-full-width="vm.isPortalMode">
@@ -37,7 +36,7 @@
- + base-path="unified_job_templates">