@myrmidon/cadmus-part-general-ui 14.0.2 → 14.0.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -43,6 +43,8 @@ import * as i5$2 from '@cisstech/nge/markdown';
43
43
  import { NgeMarkdownModule } from '@cisstech/nge/markdown';
44
44
  import { DecoratedCountsComponent } from '@myrmidon/cadmus-refs-decorated-counts';
45
45
  import { ProperNameComponent, CadmusProperNamePipe } from '@myrmidon/cadmus-refs-proper-name';
46
+ import { FlagSetComponent } from '@myrmidon/cadmus-ui-flag-set';
47
+ import { NoteSetComponent } from '@myrmidon/cadmus-ui-note-set';
46
48
  import { PhysicalMeasurementSetComponent } from '@myrmidon/cadmus-mat-physical-size';
47
49
  import { PhysicalStateComponent } from '@myrmidon/cadmus-mat-physical-state';
48
50
  import { moveItemInArray, CdkDropListGroup, CdkDropList, CdkDrag, CdkDragPlaceholder } from '@angular/cdk/drag-drop';
@@ -3475,6 +3477,212 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.1.4", ngImpor
3475
3477
  ], template: "<form [formGroup]=\"form\" (submit)=\"save()\">\r\n <mat-card appearance=\"outlined\">\r\n <mat-card-header>\r\n <div mat-card-avatar>\r\n <mat-icon>picture_in_picture</mat-icon>\r\n </div>\r\n <mat-card-title>{{\r\n (modelName() | titlecase) || \"External IDs Part\"\r\n }}</mat-card-title>\r\n </mat-card-header>\r\n <mat-card-content>\r\n <cadmus-refs-asserted-ids\r\n [idScopeEntries]=\"idScopeEntries\"\r\n [idTagEntries]=\"idTagEntries\"\r\n [assTagEntries]=\"assTagEntries\"\r\n [refTypeEntries]=\"refTypeEntries\"\r\n [refTagEntries]=\"refTagEntries\"\r\n [ids]=\"ids.value\"\r\n (idsChange)=\"onIdsChange($event)\"\r\n />\r\n </mat-card-content>\r\n <mat-card-actions>\r\n <cadmus-close-save-buttons\r\n [form]=\"form\"\r\n [noSave]=\"userLevel < 2\"\r\n (closeRequest)=\"close()\"\r\n />\r\n </mat-card-actions>\r\n </mat-card>\r\n</form>\r\n" }]
3476
3478
  }], ctorParameters: () => [{ type: i1.AuthJwtService }, { type: i2.FormBuilder }] });
3477
3479
 
3480
+ /**
3481
+ * The type ID used to identify the FlagsPart type.
3482
+ */
3483
+ const FLAGS_PART_TYPEID = 'it.vedph.flags';
3484
+ /**
3485
+ * JSON schema for the Flags part.
3486
+ * You can use the JSON schema tool at https://jsonschema.net/.
3487
+ */
3488
+ const FLAGS_PART_SCHEMA = {
3489
+ $schema: 'http://json-schema.org/draft-07/schema#',
3490
+ $id: 'www.vedph.it/cadmus/parts/__PRJ__/__LIB__/' + FLAGS_PART_TYPEID + '.json',
3491
+ type: 'object',
3492
+ title: 'FlagsPart',
3493
+ required: [
3494
+ 'id',
3495
+ 'itemId',
3496
+ 'typeId',
3497
+ 'timeCreated',
3498
+ 'creatorId',
3499
+ 'timeModified',
3500
+ 'userId',
3501
+ 'flags',
3502
+ ],
3503
+ properties: {
3504
+ timeCreated: {
3505
+ type: 'string',
3506
+ pattern: '^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}.\\d+Z$',
3507
+ },
3508
+ creatorId: {
3509
+ type: 'string',
3510
+ },
3511
+ timeModified: {
3512
+ type: 'string',
3513
+ pattern: '^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}.\\d+Z$',
3514
+ },
3515
+ userId: {
3516
+ type: 'string',
3517
+ },
3518
+ id: {
3519
+ type: 'string',
3520
+ pattern: '^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$',
3521
+ },
3522
+ itemId: {
3523
+ type: 'string',
3524
+ pattern: '^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$',
3525
+ },
3526
+ typeId: {
3527
+ type: 'string',
3528
+ pattern: '^[a-z][-0-9a-z._]*$',
3529
+ },
3530
+ roleId: {
3531
+ type: ['string', 'null'],
3532
+ pattern: '^([a-z][-0-9a-z._]*)?$',
3533
+ },
3534
+ flags: {
3535
+ type: 'array',
3536
+ items: {
3537
+ type: 'string',
3538
+ pattern: '^[a-z][-0-9a-z._]*$',
3539
+ },
3540
+ minItems: 1,
3541
+ },
3542
+ notes: {
3543
+ type: 'object',
3544
+ additionalProperties: {
3545
+ type: 'string',
3546
+ },
3547
+ },
3548
+ },
3549
+ };
3550
+
3551
+ function entryToFlag(entry) {
3552
+ return {
3553
+ id: entry.id,
3554
+ label: entry.value,
3555
+ };
3556
+ }
3557
+ /**
3558
+ * Flags part editor component.
3559
+ * Thesauri: flags.
3560
+ * Settings: note set definitions for this part type (and role). If not defined,
3561
+ * no notes will be available.
3562
+ * See https://github.com/vedph/cadmus-bricks-shell-v3/blob/master/projects/myrmidon/cadmus-ui-note-set/README.md.
3563
+ */
3564
+ class FlagsPartComponent extends ModelEditorComponentBase {
3565
+ flags;
3566
+ notes;
3567
+ // note settings
3568
+ settings = signal(undefined, ...(ngDevMode ? [{ debugName: "settings" }] : []));
3569
+ // flags
3570
+ flagEntries = signal([], ...(ngDevMode ? [{ debugName: "flagEntries" }] : []));
3571
+ // flags mapped from thesaurus entries
3572
+ featureFlags = computed(() => this.flagEntries()?.map((e) => entryToFlag(e)) || [], ...(ngDevMode ? [{ debugName: "featureFlags" }] : []));
3573
+ constructor(authService, formBuilder) {
3574
+ super(authService, formBuilder);
3575
+ // form
3576
+ this.flags = formBuilder.control([], {
3577
+ validators: NgxToolsValidators.strictMinLengthValidator(1),
3578
+ nonNullable: true,
3579
+ });
3580
+ this.notes = formBuilder.control({ definitions: [], notes: {} }, {
3581
+ nonNullable: true,
3582
+ });
3583
+ }
3584
+ async ngOnInit() {
3585
+ super.ngOnInit();
3586
+ // load settings for this part
3587
+ if (this._appRepository) {
3588
+ this.settings.set(await this._appRepository.getSettingFor(FLAGS_PART_TYPEID, this.identity()?.roleId || undefined));
3589
+ console.log('Flags part settings:', this.settings);
3590
+ }
3591
+ }
3592
+ buildForm(formBuilder) {
3593
+ return formBuilder.group({
3594
+ flags: this.flags,
3595
+ notes: this.notes,
3596
+ });
3597
+ }
3598
+ updateThesauri(thesauri) {
3599
+ const key = 'flags';
3600
+ if (this.hasThesaurus(key)) {
3601
+ this.flagEntries.set(thesauri[key].entries || []);
3602
+ }
3603
+ else {
3604
+ this.flagEntries.set([]);
3605
+ }
3606
+ }
3607
+ getNoteSet(part) {
3608
+ // no notes if no settings defining them
3609
+ if (!this.settings()) {
3610
+ return { definitions: [], notes: {} };
3611
+ }
3612
+ // build a note set by merging definitions from settings with notes from part
3613
+ return { ...this.settings(), notes: part.notes || {} };
3614
+ }
3615
+ updateForm(part) {
3616
+ if (!part) {
3617
+ this.form.reset();
3618
+ return;
3619
+ }
3620
+ // flags
3621
+ this.flags.setValue(part.flags || []);
3622
+ // notes
3623
+ this.notes.setValue(this.getNoteSet(part));
3624
+ this.form.markAsPristine();
3625
+ }
3626
+ onDataSet(data) {
3627
+ // thesauri
3628
+ if (data?.thesauri) {
3629
+ this.updateThesauri(data.thesauri);
3630
+ }
3631
+ // form
3632
+ this.updateForm(data?.value);
3633
+ }
3634
+ onFlagsCheckedIdsChange(ids) {
3635
+ this.flags.setValue(ids);
3636
+ this.flags.markAsDirty();
3637
+ this.flags.updateValueAndValidity();
3638
+ }
3639
+ onNoteChange(note) {
3640
+ console.log(`Note "${note.key}" changed to: ${note.value}`);
3641
+ }
3642
+ onSetChange(set) {
3643
+ console.log('Complete set updated:', set);
3644
+ this.notes.setValue(set);
3645
+ }
3646
+ getValue() {
3647
+ let part = this.getEditedPart(FLAGS_PART_TYPEID);
3648
+ part.flags = this.flags.value || [];
3649
+ // remove keys with null/undefined values
3650
+ const notesObj = this.notes.value?.notes || {};
3651
+ const filteredNotes = {};
3652
+ for (const key of Object.keys(notesObj)) {
3653
+ if (notesObj[key] != null) {
3654
+ filteredNotes[key] = notesObj[key];
3655
+ }
3656
+ }
3657
+ part.notes =
3658
+ Object.keys(filteredNotes).length > 0 ? filteredNotes : undefined;
3659
+ return part;
3660
+ }
3661
+ static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.1.4", ngImport: i0, type: FlagsPartComponent, deps: [{ token: i1.AuthJwtService }, { token: i2.FormBuilder }], target: i0.ɵɵFactoryTarget.Component });
3662
+ static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "20.1.4", type: FlagsPartComponent, isStandalone: true, selector: "cadmus-flags-part", usesInheritance: true, ngImport: i0, template: "<form [formGroup]=\"form\" (submit)=\"save()\">\r\n <mat-card>\r\n <mat-card-header>\r\n <div mat-card-avatar>\r\n <mat-icon>picture_in_picture</mat-icon>\r\n </div>\r\n <mat-card-title>\r\n {{ (modelName() | titlecase) || \"Flags Part\" }}\r\n </mat-card-title>\r\n </mat-card-header>\r\n <mat-card-content>\r\n <div>\r\n @if (flagEntries().length) {\r\n <div>\r\n <cadmus-ui-flag-set\r\n [flags]=\"featureFlags()\"\r\n [checkedIds]=\"flags.value\"\r\n (checkedIdsChange)=\"onFlagsCheckedIdsChange($event)\"\r\n />\r\n </div>\r\n } @if (settings()) {\r\n <div>\r\n <fieldset>\r\n <legend>notes</legend>\r\n <cadmus-ui-note-set\r\n [(set)]=\"notes.value\"\r\n (noteChange)=\"onNoteChange($event)\"\r\n (setChange)=\"onSetChange($event)\"\r\n />\r\n </fieldset>\r\n </div>\r\n }\r\n </div>\r\n </mat-card-content>\r\n <mat-card-actions>\r\n <cadmus-close-save-buttons\r\n [form]=\"form\"\r\n [noSave]=\"userLevel < 2\"\r\n (closeRequest)=\"close()\"\r\n />\r\n </mat-card-actions>\r\n </mat-card>\r\n</form>\r\n", styles: ["fieldset{border:1px solid silver;border-radius:4px;padding:8px;margin:8px 0}fieldset legend{color:silver}\n"], dependencies: [{ kind: "ngmodule", type: CommonModule }, { kind: "ngmodule", type: ReactiveFormsModule }, { kind: "directive", type: i2.ɵNgNoValidate, selector: "form:not([ngNoForm]):not([ngNativeValidate])" }, { kind: "directive", type: i2.NgControlStatusGroup, selector: "[formGroupName],[formArrayName],[ngModelGroup],[formGroup],form:not([ngNoForm]),[ngForm]" }, { kind: "directive", type: i2.FormGroupDirective, selector: "[formGroup]", inputs: ["formGroup"], outputs: ["ngSubmit"], exportAs: ["ngForm"] }, { kind: "ngmodule", type: MatButtonModule }, { kind: "ngmodule", type: MatCardModule }, { kind: "component", type: i5$1.MatCard, selector: "mat-card", inputs: ["appearance"], exportAs: ["matCard"] }, { kind: "directive", type: i5$1.MatCardActions, selector: "mat-card-actions", inputs: ["align"], exportAs: ["matCardActions"] }, { kind: "directive", type: i5$1.MatCardAvatar, selector: "[mat-card-avatar], [matCardAvatar]" }, { kind: "directive", type: i5$1.MatCardContent, selector: "mat-card-content" }, { kind: "component", type: i5$1.MatCardHeader, selector: "mat-card-header" }, { kind: "directive", type: i5$1.MatCardTitle, selector: "mat-card-title, [mat-card-title], [matCardTitle]" }, { kind: "ngmodule", type: MatExpansionModule }, { kind: "ngmodule", type: MatFormFieldModule }, { kind: "ngmodule", type: MatIconModule }, { kind: "component", type: i5.MatIcon, selector: "mat-icon", inputs: ["color", "inline", "svgIcon", "fontSet", "fontIcon"], exportAs: ["matIcon"] }, { kind: "ngmodule", type: MatInputModule }, { kind: "ngmodule", type: MatSelectModule }, { kind: "ngmodule", type: MatTooltipModule }, { kind: "component", type:
3663
+ // cadmus
3664
+ FlagSetComponent, selector: "cadmus-ui-flag-set", inputs: ["flags", "checkedIds", "allowCustom", "hideToolbar", "numbering"], outputs: ["checkedIdsChange"] }, { kind: "component", type: NoteSetComponent, selector: "cadmus-ui-note-set", inputs: ["set"], outputs: ["setChange", "noteChange"] }, { kind: "component", type: CloseSaveButtonsComponent, selector: "cadmus-close-save-buttons", inputs: ["form", "noSave"], outputs: ["closeRequest"] }, { kind: "pipe", type: i9.TitleCasePipe, name: "titlecase" }] });
3665
+ }
3666
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.1.4", ngImport: i0, type: FlagsPartComponent, decorators: [{
3667
+ type: Component,
3668
+ args: [{ selector: 'cadmus-flags-part', imports: [
3669
+ CommonModule,
3670
+ ReactiveFormsModule,
3671
+ MatButtonModule,
3672
+ MatCardModule,
3673
+ MatExpansionModule,
3674
+ MatFormFieldModule,
3675
+ MatIconModule,
3676
+ MatInputModule,
3677
+ MatSelectModule,
3678
+ MatTooltipModule,
3679
+ // cadmus
3680
+ FlagSetComponent,
3681
+ NoteSetComponent,
3682
+ CloseSaveButtonsComponent,
3683
+ ], template: "<form [formGroup]=\"form\" (submit)=\"save()\">\r\n <mat-card>\r\n <mat-card-header>\r\n <div mat-card-avatar>\r\n <mat-icon>picture_in_picture</mat-icon>\r\n </div>\r\n <mat-card-title>\r\n {{ (modelName() | titlecase) || \"Flags Part\" }}\r\n </mat-card-title>\r\n </mat-card-header>\r\n <mat-card-content>\r\n <div>\r\n @if (flagEntries().length) {\r\n <div>\r\n <cadmus-ui-flag-set\r\n [flags]=\"featureFlags()\"\r\n [checkedIds]=\"flags.value\"\r\n (checkedIdsChange)=\"onFlagsCheckedIdsChange($event)\"\r\n />\r\n </div>\r\n } @if (settings()) {\r\n <div>\r\n <fieldset>\r\n <legend>notes</legend>\r\n <cadmus-ui-note-set\r\n [(set)]=\"notes.value\"\r\n (noteChange)=\"onNoteChange($event)\"\r\n (setChange)=\"onSetChange($event)\"\r\n />\r\n </fieldset>\r\n </div>\r\n }\r\n </div>\r\n </mat-card-content>\r\n <mat-card-actions>\r\n <cadmus-close-save-buttons\r\n [form]=\"form\"\r\n [noSave]=\"userLevel < 2\"\r\n (closeRequest)=\"close()\"\r\n />\r\n </mat-card-actions>\r\n </mat-card>\r\n</form>\r\n", styles: ["fieldset{border:1px solid silver;border-radius:4px;padding:8px;margin:8px 0}fieldset legend{color:silver}\n"] }]
3684
+ }], ctorParameters: () => [{ type: i1.AuthJwtService }, { type: i2.FormBuilder }] });
3685
+
3478
3686
  /**
3479
3687
  * The type ID used to identify the EventsPart type.
3480
3688
  */
@@ -8070,5 +8278,5 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.1.4", ngImpor
8070
8278
  * Generated bundle index. Do not edit.
8071
8279
  */
8072
8280
 
8073
- export { ASSERTED_HISTORICAL_DATES_PART_SCHEMA, ASSERTED_HISTORICAL_DATES_PART_TYPEID, AssertedHistoricalDateComponent, AssertedHistoricalDatesPartComponent, BIBLIOGRAPHY_PART_SCHEMA, BIBLIOGRAPHY_PART_TYPEID, BibAuthorsEditorComponent, BibliographyEntryComponent, BibliographyPartComponent, CATEGORIES_PART_SCHEMA, CATEGORIES_PART_TYPEID, CHRONOLOGY_FRAGMENT_SCHEMA, CHRONOLOGY_FRAGMENT_TYPEID, CHRONOTOPES_PART_TYPEID, COMMENT_FRAGMENT_SCHEMA, COMMENT_FRAGMENT_TYPEID, COMMENT_PART_SCHEMA, COMMENT_PART_TYPEID, CategoriesPartComponent, ChronologyFragmentComponent, ChronotopesPartComponent, Chronotopes_PART_SCHEMA, CommentEditorComponent, DECORATED_COUNTS_PART_SCHEMA, DECORATED_COUNTS_PART_TYPEID, DISTRICT_LOCATION_PART_SCHEMA, DISTRICT_LOCATION_PART_TYPEID, DOC_REFERENCES_PART_SCHEMA, DOC_REFERENCES_PART_TYPEID, DecoratedCountsPartComponent, DistrictLocationPartComponent, DocReferencesPartComponent, EXTERNAL_IDS_PART_SCHEMA, EXTERNAL_IDS_PART_TYPEID, ExternalIdsPartComponent, HISTORICAL_DATE_PART_SCHEMA, HISTORICAL_DATE_PART_TYPEID, HISTORICAL_EVENTS_PART_SCHEMA, HISTORICAL_EVENTS_PART_TYPEID, HistoricalDatePartComponent, HistoricalEventEditorComponent, HistoricalEventsPartComponent, INDEX_KEYWORDS_PART_SCHEMA, INDEX_KEYWORDS_PART_TYPEID, IndexKeywordComponent, IndexKeywordsPartComponent, KEYWORDS_PART_SCHEMA, KEYWORDS_PART_TYPEID, KeywordsPartComponent, METADATA_PART_SCHEMA, METADATA_PART_TYPEID, MetadataPartComponent, NAMES_PART_SCHEMA, NAMES_PART_TYPEID, NOTE_PART_SCHEMA, NOTE_PART_TYPEID, NamesPartComponent, NotePartComponent, PHYSICAL_MEASUREMENTS_PART_SCHEMA, PHYSICAL_MEASUREMENTS_PART_TYPEID, PHYSICAL_STATES_PART_SCHEMA, PHYSICAL_STATES_PART_TYPEID, PIN_LINKS_FRAGMENT_SCHEMA, PIN_LINKS_FRAGMENT_TYPEID, PIN_LINKS_PART_SCHEMA, PIN_LINKS_PART_TYPEID, PhysicalMeasurementsPartComponent, PhysicalStatesPartComponent, PinLinksFragmentComponent, PinLinksPartComponent, RelatedEntityComponent, TEXT_TILE_TEXT_DATA_NAME, TILEDTEXTPART_SCHEMA, TILED_TEXT_PART_TYPEID, TOKEN_TEXT_PART_SCHEMA, TOKEN_TEXT_PART_TYPEID, TextTileComponent, TiledDataComponent, TiledTextPartComponent, TokenTextPartComponent };
8281
+ export { ASSERTED_HISTORICAL_DATES_PART_SCHEMA, ASSERTED_HISTORICAL_DATES_PART_TYPEID, AssertedHistoricalDateComponent, AssertedHistoricalDatesPartComponent, BIBLIOGRAPHY_PART_SCHEMA, BIBLIOGRAPHY_PART_TYPEID, BibAuthorsEditorComponent, BibliographyEntryComponent, BibliographyPartComponent, CATEGORIES_PART_SCHEMA, CATEGORIES_PART_TYPEID, CHRONOLOGY_FRAGMENT_SCHEMA, CHRONOLOGY_FRAGMENT_TYPEID, CHRONOTOPES_PART_TYPEID, COMMENT_FRAGMENT_SCHEMA, COMMENT_FRAGMENT_TYPEID, COMMENT_PART_SCHEMA, COMMENT_PART_TYPEID, CategoriesPartComponent, ChronologyFragmentComponent, ChronotopesPartComponent, Chronotopes_PART_SCHEMA, CommentEditorComponent, DECORATED_COUNTS_PART_SCHEMA, DECORATED_COUNTS_PART_TYPEID, DISTRICT_LOCATION_PART_SCHEMA, DISTRICT_LOCATION_PART_TYPEID, DOC_REFERENCES_PART_SCHEMA, DOC_REFERENCES_PART_TYPEID, DecoratedCountsPartComponent, DistrictLocationPartComponent, DocReferencesPartComponent, EXTERNAL_IDS_PART_SCHEMA, EXTERNAL_IDS_PART_TYPEID, ExternalIdsPartComponent, FLAGS_PART_SCHEMA, FLAGS_PART_TYPEID, FlagsPartComponent, HISTORICAL_DATE_PART_SCHEMA, HISTORICAL_DATE_PART_TYPEID, HISTORICAL_EVENTS_PART_SCHEMA, HISTORICAL_EVENTS_PART_TYPEID, HistoricalDatePartComponent, HistoricalEventEditorComponent, HistoricalEventsPartComponent, INDEX_KEYWORDS_PART_SCHEMA, INDEX_KEYWORDS_PART_TYPEID, IndexKeywordComponent, IndexKeywordsPartComponent, KEYWORDS_PART_SCHEMA, KEYWORDS_PART_TYPEID, KeywordsPartComponent, METADATA_PART_SCHEMA, METADATA_PART_TYPEID, MetadataPartComponent, NAMES_PART_SCHEMA, NAMES_PART_TYPEID, NOTE_PART_SCHEMA, NOTE_PART_TYPEID, NamesPartComponent, NotePartComponent, PHYSICAL_MEASUREMENTS_PART_SCHEMA, PHYSICAL_MEASUREMENTS_PART_TYPEID, PHYSICAL_STATES_PART_SCHEMA, PHYSICAL_STATES_PART_TYPEID, PIN_LINKS_FRAGMENT_SCHEMA, PIN_LINKS_FRAGMENT_TYPEID, PIN_LINKS_PART_SCHEMA, PIN_LINKS_PART_TYPEID, PhysicalMeasurementsPartComponent, PhysicalStatesPartComponent, PinLinksFragmentComponent, PinLinksPartComponent, RelatedEntityComponent, TEXT_TILE_TEXT_DATA_NAME, TILEDTEXTPART_SCHEMA, TILED_TEXT_PART_TYPEID, TOKEN_TEXT_PART_SCHEMA, TOKEN_TEXT_PART_TYPEID, TextTileComponent, TiledDataComponent, TiledTextPartComponent, TokenTextPartComponent };
8074
8282
  //# sourceMappingURL=myrmidon-cadmus-part-general-ui.mjs.map