fix bug in seat plan loading

This commit is contained in:
2023-07-23 19:41:32 +02:00
parent 4aa4602f69
commit 5e5e7fee49
6 changed files with 32 additions and 11 deletions

View File

@@ -145,6 +145,9 @@ export default {
}, },
startingRow() { startingRow() {
this.calculateChairs(); this.calculateChairs();
},
data () {
this.calculateChairs();
} }
}, },
created() { created() {

View File

@@ -137,6 +137,9 @@ export default {
}, },
origin() { origin() {
this.calculateChairs(); this.calculateChairs();
},
data () {
this.calculateChairs();
} }
}, },
created() { created() {

View File

@@ -148,6 +148,10 @@ export default {
}, },
startingRow() { startingRow() {
this.calculateChairs(); this.calculateChairs();
},
data () {
console.log( 'data changed' );
this.calculateChairs();
} }
}, },
created() { created() {

View File

@@ -116,16 +116,11 @@
}; };
this.seatPlanInit(); this.seatPlanInit();
window.addEventListener( 'visibilitychange', ( e ) => {
this.seatPlanInit();
}, 1 );
}, },
seatPlanInit () { seatPlanInit () {
// Load cart // Load cart
this.cart = localStorage.getItem( 'cart' ) ? JSON.parse( localStorage.getItem( 'cart' ) ): {}; this.cart = localStorage.getItem( 'cart' ) ? JSON.parse( localStorage.getItem( 'cart' ) ): {};
// Load seatplan from server // Load seatplan from server
let height = $( document ).height() * 0.8; let height = $( document ).height() * 0.8;
this.scaleFactor = ( height / 900 ) * this.zoomFactor; this.scaleFactor = ( height / 900 ) * this.zoomFactor;
@@ -133,15 +128,17 @@
if ( res.status === 200 ) { if ( res.status === 200 ) {
res.json().then( data => { res.json().then( data => {
this.draggables = this.scaleUp( data.data ); this.draggables = this.scaleUp( data.data );
sessionStorage.setItem( 'seatplan', JSON.stringify( data.data ) ); this.prepSeatplan();
} ); } );
} else if ( res.status === 500 ) { } else if ( res.status === 500 ) {
if ( sessionStorage.getItem( 'seatplan' ) ) { if ( sessionStorage.getItem( 'seatplan' ) ) {
this.draggables = this.scaleUp( JSON.parse( sessionStorage.getItem( 'seatplan' ) ) ); this.draggables = this.scaleUp( JSON.parse( sessionStorage.getItem( 'seatplan' ) ) );
this.prepSeatplan();
} }
} }
} ); } );
},
prepSeatplan () {
// Mark all selected seats + all unavailable seats // 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 } } } } // { '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 = {}; let categoryDetails = {};
@@ -177,6 +174,10 @@
// TODO: Optimise for odd screen sizes and aspect ratios and fucking webkit // TODO: Optimise for odd screen sizes and aspect ratios and fucking webkit
sessionStorage.setItem( 'seatplan', JSON.stringify( this.scaleDown( this.draggables ) ) ); sessionStorage.setItem( 'seatplan', JSON.stringify( this.scaleDown( this.draggables ) ) );
window.addEventListener( 'visibilitychange', ( e ) => {
this.seatPlanInit();
}, 1 );
}, },
eventHandler ( e ) { eventHandler ( e ) {
if ( this.prevSize.h != window.innerHeight || this.prevSize.w != window.innerWidth ) { if ( this.prevSize.h != window.innerHeight || this.prevSize.w != window.innerWidth ) {
@@ -248,6 +249,16 @@
if ( sessionStorage.getItem( 'seatplan' ) ) { if ( sessionStorage.getItem( 'seatplan' ) ) {
this.draggables = this.scaleUp( JSON.parse( 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 ) { scaleUp ( valueArray ) {
const allowedAttributes = [ 'w', 'h', 'x', 'y' ]; const allowedAttributes = [ 'w', 'h', 'x', 'y' ];

View File

@@ -36,7 +36,7 @@
<span class="material-symbols-outlined empty-cart">remove_shopping_cart</span> <span class="material-symbols-outlined empty-cart">remove_shopping_cart</span>
</div> </div>
</div> </div>
<popups ref="popups" size="normal" @data="data => { verifyTicketDelete( data.status ) }"></popups> <popups ref="popups" size="small" @data="data => { verifyTicketDelete( data.status ) }"></popups>
</div> </div>
</template> </template>

View File

@@ -42,9 +42,9 @@
this.$router.push( '/tickets' ); this.$router.push( '/tickets' );
} }
this.eventID = sessionStorage.getItem( 'selectedTicket' ); this.eventID = sessionStorage.getItem( 'selectedTicket' );
if ( this.eventID == 'test2' ) { // if ( this.eventID == 'test2' ) {
this.hasSeatplan = false; // this.hasSeatplan = false;
} // }
} }
}; };
</script> </script>