From 33c16ff13c935558f8030c8af02ecd75b1b8b98e Mon Sep 17 00:00:00 2001 From: Nicoleta Panaghiu Date: Wed, 6 Mar 2024 13:16:21 +0200 Subject: [PATCH] RED-8649: made in-place editing for the primary attribute responsive. --- .../file-attribute.component.html | 14 ++++++++--- .../file-attribute.component.scss | 23 ++++++++++++----- .../file-attribute.component.ts | 18 ++++++++++++- .../file-name-column.component.html | 25 ++++++++++--------- .../file-name-column.component.ts | 24 +++++++++++++++++- 5 files changed, 81 insertions(+), 23 deletions(-) diff --git a/apps/red-ui/src/app/modules/dossier-overview/components/file-attribute/file-attribute.component.html b/apps/red-ui/src/app/modules/dossier-overview/components/file-attribute/file-attribute.component.html index 76e0fc659..8f6faa354 100644 --- a/apps/red-ui/src/app/modules/dossier-overview/components/file-attribute/file-attribute.component.html +++ b/apps/red-ui/src/app/modules/dossier-overview/components/file-attribute/file-attribute.component.html @@ -5,7 +5,7 @@ [ngClass]="{ 'workflow-attribute': mode === 'workflow', 'file-name-column': fileNameColumn }" class="file-attribute" > -
+
{{ fileAttribute.label }}: @@ -55,6 +55,8 @@
- +
diff --git a/apps/red-ui/src/app/modules/dossier-overview/components/file-attribute/file-attribute.component.scss b/apps/red-ui/src/app/modules/dossier-overview/components/file-attribute/file-attribute.component.scss index a30efe876..445e41f21 100644 --- a/apps/red-ui/src/app/modules/dossier-overview/components/file-attribute/file-attribute.component.scss +++ b/apps/red-ui/src/app/modules/dossier-overview/components/file-attribute/file-attribute.component.scss @@ -6,7 +6,7 @@ &.file-name-column { height: 20px; - width: fit-content; + width: 100%; border-radius: 4px; font-size: 11px; line-height: 14px; @@ -81,6 +81,18 @@ &.file-name-column-input { background: transparent; + border: none; + box-shadow: none; + + form { + iqser-circle-button { + margin-left: 15px; + + @media screen and (max-width: 1395px) { + margin-left: 6px; + } + } + } } &.workflow-edit-input { @@ -99,10 +111,6 @@ iqser-circle-button { margin: 0 5px; - &:nth-child(2) { - padding-left: 10px; - } - &:last-child { margin-right: -8px; } @@ -118,7 +126,6 @@ margin-top: 0; } - .file-name-input, .workflow-input { width: 100%; padding-left: 2px; @@ -143,6 +150,10 @@ } } + .file-name-input { + padding-left: 5px; + } + .save { margin-left: 7px; } diff --git a/apps/red-ui/src/app/modules/dossier-overview/components/file-attribute/file-attribute.component.ts b/apps/red-ui/src/app/modules/dossier-overview/components/file-attribute/file-attribute.component.ts index 4aae239d4..20f1034bd 100644 --- a/apps/red-ui/src/app/modules/dossier-overview/components/file-attribute/file-attribute.component.ts +++ b/apps/red-ui/src/app/modules/dossier-overview/components/file-attribute/file-attribute.component.ts @@ -1,4 +1,4 @@ -import { Component, computed, effect, HostListener, Input, OnDestroy } from '@angular/core'; +import { ChangeDetectionStrategy, Component, computed, effect, HostListener, Input, OnDestroy } from '@angular/core'; import { Dossier, File, FileAttributeConfigTypes, IFileAttributeConfig } from '@red/domain'; import { BaseFormComponent, @@ -43,6 +43,7 @@ import { TranslateModule } from '@ngx-translate/core'; NgTemplateOutlet, TranslateModule, ], + changeDetection: ChangeDetectionStrategy.OnPush, }) export class FileAttributeComponent extends BaseFormComponent implements OnDestroy { isInEditMode = false; @@ -62,6 +63,12 @@ export class FileAttributeComponent extends BaseFormComponent implements OnDestr this.file.fileId !== this.fileAttributesService.fileEdit())) || !this.fileAttributesService.openAttributeEdits().length, ); + @Input() width?: number; + #widthFactor = window.innerWidth >= 1800 ? 0.85 : 0.7; + + get editFieldWidth(): string { + return this.width ? `${this.width * this.#widthFactor}px` : 'unset'; + } get isDate(): boolean { return this.fileAttribute.type === FileAttributeConfigTypes.DATE; @@ -110,6 +117,15 @@ export class FileAttributeComponent extends BaseFormComponent implements OnDestr ); } + @HostListener('window:resize') + onResize() { + if (window.innerWidth >= 1800) { + this.#widthFactor = 0.85; + } else { + this.#widthFactor = 0.7; + } + } + @Debounce(60) @HostListener('document:click', ['$event']) clickOutside($event: MouseEvent) { diff --git a/apps/red-ui/src/app/modules/shared/components/file-name-column/file-name-column.component.html b/apps/red-ui/src/app/modules/shared/components/file-name-column/file-name-column.component.html index 3d84cb5d8..df427a42a 100644 --- a/apps/red-ui/src/app/modules/shared/components/file-name-column/file-name-column.component.html +++ b/apps/red-ui/src/app/modules/shared/components/file-name-column/file-name-column.component.html @@ -1,17 +1,17 @@ - -
-
- {{ file.filename }} -
+
+
+ {{ file.filename }}
+
+
@@ -26,6 +26,7 @@ [dossier]="dossier" [fileAttribute]="ctx.primaryAttribute" [fileNameColumn]="true" + [width]="width" >
diff --git a/apps/red-ui/src/app/modules/shared/components/file-name-column/file-name-column.component.ts b/apps/red-ui/src/app/modules/shared/components/file-name-column/file-name-column.component.ts index 7e193eae0..1bc56cb18 100644 --- a/apps/red-ui/src/app/modules/shared/components/file-name-column/file-name-column.component.ts +++ b/apps/red-ui/src/app/modules/shared/components/file-name-column/file-name-column.component.ts @@ -1,4 +1,14 @@ -import { ChangeDetectionStrategy, Component, Input, OnChanges, OnInit, SimpleChanges } from '@angular/core'; +import { + ChangeDetectionStrategy, + ChangeDetectorRef, + Component, + ElementRef, + Input, + OnChanges, + OnInit, + SimpleChanges, + ViewChild, +} from '@angular/core'; import { PrimaryFileAttributeService } from '@services/primary-file-attribute.service'; import { Dossier, File, IFileAttributeConfig, TrashFile } from '@red/domain'; import { FileAttributesService } from '@services/entity-services/file-attributes.service'; @@ -18,15 +28,18 @@ interface FileNameColumnContext { }) export class FileNameColumnComponent extends ContextComponent implements OnInit, OnChanges { readonly #reloadAttribute = new ReplaySubject(1); + @ViewChild('filenameColumn', { static: true }) filenameColumn: ElementRef; @Input() file?: File | TrashFile; @Input() dossier: Dossier; @Input() dossierTemplateId: string; ocrByDefault: boolean; + width: number; constructor( private readonly _fileAttributeService: FileAttributesService, private readonly _primaryFileAttributeService: PrimaryFileAttributeService, private readonly _dossierTemplateService: DossierTemplatesService, + private readonly _changeDetectorRef: ChangeDetectorRef, ) { super(); } @@ -37,6 +50,10 @@ export class FileNameColumnComponent extends ContextComponent this.#findPrimaryAttribute()), ); super._initContext({ primaryAttribute: primaryAttribute$ }); + const _observer = new ResizeObserver((entries: ResizeObserverEntry[]) => { + this.#updateItemWidth(entries[0]); + }); + _observer.observe(this.filenameColumn.nativeElement); } ngOnChanges(changes: SimpleChanges): void { @@ -57,4 +74,9 @@ export class FileNameColumnComponent extends ContextComponent a.primaryAttribute); } + + #updateItemWidth(resizeObserverEntry: ResizeObserverEntry) { + this.width = resizeObserverEntry.contentRect.width; + this._changeDetectorRef.markForCheck(); + } }