1
0
mirror of https://github.com/LaCasemate/fab-manager.git synced 2025-01-29 18:52:22 +01:00

ability to edit event with custom prices

This commit is contained in:
Sylvain 2016-08-25 13:56:07 +02:00
parent 7dc359e4ee
commit 5d91756ace
5 changed files with 29 additions and 20 deletions

View File

@ -126,6 +126,17 @@ class EventsController
##
# Initialize a new price item in the additional prices list
##
$scope.addPrice = ->
$scope.event.prices.push({
category: null,
amount: null,
})
##
# Controller used in the events listing page (admin view)
##
@ -393,9 +404,6 @@ Application.Controllers.controller "NewEventController", ["$scope", "$state", "$
## List of availables price's categories
$scope.priceCategories = priceCategoriesPromise
## List of additional prices for the event
$scope.prices = []
## Default event parameters
$scope.event =
event_files_attributes: []
@ -406,6 +414,7 @@ Application.Controllers.controller "NewEventController", ["$scope", "$state", "$
all_day: 'false'
recurrence: 'none'
category_id: null
prices: []
## Possible types of recurrences for an event
$scope.recurrenceTypes = [
@ -420,17 +429,6 @@ Application.Controllers.controller "NewEventController", ["$scope", "$state", "$
$scope.currencySymbol = $locale.NUMBER_FORMATS.CURRENCY_SYM;
##
# Initialize a new price item in the additional prices list
##
$scope.addPrice = ->
$scope.prices.push({
category: null,
amount: null,
})
## Using the EventsController
new EventsController($scope, $state)
]
@ -440,8 +438,8 @@ Application.Controllers.controller "NewEventController", ["$scope", "$state", "$
##
# Controller used in the events edition page
##
Application.Controllers.controller "EditEventController", ["$scope", "$state", "$stateParams", "$locale", 'CSRF', 'eventPromise', 'categoriesPromise', 'themesPromise', 'ageRangesPromise'
, ($scope, $state, $stateParams, $locale, CSRF, eventPromise, categoriesPromise, themesPromise, ageRangesPromise) ->
Application.Controllers.controller "EditEventController", ["$scope", "$state", "$stateParams", "$locale", 'CSRF', 'eventPromise', 'categoriesPromise', 'themesPromise', 'ageRangesPromise', 'priceCategoriesPromise'
, ($scope, $state, $stateParams, $locale, CSRF, eventPromise, categoriesPromise, themesPromise, ageRangesPromise, priceCategoriesPromise) ->
### PUBLIC SCOPE ###
@ -462,6 +460,9 @@ Application.Controllers.controller "EditEventController", ["$scope", "$state", "
## List of categories for the events
$scope.categories = categoriesPromise
## List of availables price's categories
$scope.priceCategories = priceCategoriesPromise
## List of events themes
$scope.themes = themesPromise

View File

@ -700,6 +700,9 @@ angular.module('application.router', ['ui.router']).
ageRangesPromise: ['AgeRange', (AgeRange) ->
AgeRange.query().$promise
]
priceCategoriesPromise: ['PriceCategory', (PriceCategory) ->
PriceCategory.query().$promise
]
translations: [ 'Translations', (Translations) ->
Translations.query(['app.admin.events_edit', 'app.shared.event']).$promise
]

View File

@ -237,7 +237,7 @@
<span class="help-block" translate>{{ '0_=_free' }}</span>
</div>
</div>
<div class="form-group" ng-repeat="price in prices">
<div class="form-group" ng-repeat="price in event.prices">
<div class="col-sm-5">
<select class="form-control"
ng-model="price.category"
@ -256,7 +256,7 @@
</div>
</div>
</div>
<div class="link-icon m-b" ng-hide="prices.length == priceCategories.length">
<div class="link-icon m-b" ng-hide="event.prices.length == priceCategories.length">
<div class="col-sm-offset-5">
<i class="fa fa-plus"></i> <span ng-click="addPrice()">Ajouter un tarif</span>
</div>

View File

@ -122,7 +122,6 @@
<span ng-if="!event.nb_total_places" translate>{{ 'free_entry' }}</span>
<span ng-if="event.nb_total_places && event.amount == 0" translate>{{ 'free_admission' }}</span>
<span ng-if="event.amount > 0">{{event.amount | currency}} {{ 'full_price' | translate }}</span>
<span ng-if="event.reduced_amount > 0"><br/>{{event.reduced_amount | currency}} {{ 'reduced_rate' | translate }}</span>
<div ng-if="event.nb_free_places == 0"><span class="badge font-sbold bg-red" translate>{{ 'event_full' }}</span></div>
</h6>

View File

@ -33,7 +33,13 @@ json.availability do
end
json.availability_id event.availability_id
json.amount (event.amount / 100.0) if event.amount
json.reduced_amount (event.reduced_amount / 100.0) if event.reduced_amount
json.prices event.event_price_categories do |p_cat|
json.id p_cat.id
json.amount (p_cat.amount / 100.0)
json.category do
json.extract! p_cat.price_category, :id, :name
end
end
json.nb_total_places event.nb_total_places
json.nb_free_places event.nb_free_places || event.nb_total_places