Skip to content

Commit

Permalink
feat: warning in toolbar
Browse files Browse the repository at this point in the history
  • Loading branch information
cmoinier committed Dec 23, 2024
1 parent c4186a0 commit e795192
Show file tree
Hide file tree
Showing 5 changed files with 35 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -69,5 +69,7 @@
>
<ng-icon name="iconoirBadgeCheck"></ng-icon>
</gn-ui-button> -->
<md-editor-publish-button></md-editor-publish-button>
<md-editor-publish-button
[publishWarning]="publishWarning"
></md-editor-publish-button>
</div>
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { CommonModule } from '@angular/common'
import { ChangeDetectionStrategy, Component } from '@angular/core'
import { ChangeDetectionStrategy, Component, Input } from '@angular/core'
import { MatDialog, MatDialogModule } from '@angular/material/dialog'
import { MatTooltipModule } from '@angular/material/tooltip'
import { EditorFacade } from '@geonetwork-ui/feature/editor'
Expand Down Expand Up @@ -61,6 +61,7 @@ import {
changeDetection: ChangeDetectionStrategy.OnPush,
})
export class TopToolbarComponent {
@Input() publishWarning = []
protected SaveStatus = [
'draft_only', // => when creating a record
'record_up_to_date', // => when the record was just published (ie saved on the server)
Expand Down
21 changes: 21 additions & 0 deletions apps/metadata-editor/src/app/edit/edit-page.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,34 @@
</aside>
<div class="flex flex-col h-full w-full">
<div class="w-full h-auto shrink-0 relative">
<<<<<<< HEAD
<md-editor-top-toolbar></md-editor-top-toolbar>
<div class="absolute top-full left-0 w-2/3 z-50 pointer-events-none">
=======
<md-editor-top-toolbar
[publishWarning]="hasRecordChanged$ | async"
></md-editor-top-toolbar>
<div class="absolute top-full left-0 w-2/3 z-10 pointer-events-none">
>>>>>>> 4aeaddd7f (feat: warning in toolbar)
<gn-ui-notifications-container></gn-ui-notifications-container>
</div>
</div>
<div class="grow overflow-auto p-[32px]" #scrollContainer>
<div class="container-lg mx-auto flex flex-col gap-[32px]">
<div *ngIf="hasRecordChanged$ | async as hasChanged">
<div
*ngIf="hasChanged.length > 0"
class="p-4 border border-primary bg-primary-lightest rounded-lg text-center"
translate
[translateParams]="{
date: hasChanged[0],
user: hasChanged[1]
}"
data-test="draft-alert"
>
editor.record.form.draft.updateAlert
</div>
</div>
<md-editor-page-selector></md-editor-page-selector>
<gn-ui-record-form></gn-ui-record-form>
<div
Expand Down
9 changes: 8 additions & 1 deletion apps/metadata-editor/src/app/edit/edit-page.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ import {
import { ButtonComponent } from '@geonetwork-ui/ui/inputs'
import { TranslateModule, TranslateService } from '@ngx-translate/core'
import { combineLatest, filter, firstValueFrom, Subscription, take } from 'rxjs'
import { map } from 'rxjs/operators'
import { map, skip } from 'rxjs/operators'
import { SidebarComponent } from '../dashboard/sidebar/sidebar.component'
import { PageSelectorComponent } from './components/page-selector/page-selector.component'
import { TopToolbarComponent } from './components/top-toolbar/top-toolbar.component'
Expand Down Expand Up @@ -57,6 +57,7 @@ export class EditPageComponent implements OnInit, OnDestroy {
isLastPage$ = combineLatest([this.currentPage$, this.pagesLength$]).pipe(
map(([currentPage, pagesCount]) => currentPage >= pagesCount - 1)
)
hasRecordChanged$ = this.facade.hasRecordChanged$.pipe(skip(1))

@ViewChild('scrollContainer') scrollContainer: ElementRef<HTMLElement>

Expand Down Expand Up @@ -161,6 +162,12 @@ export class EditPageComponent implements OnInit, OnDestroy {
this.router.navigate(['edit', savedRecord.uniqueIdentifier])
})
)

this.subscription.add(
this.facade.record$.subscribe((record) => {
this.facade.hasRecordChangedSinceDraft(record)
})
)
}

ngOnDestroy() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ <h1 class="text-[16px] text-main font-bold" translate>
class="shadow-md shadow-gray-300 border-[1px] border-gray-200 overflow-hidden rounded bg-white grow mx-[32px] my-[16px] text-sm"
>
<gn-ui-results-table
[hasDraft]="hasDraft"
[records]="records$ | async"
[canDuplicate]="canDuplicate"
[isUnsavedDraft]="isUnsavedDraft"
Expand Down

0 comments on commit e795192

Please sign in to comment.