-
Notifications
You must be signed in to change notification settings - Fork 32
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #938 from geonetwork/me-organize-fields-into-pages…
…-and-sections EDITOR - Organize fields into pages and sections
- Loading branch information
Showing
47 changed files
with
1,020 additions
and
266 deletions.
There are no files selected for viewing
Empty file.
43 changes: 43 additions & 0 deletions
43
apps/metadata-editor/src/app/edit/components/page-selector/page-selector.component.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
<div class="w-full flex flex-row p-8 items-center gap-6"> | ||
<ng-container | ||
*ngFor="let page of pages$ | async; let index = index; let isLast = last" | ||
> | ||
<div class="flex flex-row items-center gap-4"> | ||
<div class="flex flex-row items-center gap-4 hover:cursor-pointer"> | ||
<gn-ui-button | ||
(buttonClick)="pageSectionClickHandler(index)" | ||
class="flex flex-row items-center" | ||
[type]=" | ||
(facade.currentPage$ | async) === index ? 'primary' : 'default' | ||
" | ||
extraClass="bg-transparent border-none" | ||
> | ||
<div | ||
class="w-10 h-10 rounded-[8px] pt-3 text-center" | ||
[ngClass]=" | ||
(facade.currentPage$ | async) === index | ||
? 'bg-primary font-bold' | ||
: 'bg-gray-200' | ||
" | ||
> | ||
{{ index + 1 }} | ||
</div> | ||
<div | ||
class="ms-4" | ||
[ngClass]=" | ||
(facade.currentPage$ | async) === index | ||
? 'text-center text-black font-bold' | ||
: 'text-gray-400' | ||
" | ||
translate | ||
> | ||
{{ page.labelKey }} | ||
</div> | ||
</gn-ui-button> | ||
</div> | ||
<div *ngIf="!isLast" class="w-10"> | ||
<hr class="border-t-[2px]" /> | ||
</div> | ||
</div> | ||
</ng-container> | ||
</div> |
67 changes: 67 additions & 0 deletions
67
apps/metadata-editor/src/app/edit/components/page-selector/page-selector.component.spec.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
import { ComponentFixture, TestBed } from '@angular/core/testing' | ||
import { TranslateModule } from '@ngx-translate/core' | ||
import { PageSelectorComponent } from './page-selector.component' | ||
import { EDITOR_CONFIG } from '@geonetwork-ui/common/fixtures' | ||
import { BehaviorSubject } from 'rxjs' | ||
import { EditorFacade } from '@geonetwork-ui/feature/editor' | ||
import { By } from '@angular/platform-browser' | ||
|
||
class EditorFacadeMock { | ||
editorConfig$ = new BehaviorSubject(EDITOR_CONFIG()) | ||
currentPage$ = new BehaviorSubject(0) | ||
setCurrentPage = jest.fn() | ||
} | ||
|
||
describe('PageSelectorComponent', () => { | ||
let component: PageSelectorComponent | ||
let fixture: ComponentFixture<PageSelectorComponent> | ||
let facade: EditorFacadeMock | ||
|
||
beforeEach(async () => { | ||
await TestBed.configureTestingModule({ | ||
imports: [TranslateModule.forRoot(), PageSelectorComponent], | ||
providers: [ | ||
{ | ||
provide: EditorFacade, | ||
useClass: EditorFacadeMock, | ||
}, | ||
], | ||
}).compileComponents() | ||
|
||
fixture = TestBed.createComponent(PageSelectorComponent) | ||
component = fixture.componentInstance | ||
facade = TestBed.inject(EditorFacade) as unknown as EditorFacadeMock | ||
fixture.detectChanges() | ||
}) | ||
|
||
it('should create', () => { | ||
expect(component).toBeTruthy() | ||
}) | ||
|
||
it('should render the correct number of pages', () => { | ||
const pages = fixture.debugElement.queryAll(By.css('.w-10.h-10')) | ||
expect(pages.length).toBe(EDITOR_CONFIG().pages.length) | ||
}) | ||
|
||
it('should highlight the current page', () => { | ||
const currentPageIndex = facade.currentPage$.getValue() | ||
const currentPageElement = fixture.debugElement.queryAll( | ||
By.css('.w-10.h-10') | ||
)[currentPageIndex] | ||
expect(currentPageElement.nativeElement.classList).toContain('bg-primary') | ||
}) | ||
|
||
it('should call pageSectionClickHandler with the correct index', () => { | ||
jest.spyOn(component, 'pageSectionClickHandler') | ||
const button = fixture.debugElement.queryAll(By.css('gn-ui-button'))[1] | ||
button.triggerEventHandler('buttonClick', null) | ||
fixture.detectChanges() | ||
expect(component.pageSectionClickHandler).toHaveBeenCalledWith(1) | ||
}) | ||
|
||
it('should call facade.setCurrentPage with the correct index', () => { | ||
const index = 1 | ||
component.pageSectionClickHandler(index) | ||
expect(facade.setCurrentPage).toHaveBeenCalledWith(index) | ||
}) | ||
}) |
24 changes: 24 additions & 0 deletions
24
apps/metadata-editor/src/app/edit/components/page-selector/page-selector.component.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
import { ChangeDetectionStrategy, Component } from '@angular/core' | ||
import { CommonModule } from '@angular/common' | ||
import { ButtonComponent } from '@geonetwork-ui/ui/inputs' | ||
import { TranslateModule } from '@ngx-translate/core' | ||
import { EditorFacade } from '@geonetwork-ui/feature/editor' | ||
import { map } from 'rxjs/operators' | ||
|
||
@Component({ | ||
selector: 'md-editor-page-selector', | ||
standalone: true, | ||
imports: [CommonModule, ButtonComponent, TranslateModule], | ||
templateUrl: './page-selector.component.html', | ||
styleUrls: ['./page-selector.component.css'], | ||
changeDetection: ChangeDetectionStrategy.OnPush, | ||
}) | ||
export class PageSelectorComponent { | ||
pages$ = this.facade.editorConfig$.pipe(map((config) => config.pages)) | ||
|
||
constructor(public facade: EditorFacade) {} | ||
|
||
pageSectionClickHandler(index: number) { | ||
this.facade.setCurrentPage(index) | ||
} | ||
} |
2 changes: 1 addition & 1 deletion
2
apps/metadata-editor/src/app/edit/components/top-toolbar/top-toolbar.component.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
19 changes: 19 additions & 0 deletions
19
apps/metadata-editor/src/app/edit/edit-page.component.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,30 @@ | ||
<div class="flex flex-col h-full"> | ||
<div class="w-full h-auto shrink-0"> | ||
<md-editor-top-toolbar></md-editor-top-toolbar> | ||
<md-editor-page-selector></md-editor-page-selector> | ||
</div> | ||
<div class="grow overflow-auto relative"> | ||
<div class="absolute top-0 left-0 w-2/3 z-10 pointer-events-none"> | ||
<gn-ui-notifications-container></gn-ui-notifications-container> | ||
</div> | ||
<gn-ui-record-form></gn-ui-record-form> | ||
</div> | ||
<div class="p-8 mt-auto flex flex-row justify-between"> | ||
<gn-ui-button | ||
type="secondary" | ||
(buttonClick)="previousPageButtonHandler()" | ||
translate | ||
> | ||
{{ | ||
(currentPage$ | async) === 0 | ||
? ('editor.record.form.bottomButtons.comeBackLater' | translate) | ||
: ('editor.record.form.bottomButtons.previous' | translate) | ||
}} | ||
</gn-ui-button> | ||
<gn-ui-button type="primary" (buttonClick)="nextPageButtonHandler()" | ||
><span translate | ||
>editor.record.form.bottomButtons.next</span | ||
></gn-ui-button | ||
> | ||
</div> | ||
</div> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.