Skip to content

Commit

Permalink
#66 - sort categories by status
Browse files Browse the repository at this point in the history
  • Loading branch information
cbellone committed Aug 6, 2015
1 parent 77c1b97 commit c862190
Show file tree
Hide file tree
Showing 3 changed files with 80 additions and 74 deletions.
4 changes: 3 additions & 1 deletion src/main/java/alfio/controller/EventController.java
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
import alfio.model.Event;
import alfio.model.PromoCodeDiscount;
import alfio.model.SpecialPrice;
import alfio.model.TicketCategory;
import alfio.model.modification.TicketReservationWithOptionalCodeModification;
import alfio.model.modification.support.LocationDescriptor;
import alfio.model.system.Configuration;
Expand Down Expand Up @@ -197,7 +198,8 @@ public String showEvent(@PathVariable("eventName") String eventName,
final EventDescriptor eventDescriptor = new EventDescriptor(event);
model.addAttribute("event", eventDescriptor)//
.addAttribute("organizer", organizationRepository.getById(event.getOrganizationId()))
.addAttribute("ticketCategories", ticketCategories)//
.addAttribute("ticketCategories", ticketCategories.stream().filter(tc -> !tc.getExpired()).collect(Collectors.toList()))//
.addAttribute("expiredCategories", ticketCategories.stream().filter(SaleableTicketCategory::getExpired).collect(Collectors.toList()))//
.addAttribute("hasAccessPromotions", hasAccessPromotions)
.addAttribute("promoCode", specialCode.map(SpecialPrice::getCode).orElse(null))
.addAttribute("locationDescriptor", ld)
Expand Down
78 changes: 5 additions & 73 deletions src/main/webapp/WEB-INF/templates/event/show-event.ms
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@

<hr/>

<div class="row">
<div class="row wMarginBottom">
<div class="col-xs-12 event-description">
{{event.description}}
</div>
Expand Down Expand Up @@ -114,79 +114,11 @@
<form method="post" action="{{request.contextPath}}/event/{{event.shortName}}/reserve-tickets" class="form-horizontal">
<ul class="list-group">
{{#ticketCategories}}
<li class="list-group-item {{#expired}}text-muted{{/expired}} ticket-category-restricted-{{accessRestricted}}">
<div class="form-group">
<div class="col-sm-7" id="{{id}}-label">
<label class="control-label">{{name}}</label>
{{^expired}}
<div>
{{#saleInFuture}}
{{#i18n}}show-event.sales-not-started{{/i18n}}
{{/saleInFuture}}
{{^saleInFuture}}
{{#i18n}}show-event.sales-end [{{#format-date}}{{zonedExpiration}} dd.MM.yyyy HH:mm locale:{{#i18n}}locale{{/i18n}}{{/format-date}}]{{/i18n}}
{{/saleInFuture}}
</div>
{{/expired}}
{{#expired}}
<div>
{{#i18n}}show-event.sales-ended [{{#format-date}}{{zonedExpiration}} dd.MM.yyyy HH:mm locale:{{#i18n}}locale{{/i18n}}{{/format-date}}]{{/i18n}}
</div>
{{/expired}}
<div>
{{description}}
</div>
</div>
<div class="col-sm-3">
<label class="control-label">
{{#free}}
{{#i18n}}common.free{{/i18n}}
{{/free}}
{{^free}}
{{#expired}}
{{finalPrice}} {{event.currency}}
{{/expired}}
{{^expired}}
{{#hasPromoCodeDiscount}}
<del>{{finalPrice}}</del>
<mark>{{discountedPrice}}</mark>
{{event.currency}}
{{/hasPromoCodeDiscount}}
{{^hasPromoCodeDiscount}}
{{finalPrice}} {{event.currency}}
{{/hasPromoCodeDiscount}}
<i class="fa fa-info-circle text-info tooltip-handler" title="{{#event.vatIncluded}}{{#i18n}}show-event.incVat [{{event.vat}}]{{/i18n}}{{/event.vatIncluded}}{{^event.vatIncluded}}{{#i18n}}show-event.excVat [{{event.vat}}]{{/i18n}}{{/event.vatIncluded}}"></i>
{{/expired}}
{{/free}}
</label>
</div>
<div class="col-sm-2 text-align-center">
{{#saleable}}
<input name="reservation[{{-index}}].ticketCategoryId" value="{{id}}" type="hidden">
<select aria-labelledby="{{id}}-label" name="reservation[{{-index}}].amount" class="form-control text-align-center" placeholder="0" autocomplete="off">
{{#accessRestricted}}
<option value="0">0</option>
<option value="1">1</option>
{{/accessRestricted}}
{{^accessRestricted}}
{{#amountOfTickets}}<option value="{{this}}">{{this}}</option>{{/amountOfTickets}}
{{/accessRestricted}}
</select>
{{/saleable}}
{{^saleable}}
<label class="control-label">
{{#soldOut}}
{{#i18n}}show-event.sold-out{{/i18n}}
{{/soldOut}}
{{^soldOut}}
{{#i18n}}show-event.not-available{{/i18n}}
{{/soldOut}}
</label>
{{/saleable}}
</div>
</div>
</li>
{{> /event/ticket-category.ms }}
{{/ticketCategories}}
{{#expiredCategories}}
{{> /event/ticket-category.ms }}
{{/expiredCategories}}
</ul>

{{#hasPromoCodeDiscount}}
Expand Down
72 changes: 72 additions & 0 deletions src/main/webapp/WEB-INF/templates/event/ticket-category.ms
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
<li class="list-group-item {{#expired}}text-muted expired{{/expired}} ticket-category-restricted-{{accessRestricted}}">
<div class="form-group">
<div class="col-sm-7" id="{{id}}-label">
<label class="control-label">{{name}}</label>
{{^expired}}
<div>
{{#saleInFuture}}
{{#i18n}}show-event.sales-not-started{{/i18n}}
{{/saleInFuture}}
{{^saleInFuture}}
{{#i18n}}show-event.sales-end [{{#format-date}}{{zonedExpiration}} dd.MM.yyyy HH:mm locale:{{#i18n}}locale{{/i18n}}{{/format-date}}]{{/i18n}}
{{/saleInFuture}}
</div>
{{/expired}}
{{#expired}}
<div>
{{#i18n}}show-event.sales-ended [{{#format-date}}{{zonedExpiration}} dd.MM.yyyy HH:mm locale:{{#i18n}}locale{{/i18n}}{{/format-date}}]{{/i18n}}
</div>
{{/expired}}
<div>
{{description}}
</div>
</div>
<div class="col-sm-3">
<label class="control-label">
{{#free}}
{{#i18n}}common.free{{/i18n}}
{{/free}}
{{^free}}
{{#expired}}
{{finalPrice}} {{event.currency}}
{{/expired}}
{{^expired}}
{{#hasPromoCodeDiscount}}
<del>{{finalPrice}}</del>
<mark>{{discountedPrice}}</mark>
{{event.currency}}
{{/hasPromoCodeDiscount}}
{{^hasPromoCodeDiscount}}
{{finalPrice}} {{event.currency}}
{{/hasPromoCodeDiscount}}
<i class="fa fa-info-circle text-info tooltip-handler" title="{{#event.vatIncluded}}{{#i18n}}show-event.incVat [{{event.vat}}]{{/i18n}}{{/event.vatIncluded}}{{^event.vatIncluded}}{{#i18n}}show-event.excVat [{{event.vat}}]{{/i18n}}{{/event.vatIncluded}}"></i>
{{/expired}}
{{/free}}
</label>
</div>
<div class="col-sm-2 text-align-center">
{{#saleable}}
<input name="reservation[{{-index}}].ticketCategoryId" value="{{id}}" type="hidden">
<select aria-labelledby="{{id}}-label" name="reservation[{{-index}}].amount" class="form-control text-align-center" placeholder="0" autocomplete="off">
{{#accessRestricted}}
<option value="0">0</option>
<option value="1">1</option>
{{/accessRestricted}}
{{^accessRestricted}}
{{#amountOfTickets}}<option value="{{this}}">{{this}}</option>{{/amountOfTickets}}
{{/accessRestricted}}
</select>
{{/saleable}}
{{^saleable}}
<label class="control-label">
{{#soldOut}}
{{#i18n}}show-event.sold-out{{/i18n}}
{{/soldOut}}
{{^soldOut}}
{{#i18n}}show-event.not-available{{/i18n}}
{{/soldOut}}
</label>
{{/saleable}}
</div>
</div>
</li>

0 comments on commit c862190

Please sign in to comment.