-
+
{
let loader: HarnessLoader;
@@ -192,6 +193,28 @@ describe('CardViewSelectItemComponent', () => {
});
});
+ describe('Clickable', () => {
+ it('should copy value to clipboard on double click', async () => {
+ const clipboardService = TestBed.inject(ClipboardService);
+ spyOn(clipboardService, 'copyContentToClipboard');
+
+ component.property = new CardViewSelectItemModel({
+ ...mockDefaultProps,
+ editable: true
+ });
+
+ component.editable = true;
+ component.copyToClipboardAction = true;
+ component.ngOnChanges({});
+ fixture.detectChanges();
+
+ testingUtils.doubleClickByDataAutomationId(`card-select-label-${component.property.key}`);
+ fixture.detectChanges();
+
+ expect(clipboardService.copyContentToClipboard).toHaveBeenCalledWith('Two', 'CORE.METADATA.ACCESSIBILITY.COPY_TO_CLIPBOARD_MESSAGE');
+ });
+ });
+
describe('Filter', () => {
it('should render a list of filtered options', async () => {
appConfig.config['content-metadata'] = {
diff --git a/lib/core/src/lib/card-view/components/card-view-selectitem/card-view-selectitem.component.ts b/lib/core/src/lib/card-view/components/card-view-selectitem/card-view-selectitem.component.ts
index 051bc414e9..1d2649ad7e 100644
--- a/lib/core/src/lib/card-view/components/card-view-selectitem/card-view-selectitem.component.ts
+++ b/lib/core/src/lib/card-view/components/card-view-selectitem/card-view-selectitem.component.ts
@@ -17,7 +17,7 @@
import { Component, Input, OnChanges, OnInit, inject, ViewEncapsulation, SimpleChanges, DestroyRef } from '@angular/core';
import { CardViewSelectItemModel } from '../../models/card-view-selectitem.model';
-import { BehaviorSubject, combineLatest, Observable } from 'rxjs';
+import { BehaviorSubject, combineLatest, isObservable, Observable } from 'rxjs';
import { CardViewSelectItemOption } from '../../interfaces/card-view.interfaces';
import { MatSelectChange, MatSelectModule } from '@angular/material/select';
import { BaseCardView } from '../base-card-view';
@@ -35,6 +35,8 @@ import { CardViewPropertyValidatorDirective } from '../../directives/card-view-p
import { MatChipInputEvent, MatChipsModule } from '@angular/material/chips';
import { ENTER } from '@angular/cdk/keycodes';
import { IconModule } from '../../../icon/icon.module';
+import { ClipboardService } from '../../../clipboard/clipboard.service';
+import { TranslationService } from '../../../translation/translation.service';
@Component({
selector: 'adf-card-view-selectitem',
@@ -61,6 +63,9 @@ export class CardViewSelectItemComponent extends BaseCardView[]>;
@Input()
@@ -69,6 +74,9 @@ export class CardViewSelectItemComponent extends BaseCardView('');
showInputFilter: boolean = false;
list$: Observable[]> = null;
@@ -186,6 +194,18 @@ export class CardViewSelectItemComponent extends BaseCardView) {
+ if (isObservable(valueToCopy)) {
+ valueToCopy.pipe(take(1)).subscribe((value) => {
+ const clipboardMessage = this.translateService.instant('CORE.METADATA.ACCESSIBILITY.COPY_TO_CLIPBOARD_MESSAGE');
+ this.clipboardService.copyContentToClipboard(value, clipboardMessage);
+ });
+ } else if (typeof valueToCopy === 'string') {
+ const clipboardMessage = this.translateService.instant('CORE.METADATA.ACCESSIBILITY.COPY_TO_CLIPBOARD_MESSAGE');
+ this.clipboardService.copyContentToClipboard(valueToCopy, clipboardMessage);
+ }
+ }
+
get showProperty(): boolean {
return this.displayEmpty || !this.property.isEmpty();
}