From b16854898b4853e15c1b573a8680e66184d947b6 Mon Sep 17 00:00:00 2001 From: kialam Date: Wed, 6 Jun 2018 11:13:41 -0400 Subject: [PATCH] Refactor `Toggle Tag` Component This refactor includes the following things: - Offload credential tag formatting to the parent controller, e.g. `TemplateListController`. - Initialize the `Toggle Tag` component in the parent view instead of the List Item component view. - Rename some variables for better comprehension. --- .../templates/templatesList.controller.js | 2 +- .../templates/templatesList.view.html | 20 ++++-------------- .../lib/components/list/row-item.partial.html | 15 +------------ .../lib/components/toggle-tag/constants.js | 2 +- .../toggle-tag/toggle-tag.directive.js | 21 +++---------------- .../toggle-tag/toggle-tag.partial.html | 21 ++++++++++++------- 6 files changed, 23 insertions(+), 58 deletions(-) diff --git a/awx/ui/client/features/templates/templatesList.controller.js b/awx/ui/client/features/templates/templatesList.controller.js index ad3137e949..b8a29f4db8 100644 --- a/awx/ui/client/features/templates/templatesList.controller.js +++ b/awx/ui/client/features/templates/templatesList.controller.js @@ -164,7 +164,7 @@ function ListTemplatesController( return html; }; - + vm.buildCredentialTags = (credentials) => { return credentials.map(credential => { const icon = `${credential.kind}`; diff --git a/awx/ui/client/features/templates/templatesList.view.html b/awx/ui/client/features/templates/templatesList.view.html index d77910ac1f..5aed695f57 100644 --- a/awx/ui/client/features/templates/templatesList.view.html +++ b/awx/ui/client/features/templates/templatesList.view.html @@ -68,24 +68,12 @@ value="{{ template.summary_fields.project.name }}" value-link="/#/projects/{{ template.summary_fields.project.id }}"> - - - - - - - - - - - - - + tags-are-creds="true"> + + diff --git a/awx/ui/client/lib/components/list/row-item.partial.html b/awx/ui/client/lib/components/list/row-item.partial.html index 3c50e1fb83..48e309db8e 100644 --- a/awx/ui/client/lib/components/list/row-item.partial.html +++ b/awx/ui/client/lib/components/list/row-item.partial.html @@ -42,19 +42,6 @@ template-type="smartStatus.type" ng-if="smartStatus">
-
- -
- - - - - - - - - +
diff --git a/awx/ui/client/lib/components/toggle-tag/constants.js b/awx/ui/client/lib/components/toggle-tag/constants.js index e120030b65..f3a4951c9c 100644 --- a/awx/ui/client/lib/components/toggle-tag/constants.js +++ b/awx/ui/client/lib/components/toggle-tag/constants.js @@ -1,2 +1,2 @@ export const TRUNCATE_LENGTH = 5; -export const TRUNCATED = true; +export const IS_TRUNCATED = true; diff --git a/awx/ui/client/lib/components/toggle-tag/toggle-tag.directive.js b/awx/ui/client/lib/components/toggle-tag/toggle-tag.directive.js index 3cc49b3cea..4fec4cd794 100644 --- a/awx/ui/client/lib/components/toggle-tag/toggle-tag.directive.js +++ b/awx/ui/client/lib/components/toggle-tag/toggle-tag.directive.js @@ -1,29 +1,16 @@ -import { TRUNCATED, TRUNCATE_LENGTH } from './constants'; +import { IS_TRUNCATED, TRUNCATE_LENGTH } from './constants'; const templateUrl = require('~components/toggle-tag/toggle-tag.partial.html'); function controller (strings) { - // const { tags } = $scope; const vm = this; vm.truncatedLength = TRUNCATE_LENGTH; - vm.truncated = TRUNCATED; + vm.isTruncated = IS_TRUNCATED; vm.strings = strings; vm.toggle = () => { - vm.truncated = !vm.truncated; + vm.isTruncated = !vm.isTruncated; }; - - // vm.tags = []; - - // Let the controller handle what type of tag should be passed to the directive - // e.g. default tag, crential tag, etc. - // Object.keys(tags).forEach(key => { - // if ($scope.tagType === 'cred') { - // vm.tags.push(TagService.buildCredentialTag(tags[key])); - // } else { - // vm.tags.push(TagService.buildTag(tags[key])); - // } - // }); } controller.$inject = ['ComponentsStrings']; @@ -38,8 +25,6 @@ function atToggleTag () { templateUrl, scope: { tags: '=', - tagType: '@', - tagLength: '@', }, }; } diff --git a/awx/ui/client/lib/components/toggle-tag/toggle-tag.partial.html b/awx/ui/client/lib/components/toggle-tag/toggle-tag.partial.html index 6ab6e2d858..fada04154e 100644 --- a/awx/ui/client/lib/components/toggle-tag/toggle-tag.partial.html +++ b/awx/ui/client/lib/components/toggle-tag/toggle-tag.partial.html @@ -1,16 +1,21 @@
-
-
- - +
+
+
+ +
+ +
+
+
+ +
+
-
-
+
-
-