1
0
mirror of https://github.com/LaCasemate/fab-manager.git synced 2025-01-17 06:52:27 +01:00

display custom prices in event show

This commit is contained in:
Sylvain 2016-08-25 15:36:52 +02:00
parent 05b010b83f
commit 4fd31c3e9b
7 changed files with 40 additions and 7 deletions

View File

@ -132,8 +132,8 @@ Application.Controllers.controller "EventsController", ["$scope", "$state", 'Eve
Application.Controllers.controller "ShowEventController", ["$scope", "$state", "$stateParams", "Event", '$uibModal', 'Member', 'Reservation', 'Price', 'CustomAsset', 'eventPromise', 'reducedAmountAlert', 'growl', '_t', 'Wallet', 'helpers',
($scope, $state, $stateParams, Event, $uibModal, Member, Reservation, Price, CustomAsset, eventPromise, reducedAmountAlert, growl, _t, Wallet, helpers) ->
Application.Controllers.controller "ShowEventController", ["$scope", "$state", "$stateParams", "Event", '$uibModal', 'Member', 'Reservation', 'Price', 'CustomAsset', 'eventPromise', 'reducedAmountAlert', 'growl', '_t', 'Wallet', 'helpers', 'priceCategoriesPromise',
($scope, $state, $stateParams, Event, $uibModal, Member, Reservation, Price, CustomAsset, eventPromise, reducedAmountAlert, growl, _t, Wallet, helpers, priceCategoriesPromise) ->
@ -160,9 +160,12 @@ Application.Controllers.controller "ShowEventController", ["$scope", "$state", "
$scope.coupon =
applied: null
# get the details for the current event (event's id is recovered from the current URL)
## Get the details for the current event (event's id is recovered from the current URL)
$scope.event = eventPromise
## List of price categories for the events
$scope.priceCategories = priceCategoriesPromise
##
@ -389,6 +392,17 @@ Application.Controllers.controller "ShowEventController", ["$scope", "$state", "
##
# Return the textual description of the conditions applyable to the given price's category
# @param category_id {number} ID of the price's category
##
$scope.getPriceCategoryConditions = (category_id) ->
for cat in $scope.priceCategories
if cat.id == category_id
return cat.conditions
### PRIVATE SCOPE ###
##

View File

@ -515,6 +515,9 @@ angular.module('application.router', ['ui.router']).
reducedAmountAlert: ['Setting', (Setting)->
Setting.get(name: 'event_reduced_amount_alert').$promise
]
priceCategoriesPromise: ['PriceCategory', (PriceCategory) ->
PriceCategory.query().$promise
]
translations: [ 'Translations', (Translations) ->
Translations.query(['app.public.events_show', 'app.shared.member_select', 'app.shared.stripe',
'app.shared.valid_reservation_modal', 'app.shared.wallet', 'app.shared.coupon_input']).$promise

View File

@ -579,3 +579,12 @@ padding: 10px;
cursor: pointer;
}
}
.description-hover {
span {
display: inline-block;
border-bottom: 1px dashed #00b3ee;
cursor: help;
}
}

View File

@ -88,7 +88,12 @@
<div class="text-sm" ng-if="event.amount">
<div>{{ 'full_price_' | translate }} <span>{{ event.amount | currency}}</span></div>
<div ng-if="event.reduced_amount > 0">{{ 'reduced_rate*' | translate }} {{ event.reduced_amount | currency}}</div>
<div ng-repeat="price in event.prices" class="description-hover">
<span uib-popover="{{getPriceCategoryConditions(price.category.id)}}" popover-trigger="mouseenter">
{{price.category.name}} :
</span>
{{price.amount | currency}}
</div>
</div>
<div class="text-sm m-b" ng-if="event.nb_total_places">

View File

@ -1,5 +1,5 @@
class API::PriceCategoriesController < API::ApiController
before_action :authenticate_user!
before_action :authenticate_user!, only: [:update, :show, :create, :destroy]
before_action :set_price_category, only: [:show, :update, :destroy]
def index

View File

@ -1,5 +1,5 @@
class PriceCategoryPolicy < ApplicationPolicy
%w(index show create update destroy).each do |action|
%w(show create update destroy).each do |action|
define_method "#{action}?" do
user.is_admin?
end

View File

@ -1,4 +1,6 @@
user_is_admin = (current_user and current_user.is_admin?)
json.array!(@price_categories) do |category|
json.extract! category, :id, :name, :conditions
json.events category.event_price_category.count
json.events category.event_price_category.count if user_is_admin
end