RED-8342 - editable input for structured component value
This commit is contained in:
parent
54312abb6c
commit
962458fbf9
@ -35,8 +35,8 @@
|
||||
[placeholder]="placeholder"
|
||||
[id]="id"
|
||||
name="name"
|
||||
[style.width]="this.textArea.width + 'px'"
|
||||
[style.height]="this.textArea.height + 'px'"
|
||||
[style.width]="this.parentDimensions?.width + 'px'"
|
||||
[style.height]="this.parentDimensions?.height + 'px'"
|
||||
></textarea>
|
||||
</ng-template>
|
||||
</div>
|
||||
|
||||
@ -26,7 +26,7 @@ export class EditableInputComponent implements OnChanges {
|
||||
@Input() helpModeKey: string = '';
|
||||
@Input() lastChild = false;
|
||||
@Output() readonly save = new EventEmitter<string>();
|
||||
textArea?: { width: number; height: number };
|
||||
parentDimensions?: { width: number; height: number };
|
||||
newValue = '';
|
||||
|
||||
private _editing = false;
|
||||
@ -45,23 +45,10 @@ export class EditableInputComponent implements OnChanges {
|
||||
if (changes['value']) {
|
||||
this.editing = false;
|
||||
}
|
||||
if (changes['parentId']?.currentValue) {
|
||||
this.setTextAreaSize();
|
||||
}
|
||||
}
|
||||
|
||||
setTextAreaSize() {
|
||||
setTimeout(() => {
|
||||
const element = document.getElementById(this.id as string) as HTMLElement;
|
||||
const parentElement = document.getElementById(this.parentId as string) as HTMLElement;
|
||||
const width = parentElement.offsetWidth - 98;
|
||||
let height = (this.lastChild ? parentElement.offsetHeight : element.offsetHeight) - 16;
|
||||
if (this.lastChild) {
|
||||
const lastChildIndex = Number(this.id?.split('-')[2]);
|
||||
height = height - lastChildIndex * element.offsetHeight;
|
||||
}
|
||||
this.textArea = { width, height };
|
||||
}, 50);
|
||||
const parent = document.getElementById(this.parentId as string) as HTMLElement;
|
||||
this.parentDimensions = { width: parent.offsetWidth - 98, height: parent.offsetHeight - 16 };
|
||||
}, 20);
|
||||
}
|
||||
|
||||
saveValue(): void {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user