- update Angular packages: run
ng updateand then update the listed packages, which typically are:
ng update @angular/core @angular/cli @angular/cdk @angular/material --force- for Angular 15 you also need to migrate Material (choose all directories and all components):
ng generate @angular/material:mdc-migration- install ELF packages:
npm i @ngneat/effects-ng @ngneat/elf @ngneat/elf-cli-ng @ngneat/elf-devtools @ngneat/elf-entities @ngneat/elf-pagination @ngneat/elf-requests --force- install other Cadmus packages:
npm i @myrmidon/ngx-dirty-check --force-
update all the Cadmus-related packages to their latest versions in
package.json, and then runnpm i --force. -
ensure that
placeholderattributes in material controls are replaced withmat-labelinsidemat-form-field, e.g. this code:
<mat-form-field *ngIf="witEntries?.length">
<mat-select formControlName="id" placeholder="ID">
<mat-option *ngFor="let e of witEntries" [value]="e.id">{{
e.value
}}</mat-option>
</mat-select>
<mat-error
*ngIf="
$any(item)['controls'].id.errors?.required &&
($any(item)['controls'].id.dirty ||
$any(item)['controls'].id.touched)
"
>ID required</mat-error
>
</mat-form-field>becomes (removing placholder and adding mat-label):
<mat-form-field *ngIf="witEntries?.length">
<mat-label>ID</mat-label>
<mat-select formControlName="id">
<mat-option *ngFor="let e of witEntries" [value]="e.id">{{
e.value
}}</mat-option>
</mat-select>
<mat-error
*ngIf="
$any(item)['controls'].id.errors?.required &&
($any(item)['controls'].id.dirty ||
$any(item)['controls'].id.touched)
"
>ID required</mat-error
>
</mat-form-field>-
update parts and fragments as specified below.
-
in
app.module.ts, remove Akita packages and modules imports and add the following imports:
// ELF
import { devTools } from '@ngneat/elf-devtools';
import { Actions } from '@ngneat/effects-ng';
// myrmidon
import { NgxDirtyCheckModule } from '@myrmidon/ngx-dirty-check';Add the corresponding modules to your app imports array:
NgxDirtyCheckModule,Add the following entry to the providers array to enable ELF dev tools:
// ELF dev tools
{
provide: APP_INITIALIZER,
multi: true,
useFactory: initElfDevTools,
deps: [Actions],
},- Just before the
@NgModuleattribute introducing the app module, add this function to enable ELF dev tools:
// https://ngneat.github.io/elf/docs/dev-tools/
export function initElfDevTools(actions: Actions) {
return () => {
devTools({
name: 'Cadmus TGR',
actionsDispatcher: actions,
});
};
}- in
app.component.tsreplaceAppQueryandAppServicewithAppRepository:
import { AppRepository } from '@myrmidon/cadmus-state';- remove Akita packages:
npm uninstall @datorama/akita-ngdevtools @datorama/akita --forceNote: due to changes in Angular Material styles, which often result in slightly bigger controls, if your UI defined custom sizes for some controls you might need to adjust them to fit.
- pass
formBuilderto the super ctor. - implement
ngOnInitat least as (initEditorno more exists):
public override ngOnInit(): void {
super.ngOnInit();
}- implement
buildFormmoving there the creation of the root form (previously in ctor):
protected buildForm(formBuilder: FormBuilder): FormGroup | UntypedFormGroup {
return formBuilder.group({
// ...
});
}- change
onThesauriSetinto a privateupdateThesauriand call it fromonDataSet, e.g.:
private updateThesauri(thesauri: ThesauriSet): void {
let key = 'bibliography-languages';
if (this.hasThesaurus(key)) {
this.langEntries = thesauri[key].entries;
} else {
this.langEntries = undefined;
}
key = 'bibliography-types';
if (this.hasThesaurus(key)) {
this.typeEntries = thesauri[key].entries;
} else {
this.typeEntries = undefined;
}
}-
ensure that
updateFormis ok (ensure that it receives a part/fragment which can also beundefinedornull) and call it fromOnDataSet. -
rename
onModelSettoonDataSetand adjust it as required, like:
protected override onDataSet(data?: EditedObject<ChronotopesPart>): void {
// thesauri
if (data?.thesauri) {
this.updateThesauri(data.thesauri);
}
// form
this.updateForm(data?.value);
}- rename
getModelFromFormtogetValueand adjust, e.g.:
// for parts
protected getValue(): ChronotopesPart {
let part = this.getEditedPart(CHRONOTOPES_PART_TYPEID) as ChronotopesPart;
part.chronotopes = this.chronotopes.value;
return part;
}
// for fragments
protected getValue(): OrthographyFragment {
const fr = this.getEditedFragment() as OrthographyFragment;
fr.standard = this.standard.value.trim();
fr.operations = this.getOperations();
return fr;
}- for fragments, in the template replace the location and base text references from
model?.locationandmodel?.baseTexttodata()?.value?.locationanddata()?.baseText.
Note:
CadmusValidatorshas been removed from core, as its functionalities are found inNgxToolsValidators(from@myrmidon/ng-tools). So, if your code was using these validators, just replace the validators class.
-
remove all the state-related files.
-
replace the constructor:
import { EditPartFeatureBase, PartEditorService } from '@myrmidon/cadmus-state';
import { ItemService, ThesaurusService } from '@myrmidon/cadmus-api';
constructor(
router: Router,
route: ActivatedRoute,
snackbar: MatSnackBar,
itemService: ItemService,
thesaurusService: ThesaurusService,
editorService: PartEditorService
) {
super(
router,
route,
snackbar,
itemService,
thesaurusService,
editorService
);
}- replace
ngOnInitwithgetReqThesauriIdsoverride when thesauri are required, else just remove it:
protected override getReqThesauriIds(): string[] {
return [
'bibliography-languages',
'bibliography-types',
'bibliography-tags',
'bibliography-author-roles',
];
}- change the template like this:
<cadmus-current-item-bar></cadmus-current-item-bar>
<cadmus-bibliography-part
[identity]="identity"
[data]="$any(data)"
(dataChange)="save($event)"
(editorClose)="close()"
(dirtyChange)="onDirtyChange($event)"
></cadmus-bibliography-part>-
remove all the state-related files.
-
replace the constructor:
import {
EditFragmentFeatureBase,
FragmentEditorService,
} from '@myrmidon/cadmus-state';
constructor(
router: Router,
route: ActivatedRoute,
snackbar: MatSnackBar,
editorService: FragmentEditorService,
libraryRouteService: LibraryRouteService
) {
super(router, route, snackbar, editorService, libraryRouteService);
}- replace
ngOnInitwithgetReqThesauriIdsoverride when thesauri are required, else just remove it.
protected override getReqThesauriIds(): string[] {
return [
// ...
];
}- change the template like this:
<cadmus-current-item-bar></cadmus-current-item-bar>
<div class="base-text">
<cadmus-decorated-token-text
[baseText]="data?.baseText || ''"
[locations]="frLoc ? [frLoc] : []"
></cadmus-decorated-token-text>
</div>
<cadmus-chronology-fragment
[data]="$any(data)"
(dataChange)="save($event)"
(editorClose)="close()"
(dirtyChange)="onDirtyChange($event)"
></cadmus-chronology-fragment>