@bd-innovations/abstract-section
Version:
A bunch of abstract logic for the section
91 lines (90 loc) • 3.32 kB
TypeScript
import { OnDestroy, OnInit } from '@angular/core';
import { MatDialog, MatDialogConfig } from '@angular/material/dialog';
import { AbstractDialogConfig } from '../config/abstract-dialog.config';
import { AbstractService } from '../providers/abstract.service';
import { ComponentType } from '@angular/cdk/portal';
import { AbstractEditComponent } from '../abstract-dialog/abstract-edit/abstract-edit.component';
import { AbstractDialogComponent } from '../abstract-dialog/abstract-dialog.component';
import { Subject } from 'rxjs';
/**
* @deprecated
* */
export declare abstract class AbstractComponent<T> implements OnInit, OnDestroy {
service: AbstractService<T>;
dialog: MatDialog;
dialog_config: MatDialogConfig;
abstract_dialog_config: AbstractDialogConfig<T>;
/**
* by default true, override with false when data already exist
*/
requestInitialData: boolean;
/** DIALOGS SETTINGS */
dialogPanelClass: string;
editDialogWidth: string;
editDialogPanelClass: string;
newDialogWidth: string;
newDialogPanelClass: string;
deleteDialogWidth: string;
deleteDialogPanelClass: string;
readonly onDestroy$: Subject<void>;
protected constructor(service: AbstractService<T>, dialog: MatDialog);
/**
* calls getData() if requestInitData is true (by default it is)
*/
ngOnInit(): void;
ngOnDestroy(): void;
abstract getData(key?: any): any;
onSuccessfulDataInit(res: any): void;
afterDataInit(): void;
onDataInitError(error: any): void;
abstract returnEditComponentType(): ComponentType<AbstractEditComponent<T>>;
abstract returnDeleteComponentType(): ComponentType<AbstractDialogComponent>;
/** EDIT DIALOG */
/**
* calls onBeforeEditOpen()
* opens dialog
* subscribe on dialog afterClosed and emits value into afterEditClosed()
* @param t: element
*/
openEdit(t: T): void;
/**
* setup dialog data with t, dialog width with editDialogWidth & dialog panelClasses with dialogPanelClass & editDialogPanelClass
* @param t: element
*/
onBeforeEditOpen(t: T): void;
/**
* if submit true calls onSuccessfulEdit()
* when false onEditCancel()
* @param submit: true when edited/false when canceled
*/
afterEditClose(submit: boolean | any): void;
onSuccessfulEdit(submit: any): void;
onEditCancel(): void;
/** DELETE DIALOG */
/**
* calls onBeforeDeleteOpen()
* opens dialog
* subscribe on dialog afterClosed and emits value into afterDeleteClose()
* @param t: element
*/
openDelete(t: T): void;
/**
* setup dialog data with t, dialog width with deleteDialogWidth & dialog panelClasses with dialogPanelClass & deleteDialogPanelClass
* @param t: element
*/
onBeforeDeleteOpen(t: T): void;
/**
* if submit true calls onSuccessfulDelete()
* when false onDeleteCancel()
* @param submit: true when edited/false when canceled
* @param t: element to delete
*/
afterDeleteClose(submit: boolean, t: T | any): void;
/**
* calls getData()
* @param submit: true when edited/false when canceled
* @param t: element to delete
*/
abstract onSuccessfulDelete(submit: any, t: any): void;
onDeleteCancel(): void;
}