mirror of
https://github.com/ansible/awx.git
synced 2026-05-24 00:57:48 -02:30
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.
This commit is contained in:
@@ -68,24 +68,12 @@
|
|||||||
value="{{ template.summary_fields.project.name }}"
|
value="{{ template.summary_fields.project.name }}"
|
||||||
value-link="/#/projects/{{ template.summary_fields.project.id }}">
|
value-link="/#/projects/{{ template.summary_fields.project.id }}">
|
||||||
</at-row-item>
|
</at-row-item>
|
||||||
<!-- TODO: add see more for creds -->
|
<at-row-item
|
||||||
<at-toggle-tag tags="vm.buildCredentialTags(template.summary_fields.credentials)"></at-toggle-tag>
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
<!-- <at-row-item
|
|
||||||
label-value="{{:: vm.strings.get('list.ROW_ITEM_LABEL_CREDENTIALS') }}"
|
label-value="{{:: vm.strings.get('list.ROW_ITEM_LABEL_CREDENTIALS') }}"
|
||||||
tag-values="template.summary_fields.credentials"
|
tag-values="template.summary_fields.credentials"
|
||||||
tags-are-creds="true"> -->
|
tags-are-creds="true">
|
||||||
|
<at-toggle-tag ng-init="credTags=vm.buildCredentialTags(template.summary_fields.credentials)" tags="credTags"></at-toggle-tag>
|
||||||
<!-- If there are 5 or less credential tags, show them all with Tag Component -->
|
</at-row-item>
|
||||||
<!-- <div ng-if="tagValues.length <= 5" ng-repeat="tag in tagValues">
|
|
||||||
<at-tag tag="tag.name" icon="{{ tag.kind }}" link="/#/credentials/{{ tag.id }}"></at-tag>
|
|
||||||
</div> -->
|
|
||||||
<!-- If there are 5 or MORE credential tags, handle them accordingly with Toggle Tag Component -->
|
|
||||||
<!-- <at-toggle-tag tag-type="cred" tags="tagValues" ng-if="tagValues.length > 5"></at-toggle-tag> -->
|
|
||||||
<!-- </at-row-item> -->
|
|
||||||
<at-row-item
|
<at-row-item
|
||||||
label-value="{{:: vm.strings.get('list.ROW_ITEM_LABEL_MODIFIED') }}"
|
label-value="{{:: vm.strings.get('list.ROW_ITEM_LABEL_MODIFIED') }}"
|
||||||
value-bind-html="{{ vm.getModified(template) }}">
|
value-bind-html="{{ vm.getModified(template) }}">
|
||||||
|
|||||||
@@ -42,19 +42,6 @@
|
|||||||
template-type="smartStatus.type" ng-if="smartStatus">
|
template-type="smartStatus.type" ng-if="smartStatus">
|
||||||
</aw-smart-status>
|
</aw-smart-status>
|
||||||
<div class="at-RowItem-tagContainer" ng-if="tagValues && tagValues.length">
|
<div class="at-RowItem-tagContainer" ng-if="tagValues && tagValues.length">
|
||||||
<div ng-if="tagValues.length <= 5" ng-repeat="tag in tagValues">
|
<ng-transclude></ng-transclude>
|
||||||
<at-tag tag="tag.name" icon="{{ tag.kind }}" link="/#/credentials/{{ tag.id }}"></at-tag>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
<!-- <at-toggle-tag tag-length="tagValues.length" tags="tagValues"></at-toggle-tag> -->
|
|
||||||
<!-- <at-tag tag="thing"></at-tag> -->
|
|
||||||
<!-- If there are 5 or less credential tags, show them all with Tag Component -->
|
|
||||||
<!-- <div ng-if="tagValues.length <= 5" ng-repeat="tag in tagValues">
|
|
||||||
<at-tag tag="tag.name" icon="{{ tag.kind }}" link="/#/credentials/{{ tag.id }}"></at-tag>
|
|
||||||
</div> -->
|
|
||||||
<!-- If there are 5 or MORE credential tags, handle them accordingly with Toggle Tag Component -->
|
|
||||||
<!-- <at-toggle-tag tag-type="cred" tags="tagValues" ng-if="tagValues.length > 5"></at-toggle-tag> -->
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -1,2 +1,2 @@
|
|||||||
export const TRUNCATE_LENGTH = 5;
|
export const TRUNCATE_LENGTH = 5;
|
||||||
export const TRUNCATED = true;
|
export const IS_TRUNCATED = true;
|
||||||
|
|||||||
@@ -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');
|
const templateUrl = require('~components/toggle-tag/toggle-tag.partial.html');
|
||||||
|
|
||||||
function controller (strings) {
|
function controller (strings) {
|
||||||
// const { tags } = $scope;
|
|
||||||
const vm = this;
|
const vm = this;
|
||||||
vm.truncatedLength = TRUNCATE_LENGTH;
|
vm.truncatedLength = TRUNCATE_LENGTH;
|
||||||
vm.truncated = TRUNCATED;
|
vm.isTruncated = IS_TRUNCATED;
|
||||||
vm.strings = strings;
|
vm.strings = strings;
|
||||||
|
|
||||||
vm.toggle = () => {
|
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'];
|
controller.$inject = ['ComponentsStrings'];
|
||||||
@@ -38,8 +25,6 @@ function atToggleTag () {
|
|||||||
templateUrl,
|
templateUrl,
|
||||||
scope: {
|
scope: {
|
||||||
tags: '=',
|
tags: '=',
|
||||||
tagType: '@',
|
|
||||||
tagLength: '@',
|
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,16 +1,21 @@
|
|||||||
<div class="ToggleComponent-wrapper">
|
<div class="ToggleComponent-wrapper">
|
||||||
<div ng-show="vm.truncated" class="ToggleComponent-container">
|
<div ng-if="tags.length > vm.truncatedLength">
|
||||||
|
<div ng-show="vm.isTruncated" class="ToggleComponent-container">
|
||||||
<div ng-repeat="tag in tags | limitTo: vm.truncatedLength">
|
<div ng-repeat="tag in tags | limitTo: vm.truncatedLength">
|
||||||
<at-tag tag="tag.value" icon="{{ tag.icon }}" link="{{ tag.link }}"></at-tag>
|
<at-tag tag="tag.value" icon="{{ tag.icon }}" link="{{ tag.link }}"></at-tag>
|
||||||
<!-- <at-tag tag="tag.value"></at-tag> -->
|
|
||||||
</div>
|
</div>
|
||||||
<button class="ToggleComponent-button" ng-click="vm.toggle()">{{:: vm.strings.get('toggle.VIEW_MORE') }}</button>
|
<button class="ToggleComponent-button" ng-click="vm.toggle()">{{:: vm.strings.get('toggle.VIEW_MORE') }}</button>
|
||||||
</div>
|
</div>
|
||||||
<div ng-show="!vm.truncated" class="ToggleComponent-container">
|
<div ng-show="!vm.isTruncated" class="ToggleComponent-container">
|
||||||
<div ng-repeat="tag in tags">
|
<div ng-repeat="tag in tags">
|
||||||
<!-- <at-tag ng-if="tagType === 'cred'" tag="tag.value" icon="{{ tag.icon }}" link="{{ tag.link }}"></at-tag> -->
|
|
||||||
<at-tag tag="tag.value" icon="{{ tag.icon }}" link="{{ tag.link }}"></at-tag>
|
<at-tag tag="tag.value" icon="{{ tag.icon }}" link="{{ tag.link }}"></at-tag>
|
||||||
</div>
|
</div>
|
||||||
<button class="ToggleComponent-button" ng-click="vm.toggle()">{{:: vm.strings.get('toggle.VIEW_LESS') }}</button>
|
<button class="ToggleComponent-button" ng-click="vm.toggle()">{{:: vm.strings.get('toggle.VIEW_LESS') }}</button>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
<div ng-if="tags.length <= vm.truncatedLength" class="ToggleComponent-container">
|
||||||
|
<div ng-repeat="tag in tags">
|
||||||
|
<at-tag tag="tag.value" icon="{{ tag.icon }}" link="{{ tag.link }}"></at-tag>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|||||||
Reference in New Issue
Block a user