From 1e5af1212db380d4daf080ab29fada46b2cb8e12 Mon Sep 17 00:00:00 2001 From: Greg Considine Date: Fri, 10 Mar 2017 17:33:58 -0500 Subject: [PATCH 1/4] Add anchor tag in place of button --- awx/ui/client/src/job-submission/job-submission.partial.html | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/awx/ui/client/src/job-submission/job-submission.partial.html b/awx/ui/client/src/job-submission/job-submission.partial.html index d3c6689e1c..bd8a83c8a9 100644 --- a/awx/ui/client/src/job-submission/job-submission.partial.html +++ b/awx/ui/client/src/job-submission/job-submission.partial.html @@ -26,7 +26,7 @@ None selected
- + REVERT
@@ -41,7 +41,7 @@ None selected
- + REVERT
From 5d9f27db620f6d6f62a7cd4c6fbb076d61c14200 Mon Sep 17 00:00:00 2001 From: Greg Considine Date: Mon, 13 Mar 2017 17:08:50 -0400 Subject: [PATCH 2/4] Fix default selection logic and revert link style The default selection wasn't represented in the UI for inventory and credential prompts, and the UI wasn't updated when revert was clicked. This addresses those bugs and adjust the style of the revert link to increase padding-left. --- .../job-submission/job-submission.block.less | 14 ++++---------- .../job-submission.controller.js | 18 ------------------ .../job-submission/job-submission.partial.html | 8 ++++---- .../credential/job-sub-cred-list.directive.js | 11 ++++++----- .../inventory/job-sub-inv-list.directive.js | 10 ++++++---- 5 files changed, 20 insertions(+), 41 deletions(-) diff --git a/awx/ui/client/src/job-submission/job-submission.block.less b/awx/ui/client/src/job-submission/job-submission.block.less index f99fd0ae1f..4d16d349a3 100644 --- a/awx/ui/client/src/job-submission/job-submission.block.less +++ b/awx/ui/client/src/job-submission/job-submission.block.less @@ -175,18 +175,12 @@ background-color: @btn-bg-hov; color: @btn-txt; } -.JobSubmission-revertButton { - background-color: @default-bg; - color: @default-link; - text-transform: uppercase; - padding-left:15px; - padding-right: 15px; + +.JobSubmission-revertLink { + padding-left:10px; font-size: 11px; } -.JobSubmission-revertButton:hover{ - background-color: @default-bg; - color: @default-link-hov; -} + .JobSubmission-selectedItem { display: flex; flex: 1 0 auto; diff --git a/awx/ui/client/src/job-submission/job-submission.controller.js b/awx/ui/client/src/job-submission/job-submission.controller.js index 49fb8b7640..0ac9335e12 100644 --- a/awx/ui/client/src/job-submission/job-submission.controller.js +++ b/awx/ui/client/src/job-submission/job-submission.controller.js @@ -316,15 +316,6 @@ export default $scope.revertToDefaultInventory = function() { if($scope.has_default_inventory) { $scope.selected_inventory = angular.copy($scope.defaults.inventory); - - // Loop across inventories and set update the "checked" attribute for each row - $scope.inventories.forEach(function(row, i) { - if (row.id === $scope.selected_inventory.id) { - $scope.inventories[i].checked = 1; - } else { - $scope.inventories[i].checked = 0; - } - }); } }; @@ -332,15 +323,6 @@ export default if($scope.has_default_credential) { $scope.selected_credential = angular.copy($scope.defaults.credential); updateRequiredPasswords(); - - // Loop across credentials and set update the "checked" attribute for each row - $scope.credentials.forEach(function(row, i) { - if (row.id === $scope.selected_credential.id) { - $scope.credentials[i].checked = 1; - } else { - $scope.credentials[i].checked = 0; - } - }); } }; diff --git a/awx/ui/client/src/job-submission/job-submission.partial.html b/awx/ui/client/src/job-submission/job-submission.partial.html index bd8a83c8a9..f05bdd25a8 100644 --- a/awx/ui/client/src/job-submission/job-submission.partial.html +++ b/awx/ui/client/src/job-submission/job-submission.partial.html @@ -26,10 +26,10 @@ None selected - +
@@ -41,10 +41,10 @@ None selected
- +
Launching this job requires the passwords listed below. Enter and confirm each password before continuing.
diff --git a/awx/ui/client/src/job-submission/lists/credential/job-sub-cred-list.directive.js b/awx/ui/client/src/job-submission/lists/credential/job-sub-cred-list.directive.js index ca33857d21..7f93de9947 100644 --- a/awx/ui/client/src/job-submission/lists/credential/job-sub-cred-list.directive.js +++ b/awx/ui/client/src/job-submission/lists/credential/job-sub-cred-list.directive.js @@ -9,7 +9,9 @@ import jobSubCredListController from './job-sub-cred-list.controller'; export default [ 'templateUrl', 'QuerySet', 'GetBasePath', 'generateList', '$compile', 'CredentialList', function(templateUrl, qs, GetBasePath, GenerateList, $compile, CredentialList) { return { - scope: {}, + scope: { + selectedCredential: '=' + }, templateUrl: templateUrl('job-submission/lists/credential/job-sub-cred-list'), controller: jobSubCredListController, restrict: 'E', @@ -43,11 +45,11 @@ export default [ 'templateUrl', 'QuerySet', 'GetBasePath', 'generateList', '$com $('#job-submission-credential-lookup').append($compile(html)(scope)); - scope.$watchCollection('credentials', function () { - if(scope.selected_credential) { + scope.$watchCollection('selectedCredential', function () { + if(scope.selectedCredential) { // Loop across the inventories and see if one of them should be "checked" scope.credentials.forEach(function(row, i) { - if (row.id === scope.selected_credential.id) { + if (row.id === scope.selectedCredential.id) { scope.credentials[i].checked = 1; } else { @@ -56,7 +58,6 @@ export default [ 'templateUrl', 'QuerySet', 'GetBasePath', 'generateList', '$com }); } }); - }); } }; diff --git a/awx/ui/client/src/job-submission/lists/inventory/job-sub-inv-list.directive.js b/awx/ui/client/src/job-submission/lists/inventory/job-sub-inv-list.directive.js index adb3bd8c12..d87347ced7 100644 --- a/awx/ui/client/src/job-submission/lists/inventory/job-sub-inv-list.directive.js +++ b/awx/ui/client/src/job-submission/lists/inventory/job-sub-inv-list.directive.js @@ -9,7 +9,9 @@ import jobSubInvListController from './job-sub-inv-list.controller'; export default [ 'templateUrl', 'QuerySet', 'GetBasePath', 'generateList', '$compile', 'InventoryList', function(templateUrl, qs, GetBasePath, GenerateList, $compile, InventoryList) { return { - scope: {}, + scope: { + selectedInventory: '=' + }, templateUrl: templateUrl('job-submission/lists/inventory/job-sub-inv-list'), controller: jobSubInvListController, restrict: 'E', @@ -41,11 +43,11 @@ export default [ 'templateUrl', 'QuerySet', 'GetBasePath', 'generateList', '$com $('#job-submission-inventory-lookup').append($compile(html)(scope)); - scope.$watchCollection('inventories', function () { - if(scope.selected_inventory) { + scope.$watchCollection('selectedInventory', function () { + if(scope.selectedInventory) { // Loop across the inventories and see if one of them should be "checked" scope.inventories.forEach(function(row, i) { - if (row.id === scope.selected_inventory.id) { + if (row.id === scope.selectedInventory.id) { scope.inventories[i].checked = 1; } else { From d4addb83dfe862ea0749395f525c89065da6e266 Mon Sep 17 00:00:00 2001 From: Greg Considine Date: Tue, 14 Mar 2017 13:22:47 -0400 Subject: [PATCH 3/4] Add logic to unset watchers using scope on destroy --- .../credential/job-sub-cred-list.directive.js | 18 +++++++++++------- .../inventory/job-sub-inv-list.directive.js | 18 +++++++++++------- 2 files changed, 22 insertions(+), 14 deletions(-) diff --git a/awx/ui/client/src/job-submission/lists/credential/job-sub-cred-list.directive.js b/awx/ui/client/src/job-submission/lists/credential/job-sub-cred-list.directive.js index 7f93de9947..93964e6774 100644 --- a/awx/ui/client/src/job-submission/lists/credential/job-sub-cred-list.directive.js +++ b/awx/ui/client/src/job-submission/lists/credential/job-sub-cred-list.directive.js @@ -7,7 +7,7 @@ import jobSubCredListController from './job-sub-cred-list.controller'; export default [ 'templateUrl', 'QuerySet', 'GetBasePath', 'generateList', '$compile', 'CredentialList', - function(templateUrl, qs, GetBasePath, GenerateList, $compile, CredentialList) { + (templateUrl, qs, GetBasePath, GenerateList, $compile, CredentialList) => { return { scope: { selectedCredential: '=' @@ -15,7 +15,9 @@ export default [ 'templateUrl', 'QuerySet', 'GetBasePath', 'generateList', '$com templateUrl: templateUrl('job-submission/lists/credential/job-sub-cred-list'), controller: jobSubCredListController, restrict: 'E', - link: function(scope) { + link: scope => { + let toDestroy = []; + scope.credential_default_params = { order_by: 'name', page_size: 5, @@ -30,11 +32,11 @@ export default [ 'templateUrl', 'QuerySet', 'GetBasePath', 'generateList', '$com // Fire off the initial search qs.search(GetBasePath('credentials'), scope.credential_default_params) - .then(function(res) { + .then(res => { scope.credential_dataset = res.data; scope.credentials = scope.credential_dataset.results; - var credList = _.cloneDeep(CredentialList); + let credList = _.cloneDeep(CredentialList); let html = GenerateList.build({ list: credList, input_type: 'radio', @@ -45,10 +47,10 @@ export default [ 'templateUrl', 'QuerySet', 'GetBasePath', 'generateList', '$com $('#job-submission-credential-lookup').append($compile(html)(scope)); - scope.$watchCollection('selectedCredential', function () { + toDestroy.push(scope.$watchCollection('selectedCredential', () => { if(scope.selectedCredential) { // Loop across the inventories and see if one of them should be "checked" - scope.credentials.forEach(function(row, i) { + scope.credentials.forEach((row, i) => { if (row.id === scope.selectedCredential.id) { scope.credentials[i].checked = 1; } @@ -57,8 +59,10 @@ export default [ 'templateUrl', 'QuerySet', 'GetBasePath', 'generateList', '$com } }); } - }); + })); }); + + scope.$on('$destroy', () => toDestroy.forEach(watcher => watcher())); } }; }]; diff --git a/awx/ui/client/src/job-submission/lists/inventory/job-sub-inv-list.directive.js b/awx/ui/client/src/job-submission/lists/inventory/job-sub-inv-list.directive.js index d87347ced7..2025a6b213 100644 --- a/awx/ui/client/src/job-submission/lists/inventory/job-sub-inv-list.directive.js +++ b/awx/ui/client/src/job-submission/lists/inventory/job-sub-inv-list.directive.js @@ -7,7 +7,7 @@ import jobSubInvListController from './job-sub-inv-list.controller'; export default [ 'templateUrl', 'QuerySet', 'GetBasePath', 'generateList', '$compile', 'InventoryList', - function(templateUrl, qs, GetBasePath, GenerateList, $compile, InventoryList) { + (templateUrl, qs, GetBasePath, GenerateList, $compile, InventoryList) => { return { scope: { selectedInventory: '=' @@ -15,7 +15,9 @@ export default [ 'templateUrl', 'QuerySet', 'GetBasePath', 'generateList', '$com templateUrl: templateUrl('job-submission/lists/inventory/job-sub-inv-list'), controller: jobSubInvListController, restrict: 'E', - link: function(scope) { + link: scope => { + let toDestroy = []; + scope.inventory_default_params = { order_by: 'name', page_size: 5 @@ -28,11 +30,11 @@ export default [ 'templateUrl', 'QuerySet', 'GetBasePath', 'generateList', '$com // Fire off the initial search qs.search(GetBasePath('inventory'), scope.inventory_default_params) - .then(function(res) { + .then(res => { scope.inventory_dataset = res.data; scope.inventories = scope.inventory_dataset.results; - var invList = _.cloneDeep(InventoryList); + let invList = _.cloneDeep(InventoryList); let html = GenerateList.build({ list: invList, input_type: 'radio', @@ -43,10 +45,10 @@ export default [ 'templateUrl', 'QuerySet', 'GetBasePath', 'generateList', '$com $('#job-submission-inventory-lookup').append($compile(html)(scope)); - scope.$watchCollection('selectedInventory', function () { + toDestroy.push(scope.$watchCollection('selectedInventory', () => { if(scope.selectedInventory) { // Loop across the inventories and see if one of them should be "checked" - scope.inventories.forEach(function(row, i) { + scope.inventories.forEach((row, i) => { if (row.id === scope.selectedInventory.id) { scope.inventories[i].checked = 1; } @@ -55,8 +57,10 @@ export default [ 'templateUrl', 'QuerySet', 'GetBasePath', 'generateList', '$com } }); } - }); + })); }); + + scope.$on('$destory', () => toDestroy.forEach(watcher => watcher())); } }; }]; From 377b55dd2fa198b7bde2855aae1f035ddcaab7a4 Mon Sep 17 00:00:00 2001 From: Greg Considine Date: Tue, 14 Mar 2017 14:51:20 -0400 Subject: [PATCH 4/4] Fix typo in reference to --- .../lists/inventory/job-sub-inv-list.directive.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/awx/ui/client/src/job-submission/lists/inventory/job-sub-inv-list.directive.js b/awx/ui/client/src/job-submission/lists/inventory/job-sub-inv-list.directive.js index 2025a6b213..305643e0e3 100644 --- a/awx/ui/client/src/job-submission/lists/inventory/job-sub-inv-list.directive.js +++ b/awx/ui/client/src/job-submission/lists/inventory/job-sub-inv-list.directive.js @@ -60,7 +60,7 @@ export default [ 'templateUrl', 'QuerySet', 'GetBasePath', 'generateList', '$com })); }); - scope.$on('$destory', () => toDestroy.forEach(watcher => watcher())); + scope.$on('$destroy', () => toDestroy.forEach(watcher => watcher())); } }; }];