import { NextObserver, Observable } from 'rxjs'; import { EventEmitter, AfterViewInit, OnDestroy } from '@angular/core'; import { HttpErrorResponse } from '@angular/common/http'; import { MatSnackBar } from '@angular/material/snack-bar'; import { TranslateService } from '@ngx-translate/core'; import { NgbModal as Modal } from '@ng-bootstrap/ng-bootstrap'; import { SortOrder } from 'mel-common'; import { DeleteResult, EntityService, UpdateResult } from '../../services/core/entity.service'; import { ClientFilterCondition, FieldConditions } from '../../services/core/client-filter-condition'; import { ClientFilters } from '../../services/core/client-filters'; import { AlertService } from '../../services/alert.service'; import { BaseEntityService } from '../../services/core/baseentity.service'; import { EntityPage } from './entity-page'; import { AnyObjectLiteral, EntityLiteral } from '../../core/types'; import { Entity } from '../../models/entity'; import * as i0 from "@angular/core"; /** * Baseclass for all pages with database-service * EntityPage --> * ServicePage --> ListPage * --> ListRouted * --> all routed entityspecific lists * --> ListPart * --> all entityspecific lists as a part of a card * --> Card * --> all routed entityspecific cards * --> CardPart * --> all entityspecific cards as as part of a card * The derivied classes must: * - implement the abstract methods, * - set the entity-name by the entity-Property * - set the permissions by the permissions-property * - set the pagetype by the pageType-property * the derivied classes could: * - set a viewfilter (initial filters an sort-order) * - lock the page by the lock-property to prevent modifications * Initialization: * The constructor is provided by an injector, the translateservice, a mat-dialog and a snackbar-service. * When the entityname is set (in the constructor or later from an @Input), the metadata is got, the databaseservice for * this entity is created and the triggers are subribed depending on the permissions * At last the abstract method afterDatabaseServiceCreated() is called, where the derivied classes can start to use the service * * Datahandling: * When the data arrives from the database by the entitservice, each record is stored in a datasource-row * - in a pretty and editable format (inputRec) and * - as a copy of the original entitydata for validation (validRec). * The datasource contains an array of datasource-rows * A "Card" has exactly one entry, a "List" can have zero datasource-rows. * The datasource-row is the interface between entityservice an the page-input-data * * When a new record should be added, an empty validRec will be initialized by defaults and formatted into the inputRec * The datasource-row get the "new"-state * A row must be inserted, if the new-state in the datasource-row is set. * A row must be updatet, if one of the fields is dirty * * Change-detection: * When an editable field is left, the input-value is stored into the validRec. If the validRec-Field is different from the entityservice-record, * the fieldvalue has changed and the field becomes "dirty". * * Validation: * When an editable field becomes dirty, this field will be validated and an errormessage is shown * Because of the possible dependencies between the field-values, all fields must be validated, when a row is to be inserted or updated * The row can only been saved, when it is valid. In a List, you can't edit another row until the current row is invalid (and not saved). * * Fieldtrigger: * After a sucessfull fieldvalidation a frieldtrigger can be called to provide other small businesslogic * * */ export declare abstract class DbPage extends EntityPage implements AfterViewInit, OnDestroy { protected _recService: EntityService; protected modal: Modal; protected snackBar: MatSnackBar; alertService: AlertService; protected abstract retrieveData(): void; protected abstract deleteData(): void; protected abstract saveData(): void; protected abstract get shouldSave(): boolean; abstract onNew(): void; constructor(_recService: EntityService, translate: TranslateService, modal: Modal, snackBar: MatSnackBar, alertService: AlertService); get capturedActionKeys(): string[]; actionkeyEmitterMap: Map>; protected viewFilters?: ClientFilters; protected get Rec(): EntityService; get entityName(): string; get listRoute(): string; get cardRoute(): string; protected afterDeleteEntity(): void; protected afterModifyEntity(): void; protected afterInsertEntity(): void; protected afterRenameEntity(): void; unsubscribe(): void; ngAfterViewInit(): void; ngOnDestroy(): void; afterFilterChanged(): void; removeFilters(event: any): void; removeFlowFilters(event: any): void; deleteDlg(messageKey: string, params: AnyObjectLiteral, observer: NextObserver): void; /** * * @param event an event * @param useFlowFilters true, if the flowfilters should be filtertered , otherwise false. default: false */ filterDlg(event: any, useFlowfilters?: boolean): void; alertWarning(text: string): void; alertInfo(infoText: string): void; alertError(error: string | HttpErrorResponse): void; protected handleServerError(error: HttpErrorResponse | Error): void; snack(message: string): void; /** * Add a new record * @param event */ add(event?: Event): void; /** * Save a record * Menuaction call * @param event */ save(event?: Event): void; /** * delete a record * Menuaction call * @param event */ remove(event?: Event): void; copyData(from: BaseEntityService): BaseEntityService; copyDataset(from: EntityService): EntityService; copy(from: EntityService): EntityService; get rec(): E; get xRec(): E; get recordSet(): E[]; setRecordSet(set: E[]): void; get primaryKeyFields(): Partial; get hasFilters(): boolean; get hasFlowFilters(): boolean; get hasActiveFlowFilters(): boolean; get hasUnlockedFilters(): boolean; get fiendlyFilters(): string; setRange(fieldName: string, range?: any): EntityService; setFilter(fieldName: string, condition: ClientFilterCondition | string): EntityService; setFilters(fieldConditions: FieldConditions): EntityService; setNormalFilters(fieldConditions: FieldConditions): EntityService; setFlowFilters(fieldConditions: FieldConditions): EntityService; mergeFilters(filters: ClientFilters, overwrite?: boolean): EntityService; setParameter(param: string | string[] | undefined): EntityService; addParameter(param: string | string[] | undefined): EntityService; resetAll(): EntityService; lockFilters(toLock: string | string[]): EntityService; copyFilters(from: EntityService): EntityService; copyNormalFilters(from: EntityService, includeLocked?: boolean): EntityService; copyFlowFilters(from: EntityService, includeLocked?: boolean): EntityService; getNormalFilters(includeLocked?: boolean): ClientFilters; getFlowFilters(): ClientFilters; resetNormalFilters(): EntityService; resetFlowFilters(): EntityService; resetFilters(): EntityService; clearFilters(): EntityService; select(fieldNames: string[]): EntityService; setOrder(order: SortOrder | undefined): EntityService; setCalcFields(calcFieldNames: string[]): EntityService; take(n: number): EntityService; skip(n: number): EntityService; count(): Observable; get(): Observable; findFirst(): Observable; findLast(): Observable; findMany(): Observable; calcFields(fieldsToCalculate: string[]): Observable; insert(): Observable; rename(): Observable; update(): Observable; updateMany(): Observable; delete(): Observable; deleteMany(): Observable; static ɵfac: i0.ɵɵFactoryDeclaration, never>; static ɵdir: i0.ɵɵDirectiveDeclaration, never, never, {}, {}, never>; }