[ADF-3726] Enable/disable Copy to clipboard in Metadata from config (#5578)

* [ADF-3726] Enable/disable Copy to clipboard in Metadata from config

* Update app.config.json

* Fix e2e tests
This commit is contained in:
davidcanonieto
2020-03-31 14:10:52 +01:00
committed by GitHub
parent 50f19c99f2
commit c1bf8e4db9
11 changed files with 117 additions and 28 deletions

View File

@@ -27,6 +27,7 @@ import {
import { CardViewItem } from '../../interfaces/card-view-item.interface';
import { CardItemTypeService } from '../../services/card-item-types.service';
import { CardViewContentProxyDirective } from '../../directives/card-view-content-proxy.directive';
import { DEFAULT_SEPARATOR } from '../card-view-textitem/card-view-textitem.component';
@Component({
selector: 'adf-card-view-item-dispatcher',
@@ -48,6 +49,15 @@ export class CardViewItemDispatcherComponent implements OnChanges {
@Input()
displayClearAction: boolean = true;
@Input()
copyToClipboardAction: boolean = true;
@Input()
useChipsForMultiValueProperty: boolean = true;
@Input()
multiValueSeparator: string = DEFAULT_SEPARATOR;
@ViewChild(CardViewContentProxyDirective)
private content: CardViewContentProxyDirective;
@@ -100,6 +110,9 @@ export class CardViewItemDispatcherComponent implements OnChanges {
this.componentReference.instance.displayEmpty = this.displayEmpty;
this.componentReference.instance.displayNoneOption = this.displayNoneOption;
this.componentReference.instance.displayClearAction = this.displayClearAction;
this.componentReference.instance.copyToClipboardAction = this.copyToClipboardAction;
this.componentReference.instance.useChipsForMultiValueProperty = this.useChipsForMultiValueProperty;
this.componentReference.instance.multiValueSeparator = this.multiValueSeparator;
}
private proxy(methodName, ...args) {

View File

@@ -6,7 +6,12 @@
<span *ngIf="!isClickable(); else nonClickableTemplate"
[attr.data-automation-id]="'card-textitem-value-' + property.key">
<span *ngIf="!isChipViewEnabled; else chipListTemplate">
<span *ngIf="showProperty()"
<span *ngIf="showProperty() && !copyToClipboardAction"
[ngClass]="property.multiline?'adf-textitem-multiline':'adf-textitem-scroll'"
class="adf-textitem-value">
{{ property.displayValue }}
</span>
<span *ngIf="showProperty() && copyToClipboardAction"
[ngClass]="property.multiline?'adf-textitem-multiline':'adf-textitem-scroll'"
(dblclick)="copyToClipboard(property.displayValue)"
class="adf-textitem-value"

View File

@@ -18,12 +18,13 @@
import { Component, Input, OnChanges, ViewChild } from '@angular/core';
import { CardViewTextItemModel } from '../../models/card-view-textitem.model';
import { CardViewUpdateService } from '../../services/card-view-update.service';
import { AppConfigService } from '../../../app-config/app-config.service';
import { BaseCardView } from '../base-card-view';
import { MatChipInputEvent } from '@angular/material';
import { ClipboardService } from '../../../clipboard/clipboard.service';
import { TranslationService } from '../../../services/translation.service';
export const DEFAULT_SEPARATOR = ', ';
@Component({
selector: 'adf-card-view-textitem',
templateUrl: './card-view-textitem.component.html',
@@ -31,31 +32,32 @@ import { TranslationService } from '../../../services/translation.service';
})
export class CardViewTextItemComponent extends BaseCardView<CardViewTextItemModel> implements OnChanges {
static DEFAULT_SEPARATOR = ', ';
static DEFAULT_USE_CHIPS = false;
@Input()
editable: boolean = false;
@Input()
displayEmpty: boolean = true;
@Input()
copyToClipboardAction: boolean = true;
@Input()
useChipsForMultiValueProperty: boolean = true;
@Input()
multiValueSeparator: string = DEFAULT_SEPARATOR;
@ViewChild('editorInput')
private editorInput: any;
inEdit: boolean = false;
editedValue: string | string[];
errorMessages: string[];
valueSeparator: string;
useChipsForMultiValueProperty: boolean;
constructor(cardViewUpdateService: CardViewUpdateService,
private appConfig: AppConfigService,
private clipboardService: ClipboardService,
private translateService: TranslationService) {
super(cardViewUpdateService);
this.valueSeparator = this.appConfig.get<string>('content-metadata.multi-value-pipe-separator') || CardViewTextItemComponent.DEFAULT_SEPARATOR;
this.useChipsForMultiValueProperty = this.appConfig.get<boolean>('content-metadata.multi-value-chips') || CardViewTextItemComponent.DEFAULT_USE_CHIPS;
}
ngOnChanges(): void {
@@ -131,7 +133,7 @@ export class CardViewTextItemComponent extends BaseCardView<CardViewTextItemMode
prepareValueForUpload(property: CardViewTextItemModel, value: string | string[]): string | string[] {
if (property.multivalued && typeof value === 'string') {
const listOfValues = value.split(this.valueSeparator.trim()).map((item) => item.trim());
const listOfValues = value.split(this.multiValueSeparator.trim()).map((item) => item.trim());
return listOfValues;
}
return value;

View File

@@ -6,7 +6,10 @@
[editable]="editable"
[displayEmpty]="displayEmpty"
[displayNoneOption]="displayNoneOption"
[displayClearAction]="displayClearAction">
[displayClearAction]="displayClearAction"
[copyToClipboardAction]="copyToClipboardAction"
[useChipsForMultiValueProperty]="useChipsForMultiValueProperty"
[multiValueSeparator]="multiValueSeparator">
</adf-card-view-item-dispatcher>
</div>
</div>

View File

@@ -17,6 +17,7 @@
import { Component, Input } from '@angular/core';
import { CardViewItem } from '../../interfaces/card-view-item.interface';
import { DEFAULT_SEPARATOR } from '../card-view-textitem/card-view-textitem.component';
@Component({
selector: 'adf-card-view',
@@ -43,4 +44,16 @@ export class CardViewComponent {
/** Toggles whether or not to display clear action. */
@Input()
displayClearAction: boolean = true;
/** Toggles whether or not to enable copy to clipboard action. */
@Input()
copyToClipboardAction: boolean = true;
/** Toggles whether or not to enable chips for multivalued properties. */
@Input()
useChipsForMultiValueProperty: boolean = true;
/** String separator between multi-value property items. */
@Input()
multiValueSeparator: string = DEFAULT_SEPARATOR;
}