File

projects/netgrif-components-core/src/lib/task-content/services/unlimited-task-content.service.ts

Description

Provides an implementation of the TaskContentService abstract class that allows an unlimited number of calls to the setter of the managed Task object.

If you want to limit the number of calls to 1 use SingleTaskContentService instead.

Extends

TaskContentService

Index

Properties
Methods
Accessors

Constructor

constructor(_fieldConverterService: FieldConverterService, _snackBarService: SnackBarService, _translate: TranslateService, _logger: LoggerService, _injector: Injector)
Parameters :
Name Type Optional
_fieldConverterService FieldConverterService No
_snackBarService SnackBarService No
_translate TranslateService No
_logger LoggerService No
_injector Injector No

Methods

ngOnDestroy
ngOnDestroy()
Inherited from TaskContentService

Completes the underling stream.

Returns : void
Public blockFields
blockFields(blockingState: boolean)
Inherited from TaskContentService

Changes the blocking state of all fields in the managed Task.

Parameters :
Name Type Optional Description
blockingState boolean No

whether the field should be blocked or not

Returns : void
Public expansionFinished
expansionFinished()
Inherited from TaskContentService

Changes the state of the task content to not expanding.

Returns : void
Public expansionStarted
expansionStarted()
Inherited from TaskContentService

Changes the state of the task content to expanding.

Returns : void
Protected findTaskRefId
findTaskRefId(taskId: string, fields: literal type)
Inherited from TaskContentService
Parameters :
Name Type Optional
taskId string No
fields literal type No
Returns : DataField<any>
Public getInvalidTaskData
getInvalidTaskData()
Inherited from TaskContentService

Finds invalid data of task

array of invalid datafields

Protected getReferencedTaskId
getReferencedTaskId(changedField: string, chFields: ChangedFields)
Inherited from TaskContentService
Parameters :
Name Type Optional
changedField string No
chFields ChangedFields No
Returns : string
Protected isFieldInTask
isFieldInTask(taskId: string, changedField: string)
Inherited from TaskContentService
Parameters :
Name Type Optional
taskId string No
changedField string No
Returns : boolean
Protected updateField
updateField(chFields: ChangedFields, field: DataField<any>, frontendActions: Change, referenced: boolean)
Inherited from TaskContentService
Parameters :
Name Type Optional Default value
chFields ChangedFields No
field DataField<any> No
frontendActions Change No
referenced boolean No false
Returns : void
Public updateFromChangedFields
updateFromChangedFields(chFields: ChangedFields)
Inherited from TaskContentService

Updates the properties of fields in the managed task based on a delta of changes from previous state.

Parameters :
Name Type Optional Description
chFields ChangedFields No

object containing the delta of the changes from the previous state

Returns : void
Public updateStateData
updateStateData(eventOutcome: TaskEventOutcome)
Inherited from TaskContentService

Clears the assignee, start date and finish date from the managed Task.

Parameters :
Name Type Optional
eventOutcome TaskEventOutcome No
Returns : void
Public validateDynamicEnumField
validateDynamicEnumField()
Inherited from TaskContentService
Returns : boolean
Public validateTaskData
validateTaskData(taskId?: string)
Inherited from TaskContentService

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 :
Name Type Optional
taskId string Yes
Returns : boolean

whether the task is valid or not

Properties

Protected _task$
Type : ReplaySubject<Task>

Acts as the underling stream for notifications on Task changes.

bufferSize of the ReplaySubject instance is set to 1.

Protected _isExpanding$
Type : BehaviorSubject<boolean>
Inherited from TaskContentService
Protected _referencedTaskAndCaseIds
Type : literal type
Default value : {}
Inherited from TaskContentService
Protected _task
Type : Task
Inherited from TaskContentService
Protected _taskDataReloadRequest$
Type : Subject<Change>
Inherited from TaskContentService
Protected _taskFieldsIndex
Type : literal type
Default value : {}
Inherited from TaskContentService
$shouldCreate
Type : ReplaySubject<Array<DataGroup>>
Inherited from TaskContentService
$shouldCreateCounter
Type : BehaviorSubject<number>
Inherited from TaskContentService
Static Readonly ACTION
Type : string
Default value : 'action'
Inherited from TaskContentService
Static Readonly FRONTEND_ACTIONS_KEY
Type : string
Default value : '_frontend_actions'
Inherited from TaskContentService

Accessors

task
gettask()
Returns : Task | undefined
settask(task: Task)

Setting a Task also emits it into the stream accessible by the task$ getter method.

Parameters :
Name Type Optional Description
task Task No

the Task that owns the content managed by this service

Returns : void
task$
gettask$()

Stream returns a Task object every time this object is set.

Use task setter method to set the Task.

Returns : Observable<Task>
import {Injectable, Injector, OnDestroy} from '@angular/core';
import {TaskContentService} from './task-content.service';
import {Observable, ReplaySubject} from 'rxjs';
import {Task} from '../../resources/interface/task';
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';

/**
 * Provides an implementation of the {@link TaskContentService} abstract class that allows
 * an unlimited number of calls to the setter of the managed Task object.
 *
 * If you want to limit the number of calls to 1 use {@link SingleTaskContentService} instead.
 */
@Injectable()
export class UnlimitedTaskContentService 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;
    }

    /**
     * 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
     */
    set task(task: Task) {
        this._task = task;
        this._task$.next(task);
    }

    /**
     * Stream returns a {@link Task} object every time this object is set.
     *
     * 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();
        this._task$.complete();
    }
}

result-matching ""

    No results matching ""