-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
10 changed files
with
196 additions
and
45 deletions.
There are no files selected for viewing
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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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
51 changes: 51 additions & 0 deletions
51
.../archive-preview/archive-unit-description-tab/archive-unit-description-tab.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,51 @@ | ||
<vitamui-common-archive-unit-viewer | ||
[ngStyle]="{ display: !editMode ? 'block' : 'none' }" | ||
[data]="archiveUnit" | ||
></vitamui-common-archive-unit-viewer> | ||
<div [ngStyle]="{ display: editMode ? 'block' : 'none' }"> | ||
<vitamui-common-editor-banner class="editor-banner"> | ||
<button (click)="onSave()" [disabled]="editObject?.control?.pristine" class="btn primary save"> | ||
{{ 'COMMON.SAVE' | translate }} | ||
</button> | ||
<button (click)="onCancel()" class="btn primary cancel"> | ||
{{ 'COMMON.UNDO' | translate }} | ||
</button> | ||
</vitamui-common-editor-banner> | ||
<vitamui-common-archive-unit-editor [data]="archiveUnit"></vitamui-common-archive-unit-editor> | ||
</div> | ||
|
||
<ng-template #updateDialog> | ||
<mat-dialog-content> | ||
<br /> | ||
<div class="text-title"> | ||
{{ 'UNIT_UPDATE.HINT' | translate }} | ||
</div> | ||
|
||
<div class="text large bold"> | ||
{{ 'UNIT_UPDATE.MESSAGE' | translate }} | ||
</div> | ||
</mat-dialog-content> | ||
<br /> | ||
<mat-dialog-actions> | ||
<button [matDialogClose]="true" class="btn primary btn-confirm-dialog margin-btn">{{ 'RULES.COMMON.CONFIRM' | translate }}</button> | ||
<button matDialogClose class="btn link cancel cancel-popup">{{ 'RULES.COMMON.UNDO' | translate }}</button> | ||
</mat-dialog-actions> | ||
</ng-template> | ||
|
||
<ng-template #cancelDialog> | ||
<mat-dialog-content> | ||
<br /> | ||
<div class="text-title"> | ||
{{ 'UNIT_UPDATE.CLOSE_WINDOW_HINT' | translate }} | ||
</div> | ||
|
||
<div class="text large bold"> | ||
{{ 'UNIT_UPDATE.CONFIRM_CLOSE' | translate }} | ||
</div> | ||
</mat-dialog-content> | ||
<br /> | ||
<mat-dialog-actions> | ||
<button [matDialogClose]="true" class="btn primary btn-confirm-dialog margin-btn">{{ 'COMMON.CLOSE' | translate }}</button> | ||
<button matDialogClose class="btn link cancel cancel-popup">{{ 'COMMON.UNDO' | translate }}</button> | ||
</mat-dialog-actions> | ||
</ng-template> |
21 changes: 21 additions & 0 deletions
21
.../archive-preview/archive-unit-description-tab/archive-unit-description-tab.component.scss
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,21 @@ | ||
button { | ||
&.save { | ||
background-color: white; | ||
color: var(--vitamui-primary); | ||
} | ||
|
||
&.cancel { | ||
background-color: transparent; | ||
color: white; | ||
box-shadow: none; | ||
border: none; | ||
} | ||
} | ||
|
||
.editor-banner { | ||
margin-left: -40px; | ||
margin-right: -40px; | ||
position: sticky; | ||
z-index: 10; | ||
top: -20px; | ||
} |
111 changes: 111 additions & 0 deletions
111
...ve/archive-preview/archive-unit-description-tab/archive-unit-description-tab.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,111 @@ | ||
import { AfterViewInit, Component, EventEmitter, Input, OnDestroy, OnInit, Output, TemplateRef, ViewChild } from '@angular/core'; | ||
import { MatDialog, MatDialogConfig } from '@angular/material/dialog'; | ||
import { MatSnackBar, MatSnackBarConfig } from '@angular/material/snack-bar'; | ||
import { ActivatedRoute } from '@angular/router'; | ||
import { TranslateService } from '@ngx-translate/core'; | ||
import { Subscription } from 'rxjs'; | ||
import { filter, switchMap } from 'rxjs/operators'; | ||
import { ArchiveUnit, ArchiveUnitEditorComponent, Logger, StartupService } from 'ui-frontend-common'; | ||
import { EditObject } from 'ui-frontend-common/app/modules/object-editor/models/edit-object.model'; | ||
import { VitamUISnackBarComponent } from '../../shared/vitamui-snack-bar'; | ||
|
||
@Component({ | ||
selector: 'app-archive-unit-description-tab', | ||
templateUrl: './archive-unit-description-tab.component.html', | ||
styleUrls: ['./archive-unit-description-tab.component.scss'], | ||
}) | ||
export class ArchiveUnitDescriptionTabComponent implements OnInit, AfterViewInit, OnDestroy { | ||
@Input() archiveUnit: ArchiveUnit; | ||
@Input() editMode = false; | ||
@Output() editModeChange = new EventEmitter<boolean>(); | ||
|
||
@ViewChild('updateDialog') updateDialog: TemplateRef<ArchiveUnitDescriptionTabComponent>; | ||
@ViewChild('cancelDialog') cancelDialog: TemplateRef<ArchiveUnitDescriptionTabComponent>; | ||
@ViewChild(ArchiveUnitEditorComponent) archiveUnitEditor!: ArchiveUnitEditorComponent; | ||
|
||
editObject: EditObject; | ||
tenantId: number; | ||
|
||
private readonly subscriptions = new Subscription(); | ||
private readonly dialogConfig: MatDialogConfig = { panelClass: 'vitamui-dialog' }; | ||
private readonly snackBarConfig: MatSnackBarConfig = { | ||
panelClass: 'vitamui-snack-bar', | ||
data: { | ||
type: 'WorkflowSuccessSnackBar', | ||
}, | ||
duration: 100000, | ||
}; | ||
|
||
constructor( | ||
private logger: Logger, | ||
private dialog: MatDialog, | ||
private snackBar: MatSnackBar, | ||
private startupService: StartupService, | ||
private translateService: TranslateService, | ||
private route: ActivatedRoute, | ||
) {} | ||
|
||
ngOnInit(): void { | ||
this.subscriptions.add( | ||
this.route.params.subscribe((params) => { | ||
this.tenantId = params.tenantIdentifier; | ||
}), | ||
); | ||
} | ||
|
||
ngAfterViewInit(): void { | ||
this.subscriptions.add( | ||
this.archiveUnitEditor.editObject$.subscribe((editObject) => { | ||
this.editObject = editObject; | ||
}), | ||
); | ||
} | ||
|
||
ngOnDestroy(): void { | ||
this.subscriptions.unsubscribe(); | ||
} | ||
|
||
onCancel(): void { | ||
this.subscriptions.add( | ||
this.dialog | ||
.open(this.cancelDialog, this.dialogConfig) | ||
.afterClosed() | ||
.pipe(filter((result) => !!result)) | ||
.subscribe(() => { | ||
this.archiveUnit = { ...this.archiveUnit }; | ||
this.editMode = false; | ||
this.editModeChange.emit(this.editMode); | ||
}), | ||
); | ||
} | ||
|
||
onSave(): void { | ||
this.subscriptions.add( | ||
this.dialog | ||
.open(this.updateDialog, this.dialogConfig) | ||
.afterClosed() | ||
.pipe( | ||
filter((result) => !!result), | ||
switchMap(() => this.archiveUnitEditor.update()), | ||
) | ||
.subscribe(({ operationId }) => { | ||
if (!operationId) return this.logger.error(this, 'Operation id is mandatory to build logbook operation link'); | ||
if (!this.tenantId) return this.logger.error(this, 'Tenant id is mandatory to build logbook operation link'); | ||
|
||
const serviceUrl = `${this.startupService.getReferentialUrl()}/logbook-operation/tenant/${this.tenantId}?guid=${operationId}`; | ||
const translationKey = 'RULES.EXECUTE_RULE_UPDATE_MESSAGE'; | ||
const message = this.translateService.instant(translationKey); | ||
|
||
this.snackBar.openFromComponent(VitamUISnackBarComponent, { | ||
...this.snackBarConfig, | ||
data: { | ||
...this.snackBarConfig.data, | ||
message, | ||
serviceUrl, | ||
}, | ||
}); | ||
this.editObject.control.markAsPristine(); | ||
}), | ||
); | ||
} | ||
} |
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