@rero/ng-core
Version:
RERO angular core library.
194 lines (193 loc) • 7.37 kB
TypeScript
import { Location } from '@angular/common';
import { EventEmitter, OnChanges, OnDestroy, OnInit, SimpleChanges } from '@angular/core';
import { UntypedFormGroup } from '@angular/forms';
import { ActivatedRoute } from '@angular/router';
import { FormlyFieldConfig, FormlyFormOptions } from '@ngx-formly/core';
import { FormlyJsonschema } from '@ngx-formly/core/json-schema';
import { TranslateService } from '@ngx-translate/core';
import { MessageService } from 'primeng/api';
import { DialogService, DynamicDialogRef } from 'primeng/dynamicdialog';
import { Observable } from 'rxjs';
import { ApiService } from '../../api/api.service';
import { AbstractCanDeactivateComponent } from '../../component/abstract-can-deactivate.component';
import { Error } from '../../error/error';
import { RouteCollectionService } from '../../route/route-collection.service';
import { LoggerService } from '../../service/logger.service';
import { RecordUiService } from '../record-ui.service';
import { RecordService } from '../record.service';
import { JSONSchemaService } from './services/jsonschema.service';
import * as i0 from "@angular/core";
export declare class EditorComponent extends AbstractCanDeactivateComponent implements OnInit, OnChanges, OnDestroy {
protected formlyJsonschema: FormlyJsonschema;
protected recordService: RecordService;
protected apiService: ApiService;
protected route: ActivatedRoute;
protected recordUiService: RecordUiService;
protected translateService: TranslateService;
protected location: Location;
protected routeCollectionService: RouteCollectionService;
protected loggerService: LoggerService;
protected jsonschemaService: JSONSchemaService;
protected dialogService: DialogService;
protected messageService: MessageService;
model: any;
modelChange: EventEmitter<any>;
loadingChange: EventEmitter<boolean>;
canDeactivateChange: EventEmitter<boolean>;
title?: string;
description?: string;
canDeactivate: boolean;
form: UntypedFormGroup;
options: FormlyFormOptions;
fields: FormlyFieldConfig[];
rootField: FormlyFieldConfig;
tocFields$: Observable<any>;
schema: any;
editorSettings: {
longMode: boolean;
template: {
recordType: any;
loadFromTemplate: boolean;
saveAsTemplate: boolean;
};
};
pid: any;
saveAlternatives: {
label: string;
command: any;
}[];
recordType: any;
error: Error;
/** Disables the save button during the action */
isSaveButtonDisabled: boolean;
private _subscribers;
private _resourceConfig;
private _hiddenFields;
private _hiddenFieldsSubject;
ref: DynamicDialogRef | undefined;
get hiddenFields$(): Observable<any[]>;
get longMode(): boolean;
get editorComponent(): () => EditorComponent;
/** Constructor */
constructor();
/**
* Component has changed
* Called before ngOnInit() and whenever one of the input properties change.
* @param changes: the changed properties
*/
ngOnChanges(changes: SimpleChanges): void;
/** onInit hook */
ngOnInit(): void;
/** onDestroy hook */
ngOnDestroy(): void;
/**
* Set the model
* @param model: The data to use as new model
*/
private _setModel;
/**
* Emit value when model is changed.
* @param modelValue Model.
*/
modelChanged(modelValue: any): void;
/**
* Preprocess the record before passing it to the editor
* @param record - Record object to preprocess
*/
private preprocessRecord;
/**
* Postprocess the record before save
* @param record - Record object to postprocess
*/
private postprocessRecord;
/**
* Pre Create Record
* @param record - Record object
*/
private preCreateRecord;
/**
* Pre Update Record
* @param record - Record object
*/
private preUpdateRecord;
/**
* Preprocess the record before passing it to the editor
* @param schema - object, JSONSchema
*/
setSchema(schema: any): void;
/**
* Save the data on the server.
*/
submit(): void;
/** Save the current editor content as a template */
saveAsTemplate(): void;
/**
* Scroll the window in to the DOM element corresponding to a given config field.
* @param event - click DOM event
* @param field - FormlyFieldConfig, the form config corresponding to the DOM element to jump to.
*/
setFocus(event: any, field: FormlyFieldConfig): void;
/**
* Cancel editing and back to previous page
*/
cancel(): void;
/**
* Open a modal dialog box to load a template.
*/
showLoadTemplateDialog(): void;
/**
* Can the `load template` should be visible.
* The 'load template' button will be visible only if the corresponding setting is set and the user
* isn't in 'edit mode' (load template is only available for new resources)
* @return True if the button could be visible ; False otherwise
*/
canLoadTemplate(): boolean;
/********** Form field manipulation **********/
/**
* Scroll to a field or fieldGroup and set focus in the first field candidate.
* @param field: the field or fieldGroup where to search about field candidate.
* @param scroll: is the screen should scroll to the field.
*/
setFieldFocus(field: FormlyFieldConfig, scroll?: boolean): boolean;
/**
* Add a field to the hidden list
* @param field - FormlyFieldConfig, form config to be added
*/
addHiddenField(field: FormlyFieldConfig): void;
/**
* Clear the list of the hidden fields
*/
clearHiddenFields(): void;
/**
* Remove a field to the hidden list
* @param field - FormlyFieldConfig, form config to be removed
*/
removeHiddenField(field: FormlyFieldConfig): void;
/**
* Am I at the root of the form?
* @param field - FormlyFieldConfig, the field to hide
* @returns boolean, true if I'm the root
*/
isRoot(field: FormlyFieldConfig): boolean;
/**
* Can the field be hidden?
* @param field - FormlyFieldConfig, the field to hide
* @returns boolean, true if the field can be hidden
*/
canHide(field: FormlyFieldConfig): boolean;
/**
* Hide the given formly field.
* @param field - FormlyFieldConfig, the field to hide
*/
setHide(field: FormlyFieldConfig, value: boolean, scroll?: boolean): void;
/********************* Private ***************************************/
/**
* Handle form error
* @param error: object with status and title parameters
* @return Observable<Error>
*/
private _handleError;
private _canDeactivate;
static ɵfac: i0.ɵɵFactoryDeclaration<EditorComponent, never>;
static ɵcmp: i0.ɵɵComponentDeclaration<EditorComponent, "ng-core-editor", never, { "model": { "alias": "model"; "required": false; }; "schema": { "alias": "schema"; "required": false; }; "editorSettings": { "alias": "editorSettings"; "required": false; }; "pid": { "alias": "pid"; "required": false; }; }, { "modelChange": "modelChange"; "loadingChange": "loadingChange"; "canDeactivateChange": "canDeactivateChange"; }, never, ["[beforeTableOfContent]"], false, never>;
}