UNPKG

@netgrif/components-core

Version:

Netgrif Application engine frontend core Angular library

125 lines (124 loc) 5.5 kB
import { OnDestroy } from '@angular/core'; import { DataGroup } from '../../resources/interface/data-groups'; import { BehaviorSubject, Observable, ReplaySubject, Subject } from 'rxjs'; import { Task } from '../../resources/interface/task'; import { LoggerService } from '../../logger/services/logger.service'; import { SnackBarService } from '../../snack-bar/services/snack-bar.service'; import { TranslateService } from '@ngx-translate/core'; import { Change, ChangedFields } from '../../data-fields/models/changed-fields'; import { FieldConverterService } from './field-converter.service'; import { TaskEventOutcome } from '../../event/model/event-outcomes/task-outcomes/task-event-outcome'; import { DataField } from '../../data-fields/models/abstract-data-field'; import { TaskFields } from '../model/task-fields'; import * as i0 from "@angular/core"; /** * Acts as a communication interface between the Component that renders Task content and it's parent Component. * Also provides some general functionality that is needed when working with task content. * * Notable example of a parent Component is the {@link AbstractTaskPanelComponent}. * * Notable example of a task content renderer is the {@link AbstractTaskContentComponent}. */ export declare abstract class TaskContentService implements OnDestroy { protected _fieldConverterService: FieldConverterService; protected _snackBarService: SnackBarService; protected _translate: TranslateService; protected _logger: LoggerService; static readonly FRONTEND_ACTIONS_KEY = "_frontend_actions"; static readonly ACTION = "action"; $shouldCreate: ReplaySubject<Array<DataGroup>>; $shouldCreateCounter: BehaviorSubject<number>; protected _task: Task; protected _taskDataReloadRequest$: Subject<Change>; protected _isExpanding$: BehaviorSubject<boolean>; protected _taskFieldsIndex: { [taskId: string]: TaskFields; }; protected _referencedTaskAndCaseIds: { [caseId: string]: Array<string>; }; protected constructor(_fieldConverterService: FieldConverterService, _snackBarService: SnackBarService, _translate: TranslateService, _logger: LoggerService); ngOnDestroy(): void; /** * @returns the Task object if set and `undefined` otherwise */ abstract get task(): Task | undefined; /** * Setting a Task also emits it into the stream accessible by the [task$]{@link TaskContentService#task$} getter method. * @param task the Task that owns the content managed by this service */ abstract set task(task: Task); /** * Stream returns a {@link Task} object every time this object is set. * * Use [task]{@link TaskContentService#task} setter method to set the Task. */ abstract get task$(): Observable<Task>; /** * Stream that emits every time a data reload is requested. */ get taskDataReloadRequest$(): Observable<Change>; get taskFieldsIndex(): { [p: string]: TaskFields; }; set taskFieldsIndex(value: { [p: string]: TaskFields; }); get referencedTaskAndCaseIds(): { [p: string]: Array<string>; }; set referencedTaskAndCaseIds(value: { [p: string]: Array<string>; }); /** * Whether the panel that the task content is contained in is currently expanding. * * If the task content is not contained in a panel, `isExpanding` will be always `false`. */ get isExpanding(): boolean; /** * Changes the state of the task content to `expanding`. */ expansionStarted(): void; /** * Changes the state of the task content to `not expanding`. */ expansionFinished(): void; /** * Checks the validity of all data fields in the managed {@link Task}. * * If some of the fields are invalid touches them so their validation errors will appear (if set). * A snackbar will also be displayed to the user, informing them of the fact that the fields are invalid. * @returns whether the task is valid or not */ validateTaskData(taskId?: string): boolean; /** * Finds invalid data of task * * @returns array of invalid datafields */ getInvalidTaskData(): Array<DataField<any>>; validateDynamicEnumField(): boolean; /** * Changes the blocking state of all fields in the managed Task. * @param blockingState whether the field should be blocked or not */ blockFields(blockingState: boolean): void; /** * Clears the assignee, start date and finish date from the managed Task. */ updateStateData(eventOutcome: TaskEventOutcome): void; /** * Updates the properties of fields in the managed task based on a delta of changes from previous state. * @param chFields object containing the delta of the changes from the previous state */ updateFromChangedFields(chFields: ChangedFields): void; protected updateField(chFields: ChangedFields, field: DataField<any>, frontendActions: Change, referenced?: boolean): void; protected isFieldInTask(taskId: string, changedField: string): boolean; protected getReferencedTaskId(changedField: string, chFields: ChangedFields): string; protected findTaskRefId(taskId: string, fields: { [fieldId: string]: DataField<any>; }): DataField<any>; static ɵfac: i0.ɵɵFactoryDeclaration<TaskContentService, never>; static ɵprov: i0.ɵɵInjectableDeclaration<TaskContentService>; }