mirror of
https://github.com/janishutz/libreevent.git
synced 2025-11-25 05:14:23 +00:00
finished cart management
This commit is contained in:
@@ -105,6 +105,9 @@ export default {
|
||||
}
|
||||
},
|
||||
created () {
|
||||
window.addEventListener( 'visibilitychange', ( e ) => {
|
||||
this.cart = localStorage.getItem( 'cart' ) ? JSON.parse( localStorage.getItem( 'cart' ) ): {};
|
||||
}, 1 );
|
||||
this.cart = localStorage.getItem( 'cart' ) ? JSON.parse( localStorage.getItem( 'cart' ) ): {};
|
||||
// this.loadTickets();
|
||||
}
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
<div class="message-container">
|
||||
<div v-if="contentType === 'string'" class="options">
|
||||
<h3>{{ data.message }}</h3>
|
||||
<div style="width: 100%; margin-top: 3%;">
|
||||
<div class="button-wrapper">
|
||||
<button @click="closePopup( 'ok' )" title="Close popup">Ok</button>
|
||||
</div>
|
||||
</div>
|
||||
@@ -14,14 +14,14 @@
|
||||
<div v-else-if="contentType === 'settings'" class="options">
|
||||
<h3>{{ data.message }}</h3>
|
||||
<settings v-model:settings="data.options"></settings>
|
||||
<div style="width: 100%; margin-top: 3%;">
|
||||
<div class="button-wrapper">
|
||||
<button @click="closePopup( 'ok' )" title="Save changes">Save</button>
|
||||
<button @click="closePopup( 'cancel' )" title="Cancel changes">Cancel</button>
|
||||
</div>
|
||||
</div>
|
||||
<div v-else-if="contentType === 'confirm'" class="confirm options">
|
||||
<h3>{{ data.message }}</h3>
|
||||
<div style="width: 100%; margin-top: 3%;">
|
||||
<div class="button-wrapper">
|
||||
<button @click="closePopup( 'ok' )" title="Confirm operation">Ok</button>
|
||||
<button @click="closePopup( 'cancel' )" title="Cancel operation">Cancel</button>
|
||||
</div>
|
||||
@@ -31,7 +31,7 @@
|
||||
<select id="select" v-model="data.selected">
|
||||
<option v-for="selectOption in data.options" :value="selectOption.value">{{ selectOption.displayName }}</option>
|
||||
</select>
|
||||
<div style="width: 100%; margin-top: 3%;">
|
||||
<div class="button-wrapper">
|
||||
<button @click="closePopup( 'ok' )" title="Save changes">Save</button>
|
||||
<button @click="closePopup( 'cancel' )" title="Cancel changes">Cancel</button>
|
||||
</div>
|
||||
@@ -59,7 +59,7 @@
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
<div style="width: 100%; margin-top: 3%;">
|
||||
<div class="button-wrapper">
|
||||
<button @click="submitTicket()" title="Save changes">Save</button>
|
||||
<button @click="closePopup( 'cancel' )" title="Cancel changes">Cancel</button>
|
||||
</div>
|
||||
@@ -151,6 +151,15 @@
|
||||
flex-direction: column;
|
||||
}
|
||||
|
||||
.button-wrapper {
|
||||
width: 100%;
|
||||
margin-top: 3%;
|
||||
display: flex;
|
||||
justify-content: center;
|
||||
align-items: center;
|
||||
flex-direction: row;
|
||||
}
|
||||
|
||||
.close-wrapper {
|
||||
width: 100%;
|
||||
height: 5%;
|
||||
|
||||
@@ -115,6 +115,13 @@
|
||||
}
|
||||
};
|
||||
|
||||
this.seatPlanInit();
|
||||
|
||||
window.addEventListener( 'visibilitychange', ( e ) => {
|
||||
this.seatPlanInit();
|
||||
}, 1 );
|
||||
},
|
||||
seatPlanInit () {
|
||||
// Load cart
|
||||
this.cart = localStorage.getItem( 'cart' ) ? JSON.parse( localStorage.getItem( 'cart' ) ): {};
|
||||
|
||||
@@ -314,13 +321,19 @@
|
||||
const d = this.draggables[ id ];
|
||||
const evG = this.event.ageGroups;
|
||||
let count = {};
|
||||
if ( this.cart[ this.event.name ] ) {
|
||||
for ( let ageGroup in evG ) {
|
||||
if ( this.cart[ 'ticket' + id + '_' + ageGroup ] ) {
|
||||
count[ ageGroup ] = this.cart[ 'ticket' + id + '_' + ageGroup ].count;
|
||||
if ( this.cart[ this.event.name ][ 'tickets' ][ 'ticket' + id + '_' + ageGroup ] ) {
|
||||
count[ ageGroup ] = this.cart[ this.event.name ][ 'tickets' ][ 'ticket' + id + '_' + ageGroup ].count;
|
||||
} else {
|
||||
count[ ageGroup ] = 0;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
for ( let ageGroup in evG ) {
|
||||
count[ ageGroup ] = 0;
|
||||
}
|
||||
}
|
||||
this.$refs.popups.openPopup( 'Select tickets', {
|
||||
'id': id,
|
||||
'max': d.ticketCount,
|
||||
@@ -332,7 +345,26 @@
|
||||
}, 'tickets' );
|
||||
},
|
||||
standingTicketHandling ( data ) {
|
||||
console.log( data );
|
||||
if ( !this.cart[ this.event.name ] ) {
|
||||
this.cart[ this.event.name ] = { 'displayName': this.event.name, 'tickets': {} };
|
||||
}
|
||||
|
||||
for ( let group in data.data ) {
|
||||
if ( !this.cart[ this.event.name ][ 'tickets' ][ 'ticket' + data.component + '_' + group ] ) {
|
||||
if ( data.data[ group ] > 0 ) {
|
||||
this.cart[ this.event.name ][ 'tickets' ][ 'ticket' + data.component + '_' + group ] = { 'displayName': 'Ticket ' + data.component + ' (' + this.event.ageGroups[ group ].name + ')', 'price': this.event.categories[ this.draggables[ data.component ].category ].price[ group ], 'id': 'ticket' + data.component + '_' + group, 'count': data.data[ group ], 'comp': data.component };
|
||||
} else {
|
||||
delete this.cart[ this.event.name ][ 'tickets' ][ 'ticket' + data.component + '_' + group ];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ( Object.keys( this.cart[ this.event.name ][ 'tickets' ] ).length < 1 ) {
|
||||
delete this.cart[ this.event.name ];
|
||||
}
|
||||
|
||||
this.$refs.cart.calculateTotal();
|
||||
localStorage.setItem( 'cart', JSON.stringify( this.cart ) );
|
||||
}
|
||||
},
|
||||
created () {
|
||||
|
||||
@@ -130,6 +130,10 @@
|
||||
},
|
||||
},
|
||||
created () {
|
||||
window.addEventListener( 'visibilitychange', ( e ) => {
|
||||
this.cart = localStorage.getItem( 'cart' ) ? JSON.parse( localStorage.getItem( 'cart' ) ): {};
|
||||
this.calculateTotal();
|
||||
}, 1 );
|
||||
this.cart = localStorage.getItem( 'cart' ) ? JSON.parse( localStorage.getItem( 'cart' ) ): {};
|
||||
this.calculateTotal();
|
||||
}
|
||||
|
||||
@@ -42,9 +42,9 @@
|
||||
this.$router.push( '/tickets' );
|
||||
}
|
||||
this.eventID = sessionStorage.getItem( 'selectedTicket' );
|
||||
// if ( this.eventID == 'test' ) {
|
||||
// this.hasSeatplan = false;
|
||||
// }
|
||||
if ( this.eventID == 'test2' ) {
|
||||
this.hasSeatplan = false;
|
||||
}
|
||||
}
|
||||
};
|
||||
</script>
|
||||
|
||||
@@ -58,7 +58,7 @@
|
||||
res.json().then( json => {
|
||||
if ( json.status === 'ok' ) {
|
||||
this.userStore.setUserAuth( true );
|
||||
this.$router.push( sessionStorage.getItem( 'redirect' ) ? sessionStorage.getItem( 'redirect' ) : '/account' );
|
||||
this.$router.push( sessionStorage.getItem( 'redirect' ) ?? '/account' );
|
||||
sessionStorage.removeItem( 'redirect' );
|
||||
} else if ( json.status === '2fa' ) {
|
||||
this.userStore.setUser2fa( true );
|
||||
|
||||
@@ -5,8 +5,8 @@
|
||||
<div class="code-container" v-if="code[ 1 ] != ''">
|
||||
<p>Open the link in the email and enter this code:</p>
|
||||
<div class="code">
|
||||
<div class="code-sub" id="code-part1">{{ code[1] }}</div>
|
||||
<div class="code-sub" id="code-part2">{{ code[2] }}</div>
|
||||
<div class="code-sub" id="code-part1">{{ code[ 1 ] }}</div>
|
||||
<div class="code-sub" id="code-part2">{{ code[ 2 ] }}</div>
|
||||
</div>
|
||||
</div>
|
||||
<notifications ref="notification" location="bottomright" size="bigger"></notifications>
|
||||
@@ -42,8 +42,7 @@
|
||||
source.onmessage = ( e ) => {
|
||||
if ( e.data === 'authenticated' ) {
|
||||
self.userStore.setUserAuth( true );
|
||||
self.$router.push( '/account' );
|
||||
console.log( e.data );
|
||||
self.$router.push( sessionStorage.getItem( 'redirect' ) ?? '/account' );
|
||||
}
|
||||
}
|
||||
|
||||
@@ -52,11 +51,10 @@
|
||||
self.$refs.notification.cancelNotification( startNotification );
|
||||
};
|
||||
|
||||
source.addEventListener( 'error', function(e) {
|
||||
if (e.eventPhase == EventSource.CLOSED) source.close();
|
||||
source.addEventListener( 'error', function( e ) {
|
||||
if ( e.eventPhase == EventSource.CLOSED ) source.close();
|
||||
|
||||
if (e.target.readyState == EventSource.CLOSED) {
|
||||
console.log( e );
|
||||
if ( e.target.readyState == EventSource.CLOSED ) {
|
||||
self.$refs.notification.cancelNotification( startNotification );
|
||||
self.$refs.notification.createNotification( 'Could not connect to status service', 5, 'error', 'normal' );
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user