From 5e5e7fee49e4d79bc122029e87cb649df9530bd9 Mon Sep 17 00:00:00 2001 From: Janis Hutz Date: Sun, 23 Jul 2023 19:41:32 +0200 Subject: [PATCH] fix bug in seat plan loading --- .../seatplanComponents/seats/circular.vue | 3 +++ .../seatplanComponents/seats/rectangular.vue | 3 +++ .../seatplanComponents/seats/trapezoid.vue | 4 +++ .../seatplan/userApp/userWindow.vue | 25 +++++++++++++------ .../main/src/views/purchasing/CartView.vue | 2 +- .../views/purchasing/TicketsOrderingView.vue | 6 ++--- 6 files changed, 32 insertions(+), 11 deletions(-) diff --git a/src/webapp/main/src/components/seatplan/userApp/seatplanComponents/seats/circular.vue b/src/webapp/main/src/components/seatplan/userApp/seatplanComponents/seats/circular.vue index bc783f8..7e442c9 100644 --- a/src/webapp/main/src/components/seatplan/userApp/seatplanComponents/seats/circular.vue +++ b/src/webapp/main/src/components/seatplan/userApp/seatplanComponents/seats/circular.vue @@ -145,6 +145,9 @@ export default { }, startingRow() { this.calculateChairs(); + }, + data () { + this.calculateChairs(); } }, created() { diff --git a/src/webapp/main/src/components/seatplan/userApp/seatplanComponents/seats/rectangular.vue b/src/webapp/main/src/components/seatplan/userApp/seatplanComponents/seats/rectangular.vue index 69ccb27..d6e6d50 100644 --- a/src/webapp/main/src/components/seatplan/userApp/seatplanComponents/seats/rectangular.vue +++ b/src/webapp/main/src/components/seatplan/userApp/seatplanComponents/seats/rectangular.vue @@ -137,6 +137,9 @@ export default { }, origin() { this.calculateChairs(); + }, + data () { + this.calculateChairs(); } }, created() { diff --git a/src/webapp/main/src/components/seatplan/userApp/seatplanComponents/seats/trapezoid.vue b/src/webapp/main/src/components/seatplan/userApp/seatplanComponents/seats/trapezoid.vue index 8f2bda6..02a642f 100644 --- a/src/webapp/main/src/components/seatplan/userApp/seatplanComponents/seats/trapezoid.vue +++ b/src/webapp/main/src/components/seatplan/userApp/seatplanComponents/seats/trapezoid.vue @@ -148,6 +148,10 @@ export default { }, startingRow() { this.calculateChairs(); + }, + data () { + console.log( 'data changed' ); + this.calculateChairs(); } }, created() { diff --git a/src/webapp/main/src/components/seatplan/userApp/userWindow.vue b/src/webapp/main/src/components/seatplan/userApp/userWindow.vue index b550f73..4327637 100644 --- a/src/webapp/main/src/components/seatplan/userApp/userWindow.vue +++ b/src/webapp/main/src/components/seatplan/userApp/userWindow.vue @@ -116,16 +116,11 @@ }; this.seatPlanInit(); - - window.addEventListener( 'visibilitychange', ( e ) => { - this.seatPlanInit(); - }, 1 ); }, seatPlanInit () { // Load cart this.cart = localStorage.getItem( 'cart' ) ? JSON.parse( localStorage.getItem( 'cart' ) ): {}; - // Load seatplan from server let height = $( document ).height() * 0.8; this.scaleFactor = ( height / 900 ) * this.zoomFactor; @@ -133,15 +128,17 @@ if ( res.status === 200 ) { res.json().then( data => { this.draggables = this.scaleUp( data.data ); - sessionStorage.setItem( 'seatplan', JSON.stringify( data.data ) ); + this.prepSeatplan(); } ); } else if ( res.status === 500 ) { if ( sessionStorage.getItem( 'seatplan' ) ) { this.draggables = this.scaleUp( JSON.parse( sessionStorage.getItem( 'seatplan' ) ) ); + this.prepSeatplan(); } } } ); - + }, + prepSeatplan () { // Mark all selected seats + all unavailable seats // { 'sector': 'A', 'sectorCount': 1, 'unavailableSeats': { 'secAr0s0': 'nav' }, 'categoryInfo': { 'pricing': { '1': { 'displayName': 'Adults - CHF 20.-', 'value': 'adult', 'price': 20 }, '2': { 'displayName': 'Child (0 - 15.99y) - CHF 15.-', 'value': 'child', 'price': 15 } } } } let categoryDetails = {}; @@ -177,6 +174,10 @@ // TODO: Optimise for odd screen sizes and aspect ratios and fucking webkit sessionStorage.setItem( 'seatplan', JSON.stringify( this.scaleDown( this.draggables ) ) ); + + window.addEventListener( 'visibilitychange', ( e ) => { + this.seatPlanInit(); + }, 1 ); }, eventHandler ( e ) { if ( this.prevSize.h != window.innerHeight || this.prevSize.w != window.innerWidth ) { @@ -248,6 +249,16 @@ if ( sessionStorage.getItem( 'seatplan' ) ) { this.draggables = this.scaleUp( JSON.parse( sessionStorage.getItem( 'seatplan' ) ) ); } + + if ( this.cart[ this.event.name ] ) { + let tickets = this.cart[ this.event.name ][ 'tickets' ]; + for ( let ticket in tickets ) { + this.draggables[ tickets[ ticket ].comp ][ 'data' ][ 'unavailableSeats' ][ ticket ] = 'sel'; + } + } + + console.log( this.draggables ); + console.log( 'load' ); }, scaleUp ( valueArray ) { const allowedAttributes = [ 'w', 'h', 'x', 'y' ]; diff --git a/src/webapp/main/src/views/purchasing/CartView.vue b/src/webapp/main/src/views/purchasing/CartView.vue index fafe56e..f0d5a5f 100644 --- a/src/webapp/main/src/views/purchasing/CartView.vue +++ b/src/webapp/main/src/views/purchasing/CartView.vue @@ -36,7 +36,7 @@ remove_shopping_cart - + diff --git a/src/webapp/main/src/views/purchasing/TicketsOrderingView.vue b/src/webapp/main/src/views/purchasing/TicketsOrderingView.vue index 7159464..c3107fa 100644 --- a/src/webapp/main/src/views/purchasing/TicketsOrderingView.vue +++ b/src/webapp/main/src/views/purchasing/TicketsOrderingView.vue @@ -42,9 +42,9 @@ this.$router.push( '/tickets' ); } this.eventID = sessionStorage.getItem( 'selectedTicket' ); - if ( this.eventID == 'test2' ) { - this.hasSeatplan = false; - } + // if ( this.eventID == 'test2' ) { + // this.hasSeatplan = false; + // } } };