Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature create ticket types #81

Merged
merged 11 commits into from
Dec 18, 2019
2 changes: 1 addition & 1 deletion src/lancie-admin-content.html
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
<lancie-admin-orders data-route="orders" data-path="lancie-admin-endpoint/lancie-admin-pages/lancie-admin-orders.html"></lancie-admin-orders>
<lancie-admin-tickets data-route="tickets" data-path="lancie-admin-endpoint/lancie-admin-pages/lancie-admin-tickets.html"></lancie-admin-tickets>
<lancie-admin-teams data-route="teams" data-path="lancie-admin-endpoint/lancie-admin-pages/lancie-admin-teams.html"></lancie-admin-teams>
<lancie-admin-types data-route="types" data-path="lancie-admin-endpoint/lancie-admin-pages/lancie-admin-types.html"></lancie-admin-types>
<lancie-admin-types data-route="types" data-path="lancie-admin-endpoint/lancie-admin-pages/lancie-admin-types/lancie-admin-types.html"></lancie-admin-types>
<lancie-admin-seats data-route="seats" data-path="lancie-admin-endpoint/lancie-admin-pages/lancie-admin-seats.html"></lancie-admin-seats>
<lancie-admin-homepage-text data-route="text" data-path="lancie-admin-endpoint/lancie-admin-pages/lancie-admin-homepage-text.html"></lancie-admin-homepage-text>
<lancie-admin-mail data-route="mail" data-path="lancie-admin-endpoint/lancie-admin-pages/lancie-admin-mail/lancie-admin-mail.html"></lancie-admin-mail>
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
<link rel="import" href="../../../../bower_components/polymer/polymer.html">
<link rel="import" href="../../../../bower_components/iron-flex-layout/iron-flex-layout-classes.html">
<link rel="import" href="../../../../bower_components/iron-icon/iron-icon.html">

<dom-module id="lancie-admin-ticket-option">
<template>
<style>
:host {
display: block;
}

iron-icon {
margin-right: 10px;
}

.delete-button {
cursor: pointer;
}

.align-right {
text-align: right;
}

.flex-horizontal-with-ratios {
@apply (--layout-horizontal);
}

.flexchild {
@apply (--layout-flex);
}

.flex2child {
@apply (--layout-flex-4);
}

.flex3child {
@apply (--layout-flex-9);
}
</style>

<paper-item class="container flex-horizontal-with-ratios">
<div class="flex2child">[[option.name]]</div>
<div class="flexchild">Price: [[option.price]]</div>
<div class="flexchild align-right">
<iron-icon icon="icons:delete" on-tap="deleteTicketOptionDialog" class="delete-button"></iron-icon>
</div>
</paper-item>

</template>
<script>
(function() {
'use strict';

class LancieAdminTicketOption extends Polymer.Element {
static get is() {
return 'lancie-admin-ticket-option';
}

static get properties() {
return {
option: Object
}
}

deleteTicketOptionDialog() {
this.dispatchEvent(new CustomEvent('delete-ticket-option-dialog', {
detail: {
id: this.option.id
},
bubbles: true,
composed: true
}));
}
}

customElements.define(LancieAdminTicketOption.is, LancieAdminTicketOption);
})();
</script>
</dom-module>
Original file line number Diff line number Diff line change
@@ -0,0 +1,164 @@
<link rel="import" href="../../../../bower_components/polymer/polymer.html">
<link rel="import" href="../../../../bower_components/lancie-ajax/lancie-ajax.html">
<link rel="import" href="../../../../bower_components/lancie-form/lancie-form.html">
<link rel="import" href="../../../../bower_components/lancie-dialog/lancie-dialog.html">
<link rel="import" href="../../../../bower_components/lancie-error/lancie-error.html">
<link rel="import" href="../../../../bower_components/paper-dropdown-menu/paper-dropdown-menu.html">
<link rel="import" href="../../../../bower_components/neon-animation/web-animations.html">
<link rel="import" href="../../../../bower_components/paper-listbox/paper-listbox.html">
<link rel="import" href="../../../../bower_components/paper-item/paper-item.html">

<link rel="import" href="../../lancie-admin-page-layout.html">
<link rel="import" href="../../../lancie-admin-table/lancie-admin-table.html">

<link rel="import" href="lancie-admin-ticket-option.html">

<dom-module id="lancie-admin-ticket-options">
<template>
<style include="iron-flex iron-flex-alignment"></style>
<style>
:host {
display: block;
}

paper-card {
width: calc(100% - 32px);
margin: 16px;
}

[hidden] {
display: none !important;
}

@media (max-width: 640px) {
paper-card {
width: 100%;
margin: 0;
}
}
</style>

<lancie-ajax auto-fire id="getOptionAjax" refurl="tickets/options" on-lancie-ajax="onOptionResponse"></lancie-ajax>

<lancie-ajax id="ajaxDeleteTicketOption" method="DELETE" refurl="tickets/options/[[deleteOption.id]]" on-lancie-ajax="onDeleteResponse"></lancie-ajax>

<paper-card heading="Ticket Options">
<div class="card-content" on-delete-ticket-option-dialog="deleteTicketOptionDialog">
<lancie-error id="optionError"></lancie-error>
<template is="dom-repeat" items="{{options}}">
bramvankooten marked this conversation as resolved.
Show resolved Hide resolved
<lancie-admin-ticket-option option="[[item]]"></lancie-admin-ticket-option>
</template>
</div>
<div class="card-actions">
<paper-button on-tap="openAddOptionDialog">Add Ticket Option</paper-button>
</div>
</paper-card>
<lancie-dialog id="addTicketOptionDialog">
<h2>Add Ticket Option</h2>
<div class="dialog-content">
<lancie-error id="addDialogError"></lancie-error>
<lancie-form id="addTicketOptionForm" refurl="tickets/options" on-response="onAddOptionResponse">
<paper-input label="Name" name="name" auto-validate required error-message="This field is required!"></paper-input>
<paper-input label="Price" name="price" step=".01" type="number" auto-validate required error-message="This field is required!"></paper-input>
bramvankooten marked this conversation as resolved.
Show resolved Hide resolved
</lancie-form>
</div>
<div class="dialog-actions">
<paper-button on-tap="tryAddOption">Add</paper-button>
</div>
</lancie-dialog>

<lancie-dialog id="deleteTicketOptionDialog">
<h2>Confirm deletion</h2>
<div class="dialog-content">
<lancie-error id="dialogError"></lancie-error>
<h4>Are you certain you want to delete this ticket option?</h4>
<p>[[deleteOption.name]]</p>
</div>
<div class="dialog-actions">
<paper-button dialog-dismiss>Cancel</paper-button>
<paper-button on-tap="tryOptionDelete" class="confirm-delete-button">Delete</paper-button>
bramvankooten marked this conversation as resolved.
Show resolved Hide resolved
</div>
</lancie-dialog>
</template>
<script>
(function () {
'use strict';

Polymer({
is: 'lancie-admin-ticket-options',
properties: {
data: Object,
mappings: {
type: Object,
value: function() {
return {
};
}
},
renderers: {
type: Object,
value: function() {
return {
possibleOptions: function(data) {
var text = data.reduce(function(text, t){
bramvankooten marked this conversation as resolved.
Show resolved Hide resolved
return text + t.name + ' ' + t.price +', ';
bramvankooten marked this conversation as resolved.
Show resolved Hide resolved
}, '');
return text.substr(0, text.length - 2);
},
};
}
}
},

tryAddOption: function(e, request) {
this.$.addTicketOptionForm.validateAndSubmit();
bramvankooten marked this conversation as resolved.
Show resolved Hide resolved
this.$.addTicketOptionForm.reset();
},

openAddOptionDialog: function() {
this.$.addTicketOptionForm.reset();
this.$.addTicketOptionDialog.open();
},

onAddOptionResponse: function(e, request) {
if (request.succeeded) {
this.$.addTicketOptionDialog.close();
this.$.getOptionAjax.generateRequest();
} else {
this.$.addDialogError.setError("Could not add option. Please refresh and try again.")
}
bramvankooten marked this conversation as resolved.
Show resolved Hide resolved
},

deleteTicketOptionDialog: function(event) {
this.deleteOption = this.options.filter(option => {
bramvankooten marked this conversation as resolved.
Show resolved Hide resolved
return option.id === event.detail.id;
})[0];
this.$.deleteTicketOptionDialog.open();
},

tryOptionDelete: function() {
this.$.ajaxDeleteTicketOption.generateRequest();
},

onOptionDeleteResponse: function(e, request) {
bramvankooten marked this conversation as resolved.
Show resolved Hide resolved
if (request.succeeded) {
this.$.deleteCommitteeMemberDialog.close();
this.$.getOptionAjax.generateRequest(); // Ensures we have a mirror of the latest server state
} else {
this.$.dialogError.setError('Something went wrong! Please refresh and try again.')
}
},

onOptionResponse: function(e, request) {
martijnjanssen marked this conversation as resolved.
Show resolved Hide resolved
if (request.succeeded) {
this.fire('set-options', {'options': request.response})
this.options = request.response;
} else {
this.$.optionError.setError('Could not retrieve options. Please refresh and try again.')
}
}

});
})();
</script>
</dom-module>
Loading