@eggslib/schematics
v0.2.7
Published
EggsNext schematics
Downloads
94
Readme
EggsNext Schematics
Prequisiti
Generali
Nella sezione path di config.json del progetto abilitare l'importazione abbreviata degli shared
"paths": { "@shared/": ["src/app/shared/"] },
in modo che sia possibile fare gli import abbreviati tipo
import {AuthService} from '@shared/services/auth.service';
Nella cartella src/app/shared devono essere presenti le cartelle con i business-services e i dyn-form (cfr. per esempio eggs-giri-ng)
Installazione
npm i -save-dev @eggslib/schematics
Configurazioni
Il package prevede una distribuzione standard delle cartelle
src | - app | - modules | - modulo | - models (cartella deile entità/modelli) | - pages (cartella deile pagine list, edit, etc) | - service (cartella dei servizi)
Schematics
PageService
Creazione di un service che estende AbstractPageService
Help:
Create a service which extends AbstractPageService arguments: path Target folder
options: --immutable If readonly model --model Model name --name Service name. If not set equals model
Utilizzo:
ng g @eggslib/schematics:page-service path --model=nodelname [--name=my-service] [--immutable]
Ex:
ng g @eggslib/schematics:page-service modules/module/services --model=my-model
Crea il file src/app/modules/module/services/my-model.service.ts La classe (MyModelService) estende AbstractPageService
--
ng g @eggslib/schematics:page-service modules/module/services --model=my-model --name=other-service-name
Crea il file src/app/modules/module/services/other-service-name.service.ts. La classe (OtherServiceService) estende AbstractPageService
ListPage
Creazione di una pagina per la gestione della lista di entità
Help: (ng g @eggslib/schematics:list-page --help)
Create a simple list page arguments: path Target folder
options: --model Model name. Required. --exports Add support for csv export. Optional. Default=false --filters Add support for bar filters. Optional. Default=false --name Page name. Optional. If not set it equals model --service-name Service name. Optional. It must be the name of the service component (ie model-service for model-service.service.ts). If not set it equals model. (ie mode.service.ts component)
Utilizzo:
ng g @eggslib/schematics:list-page path --model=nodelname [--service-name=my-service] [--name=my-page] [--filters] [--exports]
Ex:
ng g @eggslib/schematics:list-page modules/module/pages --model=my-model
Crea il file src/app/modules/module/pages/my-model-list.component.ts (less, html)
EditPage
Creazione di una pagina per la gestione dell'edit
Help: (ng g @eggslib/schematics:edit-page --help)
Create a simple edit page arguments: path Target folder
options: --form-data Form-data file path. Required. --model Model name. Required. --name Page name. Optional. If not set it equals model --service-name Service name. Optional. It must be the name of the service component (ie model-service for model-service.service.ts). If not set it equals model. (ie mode.service.ts component)
Utilizzo:
ng g @eggslib/schematics:edit-page path --form-data=form.json --model=my-model [--service-name=my-service] [--name=my-page] [--filters] [--exports]
Ex:
ng g @eggslib/schematics:edit-page modules/module/pages --form-data=temp.form.json --model=my-model
Crea il file src/app/modules/module/pages/my-model-edit.component.ts (less, html) partendo da un file temp.form.json dove vengono descritti i campi da gestire come ad esempio
[ { "name": "codice", "manage": true, "formControlName": "codice", "required": true, "maxlength": 32, "type": "input" }, { "name": "descrizione", "manage": true, "formControlName": "descrizione", "required": true, "maxlength": 128, "type": "input" } ]
Gli elementi devono corrispondere all'interfaccia
export type DynFormFieldDataType = 'input' | 'date' | 'time' | 'textarea' | 'pickhelper' | 'dropdown' | 'number' | 'boolean' | 'manual';
export interface DynFormFieldDataExt { name: string; // Nome elemento field?: string; // Nome property dell'entity, default = name manage: boolean; // formControlName: string; // required: boolean; valueChanges?: boolean; maxlength?: number; // Se 'input' o 'number' definisce il maxlength decimali?: number; // Se 'number' definisce il numero di decimali pickhelperEntity?: string; // Nome entity per i pickerhelper type: DynFormFieldDataType; // }
ViewPage
Creazione di una pagina per la gestione della view
Help: (ng g @eggslib/schematics:view-page --help)
Create a simple view page arguments: path Target folder
options: --form-data Form-data file path. Required. --model Model name. Required. --name Page name. Optional. If not set it equals model --service-name Service name. Optional. It must be the name of the service component (ie model-service for model-service.service.ts). If not set it equals model. (ie mode.service.ts component)
Utilizzo:
ng g @eggslib/schematics:edit-view path --form-data=form.json --model=my-model [--service-name=my-service] [--name=my-page]
Ex:
ng g @eggslib/schematics:view-page modules/module/pages --form-data=temp.form.json --model=my-model
Crea il file src/app/modules/module/pages/my-model-view.component.ts (less, html) partendo da un file temp.form.json (cfr. EditPage)