Skip to content
Snippets Groups Projects
Commit dece40f8 authored by rhenck's avatar rhenck
Browse files

[editor] Fix ID handling in Table elements

parent ae17387a
No related branches found
No related tags found
No related merge requests found
...@@ -66,8 +66,8 @@ import { PositionedUIElement, UIElementType } from 'common/interfaces'; ...@@ -66,8 +66,8 @@ import { PositionedUIElement, UIElementType } from 'common/interfaces';
<ng-container *ngIf="editorMode"> <ng-container *ngIf="editorMode">
{{$any($any(elementGrid[i][j]).constructor).title}} {{$any($any(elementGrid[i][j]).constructor).title}}
</ng-container> </ng-container>
<ng-container *ngIf="editorMode && $any(elementGrid[i][j]).id !== 'id-placeholder'"> <ng-container *ngIf="editorMode && $any(elementGrid[i][j]).alias !== 'alias-placeholder'">
- {{$any(elementGrid[i][j]).id}} - {{$any(elementGrid[i][j]).alias}}
</ng-container> </ng-container>
</div> </div>
<aspect-table-child-overlay [element]="$any(elementGrid[i][j])" <aspect-table-child-overlay [element]="$any(elementGrid[i][j])"
......
...@@ -76,8 +76,12 @@ export class TableElement extends CompoundElement implements TableProperties { ...@@ -76,8 +76,12 @@ export class TableElement extends CompoundElement implements TableProperties {
} }
setProperty(property: string, value: UIElementValue): void { setProperty(property: string, value: UIElementValue): void {
// Don't preserve original array, so Component gets updated if (property === 'gridColumnSizes' || property === 'gridRowSizes') {
this[property] = value; // Don't preserve original array, so Component gets updated
this[property] = value as { value: number; unit: string }[];
} else {
super.setProperty(property, value);
}
} }
getElementComponent(): Type<ElementComponent> { getElementComponent(): Type<ElementComponent> {
......
...@@ -11,6 +11,7 @@ import { AudioProperties } from 'common/models/elements/media-elements/audio'; ...@@ -11,6 +11,7 @@ import { AudioProperties } from 'common/models/elements/media-elements/audio';
import { ImageProperties } from 'common/models/elements/media-elements/image'; import { ImageProperties } from 'common/models/elements/media-elements/image';
import { DropListProperties } from 'common/models/elements/input-elements/drop-list'; import { DropListProperties } from 'common/models/elements/input-elements/drop-list';
import { UIElementProperties, UIElementType } from 'common/interfaces'; import { UIElementProperties, UIElementType } from 'common/interfaces';
import { IDService } from 'editor/src/app/services/id.service';
@Component({ @Component({
selector: 'aspect-editor-table-edit-dialog', selector: 'aspect-editor-table-edit-dialog',
...@@ -46,8 +47,8 @@ export class TableEditDialogComponent { ...@@ -46,8 +47,8 @@ export class TableEditDialogComponent {
@ViewChild(TableComponent) tableComp!: TableComponent; @ViewChild(TableComponent) tableComp!: TableComponent;
newTable: TableElement; newTable: TableElement;
constructor(@Inject(MAT_DIALOG_DATA) public data: { table: TableElement }) { constructor(@Inject(MAT_DIALOG_DATA) public data: { table: TableElement }, private idService: IDService) {
this.newTable = new TableElement(data.table); this.newTable = data.table;
} }
async addElement(el: { elementType: UIElementType, row: number, col: number }): Promise<void> { async addElement(el: { elementType: UIElementType, row: number, col: number }): Promise<void> {
...@@ -80,7 +81,7 @@ export class TableEditDialogComponent { ...@@ -80,7 +81,7 @@ export class TableEditDialogComponent {
const newEle = ElementFactory.createElement({ const newEle = ElementFactory.createElement({
type: el.elementType, type: el.elementType,
...extraProps ...extraProps
}); }, this.idService);
delete newEle.position; delete newEle.position;
delete newEle.dimensions; delete newEle.dimensions;
newEle.gridRow = el.row + 1; newEle.gridRow = el.row + 1;
...@@ -95,6 +96,7 @@ export class TableEditDialogComponent { ...@@ -95,6 +96,7 @@ export class TableEditDialogComponent {
removeElement(coords: { row: number, col: number }): void { removeElement(coords: { row: number, col: number }): void {
const index = this.newTable.elements const index = this.newTable.elements
.findIndex(el => el.gridRow === (coords.row + 1) && el.gridColumn === (coords.col + 1)); .findIndex(el => el.gridRow === (coords.row + 1) && el.gridColumn === (coords.col + 1));
this.newTable.elements[index].unregisterIDs();
this.newTable.elements.splice(index, 1); this.newTable.elements.splice(index, 1);
} }
} }
...@@ -330,9 +330,6 @@ export class ElementService { ...@@ -330,9 +330,6 @@ export class ElementService {
this.dialogService.showTableEditDialog(element as TableElement) this.dialogService.showTableEditDialog(element as TableElement)
.subscribe((result: UIElement[]) => { .subscribe((result: UIElement[]) => {
if (result) { if (result) {
result.forEach(el => {
if (el.id === 'id-placeholder') Object.assign(el, this.idService.getAndRegisterNewIDs(el.type));
});
this.updateElementsProperty([element], 'elements', result); this.updateElementsProperty([element], 'elements', result);
} }
}); });
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment