From a0e7e7951f5ca562ea40a722ad3fee9530f4d5f1 Mon Sep 17 00:00:00 2001 From: Sylvain Date: Tue, 28 Feb 2017 11:59:48 +0100 Subject: [PATCH] [ongoing] display spaces in public calendar --- .../javascripts/controllers/calendar.coffee | 18 ++++++++-- app/assets/javascripts/router.coffee.erb | 3 ++ app/assets/stylesheets/app.colors.scss | 1 + .../templates/calendar/calendar.html.erb | 8 ++--- app/assets/templates/calendar/filter.html.erb | 18 +++++++--- .../api/availabilities_controller.rb | 33 +++++++++++++++++-- .../api/availabilities/public.json.jbuilder | 32 ++++++++++++++---- config/locales/app.public.en.yml | 11 +++++-- config/locales/app.public.fr.yml | 11 +++++-- 9 files changed, 108 insertions(+), 27 deletions(-) diff --git a/app/assets/javascripts/controllers/calendar.coffee b/app/assets/javascripts/controllers/calendar.coffee index bb020c1ff..6a033644c 100644 --- a/app/assets/javascripts/controllers/calendar.coffee +++ b/app/assets/javascripts/controllers/calendar.coffee @@ -4,14 +4,15 @@ # Controller used in the public calendar global ## -Application.Controllers.controller "CalendarController", ["$scope", "$state", "$aside", "moment", "Availability", 'Slot', 'Setting', 'growl', 'dialogs', 'bookingWindowStart', 'bookingWindowEnd', '_t', 'uiCalendarConfig', 'CalendarConfig', 'trainingsPromise', 'machinesPromise', -($scope, $state, $aside, moment, Availability, Slot, Setting, growl, dialogs, bookingWindowStart, bookingWindowEnd, _t, uiCalendarConfig, CalendarConfig, trainingsPromise, machinesPromise) -> +Application.Controllers.controller "CalendarController", ["$scope", "$state", "$aside", "moment", "Availability", 'Slot', 'Setting', 'growl', 'dialogs', 'bookingWindowStart', 'bookingWindowEnd', '_t', 'uiCalendarConfig', 'CalendarConfig', 'trainingsPromise', 'machinesPromise', 'spacesPromise', +($scope, $state, $aside, moment, Availability, Slot, Setting, growl, dialogs, bookingWindowStart, bookingWindowEnd, _t, uiCalendarConfig, CalendarConfig, trainingsPromise, machinesPromise, spacesPromise) -> ### PRIVATE STATIC CONSTANTS ### currentMachineEvent = null machinesPromise.forEach((m) -> m.checked = true) trainingsPromise.forEach((t) -> t.checked = true) + spacesPromise.forEach((s) -> s.checked = true) ## check all formation/machine is select in filter isSelectAll = (type, scope) -> @@ -25,6 +26,9 @@ Application.Controllers.controller "CalendarController", ["$scope", "$state", "$ ## List of machines $scope.machines = machinesPromise + ## List of spaces + $scope.spaces = spacesPromise + ## add availabilities source to event sources $scope.eventSources = [] @@ -34,6 +38,7 @@ Application.Controllers.controller "CalendarController", ["$scope", "$state", "$ scope.filter = $scope.filter = trainings: isSelectAll('trainings', scope) machines: isSelectAll('machines', scope) + spaces: isSelectAll('spaces', scope) evt: filter.evt dispo: filter.dispo $scope.calendarConfig.events = availabilitySourceUrl() @@ -43,6 +48,7 @@ Application.Controllers.controller "CalendarController", ["$scope", "$state", "$ $scope.filter = trainings: isSelectAll('trainings', $scope) machines: isSelectAll('machines', $scope) + spaces: isSelectAll('spaces', $scope) evt: true dispo: true @@ -62,15 +68,18 @@ Application.Controllers.controller "CalendarController", ["$scope", "$state", "$ $scope.trainings machines: -> $scope.machines + spaces: -> + $scope.spaces filter: -> $scope.filter toggleFilter: -> $scope.toggleFilter filterAvailabilities: -> $scope.filterAvailabilities - controller: ['$scope', '$uibModalInstance', 'trainings', 'machines', 'filter', 'toggleFilter', 'filterAvailabilities', ($scope, $uibModalInstance, trainings, machines, filter, toggleFilter, filterAvailabilities) -> + controller: ['$scope', '$uibModalInstance', 'trainings', 'machines', 'spaces', 'filter', 'toggleFilter', 'filterAvailabilities', ($scope, $uibModalInstance, trainings, machines, spaces, filter, toggleFilter, filterAvailabilities) -> $scope.trainings = trainings $scope.machines = machines + $scope.spaces = spaces $scope.filter = filter $scope.toggleFilter = (type, filter) -> @@ -94,6 +103,9 @@ Application.Controllers.controller "CalendarController", ["$scope", "$state", "$ currentMachineEvent = event calendar.fullCalendar('changeView', 'agendaDay') calendar.fullCalendar('gotoDate', event.start) + else if event.available_type == 'space' + calendar.fullCalendar('changeView', 'agendaDay') + calendar.fullCalendar('gotoDate', event.start) else if event.available_type == 'event' $state.go('app.public.events_show', {id: event.event_id}) diff --git a/app/assets/javascripts/router.coffee.erb b/app/assets/javascripts/router.coffee.erb index aaee143c0..7ffadb9ea 100644 --- a/app/assets/javascripts/router.coffee.erb +++ b/app/assets/javascripts/router.coffee.erb @@ -640,6 +640,9 @@ angular.module('application.router', ['ui.router']). machinesPromise: ['Machine', (Machine)-> Machine.query().$promise ] + spacesPromise: ['Space', (Space) -> + Space.query().$promise + ] translations: [ 'Translations', (Translations) -> Translations.query(['app.public.calendar']).$promise ] diff --git a/app/assets/stylesheets/app.colors.scss b/app/assets/stylesheets/app.colors.scss index 914f5ff07..7637f3c10 100644 --- a/app/assets/stylesheets/app.colors.scss +++ b/app/assets/stylesheets/app.colors.scss @@ -40,4 +40,5 @@ .text-purple { color: $violet !important; } .text-japonica { color: $japonica !important; } .text-beige { color: $beige !important; } +.text-cyan { color: $cyan !important; } .text-green, .green { color: #79C84A !important; } diff --git a/app/assets/templates/calendar/calendar.html.erb b/app/assets/templates/calendar/calendar.html.erb index 7e2775c9d..bc3c16530 100644 --- a/app/assets/templates/calendar/calendar.html.erb +++ b/app/assets/templates/calendar/calendar.html.erb @@ -7,14 +7,14 @@
-

{{ 'calendar' }}

+

{{ 'calendar.calendar' }}

@@ -38,7 +38,7 @@