projects/netgrif-components-core/src/lib/task-content/services/single-task-content.service.ts
Provides an implementation of the TaskContentService abstract class that allows only a single call to the setter of the managed Task object.
If you want to use an unlimited number of calls use UnlimitedTaskContentService instead.
Properties |
|
Methods |
|
Accessors |
constructor(_fieldConverterService: FieldConverterService, _snackBarService: SnackBarService, _translate: TranslateService, _logger: LoggerService, _injector: Injector)
|
||||||||||||||||||
Parameters :
|
ngOnDestroy |
ngOnDestroy()
|
Inherited from
TaskContentService
|
Defined in
TaskContentService:68
|
Completes the underling stream.
Returns :
void
|
Public blockFields | ||||||||
blockFields(blockingState: boolean)
|
||||||||
Inherited from
TaskContentService
|
||||||||
Defined in
TaskContentService:196
|
||||||||
Changes the blocking state of all fields in the managed Task.
Parameters :
Returns :
void
|
Public expansionFinished |
expansionFinished()
|
Inherited from
TaskContentService
|
Defined in
TaskContentService:124
|
Changes the state of the task content to
Returns :
void
|
Public expansionStarted |
expansionStarted()
|
Inherited from
TaskContentService
|
Defined in
TaskContentService:117
|
Changes the state of the task content to
Returns :
void
|
Protected findTaskRefId | |||||||||
findTaskRefId(taskId: string, fields: literal type)
|
|||||||||
Inherited from
TaskContentService
|
|||||||||
Defined in
TaskContentService:312
|
|||||||||
Parameters :
Returns :
DataField<any>
|
Public getInvalidTaskData |
getInvalidTaskData()
|
Inherited from
TaskContentService
|
Defined in
TaskContentService:156
|
Finds invalid data of task
Returns :
Array<DataField<any>>
array of invalid datafields |
Protected getReferencedTaskId | |||||||||
getReferencedTaskId(changedField: string, chFields: ChangedFields)
|
|||||||||
Inherited from
TaskContentService
|
|||||||||
Defined in
TaskContentService:306
|
|||||||||
Parameters :
Returns :
string
|
Protected isFieldInTask |
isFieldInTask(taskId: string, changedField: string)
|
Inherited from
TaskContentService
|
Defined in
TaskContentService:299
|
Returns :
boolean
|
Protected updateField | ||||||||||||||||||||
updateField(chFields: ChangedFields, field: DataField<any>, frontendActions: Change, referenced: boolean)
|
||||||||||||||||||||
Inherited from
TaskContentService
|
||||||||||||||||||||
Defined in
TaskContentService:237
|
||||||||||||||||||||
Parameters :
Returns :
void
|
Public updateFromChangedFields | ||||||||
updateFromChangedFields(chFields: ChangedFields)
|
||||||||
Inherited from
TaskContentService
|
||||||||
Defined in
TaskContentService:221
|
||||||||
Updates the properties of fields in the managed task based on a delta of changes from previous state.
Parameters :
Returns :
void
|
Public updateStateData | ||||||
updateStateData(eventOutcome: TaskEventOutcome)
|
||||||
Inherited from
TaskContentService
|
||||||
Defined in
TaskContentService:209
|
||||||
Clears the assignee, start date and finish date from the managed Task.
Parameters :
Returns :
void
|
Public validateDynamicEnumField |
validateDynamicEnumField()
|
Inherited from
TaskContentService
|
Defined in
TaskContentService:163
|
Returns :
boolean
|
Public validateTaskData | ||||||
validateTaskData(taskId?: string)
|
||||||
Inherited from
TaskContentService
|
||||||
Defined in
TaskContentService:135
|
||||||
Checks the validity of all data fields in the managed 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.
Parameters :
Returns :
boolean
whether the task is valid or not |
Protected _task$ |
Type : ReplaySubject<Task>
|
Acts as the underling stream for notifications on Task changes.
|
Protected _isExpanding$ |
Type : BehaviorSubject<boolean>
|
Inherited from
TaskContentService
|
Defined in
TaskContentService:38
|
Protected _referencedTaskAndCaseIds |
Type : literal type
|
Default value : {}
|
Inherited from
TaskContentService
|
Defined in
TaskContentService:42
|
Protected _task |
Type : Task
|
Inherited from
TaskContentService
|
Defined in
TaskContentService:36
|
Protected _taskDataReloadRequest$ |
Type : Subject<Change>
|
Inherited from
TaskContentService
|
Defined in
TaskContentService:37
|
Protected _taskFieldsIndex |
Type : literal type
|
Default value : {}
|
Inherited from
TaskContentService
|
Defined in
TaskContentService:39
|
$shouldCreate |
Type : ReplaySubject<Array<DataGroup>>
|
Inherited from
TaskContentService
|
Defined in
TaskContentService:34
|
$shouldCreateCounter |
Type : BehaviorSubject<number>
|
Inherited from
TaskContentService
|
Defined in
TaskContentService:35
|
Static Readonly ACTION |
Type : string
|
Default value : 'action'
|
Inherited from
TaskContentService
|
Defined in
TaskContentService:32
|
Static Readonly FRONTEND_ACTIONS_KEY |
Type : string
|
Default value : '_frontend_actions'
|
Inherited from
TaskContentService
|
Defined in
TaskContentService:31
|
task | ||||||||
gettask()
|
||||||||
Returns :
Task | undefined
|
||||||||
settask(task: Task)
|
||||||||
The task can be only set once. All other call do nothing and log an error.
Parameters :
Returns :
void
|
task$ |
gettask$()
|
Returns :
Observable<Task>
|
import {Injectable, Injector, OnDestroy} from '@angular/core';
import {TaskContentService} from './task-content.service';
import {FieldConverterService} from './field-converter.service';
import {SnackBarService} from '../../snack-bar/services/snack-bar.service';
import {TranslateService} from '@ngx-translate/core';
import {LoggerService} from '../../logger/services/logger.service';
import {Observable, ReplaySubject} from 'rxjs';
import {Task} from '../../resources/interface/task';
/**
* Provides an implementation of the {@link TaskContentService} abstract class that allows only a
* single call to the setter of the managed Task object.
*
* If you want to use an unlimited number of calls use {@link UnlimitedTaskContentService} instead.
*/
@Injectable()
export class SingleTaskContentService extends TaskContentService implements OnDestroy {
/**
* Acts as the underling stream for notifications on Task changes.
*
* `bufferSize` of the `ReplaySubject` instance is set to 1.
*/
protected _task$: ReplaySubject<Task>;
constructor(_fieldConverterService: FieldConverterService,
_snackBarService: SnackBarService,
_translate: TranslateService,
_logger: LoggerService,
_injector: Injector) {
super(_fieldConverterService, _snackBarService, _translate, _logger);
this._task$ = new ReplaySubject<Task>(1);
}
/**
* @returns the Task object if set and `undefined` otherwise
*/
get task(): Task | undefined {
return this._task;
}
/**
* The task can be only set once. All other call do nothing and log an error.
* @param task the Task that owns the content managed by this service
*/
set task(task: Task) {
if (!this._task$.closed) {
this._task = task;
this._task$.next(task);
this._task$.complete();
} else {
this._logger.error('TaskContentService can have it\'s task set only once');
}
}
/**
* Stream returns a single {@link Task} object and then completes.
*
* Use [task]{@link TaskContentService#task} setter method to set the Task.
*/
get task$(): Observable<Task> {
return this._task$.asObservable();
}
/**
* Completes the underling stream.
*/
ngOnDestroy(): void {
super.ngOnDestroy();
if (!this._task$.closed) {
this._task$.complete();
}
}
}