|
|
@@ -33,6 +33,7 @@ export type PreviewPreset = 'tiny' | 'thumb' | 'small' | 'medium' | 'large' | ''
|
|
|
})
|
|
|
export class AssetPreviewComponent implements OnInit, OnDestroy {
|
|
|
@Input() asset: AssetLike;
|
|
|
+ @Input() assets?: AssetLike[];
|
|
|
@Input() editable = false;
|
|
|
@Input() customFields: CustomFieldConfig[] = [];
|
|
|
@Input() customFieldsForm: UntypedFormGroup | undefined;
|
|
|
@@ -50,6 +51,10 @@ export class AssetPreviewComponent implements OnInit, OnDestroy {
|
|
|
centered = true;
|
|
|
settingFocalPoint = false;
|
|
|
lastFocalPoint?: Point;
|
|
|
+ previewAssetIndex = 0;
|
|
|
+ disableNextButton = false;
|
|
|
+ disablePreviousButton = false;
|
|
|
+ showSlideButtons = false;
|
|
|
@ViewChild('imageElement', { static: true }) private imageElementRef: ElementRef<HTMLImageElement>;
|
|
|
@ViewChild('previewDiv', { static: true }) private previewDivRef: ElementRef<HTMLDivElement>;
|
|
|
private subscription: Subscription;
|
|
|
@@ -61,7 +66,7 @@ export class AssetPreviewComponent implements OnInit, OnDestroy {
|
|
|
private notificationService: NotificationService,
|
|
|
private changeDetector: ChangeDetectorRef,
|
|
|
private modalService: ModalService,
|
|
|
- ) {}
|
|
|
+ ) { }
|
|
|
|
|
|
get fpx(): number | null {
|
|
|
return this.asset.focalPoint ? this.asset.focalPoint.x : null;
|
|
|
@@ -73,6 +78,14 @@ export class AssetPreviewComponent implements OnInit, OnDestroy {
|
|
|
|
|
|
ngOnInit() {
|
|
|
const { focalPoint } = this.asset;
|
|
|
+ if (this.assets?.length) {
|
|
|
+ this.showSlideButtons = true;
|
|
|
+ this.previewAssetIndex = this.assets.findIndex(asset => asset.id === this.asset.id) || 0;
|
|
|
+ } else {
|
|
|
+ this.showSlideButtons = false;
|
|
|
+ this.updateButtonAccessibility();
|
|
|
+ }
|
|
|
+ this.updateButtonAccessibility();
|
|
|
this.form.get('name')?.setValue(this.asset.name);
|
|
|
this.form.get('tags')?.setValue(this.asset.tags?.map(t => t.value));
|
|
|
this.subscription = this.form.valueChanges.subscribe(value => {
|
|
|
@@ -206,4 +219,26 @@ export class AssetPreviewComponent implements OnInit, OnDestroy {
|
|
|
}
|
|
|
});
|
|
|
}
|
|
|
+
|
|
|
+ nextImage() {
|
|
|
+ this.previewAssetIndex = this.previewAssetIndex + 1;
|
|
|
+ if (Array.isArray(this.assets)) {
|
|
|
+ this.asset = this.assets[this.previewAssetIndex];
|
|
|
+ this.updateButtonAccessibility();
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ previousImage() {
|
|
|
+ this.previewAssetIndex = this.previewAssetIndex - 1;
|
|
|
+ if (Array.isArray(this.assets)) {
|
|
|
+ this.asset = this.assets[this.previewAssetIndex];
|
|
|
+ this.updateButtonAccessibility();
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ updateButtonAccessibility() {
|
|
|
+ this.disableNextButton = this.assets?.[this.previewAssetIndex + 1]?.id ? false : true;
|
|
|
+ this.disablePreviousButton = this.assets?.[this.previewAssetIndex - 1]?.id ? false : true;
|
|
|
+ }
|
|
|
+
|
|
|
}
|