mirror of
https://github.com/LaCasemate/fab-manager.git
synced 2025-01-17 06:52:27 +01:00
fix events/index order, frontend js code was conflicting with server-side behaviour
This commit is contained in:
parent
2f4dd4642a
commit
a29ba926c0
@ -31,7 +31,7 @@ Application.Controllers.controller "EventsController", ["$scope", "$state", 'Eve
|
||||
theme_id: null
|
||||
age_range_id: null
|
||||
|
||||
|
||||
$scope.monthNames = [<%= t('date.month_names')[1..-1].map { |m| "\"#{m}\"" }.join(', ') %>]
|
||||
|
||||
##
|
||||
# Adds a resultset of events to the bottom of the page, grouped by month
|
||||
@ -106,19 +106,10 @@ Application.Controllers.controller "EventsController", ["$scope", "$state", 'Eve
|
||||
groupEvents = (events) ->
|
||||
if events.length > 0
|
||||
eventsGroupedByMonth = _.groupBy(events, (obj) ->
|
||||
_.map ['month', 'year'], (key, value) -> obj[key]
|
||||
_.map ['month_id', 'year'], (key, value) -> obj[key]
|
||||
)
|
||||
$scope.eventsGroupByMonth = Object.assign($scope.eventsGroupByMonth, eventsGroupedByMonth)
|
||||
|
||||
monthsOrder = _.sortBy _.keys($scope.eventsGroupByMonth), (k)->
|
||||
monthYearArray = k.split(',')
|
||||
date = new Date()
|
||||
date.setMonth(monthYearArray[0])
|
||||
date.setYear(monthYearArray[1])
|
||||
return -date.getTime()
|
||||
|
||||
$scope.monthOrder = monthsOrder
|
||||
|
||||
$scope.monthOrder = Object.keys($scope.eventsGroupByMonth)
|
||||
|
||||
|
||||
## !!! MUST BE CALLED AT THE END of the controller
|
||||
|
@ -41,7 +41,7 @@
|
||||
</div>
|
||||
|
||||
<div ng-repeat="month in monthOrder">
|
||||
<h1>{{month.split(',')[0]}}, {{month.split(',')[1]}}</h1>
|
||||
<h1>{{monthNames[month.split(',')[0] - 1]}}, {{month.split(',')[1]}}</h1>
|
||||
|
||||
<div class="row" ng-repeat="event in (eventsGroupByMonth[month].length/3 | array)">
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user