Create TagService

This new Service can be used anywhere that needs a credentials tag and
can be expanded upon to include other helpful tag methods as needed.
This commit is contained in:
kialam
2018-05-31 13:40:51 -04:00
parent 62f4beddb2
commit f49b61ecfa
5 changed files with 32 additions and 6 deletions

View File

@@ -168,6 +168,7 @@
display: flex;
margin-left: @at-margin-left-list-row-item-tag-container;
flex-wrap: wrap;
line-height: initial;
}
.at-RowItem-tag {

View File

@@ -2,7 +2,8 @@ import { TRUNCATED, TRUNCATE_LENGTH } from './constants';
const templateUrl = require('~components/toggle/toggle-tag.partial.html');
function controller () {
function controller ($scope, TagService) {
const { tags } = $scope;
const vm = this;
vm.truncatedLength = TRUNCATE_LENGTH;
vm.truncated = TRUNCATED;
@@ -10,8 +11,16 @@ function controller () {
vm.toggle = () => {
vm.truncated = !vm.truncated;
};
vm.tags = [];
// build credentials from tags object
Object.keys(tags).forEach(key => {
vm.tags.push(TagService.buildCredentialTag(tags[key]));
});
}
controller.$inject = ['$scope', 'TagService'];
function atToggleTag () {
return {
restrict: 'E',

View File

@@ -1,13 +1,13 @@
<div class="ToggleComponent-wrapper">
<div ng-show="vm.truncated" class="ToggleComponent-container">
<div ng-repeat="tag in tags | limitTo: vm.truncatedLength">
<at-tag tag="tag.name" icon="{{ tag.kind }}"></at-tag>
<div ng-repeat="tag in vm.tags | limitTo: vm.truncatedLength">
<at-tag tag="tag.value" icon="{{ tag.icon }}" link="{{ tag.link }}"></at-tag>
</div>
<button class="ToggleComponent-button" ng-click="vm.toggle()">VIEW MORE</button>
</div>
<div ng-show="!vm.truncated" class="ToggleComponent-container">
<div ng-repeat="tag in tags">
<at-tag tag="tag.name" icon="{{ tag.kind }}"></at-tag>
<div ng-repeat="tag in vm.tags">
<at-tag tag="tag.value" icon="{{ tag.icon }}" link="{{ tag.link }}"></at-tag>
</div>
<button class="ToggleComponent-button" ng-click="vm.toggle()">VIEW LESS</button>
</div>