From 6ca4c7de9dc918d194150b47808942f1ca682fa5 Mon Sep 17 00:00:00 2001 From: kialam Date: Tue, 5 Jun 2018 17:40:59 -0400 Subject: [PATCH] Offload tag formatting logic to `templateList` controller --- .../templates/templatesList.controller.js | 11 +++++++++ .../templates/templatesList.view.html | 18 ++++++++++++--- .../lib/components/list/row-item.partial.html | 12 ++++++++-- .../toggle-tag/toggle-tag.directive.js | 23 ++++++++++--------- .../toggle-tag/toggle-tag.partial.html | 12 +++++----- 5 files changed, 54 insertions(+), 22 deletions(-) diff --git a/awx/ui/client/features/templates/templatesList.controller.js b/awx/ui/client/features/templates/templatesList.controller.js index 4f0ec55116..ad3137e949 100644 --- a/awx/ui/client/features/templates/templatesList.controller.js +++ b/awx/ui/client/features/templates/templatesList.controller.js @@ -165,6 +165,17 @@ function ListTemplatesController( return html; }; + vm.buildCredentialTags = (credentials) => { + return credentials.map(credential => { + const icon = `${credential.kind}`; + const link = `/#/credentials/${credential.id}`; + const tooltip = strings.get('tooltips.VIEW_THE_CREDENTIAL'); + const value = $filter('sanitize')(credential.name); + + return { icon, link, tooltip, value }; + }) + }; + vm.getLastRan = template => { const lastJobRun = _.get(template, 'last_job_run'); diff --git a/awx/ui/client/features/templates/templatesList.view.html b/awx/ui/client/features/templates/templatesList.view.html index 5a00912663..d77910ac1f 100644 --- a/awx/ui/client/features/templates/templatesList.view.html +++ b/awx/ui/client/features/templates/templatesList.view.html @@ -69,11 +69,23 @@ value-link="/#/projects/{{ template.summary_fields.project.id }}"> - + + + + + + + + + + + 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 69058b1c43..3c50e1fb83 100644 --- a/awx/ui/client/lib/components/list/row-item.partial.html +++ b/awx/ui/client/lib/components/list/row-item.partial.html @@ -42,11 +42,19 @@ template-type="smartStatus.type" ng-if="smartStatus">
-
+ + + + + + + - +
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 1fc7c02990..3cc49b3cea 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 @@ -2,8 +2,8 @@ import { TRUNCATED, TRUNCATE_LENGTH } from './constants'; const templateUrl = require('~components/toggle-tag/toggle-tag.partial.html'); -function controller ($scope, TagService, strings) { - const { tags } = $scope; +function controller (strings) { + // const { tags } = $scope; const vm = this; vm.truncatedLength = TRUNCATE_LENGTH; vm.truncated = TRUNCATED; @@ -13,20 +13,20 @@ function controller ($scope, TagService, strings) { vm.truncated = !vm.truncated; }; - vm.tags = []; + // 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])); - } - }); + // 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 = ['$scope', 'TagService', 'ComponentsStrings']; +controller.$inject = ['ComponentsStrings']; function atToggleTag () { return { @@ -39,6 +39,7 @@ function atToggleTag () { 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 7997e0e741..6ab6e2d858 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,15 +1,15 @@
-
- - +
+ +
-
- - +
+ +