mirror of
https://github.com/Alfresco/alfresco-ng2-components.git
synced 2026-09-09 18:03:21 +00:00
[ADF-4391] Doc review for 3.2 (#4601)
* [ADF-4391] Reviewed new clipboard class docs * [ADF-4391] Reviewed new proc cloud class docs * [ADF-4391] Reviewed new datatable doc additions
This commit is contained in:
committed by
Eugenio Romano
parent
16aaa0f0b3
commit
921fdc00df
@@ -23,13 +23,16 @@ import { ClipboardService } from './clipboard.service';
|
||||
exportAs: 'adfClipboard'
|
||||
})
|
||||
export class ClipboardDirective {
|
||||
/** Translation key or message for the tooltip. */
|
||||
// tslint:disable-next-line:no-input-rename
|
||||
@Input('adf-clipboard')
|
||||
placeholder: string;
|
||||
|
||||
/** Reference to the HTML element containing the text to copy. */
|
||||
@Input()
|
||||
target: HTMLInputElement | HTMLTextAreaElement;
|
||||
|
||||
/** Translation key or message for snackbar notification. */
|
||||
// tslint:disable-next-line:no-input-rename
|
||||
@Input('clipboard-notification') message: string;
|
||||
|
||||
|
||||
@@ -28,6 +28,11 @@ export class ClipboardService {
|
||||
private logService: LogService,
|
||||
private notificationService: NotificationService) {}
|
||||
|
||||
/**
|
||||
* Checks if the target element can have its text copied.
|
||||
* @param target Target HTML element
|
||||
* @returns True if the text can be copied, false otherwise
|
||||
*/
|
||||
isTargetValid(target: HTMLInputElement | HTMLTextAreaElement) {
|
||||
if (target instanceof HTMLInputElement || target instanceof HTMLTextAreaElement) {
|
||||
return !target.hasAttribute('disabled');
|
||||
@@ -35,6 +40,11 @@ export class ClipboardService {
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Copies text from an HTML element to the clipboard.
|
||||
* @param target HTML element to be copied
|
||||
* @param message Snackbar message to alert when copying happens
|
||||
*/
|
||||
copyToClipboard(target: HTMLInputElement | HTMLTextAreaElement, message?: string) {
|
||||
if (this.isTargetValid(target)) {
|
||||
try {
|
||||
@@ -48,6 +58,11 @@ export class ClipboardService {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Copies a text string to the clipboard.
|
||||
* @param content Text to copy
|
||||
* @param message Snackbar message to alert when copying happens
|
||||
*/
|
||||
copyContentToClipboard(content: string, message: string) {
|
||||
try {
|
||||
document.addEventListener('copy', (e: ClipboardEvent) => {
|
||||
|
||||
@@ -32,7 +32,7 @@ export class DataColumnComponent implements OnInit {
|
||||
key: string;
|
||||
|
||||
/** Value type for the column. Possible settings are 'text', 'image',
|
||||
* 'date', 'fileSize' and 'location'.
|
||||
* 'date', 'fileSize', 'location', and 'json'.
|
||||
*/
|
||||
@Input()
|
||||
type: string = 'text';
|
||||
@@ -66,7 +66,7 @@ export class DataColumnComponent implements OnInit {
|
||||
@Input('class')
|
||||
cssClass: string;
|
||||
|
||||
/** flag to show the copy content directive */
|
||||
/** Enables/disables a Clipboard directive to allow copying of cell contents. */
|
||||
@Input()
|
||||
copyContent: boolean;
|
||||
|
||||
|
||||
@@ -55,20 +55,25 @@ import { Node } from '@alfresco/js-api';
|
||||
host: { class: 'adf-datatable-cell' }
|
||||
})
|
||||
export class DataTableCellComponent implements OnInit, OnDestroy {
|
||||
/** Data table adapter instance. */
|
||||
@Input()
|
||||
data: DataTableAdapter;
|
||||
|
||||
/** Data that defines the column. */
|
||||
@Input()
|
||||
column: DataColumn;
|
||||
|
||||
/** Data that defines the row. */
|
||||
@Input()
|
||||
row: DataRow;
|
||||
|
||||
value$ = new BehaviorSubject<any>('');
|
||||
|
||||
/** Enables/disables a Clipboard directive to allow copying of the cell's content. */
|
||||
@Input()
|
||||
copyContent: boolean;
|
||||
|
||||
/** Text for the cell's tooltip. */
|
||||
@Input()
|
||||
tooltip: string;
|
||||
|
||||
|
||||
@@ -36,6 +36,12 @@ export class FormCloudService {
|
||||
private logService: LogService
|
||||
) {}
|
||||
|
||||
/**
|
||||
* Gets the form definition of a task.
|
||||
* @param appName Name of the app
|
||||
* @param taskId ID of the target task
|
||||
* @returns Form definition
|
||||
*/
|
||||
getTaskForm(appName: string, taskId: string): Observable<any> {
|
||||
return this.getTask(appName, taskId).pipe(
|
||||
switchMap((task: TaskDetailsCloudModel) => {
|
||||
@@ -52,6 +58,14 @@ export class FormCloudService {
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Saves a task form.
|
||||
* @param appName Name of the app
|
||||
* @param taskId ID of the target task
|
||||
* @param formId ID of the form to save
|
||||
* @param formValues Form values object
|
||||
* @returns Updated task details
|
||||
*/
|
||||
saveTaskForm(appName: string, taskId: string, formId: string, formValues: FormValues): Observable<TaskDetailsCloudModel> {
|
||||
const apiUrl = this.buildSaveFormUrl(appName, formId);
|
||||
const saveFormRepresentation = <SaveFormRepresentation> { values: formValues, taskId: taskId };
|
||||
@@ -89,6 +103,15 @@ export class FormCloudService {
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Completes a task form.
|
||||
* @param appName Name of the app
|
||||
* @param taskId ID of the target task
|
||||
* @param formId ID of the form to complete
|
||||
* @param formValues Form values object
|
||||
* @param outcome (Optional) Form outcome
|
||||
* @returns Updated task details
|
||||
*/
|
||||
completeTaskForm(appName: string, taskId: string, formId: string, formValues: FormValues, outcome: string): Observable<TaskDetailsCloudModel> {
|
||||
const apiUrl = this.buildSubmitFormUrl(appName, formId);
|
||||
const completeFormRepresentation: any = <CompleteFormRepresentation> { values: formValues, taskId: taskId };
|
||||
@@ -111,6 +134,12 @@ export class FormCloudService {
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets details of a task
|
||||
* @param appName Name of the app
|
||||
* @param taskId ID of the target task
|
||||
* @returns Details of the task
|
||||
*/
|
||||
getTask(appName: string, taskId: string): Observable<TaskDetailsCloudModel> {
|
||||
const apiUrl = this.buildGetTaskUrl(appName, taskId);
|
||||
return from(this.apiService
|
||||
@@ -145,6 +174,12 @@ export class FormCloudService {
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the variables of a task.
|
||||
* @param appName Name of the app
|
||||
* @param taskId ID of the target task
|
||||
* @returns Task variables
|
||||
*/
|
||||
getTaskVariables(appName: string, taskId: string): Observable<TaskVariableCloud[]> {
|
||||
const apiUrl = this.buildGetTaskVariablesUrl(appName, taskId);
|
||||
return from(this.apiService
|
||||
@@ -162,6 +197,12 @@ export class FormCloudService {
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets a form definition.
|
||||
* @param appName Name of the app
|
||||
* @param taskId ID of the target task
|
||||
* @returns Form definition
|
||||
*/
|
||||
getForm(appName: string, taskId: string): Observable<any> {
|
||||
const apiUrl = this.buildGetFormUrl(appName, taskId);
|
||||
const bodyParam = {}, pathParams = {}, queryParams = {}, headerParams = {},
|
||||
@@ -179,6 +220,13 @@ export class FormCloudService {
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Parses JSON data to create a corresponding form.
|
||||
* @param json JSON data to create the form
|
||||
* @param data (Optional) Values for the form's fields
|
||||
* @param readOnly Toggles whether or not the form should be read-only
|
||||
* @returns Form created from the JSON specification
|
||||
*/
|
||||
parseForm(json: any, data?: TaskVariableCloud[], readOnly: boolean = false): FormCloud {
|
||||
if (json) {
|
||||
const form = new FormCloud(json, data, readOnly, this);
|
||||
|
||||
Reference in New Issue
Block a user