From 84567f14d40bb2878db0e90afd90975a4ec94113 Mon Sep 17 00:00:00 2001 From: Janis Hutz Date: Sat, 27 May 2023 10:18:05 +0200 Subject: [PATCH] add origin mod to properties & fix bugs --- .../components/seatplan/editor/properties.vue | 12 +++++++++++- .../src/components/seatplan/editor/window.vue | 17 ++++++++++------- 2 files changed, 21 insertions(+), 8 deletions(-) diff --git a/src/webapp/src/components/seatplan/editor/properties.vue b/src/webapp/src/components/seatplan/editor/properties.vue index 2019458..822a948 100644 --- a/src/webapp/src/components/seatplan/editor/properties.vue +++ b/src/webapp/src/components/seatplan/editor/properties.vue @@ -31,6 +31,11 @@
{{ posSize.h }}px
+ + Origin: +
{{ posSize.origin }}
+ + @@ -41,7 +46,7 @@ export default { props: { posSize: { type: Object, - "default": { 'x': 100, 'y': 100, 'w': 200, 'h': 100 } + "default": { 'x': 100, 'y': 100, 'w': 200, 'h': 100, 'origin': 1 } }, scaleFactor: { type: Number, @@ -66,6 +71,11 @@ export default { this.isEditing[ option ] = false; this.$emit( 'updated', this.internal ) } + }, + watch: { + posSize() { + console.log( 'posSize changed' ); + } } } diff --git a/src/webapp/src/components/seatplan/editor/window.vue b/src/webapp/src/components/seatplan/editor/window.vue index dbd9ada..7364133 100644 --- a/src/webapp/src/components/seatplan/editor/window.vue +++ b/src/webapp/src/components/seatplan/editor/window.vue @@ -15,7 +15,7 @@ - + @@ -46,7 +46,7 @@ data() { return { active: 0, - draggables: { 1: { 'x': 100, 'y':100, 'h': 100, 'w': 250, 'active': false, 'draggable': true, 'resizable': true, 'id': 1 } }, + draggables: { 1: { 'x': 100, 'y':100, 'h': 100, 'w': 250, 'active': false, 'draggable': true, 'resizable': true, 'id': 1, 'origin': 1, 'categories': { 1: 0 } } }, available: { 'redo': false, 'undo': false }, selectedObject: {}, scaleFactor: 1, @@ -150,7 +150,7 @@ returnArray[ entry ] = {}; for ( let attributes in valueArray[ entry ] ) { if ( allowedAttributes.includes( attributes ) ) { - returnArray[ entry ][ attributes ] = valueArray[ entry ][ attributes ] / this.scaleFactor; + returnArray[ entry ][ attributes ] = Math.round( valueArray[ entry ][ attributes ] / this.scaleFactor ); } else { returnArray[ entry ][ attributes ] = valueArray[ entry ][ attributes ]; } @@ -165,7 +165,7 @@ returnArray[ entry ] = {}; for ( let attributes in valueArray[ entry ] ) { if ( allowedAttributes.includes( attributes ) ) { - returnArray[ entry ][ attributes ] = valueArray[ entry ][ attributes ] * this.scaleFactor; + returnArray[ entry ][ attributes ] = Math.round( valueArray[ entry ][ attributes ] * this.scaleFactor ); } else { returnArray[ entry ][ attributes ] = valueArray[ entry ][ attributes ]; } @@ -174,6 +174,7 @@ return returnArray; }, activateComponent ( id ) { + console.log( id ); this.active = id; this.selectedObject = this.draggables[ this.active ]; }, @@ -227,7 +228,7 @@ sessionStorage.setItem( 'seatplan', JSON.stringify( this.scaleDown( this.draggables ) ) ); }, addNewElement () { - this.draggables[ Object.keys( this.draggables ).length + 1 ] = { 'x': 100, 'y':100, 'h': 100, 'w': 250, 'active': false, 'draggable': true, 'resizable': true, 'id': Object.keys( this.draggables ).length + 1 }; + this.draggables[ Object.keys( this.draggables ).length + 1 ] = { 'x': 100, 'y':100, 'h': 100, 'w': 250, 'active': false, 'draggable': true, 'resizable': true, 'id': Object.keys( this.draggables ).length + 1, 'origin': 1, 'categories': { 1: 0 } }; this.saveHistory(); }, deleteSelected () { @@ -240,6 +241,7 @@ handleUpdate ( value ) { this.draggables[ this.active ] = value; this.selectedObject = value; + this.saveHistory(); } }, created () { @@ -255,8 +257,9 @@