diff --git a/apps/metadata-editor/src/app/edit/components/breadcrumbs/page-selector.component.css b/apps/metadata-editor/src/app/edit/components/page-selector/page-selector.component.css similarity index 100% rename from apps/metadata-editor/src/app/edit/components/breadcrumbs/page-selector.component.css rename to apps/metadata-editor/src/app/edit/components/page-selector/page-selector.component.css diff --git a/apps/metadata-editor/src/app/edit/components/breadcrumbs/page-selector.component.html b/apps/metadata-editor/src/app/edit/components/page-selector/page-selector.component.html similarity index 97% rename from apps/metadata-editor/src/app/edit/components/breadcrumbs/page-selector.component.html rename to apps/metadata-editor/src/app/edit/components/page-selector/page-selector.component.html index 3085adc2f5..279daf25d9 100644 --- a/apps/metadata-editor/src/app/edit/components/breadcrumbs/page-selector.component.html +++ b/apps/metadata-editor/src/app/edit/components/page-selector/page-selector.component.html @@ -20,7 +20,7 @@ : 'bg-gray-200' " > - {{ index }} + {{ index + 1 }}
{ +class EditorFacadeMock { + editorConfig$ = new BehaviorSubject(EDITOR_CONFIG()) + setCurrentPage = jest.fn() +} + +describe('PageSelectorComponent', () => { let component: PageSelectorComponent let fixture: ComponentFixture beforeEach(async () => { await TestBed.configureTestingModule({ imports: [TranslateModule.forRoot()], - providers: [], + providers: [ + { + provide: EditorFacade, + useClass: EditorFacadeMock, + }, + ], }).compileComponents() fixture = TestBed.createComponent(PageSelectorComponent) component = fixture.componentInstance - component.pages = EDITOR_CONFIG().pages - component.selectedPage = 0 fixture.detectChanges() }) diff --git a/apps/metadata-editor/src/app/edit/components/breadcrumbs/page-selector.component.ts b/apps/metadata-editor/src/app/edit/components/page-selector/page-selector.component.ts similarity index 94% rename from apps/metadata-editor/src/app/edit/components/breadcrumbs/page-selector.component.ts rename to apps/metadata-editor/src/app/edit/components/page-selector/page-selector.component.ts index 0cb4d03769..0170944011 100644 --- a/apps/metadata-editor/src/app/edit/components/breadcrumbs/page-selector.component.ts +++ b/apps/metadata-editor/src/app/edit/components/page-selector/page-selector.component.ts @@ -19,6 +19,6 @@ export class PageSelectorComponent { constructor(public facade: EditorFacade) {} pageSectionClickHandler(index: number) { - this.facade.setCurrentPage(index) // TODO + this.facade.setCurrentPage(index) } } diff --git a/apps/metadata-editor/src/app/edit/edit-page.component.spec.ts b/apps/metadata-editor/src/app/edit/edit-page.component.spec.ts index 36fc290d2d..4889c0822c 100644 --- a/apps/metadata-editor/src/app/edit/edit-page.component.spec.ts +++ b/apps/metadata-editor/src/app/edit/edit-page.component.spec.ts @@ -1,14 +1,13 @@ import { ComponentFixture, TestBed } from '@angular/core/testing' import { EditPageComponent } from './edit-page.component' import { ActivatedRoute, Router } from '@angular/router' -import { EDITOR_CONFIG, EditorFacade } from '@geonetwork-ui/feature/editor' import { NO_ERRORS_SCHEMA } from '@angular/core' -import { DATASET_RECORDS } from '@geonetwork-ui/common/fixtures' +import { DATASET_RECORDS, EDITOR_CONFIG } from '@geonetwork-ui/common/fixtures' import { BehaviorSubject, Subject } from 'rxjs' import { NotificationsService } from '@geonetwork-ui/feature/notifications' import { TranslateModule } from '@ngx-translate/core' -import { FindPipe } from '../pipes/filter.pipe' -import { PageSelectorComponent } from './components/breadcrumbs/page-selector.component' +import { PageSelectorComponent } from './components/page-selector/page-selector.component' +import { EditorFacade } from '@geonetwork-ui/feature/editor' const getRoute = () => ({ snapshot: { @@ -27,11 +26,11 @@ class RouterMock { class EditorFacadeMock { record$ = new BehaviorSubject(DATASET_RECORDS[0]) - recordFields$ = new BehaviorSubject(EDITOR_CONFIG()) openRecord = jest.fn() saveError$ = new Subject() saveSuccess$ = new Subject() draftSaveSuccess$ = new Subject() + editorConfig$ = new BehaviorSubject(EDITOR_CONFIG()) } class NotificationsServiceMock { showNotification = jest.fn() @@ -48,7 +47,6 @@ describe('EditPageComponent', () => { imports: [ EditPageComponent, TranslateModule.forRoot(), - FindPipe, PageSelectorComponent, ], schemas: [NO_ERRORS_SCHEMA], diff --git a/apps/metadata-editor/src/app/edit/edit-page.component.ts b/apps/metadata-editor/src/app/edit/edit-page.component.ts index 16d2ecc7d3..5c7a54a539 100644 --- a/apps/metadata-editor/src/app/edit/edit-page.component.ts +++ b/apps/metadata-editor/src/app/edit/edit-page.component.ts @@ -15,7 +15,7 @@ import { } from '@geonetwork-ui/feature/notifications' import { TranslateModule, TranslateService } from '@ngx-translate/core' import { filter, firstValueFrom, Subscription, take } from 'rxjs' -import { PageSelectorComponent } from './components/breadcrumbs/page-selector.component' +import { PageSelectorComponent } from './components/page-selector/page-selector.component' import { marker } from '@biesbjerg/ngx-translate-extract-marker' import { map } from 'rxjs/operators' @@ -130,7 +130,7 @@ export class EditPageComponent implements OnInit, OnDestroy { if (currentPage === 0) { this.router.navigate(['catalog', 'search']) } else { - this.facade.setCurrentPage(currentPage - 1) // TODO + this.facade.setCurrentPage(currentPage - 1) } } diff --git a/apps/metadata-editor/tsconfig.json b/apps/metadata-editor/tsconfig.json index 54f2b40f0e..099e2430b3 100644 --- a/apps/metadata-editor/tsconfig.json +++ b/apps/metadata-editor/tsconfig.json @@ -19,8 +19,7 @@ "noImplicitReturns": true, "noFallthroughCasesInSwitch": true, "target": "es2020", - "lib": ["dom", "es2020", "dom.iterable"], - "downlevelIteration": true + "lib": ["dom", "es2020", "dom.iterable"] }, "angularCompilerOptions": { "strictInjectionParameters": true, diff --git a/assets-common/css/default-fonts.css b/assets-common/css/default-fonts.css index 34941cbd8c..fc8d76c604 100644 --- a/assets-common/css/default-fonts.css +++ b/assets-common/css/default-fonts.css @@ -1,11 +1,3 @@ -/* Petrona */ -@font-face { - font-family: 'Petrona'; - font-style: normal; - font-weight: 400; - font-display: swap; - src: url(../fonts/Petrona-Regular.woff2) format('woff2'); -} /* arabic */ @font-face { font-family: 'Readex Pro'; diff --git a/libs/common/fixtures/src/index.ts b/libs/common/fixtures/src/index.ts index 850a472de6..d628b25d94 100644 --- a/libs/common/fixtures/src/index.ts +++ b/libs/common/fixtures/src/index.ts @@ -11,3 +11,5 @@ export * from './lib/records.fixtures' export * from './lib/repository.fixtures' export * from './lib/user.fixtures' export * from './lib/user-feedbacks.fixtures' + +export * from './lib/editor' diff --git a/libs/feature/editor/src/lib/fixtures/editor.fixtures.ts b/libs/common/fixtures/src/lib/editor/editor.fixtures.ts similarity index 97% rename from libs/feature/editor/src/lib/fixtures/editor.fixtures.ts rename to libs/common/fixtures/src/lib/editor/editor.fixtures.ts index d220a192ef..753cbbea0b 100644 --- a/libs/feature/editor/src/lib/fixtures/editor.fixtures.ts +++ b/libs/common/fixtures/src/lib/editor/editor.fixtures.ts @@ -1,4 +1,8 @@ -import { EditorConfig, EditorField, EditorSection } from '../models' +import { + EditorConfig, + EditorField, + EditorSection, +} from '@geonetwork-ui/feature/editor' export const EDITOR_CONFIG = (): EditorConfig => ({ pages: [ diff --git a/libs/feature/editor/src/lib/fixtures/index.ts b/libs/common/fixtures/src/lib/editor/index.ts similarity index 100% rename from libs/feature/editor/src/lib/fixtures/index.ts rename to libs/common/fixtures/src/lib/editor/index.ts diff --git a/libs/feature/editor/src/index.ts b/libs/feature/editor/src/index.ts index c95afdefd4..5e6dd85211 100644 --- a/libs/feature/editor/src/index.ts +++ b/libs/feature/editor/src/index.ts @@ -9,4 +9,3 @@ export * from './lib/components/record-form/record-form.component' export * from './lib/components/wizard/wizard.component' export * from './lib/components/wizard-field/wizard-field.component' export * from './lib/components/wizard-summarize/wizard-summarize.component' -export * from './lib/fixtures' diff --git a/libs/feature/editor/src/lib/+state/editor.effects.spec.ts b/libs/feature/editor/src/lib/+state/editor.effects.spec.ts index 7ec73663fe..49bdb73887 100644 --- a/libs/feature/editor/src/lib/+state/editor.effects.spec.ts +++ b/libs/feature/editor/src/lib/+state/editor.effects.spec.ts @@ -26,7 +26,8 @@ const initialEditorState = { saveError: null, changedSinceSave: false, alreadySavedOnce: true, - fieldsConfig: [], + editorConfig: [], + currentPage: 0, } describe('EditorEffects', () => { diff --git a/libs/feature/editor/src/lib/+state/editor.selectors.spec.ts b/libs/feature/editor/src/lib/+state/editor.selectors.spec.ts index 1b94e59ca0..425aa0509c 100644 --- a/libs/feature/editor/src/lib/+state/editor.selectors.spec.ts +++ b/libs/feature/editor/src/lib/+state/editor.selectors.spec.ts @@ -1,7 +1,12 @@ -import { EditorPartialState, initialEditorState } from './editor.reducer' +import { + EDITOR_FEATURE_KEY, + EditorPartialState, + initialEditorState, +} from './editor.reducer' import * as EditorSelectors from './editor.selectors' import { DATASET_RECORDS } from '@geonetwork-ui/common/fixtures' import { DEFAULT_FIELDS } from '../fields.config' +import { EditorSectionWithValues } from '@geonetwork-ui/feature/editor' describe('Editor Selectors', () => { let state: EditorPartialState @@ -56,22 +61,27 @@ describe('Editor Selectors', () => { }) describe('selectRecordFields', () => { - it('should return the config and value for each field', () => { - const result = EditorSelectors.selectRecordSections(state) - - const actualSections = result.pages.map((page) => page.sections).flat() - - const expectedSections = DEFAULT_FIELDS.pages - .map((page) => page.sections) - .flat() - - expect(actualSections).toEqual(expectedSections) - - const actualFields = actualSections + it('should return the config and value for specified page', () => { + const recordSections = EditorSelectors.selectRecordSections(state) + + const expectedResult = DEFAULT_FIELDS.pages[0].sections.map( + (section) => ({ + ...section, + fieldsWithValues: section.fields.map((fieldConfig) => ({ + config: fieldConfig, + value: + state[EDITOR_FEATURE_KEY].record?.[fieldConfig.model] ?? null, + })), + }) + ) as EditorSectionWithValues[] + + expect(recordSections).toEqual(expectedResult) + + const actualFields = recordSections .map((section) => section.fields) .flat() - const expectedFields = expectedSections + const expectedFields = expectedResult .map((section) => section.fields) .flat() @@ -91,15 +101,17 @@ describe('Editor Selectors', () => { }, }) - const resultFields = result.pages - .flatMap((page) => page.sections) - .flatMap((section) => section.fields) + const resultFields = result.flatMap( + (section) => section.fieldsWithValues + ) const abstractField = resultFields.find( - (field) => field.model === 'abstract' + (field) => field.config.model === 'abstract' ) - const titleField = resultFields.find((field) => field.model === 'title') + const titleField = resultFields.find( + (field) => field.config.model === 'title' + ) expect(abstractField.value).toEqual('') expect(titleField.value).toEqual('') diff --git a/libs/feature/editor/tsconfig.json b/libs/feature/editor/tsconfig.json index 9e29358f76..5879bfb75c 100644 --- a/libs/feature/editor/tsconfig.json +++ b/libs/feature/editor/tsconfig.json @@ -16,8 +16,7 @@ "noImplicitReturns": true, "noFallthroughCasesInSwitch": true, "target": "es2020", - "lib": ["dom", "es2020", "dom.iterable"], - "downlevelIteration": true + "lib": ["dom", "es2020", "dom.iterable"] }, "angularCompilerOptions": { "strictInjectionParameters": true, diff --git a/libs/feature/editor/tsconfig.lib.json b/libs/feature/editor/tsconfig.lib.json index 2a4c9a5e36..02d129fa3b 100644 --- a/libs/feature/editor/tsconfig.lib.json +++ b/libs/feature/editor/tsconfig.lib.json @@ -7,8 +7,7 @@ "declarationMap": true, "inlineSources": true, "types": [], - "lib": ["dom", "es2020", "dom.iterable"], - "downlevelIteration": true + "lib": ["dom", "es2020", "dom.iterable"] }, "exclude": [ "src/test-setup.ts", diff --git a/tailwind.base.config.js b/tailwind.base.config.js index 6464667647..faea732f64 100644 --- a/tailwind.base.config.js +++ b/tailwind.base.config.js @@ -51,7 +51,6 @@ module.exports = { title: 'var(--font-family-title, ui-serif, Georgia, Cambria, "Times New Roman", Times, serif)', // alias for serif mono: 'ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace', - petrona: ['Petrona', 'serif'], }, fontSize: { 13: '13px',