Skip to content

Commit

Permalink
#642 - create event: rearrange categories
Browse files Browse the repository at this point in the history
  • Loading branch information
cbellone committed Jul 20, 2019
1 parent 551c9ed commit b29fa0c
Show file tree
Hide file tree
Showing 6 changed files with 33 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ <h5 class="text-muted">Here the categories that have been defined for this event
<label class="btn btn-sm btn-default" data-ng-model="selection.active" data-uib-btn-checkbox><i class="fa" data-ng-class="{'fa-check-square-o': selection.active, 'fa-square-o': !selection.active}"></i> Active <span class="badge">{{countActive(event.ticketCategories)}}</span></label>
<label class="btn btn-sm btn-default" data-ng-model="selection.expired" data-uib-btn-checkbox><i class="fa" data-ng-class="{'fa-check-square-o': selection.expired, 'fa-square-o': !selection.expired}"></i> Expired <span class="badge">{{countExpired(event.ticketCategories)}}</span></label>
<label><div class="input-group"><div class="input-group-addon"><i class="fa fa-search"></i></div><input type="text" class="form-control input-sm" data-ng-model="selection.freeText" data-ng-change="updateSelectionText(selection.freeText)"></div></label>
<label class="btn btn-sm btn-default pull-right" data-ng-click="toggleRearrange()"><i class="fa fa-random"></i> Rearrange categories</label>
<label ng-if="event.ticketCategories.length > 1" class="btn btn-sm btn-default pull-right" data-ng-click="toggleRearrange()"><i class="fa fa-random"></i> Rearrange categories</label>
</div>
<script type="text/ng-template" id="categoryStats.html">
<ul class="list-unstyled">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,13 +32,17 @@ <h3>Categories</h3>
</uib-progress>
</div>
</div>
<div data-ng-form="category" data-ng-repeat="ticketCategory in event.ticketCategories | orderBy:['inception.date','inception.time']" ng-class="'category-'+$index">
<div data-ng-form="category" data-ng-repeat="ticketCategory in event.ticketCategories | orderBy:['ordinal', 'inception.date','inception.time']" ng-class="'category-'+$index">
<ticket-category-detail data-box-class="'category-' + evaluateBarType($index)"
data-event="event"
data-ticket-category="ticketCategory"
data-edit-handler="editCategory"
data-remove-handler="removeCategory"
data-panel-mode-enabled="true"></ticket-category-detail>
data-panel-mode-enabled="true"
data-swap-enabled="event.ticketCategories.length > 1"
data-swap-handler="swap"
data-is-first="$first"
data-is-last="$last"></ticket-category-detail>
</div>

<div class="alert alert-danger" ng-if="event.ticketCategories.length === 0">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ <h3>{{$ctrl.ticketCategory.name}}</h3>
<div class="pull-right">
<a class="btn btn-sm btn-default" ng-click="$ctrl.ticketCategory.error = null; $ctrl.editHandler($ctrl.ticketCategory)"><i class="fa fa-edit"></i> edit</a>
<a class="btn btn-sm btn-danger" ng-click="$ctrl.removeHandler($ctrl.ticketCategory)"><i class="fa fa-trash"></i> delete</a>
<a class="btn btn-default btn-sm" ng-if="$ctrl.swapEnabled && !$ctrl.isFirst" data-ng-click="$ctrl.swapHandler($ctrl.ticketCategory, true)"><i class="fa fa-arrow-up"></i> move up</a>
<a class="btn btn-default btn-sm" ng-if="$ctrl.swapEnabled && !$ctrl.isLast" data-ng-click="$ctrl.swapHandler($ctrl.ticketCategory, false)"><i class="fa fa-arrow-down"></i> move down</a>
</div>
</div>
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,11 @@
editHandler: '<',
removeHandler: '<',
boxClass: '<',
panelModeEnabled: '<'
panelModeEnabled: '<',
swapEnabled: '<',
swapHandler: '<',
isFirst: '<',
isLast: '<'
},
controller: [TicketCategoryDetailCtrl],
templateUrl: '../resources/js/admin/feature/ticket-category/ticket-category-detail.html'
Expand Down
3 changes: 3 additions & 0 deletions src/main/webapp/resources/js/admin/filter/util.js
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,9 @@

filters.filter('money', function() {
return function(amount, currency, hideCurrency) {
if(!currency) {
return "";
}
var formatted = new Intl.NumberFormat(navigator.language, { style: 'currency', currency: currency, currencyDisplay: 'code' }).format(amount);
if(hideCurrency) {
return formatted.substring(4);
Expand Down
16 changes: 16 additions & 0 deletions src/main/webapp/resources/js/admin/ng-app/admin-application.js
Original file line number Diff line number Diff line change
Expand Up @@ -664,10 +664,26 @@
$scope.addCategory = function() {
var category = createCategoryValidUntil(true, $scope.event.begin);
editCategory(category).then(function(res) {
category.ordinal = $scope.event.ticketCategories.length + 1;
$scope.event.ticketCategories.push(category);
});
};

$scope.swap = function(category, up) {
var list = $scope.event.ticketCategories.slice();
var index = category.ordinal - 1;
var target = up ? index - 1 : index + 1;
var toBeSwapped = list[target];
toBeSwapped.ordinal = index + 1;
category.ordinal = target + 1;
list[target] = category;
list[index] = toBeSwapped;
$scope.event.ticketCategories.length = 0;
for(var i=0; i<list.length; i++) {
$scope.event.ticketCategories.push(list[i]);
}
};

$scope.setAdditionalServices = function(event, additionalServices) {
event.additionalServices = additionalServices;
};
Expand Down

0 comments on commit b29fa0c

Please sign in to comment.