mirror of
https://github.com/Alfresco/alfresco-ng2-components.git
synced 2025-07-24 17:32:15 +00:00
[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:
@@ -819,6 +819,7 @@
|
|||||||
"default": {
|
"default": {
|
||||||
"exif:exif": "*"
|
"exif:exif": "*"
|
||||||
},
|
},
|
||||||
|
"all-aspects": "*",
|
||||||
"custom-title": [{
|
"custom-title": [{
|
||||||
"title": "Exif",
|
"title": "Exif",
|
||||||
"items": [
|
"items": [
|
||||||
@@ -837,7 +838,8 @@
|
|||||||
}]
|
}]
|
||||||
},
|
},
|
||||||
"multi-value-pipe-separator": ", ",
|
"multi-value-pipe-separator": ", ",
|
||||||
"multi-value-chips": true
|
"multi-value-chips": true,
|
||||||
|
"copy-to-clipboard-action": true
|
||||||
},
|
},
|
||||||
"sideNav": {
|
"sideNav": {
|
||||||
"expandedSidenav": true,
|
"expandedSidenav": true,
|
||||||
|
@@ -395,3 +395,22 @@ To customize the separator used by this card you can set it in your `app.config.
|
|||||||
If you want to display chips fo each value instead of a composed string you just need to enable it in the content-metadata config.
|
If you want to display chips fo each value instead of a composed string you just need to enable it in the content-metadata config.
|
||||||
|
|
||||||

|

|
||||||
|
|
||||||
|
## Copy to Clipboard on click
|
||||||
|
|
||||||
|
For easier interaction with metadata properties you can enable the Copy to Clipboard feature from your configuration in the `app.config.json` file.
|
||||||
|
|
||||||
|
Once you have enabled this feature you will be able to double click on your metadata properties and they will get copied to your clipboard for you to use.
|
||||||
|
|
||||||
|
```json
|
||||||
|
"content-metadata": {
|
||||||
|
"presets": {
|
||||||
|
"default": {
|
||||||
|
"includeAll": true,
|
||||||
|
"exclude": "exif:exif",
|
||||||
|
"exif:exif": [ "exif:pixelXDimension", "exif:pixelYDimension"]
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"copy-to-clipboard-action": true
|
||||||
|
}
|
||||||
|
```
|
||||||
|
@@ -109,6 +109,9 @@ Defining properties from Typescript:
|
|||||||
| Name | Type | Default value | Description |
|
| Name | Type | Default value | Description |
|
||||||
| ---- | ---- | ------------- | ----------- |
|
| ---- | ---- | ------------- | ----------- |
|
||||||
| displayClearAction | `boolean` | true | Toggles whether or not to display clear action. |
|
| displayClearAction | `boolean` | true | Toggles whether or not to display clear action. |
|
||||||
|
| copyToClipboardAction | `boolean` | true | Toggles whether or not to enable copy to clipboard action. |
|
||||||
|
| useChipsForMultiValueProperty | `boolean` | true | Toggles whether or not to enable chips for multivalued properties. |
|
||||||
|
| multiValueSeparator | `string` | ',' | String separator between multi-value property items. |
|
||||||
| displayEmpty | `boolean` | true | Toggles whether or not to show empty items in non-editable mode. |
|
| displayEmpty | `boolean` | true | Toggles whether or not to show empty items in non-editable mode. |
|
||||||
| displayNoneOption | `boolean` | true | Toggles whether or not to display none option. |
|
| displayNoneOption | `boolean` | true | Toggles whether or not to display none option. |
|
||||||
| editable | `boolean` | | Toggles whether or not the items can be edited. |
|
| editable | `boolean` | | Toggles whether or not the items can be edited. |
|
||||||
@@ -189,6 +192,9 @@ const textItemProperty = new CardViewTextItemModel(options);
|
|||||||
| editable | boolean | false | Toggles whether the item is editable |
|
| editable | boolean | false | Toggles whether the item is editable |
|
||||||
| clickable | boolean | false | Toggles whether the property responds to clicks |
|
| clickable | boolean | false | Toggles whether the property responds to clicks |
|
||||||
| clickableCallBack | function | null | Function to execute when click the element |
|
| clickableCallBack | function | null | Function to execute when click the element |
|
||||||
|
| copyToClipboardAction | `boolean` | true | Toggles whether or not to enable copy to clipboard action. |
|
||||||
|
| useChipsForMultiValueProperty | `boolean` | true | Toggles whether or not to enable chips for multivalued properties. |
|
||||||
|
| multiValueSeparator | `string` | ',' | String separator between multi-value property items. |
|
||||||
| icon | string | | The material icon to show beside the item if it is clickable |
|
| icon | string | | The material icon to show beside the item if it is clickable |
|
||||||
| multiline | boolean | false | Single or multiline text |
|
| multiline | boolean | false | Single or multiline text |
|
||||||
| pipes | [`CardViewTextItemPipeProperty`](../../../lib/core/card-view/interfaces/card-view-textitem-pipe-property.interface.ts)\[] | \[] | Pipes to be applied to the text before display |
|
| pipes | [`CardViewTextItemPipeProperty`](../../../lib/core/card-view/interfaces/card-view-textitem-pipe-property.interface.ts)\[] | \[] | Pipes to be applied to the text before display |
|
||||||
@@ -242,6 +248,7 @@ const dateItemProperty = new CardViewDateItemModel(options);
|
|||||||
| ---- | ---- | ------- | ----------- |
|
| ---- | ---- | ------- | ----------- |
|
||||||
| label\* | string | | Item label |
|
| label\* | string | | Item label |
|
||||||
| value\* | any | | The original data value for the item |
|
| value\* | any | | The original data value for the item |
|
||||||
|
| copyToClipboardAction | `boolean` | true | Toggles whether or not to enable copy to clipboard action. |
|
||||||
| key\* | string | | Identifying key (important when editing the item) |
|
| key\* | string | | Identifying key (important when editing the item) |
|
||||||
| default | any | | The default value to display if the value is empty |
|
| default | any | | The default value to display if the value is empty |
|
||||||
| displayValue\* | any | | The value to display |
|
| displayValue\* | any | | The value to display |
|
||||||
|
@@ -34,6 +34,10 @@ import { TasksCloudDemoPage } from '../pages/adf/demo-shell/process-services/tas
|
|||||||
import { NavigationBarPage } from '../pages/adf/navigation-bar.page';
|
import { NavigationBarPage } from '../pages/adf/navigation-bar.page';
|
||||||
import moment = require('moment');
|
import moment = require('moment');
|
||||||
|
|
||||||
|
const isValueInvalid = (value: any): boolean => {
|
||||||
|
return value === null || value === undefined;
|
||||||
|
};
|
||||||
|
|
||||||
describe('Task Header cloud component', () => {
|
describe('Task Header cloud component', () => {
|
||||||
const basicCreatedTaskName = StringUtil.generateRandomString();
|
const basicCreatedTaskName = StringUtil.generateRandomString();
|
||||||
const completedTaskName = StringUtil.generateRandomString();
|
const completedTaskName = StringUtil.generateRandomString();
|
||||||
@@ -127,16 +131,16 @@ describe('Task Header cloud component', () => {
|
|||||||
await tasksCloudDemoPage.taskListCloudComponent().selectRow(basicCreatedTaskName);
|
await tasksCloudDemoPage.taskListCloudComponent().selectRow(basicCreatedTaskName);
|
||||||
await expect(await taskHeaderCloudPage.getId()).toEqual(basicCreatedTask.entry.id);
|
await expect(await taskHeaderCloudPage.getId()).toEqual(basicCreatedTask.entry.id);
|
||||||
await expect(await taskHeaderCloudPage.getDescription())
|
await expect(await taskHeaderCloudPage.getDescription())
|
||||||
.toEqual(basicCreatedTask.entry.description === null ? CONSTANTS.TASK_DETAILS.NO_DESCRIPTION : basicCreatedTask.entry.description);
|
.toEqual(isValueInvalid(basicCreatedTask.entry.description) ? CONSTANTS.TASK_DETAILS.NO_DESCRIPTION : basicCreatedTask.entry.description);
|
||||||
await expect(await taskHeaderCloudPage.getStatus()).toEqual(basicCreatedTask.entry.status);
|
await expect(await taskHeaderCloudPage.getStatus()).toEqual(basicCreatedTask.entry.status);
|
||||||
await expect(await taskHeaderCloudPage.getPriority()).toEqual(basicCreatedTask.entry.priority.toString());
|
await expect(await taskHeaderCloudPage.getPriority()).toEqual(basicCreatedTask.entry.priority.toString());
|
||||||
await expect(await taskHeaderCloudPage.getCategory()).toEqual(!basicCreatedTask.entry.category ?
|
await expect(await taskHeaderCloudPage.getCategory()).toEqual(!basicCreatedTask.entry.category ?
|
||||||
CONSTANTS.TASK_DETAILS.NO_CATEGORY : basicCreatedTask.entry.category);
|
CONSTANTS.TASK_DETAILS.NO_CATEGORY : basicCreatedTask.entry.category);
|
||||||
await expect(await taskHeaderCloudPage.getDueDate()).toEqual(basicCreatedTask.entry.dueDate === null ?
|
await expect(await taskHeaderCloudPage.getDueDate()).toEqual(isValueInvalid(basicCreatedTask.entry.dueDate) ?
|
||||||
CONSTANTS.TASK_DETAILS.NO_DATE : basicCreatedDate);
|
CONSTANTS.TASK_DETAILS.NO_DATE : basicCreatedDate);
|
||||||
await expect(await taskHeaderCloudPage.getEndDate()).toEqual('');
|
await expect(await taskHeaderCloudPage.getEndDate()).toEqual('');
|
||||||
await expect(await taskHeaderCloudPage.getCreated()).toEqual(basicCreatedDate);
|
await expect(await taskHeaderCloudPage.getCreated()).toEqual(basicCreatedDate);
|
||||||
await expect(await taskHeaderCloudPage.getAssignee()).toEqual(basicCreatedTask.entry.assignee === null ? '' : basicCreatedTask.entry.assignee);
|
await expect(await taskHeaderCloudPage.getAssignee()).toEqual(isValueInvalid(basicCreatedTask.entry.assignee) ? '' : basicCreatedTask.entry.assignee);
|
||||||
await expect(await taskHeaderCloudPage.getParentName()).toEqual(CONSTANTS.TASK_DETAILS.NO_PARENT);
|
await expect(await taskHeaderCloudPage.getParentName()).toEqual(CONSTANTS.TASK_DETAILS.NO_PARENT);
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -146,16 +150,16 @@ describe('Task Header cloud component', () => {
|
|||||||
await tasksCloudDemoPage.taskListCloudComponent().selectRow(completedTaskName);
|
await tasksCloudDemoPage.taskListCloudComponent().selectRow(completedTaskName);
|
||||||
await expect(await taskHeaderCloudPage.getId()).toEqual(completedTask.entry.id);
|
await expect(await taskHeaderCloudPage.getId()).toEqual(completedTask.entry.id);
|
||||||
await expect(await taskHeaderCloudPage.getDescription())
|
await expect(await taskHeaderCloudPage.getDescription())
|
||||||
.toEqual(completedTask.entry.description === null ? CONSTANTS.TASK_DETAILS.NO_DESCRIPTION : completedTask.entry.description);
|
.toEqual(isValueInvalid(completedTask.entry.description) ? CONSTANTS.TASK_DETAILS.NO_DESCRIPTION : completedTask.entry.description);
|
||||||
await expect(await taskHeaderCloudPage.getStatus()).toEqual(completedTask.entry.status);
|
await expect(await taskHeaderCloudPage.getStatus()).toEqual(completedTask.entry.status);
|
||||||
await expect(await taskHeaderCloudPage.getPriority()).toEqual(completedTask.entry.priority.toString());
|
await expect(await taskHeaderCloudPage.getPriority()).toEqual(completedTask.entry.priority.toString());
|
||||||
await expect(await taskHeaderCloudPage.getCategory()).toEqual(!completedTask.entry.category ?
|
await expect(await taskHeaderCloudPage.getCategory()).toEqual(!completedTask.entry.category ?
|
||||||
CONSTANTS.TASK_DETAILS.NO_CATEGORY : completedTask.entry.category);
|
CONSTANTS.TASK_DETAILS.NO_CATEGORY : completedTask.entry.category);
|
||||||
await expect(await taskHeaderCloudPage.getDueDate()).toEqual(completedTask.entry.dueDate === null ?
|
await expect(await taskHeaderCloudPage.getDueDate()).toEqual(isValueInvalid(completedTask.entry.dueDate) ?
|
||||||
CONSTANTS.TASK_DETAILS.NO_DATE : dueDate);
|
CONSTANTS.TASK_DETAILS.NO_DATE : dueDate);
|
||||||
await expect(await taskHeaderCloudPage.getEndDate()).toEqual(completedEndDate);
|
await expect(await taskHeaderCloudPage.getEndDate()).toEqual(completedEndDate);
|
||||||
await expect(await taskHeaderCloudPage.getCreated()).toEqual(completedCreatedDate);
|
await expect(await taskHeaderCloudPage.getCreated()).toEqual(completedCreatedDate);
|
||||||
await expect(await taskHeaderCloudPage.getAssignee()).toEqual(completedTask.entry.assignee === null ? '' : completedTask.entry.assignee);
|
await expect(await taskHeaderCloudPage.getAssignee()).toEqual(isValueInvalid(completedTask.entry.assignee) ? '' : completedTask.entry.assignee);
|
||||||
await expect(await taskHeaderCloudPage.getParentName()).toEqual(CONSTANTS.TASK_DETAILS.NO_PARENT);
|
await expect(await taskHeaderCloudPage.getParentName()).toEqual(CONSTANTS.TASK_DETAILS.NO_PARENT);
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -165,19 +169,18 @@ describe('Task Header cloud component', () => {
|
|||||||
await tasksCloudDemoPage.taskListCloudComponent().selectRow(subTask.entry.name);
|
await tasksCloudDemoPage.taskListCloudComponent().selectRow(subTask.entry.name);
|
||||||
await expect(await taskHeaderCloudPage.getId()).toEqual(subTask.entry.id);
|
await expect(await taskHeaderCloudPage.getId()).toEqual(subTask.entry.id);
|
||||||
await expect(await taskHeaderCloudPage.getDescription())
|
await expect(await taskHeaderCloudPage.getDescription())
|
||||||
.toEqual(subTask.entry.description === null ? CONSTANTS.TASK_DETAILS.NO_DESCRIPTION : subTask.entry.description);
|
.toEqual(isValueInvalid(subTask.entry.description) ? CONSTANTS.TASK_DETAILS.NO_DESCRIPTION : subTask.entry.description);
|
||||||
await expect(await taskHeaderCloudPage.getStatus()).toEqual(subTask.entry.status);
|
await expect(await taskHeaderCloudPage.getStatus()).toEqual(subTask.entry.status);
|
||||||
await expect(await taskHeaderCloudPage.getPriority()).toEqual(subTask.entry.priority.toString());
|
await expect(await taskHeaderCloudPage.getPriority()).toEqual(subTask.entry.priority.toString());
|
||||||
await expect(await taskHeaderCloudPage.getCategory()).toEqual(!subTask.entry.category ?
|
await expect(await taskHeaderCloudPage.getCategory()).toEqual(!subTask.entry.category ?
|
||||||
CONSTANTS.TASK_DETAILS.NO_CATEGORY : subTask.entry.category);
|
CONSTANTS.TASK_DETAILS.NO_CATEGORY : subTask.entry.category);
|
||||||
await expect(await taskHeaderCloudPage.getDueDate()).toEqual(subTask.entry.dueDate === null ?
|
await expect(await taskHeaderCloudPage.getDueDate()).toEqual(isValueInvalid(subTask.entry.dueDate) ? CONSTANTS.TASK_DETAILS.NO_DATE : subTaskCreatedDate);
|
||||||
CONSTANTS.TASK_DETAILS.NO_DATE : subTaskCreatedDate);
|
|
||||||
await expect(await taskHeaderCloudPage.getEndDate()).toEqual('');
|
await expect(await taskHeaderCloudPage.getEndDate()).toEqual('');
|
||||||
await expect(await taskHeaderCloudPage.getCreated()).toEqual(subTaskCreatedDate);
|
await expect(await taskHeaderCloudPage.getCreated()).toEqual(subTaskCreatedDate);
|
||||||
await expect(await taskHeaderCloudPage.getAssignee()).toEqual(subTask.entry.assignee === null ? '' : subTask.entry.assignee);
|
await expect(await taskHeaderCloudPage.getAssignee()).toEqual(isValueInvalid(subTask.entry.assignee) ? '' : subTask.entry.assignee);
|
||||||
await expect(await taskHeaderCloudPage.getParentName()).toEqual(basicCreatedTask.entry.name);
|
await expect(await taskHeaderCloudPage.getParentName()).toEqual(basicCreatedTask.entry.name);
|
||||||
await expect(await taskHeaderCloudPage.getParentTaskId())
|
await expect(await taskHeaderCloudPage.getParentTaskId())
|
||||||
.toEqual(subTask.entry.parentTaskId === null ? '' : subTask.entry.parentTaskId);
|
.toEqual(isValueInvalid(subTask.entry.parentTaskId) ? '' : subTask.entry.parentTaskId);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('[C309698] - Should validate the Priority field', async () => {
|
it('[C309698] - Should validate the Priority field', async () => {
|
||||||
|
@@ -14,7 +14,10 @@
|
|||||||
(keydown)="keyDown($event)"
|
(keydown)="keyDown($event)"
|
||||||
[properties]="basicProperties$ | async"
|
[properties]="basicProperties$ | async"
|
||||||
[editable]="editable"
|
[editable]="editable"
|
||||||
[displayEmpty]="displayEmpty">
|
[displayEmpty]="displayEmpty"
|
||||||
|
[copyToClipboardAction]="copyToClipboardAction"
|
||||||
|
[useChipsForMultiValueProperty]="useChipsForMultiValueProperty"
|
||||||
|
[multiValueSeparator]="multiValueSeparator">
|
||||||
</adf-card-view>
|
</adf-card-view>
|
||||||
</mat-expansion-panel>
|
</mat-expansion-panel>
|
||||||
|
|
||||||
@@ -34,7 +37,10 @@
|
|||||||
(keydown)="keyDown($event)"
|
(keydown)="keyDown($event)"
|
||||||
[properties]="group.properties"
|
[properties]="group.properties"
|
||||||
[editable]="editable"
|
[editable]="editable"
|
||||||
[displayEmpty]="displayEmpty">
|
[displayEmpty]="displayEmpty"
|
||||||
|
[copyToClipboardAction]="copyToClipboardAction"
|
||||||
|
[useChipsForMultiValueProperty]="useChipsForMultiValueProperty"
|
||||||
|
[multiValueSeparator]="multiValueSeparator">
|
||||||
</adf-card-view>
|
</adf-card-view>
|
||||||
</mat-expansion-panel>
|
</mat-expansion-panel>
|
||||||
|
|
||||||
|
@@ -24,7 +24,8 @@ import {
|
|||||||
LogService,
|
LogService,
|
||||||
CardViewUpdateService,
|
CardViewUpdateService,
|
||||||
AlfrescoApiService,
|
AlfrescoApiService,
|
||||||
TranslationService
|
TranslationService,
|
||||||
|
AppConfigService
|
||||||
} from '@alfresco/adf-core';
|
} from '@alfresco/adf-core';
|
||||||
import { ContentMetadataService } from '../../services/content-metadata.service';
|
import { ContentMetadataService } from '../../services/content-metadata.service';
|
||||||
import { CardViewGroup } from '../../interfaces/content-metadata.interfaces';
|
import { CardViewGroup } from '../../interfaces/content-metadata.interfaces';
|
||||||
@@ -39,6 +40,8 @@ import { switchMap, takeUntil, catchError } from 'rxjs/operators';
|
|||||||
})
|
})
|
||||||
export class ContentMetadataComponent implements OnChanges, OnInit, OnDestroy {
|
export class ContentMetadataComponent implements OnChanges, OnInit, OnDestroy {
|
||||||
|
|
||||||
|
static DEFAULT_SEPARATOR = ', ';
|
||||||
|
|
||||||
protected onDestroy$ = new Subject<boolean>();
|
protected onDestroy$ = new Subject<boolean>();
|
||||||
|
|
||||||
/** (required) The node entity to fetch metadata about */
|
/** (required) The node entity to fetch metadata about */
|
||||||
@@ -75,6 +78,15 @@ export class ContentMetadataComponent implements OnChanges, OnInit, OnDestroy {
|
|||||||
@Input()
|
@Input()
|
||||||
displayAspect: string = null;
|
displayAspect: string = null;
|
||||||
|
|
||||||
|
/** 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;
|
||||||
|
|
||||||
|
multiValueSeparator: string;
|
||||||
basicProperties$: Observable<CardViewItem[]>;
|
basicProperties$: Observable<CardViewItem[]>;
|
||||||
groupedProperties$: Observable<CardViewGroup[]>;
|
groupedProperties$: Observable<CardViewGroup[]>;
|
||||||
|
|
||||||
@@ -84,8 +96,12 @@ export class ContentMetadataComponent implements OnChanges, OnInit, OnDestroy {
|
|||||||
private nodesApiService: NodesApiService,
|
private nodesApiService: NodesApiService,
|
||||||
private logService: LogService,
|
private logService: LogService,
|
||||||
private alfrescoApiService: AlfrescoApiService,
|
private alfrescoApiService: AlfrescoApiService,
|
||||||
private translationService: TranslationService
|
private translationService: TranslationService,
|
||||||
|
private appConfig: AppConfigService
|
||||||
) {
|
) {
|
||||||
|
this.copyToClipboardAction = this.appConfig.get<boolean>('content-metadata.copy-to-clipboard-action');
|
||||||
|
this.multiValueSeparator = this.appConfig.get<string>('content-metadata.multi-value-pipe-separator') || ContentMetadataComponent.DEFAULT_SEPARATOR;
|
||||||
|
this.useChipsForMultiValueProperty = this.appConfig.get<boolean>('content-metadata.multi-value-chips');
|
||||||
}
|
}
|
||||||
|
|
||||||
ngOnInit() {
|
ngOnInit() {
|
||||||
|
@@ -27,6 +27,7 @@ import {
|
|||||||
import { CardViewItem } from '../../interfaces/card-view-item.interface';
|
import { CardViewItem } from '../../interfaces/card-view-item.interface';
|
||||||
import { CardItemTypeService } from '../../services/card-item-types.service';
|
import { CardItemTypeService } from '../../services/card-item-types.service';
|
||||||
import { CardViewContentProxyDirective } from '../../directives/card-view-content-proxy.directive';
|
import { CardViewContentProxyDirective } from '../../directives/card-view-content-proxy.directive';
|
||||||
|
import { DEFAULT_SEPARATOR } from '../card-view-textitem/card-view-textitem.component';
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'adf-card-view-item-dispatcher',
|
selector: 'adf-card-view-item-dispatcher',
|
||||||
@@ -48,6 +49,15 @@ export class CardViewItemDispatcherComponent implements OnChanges {
|
|||||||
@Input()
|
@Input()
|
||||||
displayClearAction: boolean = true;
|
displayClearAction: boolean = true;
|
||||||
|
|
||||||
|
@Input()
|
||||||
|
copyToClipboardAction: boolean = true;
|
||||||
|
|
||||||
|
@Input()
|
||||||
|
useChipsForMultiValueProperty: boolean = true;
|
||||||
|
|
||||||
|
@Input()
|
||||||
|
multiValueSeparator: string = DEFAULT_SEPARATOR;
|
||||||
|
|
||||||
@ViewChild(CardViewContentProxyDirective)
|
@ViewChild(CardViewContentProxyDirective)
|
||||||
private content: CardViewContentProxyDirective;
|
private content: CardViewContentProxyDirective;
|
||||||
|
|
||||||
@@ -100,6 +110,9 @@ export class CardViewItemDispatcherComponent implements OnChanges {
|
|||||||
this.componentReference.instance.displayEmpty = this.displayEmpty;
|
this.componentReference.instance.displayEmpty = this.displayEmpty;
|
||||||
this.componentReference.instance.displayNoneOption = this.displayNoneOption;
|
this.componentReference.instance.displayNoneOption = this.displayNoneOption;
|
||||||
this.componentReference.instance.displayClearAction = this.displayClearAction;
|
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) {
|
private proxy(methodName, ...args) {
|
||||||
|
@@ -6,7 +6,12 @@
|
|||||||
<span *ngIf="!isClickable(); else nonClickableTemplate"
|
<span *ngIf="!isClickable(); else nonClickableTemplate"
|
||||||
[attr.data-automation-id]="'card-textitem-value-' + property.key">
|
[attr.data-automation-id]="'card-textitem-value-' + property.key">
|
||||||
<span *ngIf="!isChipViewEnabled; else chipListTemplate">
|
<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'"
|
[ngClass]="property.multiline?'adf-textitem-multiline':'adf-textitem-scroll'"
|
||||||
(dblclick)="copyToClipboard(property.displayValue)"
|
(dblclick)="copyToClipboard(property.displayValue)"
|
||||||
class="adf-textitem-value"
|
class="adf-textitem-value"
|
||||||
|
@@ -18,12 +18,13 @@
|
|||||||
import { Component, Input, OnChanges, ViewChild } from '@angular/core';
|
import { Component, Input, OnChanges, ViewChild } from '@angular/core';
|
||||||
import { CardViewTextItemModel } from '../../models/card-view-textitem.model';
|
import { CardViewTextItemModel } from '../../models/card-view-textitem.model';
|
||||||
import { CardViewUpdateService } from '../../services/card-view-update.service';
|
import { CardViewUpdateService } from '../../services/card-view-update.service';
|
||||||
import { AppConfigService } from '../../../app-config/app-config.service';
|
|
||||||
import { BaseCardView } from '../base-card-view';
|
import { BaseCardView } from '../base-card-view';
|
||||||
import { MatChipInputEvent } from '@angular/material';
|
import { MatChipInputEvent } from '@angular/material';
|
||||||
import { ClipboardService } from '../../../clipboard/clipboard.service';
|
import { ClipboardService } from '../../../clipboard/clipboard.service';
|
||||||
import { TranslationService } from '../../../services/translation.service';
|
import { TranslationService } from '../../../services/translation.service';
|
||||||
|
|
||||||
|
export const DEFAULT_SEPARATOR = ', ';
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'adf-card-view-textitem',
|
selector: 'adf-card-view-textitem',
|
||||||
templateUrl: './card-view-textitem.component.html',
|
templateUrl: './card-view-textitem.component.html',
|
||||||
@@ -31,31 +32,32 @@ import { TranslationService } from '../../../services/translation.service';
|
|||||||
})
|
})
|
||||||
export class CardViewTextItemComponent extends BaseCardView<CardViewTextItemModel> implements OnChanges {
|
export class CardViewTextItemComponent extends BaseCardView<CardViewTextItemModel> implements OnChanges {
|
||||||
|
|
||||||
static DEFAULT_SEPARATOR = ', ';
|
|
||||||
static DEFAULT_USE_CHIPS = false;
|
|
||||||
|
|
||||||
@Input()
|
@Input()
|
||||||
editable: boolean = false;
|
editable: boolean = false;
|
||||||
|
|
||||||
@Input()
|
@Input()
|
||||||
displayEmpty: boolean = true;
|
displayEmpty: boolean = true;
|
||||||
|
|
||||||
|
@Input()
|
||||||
|
copyToClipboardAction: boolean = true;
|
||||||
|
|
||||||
|
@Input()
|
||||||
|
useChipsForMultiValueProperty: boolean = true;
|
||||||
|
|
||||||
|
@Input()
|
||||||
|
multiValueSeparator: string = DEFAULT_SEPARATOR;
|
||||||
|
|
||||||
@ViewChild('editorInput')
|
@ViewChild('editorInput')
|
||||||
private editorInput: any;
|
private editorInput: any;
|
||||||
|
|
||||||
inEdit: boolean = false;
|
inEdit: boolean = false;
|
||||||
editedValue: string | string[];
|
editedValue: string | string[];
|
||||||
errorMessages: string[];
|
errorMessages: string[];
|
||||||
valueSeparator: string;
|
|
||||||
useChipsForMultiValueProperty: boolean;
|
|
||||||
|
|
||||||
constructor(cardViewUpdateService: CardViewUpdateService,
|
constructor(cardViewUpdateService: CardViewUpdateService,
|
||||||
private appConfig: AppConfigService,
|
|
||||||
private clipboardService: ClipboardService,
|
private clipboardService: ClipboardService,
|
||||||
private translateService: TranslationService) {
|
private translateService: TranslationService) {
|
||||||
super(cardViewUpdateService);
|
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 {
|
ngOnChanges(): void {
|
||||||
@@ -131,7 +133,7 @@ export class CardViewTextItemComponent extends BaseCardView<CardViewTextItemMode
|
|||||||
|
|
||||||
prepareValueForUpload(property: CardViewTextItemModel, value: string | string[]): string | string[] {
|
prepareValueForUpload(property: CardViewTextItemModel, value: string | string[]): string | string[] {
|
||||||
if (property.multivalued && typeof value === '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 listOfValues;
|
||||||
}
|
}
|
||||||
return value;
|
return value;
|
||||||
|
@@ -6,7 +6,10 @@
|
|||||||
[editable]="editable"
|
[editable]="editable"
|
||||||
[displayEmpty]="displayEmpty"
|
[displayEmpty]="displayEmpty"
|
||||||
[displayNoneOption]="displayNoneOption"
|
[displayNoneOption]="displayNoneOption"
|
||||||
[displayClearAction]="displayClearAction">
|
[displayClearAction]="displayClearAction"
|
||||||
|
[copyToClipboardAction]="copyToClipboardAction"
|
||||||
|
[useChipsForMultiValueProperty]="useChipsForMultiValueProperty"
|
||||||
|
[multiValueSeparator]="multiValueSeparator">
|
||||||
</adf-card-view-item-dispatcher>
|
</adf-card-view-item-dispatcher>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
@@ -17,6 +17,7 @@
|
|||||||
|
|
||||||
import { Component, Input } from '@angular/core';
|
import { Component, Input } from '@angular/core';
|
||||||
import { CardViewItem } from '../../interfaces/card-view-item.interface';
|
import { CardViewItem } from '../../interfaces/card-view-item.interface';
|
||||||
|
import { DEFAULT_SEPARATOR } from '../card-view-textitem/card-view-textitem.component';
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'adf-card-view',
|
selector: 'adf-card-view',
|
||||||
@@ -43,4 +44,16 @@ export class CardViewComponent {
|
|||||||
/** Toggles whether or not to display clear action. */
|
/** Toggles whether or not to display clear action. */
|
||||||
@Input()
|
@Input()
|
||||||
displayClearAction: boolean = true;
|
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;
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user