mirror of
https://github.com/LaCasemate/fab-manager.git
synced 2025-02-20 14:54:15 +01:00
display external calendars list in public calendar + pull availabilities
This commit is contained in:
parent
cca6b14f58
commit
22be9f6a08
@ -16,8 +16,8 @@
|
|||||||
* Controller used in the public calendar global
|
* 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', 'spacesPromise',
|
Application.Controllers.controller('CalendarController', ['$scope', '$state', '$aside', 'moment', 'Availability', 'Slot', 'Setting', 'growl', 'dialogs', 'bookingWindowStart', 'bookingWindowEnd', '_t', 'uiCalendarConfig', 'CalendarConfig', 'trainingsPromise', 'machinesPromise', 'spacesPromise', 'iCalendarPromise',
|
||||||
function ($scope, $state, $aside, moment, Availability, Slot, Setting, growl, dialogs, bookingWindowStart, bookingWindowEnd, _t, uiCalendarConfig, CalendarConfig, trainingsPromise, machinesPromise, spacesPromise) {
|
function ($scope, $state, $aside, moment, Availability, Slot, Setting, growl, dialogs, bookingWindowStart, bookingWindowEnd, _t, uiCalendarConfig, CalendarConfig, trainingsPromise, machinesPromise, spacesPromise, iCalendarPromise) {
|
||||||
/* PRIVATE STATIC CONSTANTS */
|
/* PRIVATE STATIC CONSTANTS */
|
||||||
let currentMachineEvent = null;
|
let currentMachineEvent = null;
|
||||||
machinesPromise.forEach(m => m.checked = true);
|
machinesPromise.forEach(m => m.checked = true);
|
||||||
@ -38,12 +38,11 @@ Application.Controllers.controller('CalendarController', ['$scope', '$state', '$
|
|||||||
// List of spaces
|
// List of spaces
|
||||||
$scope.spaces = spacesPromise.filter(t => !t.disabled);
|
$scope.spaces = spacesPromise.filter(t => !t.disabled);
|
||||||
|
|
||||||
|
// List of external iCalendar sources
|
||||||
|
$scope.externals = iCalendarPromise;
|
||||||
|
|
||||||
// add availabilities source to event sources
|
// add availabilities source to event sources
|
||||||
$scope.eventSources = [];
|
$scope.eventSources = [];
|
||||||
$scope.eventSources.push({
|
|
||||||
url: '/api/i_calendar/events',
|
|
||||||
textColor: 'black'
|
|
||||||
});
|
|
||||||
|
|
||||||
// filter availabilities if have change
|
// filter availabilities if have change
|
||||||
$scope.filterAvailabilities = function (filter, scope) {
|
$scope.filterAvailabilities = function (filter, scope) {
|
||||||
@ -52,10 +51,19 @@ Application.Controllers.controller('CalendarController', ['$scope', '$state', '$
|
|||||||
trainings: isSelectAll('trainings', scope),
|
trainings: isSelectAll('trainings', scope),
|
||||||
machines: isSelectAll('machines', scope),
|
machines: isSelectAll('machines', scope),
|
||||||
spaces: isSelectAll('spaces', scope),
|
spaces: isSelectAll('spaces', scope),
|
||||||
|
externals: isSelectAll('externals', scope),
|
||||||
evt: filter.evt,
|
evt: filter.evt,
|
||||||
dispo: filter.dispo
|
dispo: filter.dispo
|
||||||
});
|
});
|
||||||
return $scope.calendarConfig.events = availabilitySourceUrl();
|
$scope.calendarConfig.events = availabilitySourceUrl();
|
||||||
|
$scope.externals.filter(e => e.checked).forEach(e => {
|
||||||
|
$scope.eventSources.push({
|
||||||
|
url: `/api/i_calendar/${e.id}/events`,
|
||||||
|
textColor: e.textColor,
|
||||||
|
color: e.color
|
||||||
|
});
|
||||||
|
});
|
||||||
|
return uiCalendarConfig.calendars.calendar.fullCalendar('refetchEvents');
|
||||||
};
|
};
|
||||||
|
|
||||||
// a variable for formation/machine/event/dispo checkbox is or not checked
|
// a variable for formation/machine/event/dispo checkbox is or not checked
|
||||||
@ -63,6 +71,7 @@ Application.Controllers.controller('CalendarController', ['$scope', '$state', '$
|
|||||||
trainings: isSelectAll('trainings', $scope),
|
trainings: isSelectAll('trainings', $scope),
|
||||||
machines: isSelectAll('machines', $scope),
|
machines: isSelectAll('machines', $scope),
|
||||||
spaces: isSelectAll('spaces', $scope),
|
spaces: isSelectAll('spaces', $scope),
|
||||||
|
externals: isSelectAll('externals', $scope),
|
||||||
evt: true,
|
evt: true,
|
||||||
dispo: true
|
dispo: true
|
||||||
};
|
};
|
||||||
@ -89,6 +98,9 @@ Application.Controllers.controller('CalendarController', ['$scope', '$state', '$
|
|||||||
spaces () {
|
spaces () {
|
||||||
return $scope.spaces;
|
return $scope.spaces;
|
||||||
},
|
},
|
||||||
|
externals () {
|
||||||
|
return $scope.externals;
|
||||||
|
},
|
||||||
filter () {
|
filter () {
|
||||||
return $scope.filter;
|
return $scope.filter;
|
||||||
},
|
},
|
||||||
@ -99,10 +111,11 @@ Application.Controllers.controller('CalendarController', ['$scope', '$state', '$
|
|||||||
return $scope.filterAvailabilities;
|
return $scope.filterAvailabilities;
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
controller: ['$scope', '$uibModalInstance', 'trainings', 'machines', 'spaces', 'filter', 'toggleFilter', 'filterAvailabilities', function ($scope, $uibModalInstance, trainings, machines, spaces, filter, toggleFilter, filterAvailabilities) {
|
controller: ['$scope', '$uibModalInstance', 'trainings', 'machines', 'spaces', 'externals', 'filter', 'toggleFilter', 'filterAvailabilities', function ($scope, $uibModalInstance, trainings, machines, spaces, externals, filter, toggleFilter, filterAvailabilities) {
|
||||||
$scope.trainings = trainings;
|
$scope.trainings = trainings;
|
||||||
$scope.machines = machines;
|
$scope.machines = machines;
|
||||||
$scope.spaces = spaces;
|
$scope.spaces = spaces;
|
||||||
|
$scope.externals = externals;
|
||||||
$scope.filter = filter;
|
$scope.filter = filter;
|
||||||
|
|
||||||
$scope.toggleFilter = (type, filter) => toggleFilter(type, filter);
|
$scope.toggleFilter = (type, filter) => toggleFilter(type, filter);
|
||||||
@ -124,19 +137,19 @@ Application.Controllers.controller('CalendarController', ['$scope', '$state', '$
|
|||||||
if (event.available_type === 'machines') {
|
if (event.available_type === 'machines') {
|
||||||
currentMachineEvent = event;
|
currentMachineEvent = event;
|
||||||
calendar.fullCalendar('changeView', 'agendaDay');
|
calendar.fullCalendar('changeView', 'agendaDay');
|
||||||
return calendar.fullCalendar('gotoDate', event.start);
|
calendar.fullCalendar('gotoDate', event.start);
|
||||||
} else if (event.available_type === 'space') {
|
} else if (event.available_type === 'space') {
|
||||||
calendar.fullCalendar('changeView', 'agendaDay');
|
calendar.fullCalendar('changeView', 'agendaDay');
|
||||||
return calendar.fullCalendar('gotoDate', event.start);
|
calendar.fullCalendar('gotoDate', event.start);
|
||||||
} else if (event.available_type === 'event') {
|
} else if (event.available_type === 'event') {
|
||||||
return $state.go('app.public.events_show', { id: event.event_id });
|
$state.go('app.public.events_show', { id: event.event_id });
|
||||||
} else if (event.available_type === 'training') {
|
} else if (event.available_type === 'training') {
|
||||||
return $state.go('app.public.training_show', { id: event.training_id });
|
$state.go('app.public.training_show', { id: event.training_id });
|
||||||
} else {
|
} else {
|
||||||
if (event.machine_id) {
|
if (event.machine_id) {
|
||||||
return $state.go('app.public.machines_show', { id: event.machine_id });
|
$state.go('app.public.machines_show', { id: event.machine_id });
|
||||||
} else if (event.space_id) {
|
} else if (event.space_id) {
|
||||||
return $state.go('app.public.space_show', { id: event.space_id });
|
$state.go('app.public.space_show', { id: event.space_id });
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
@ -638,6 +638,7 @@ angular.module('application.router', ['ui.router'])
|
|||||||
trainingsPromise: ['Training', function (Training) { return Training.query().$promise; }],
|
trainingsPromise: ['Training', function (Training) { return Training.query().$promise; }],
|
||||||
machinesPromise: ['Machine', function (Machine) { return Machine.query().$promise; }],
|
machinesPromise: ['Machine', function (Machine) { return Machine.query().$promise; }],
|
||||||
spacesPromise: ['Space', function (Space) { return Space.query().$promise; }],
|
spacesPromise: ['Space', function (Space) { return Space.query().$promise; }],
|
||||||
|
iCalendarPromise: ['ICalendar', function (ICalendar) { return ICalendar.query().$promise; }],
|
||||||
translations: ['Translations', function (Translations) { return Translations.query(['app.public.calendar']).$promise; }]
|
translations: ['Translations', function (Translations) { return Translations.query(['app.public.calendar']).$promise; }]
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
@ -36,3 +36,14 @@
|
|||||||
<h3 class="col-md-11 col-sm-11 col-xs-11 text-black" translate>{{ 'calendar.show_unavailables' }}</h3>
|
<h3 class="col-md-11 col-sm-11 col-xs-11 text-black" translate>{{ 'calendar.show_unavailables' }}</h3>
|
||||||
<input class="col-md-1 col-sm-1 col-xs-1" type="checkbox" ng-model="filter.dispo" ng-change="filterAvailabilities(filter)">
|
<input class="col-md-1 col-sm-1 col-xs-1" type="checkbox" ng-model="filter.dispo" ng-change="filterAvailabilities(filter)">
|
||||||
</div>
|
</div>
|
||||||
|
<div class="m-t">
|
||||||
|
<div class="row">
|
||||||
|
<h3 class="col-md-11 col-sm-11 col-xs-11 text-black" translate>{{ 'calendar.externals' }}</h3>
|
||||||
|
<input class="col-md-1 col-sm-1 col-xs-1" type="checkbox" ng-model="filter.externals" ng-change="toggleFilter('externals', filter)">
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="row" ng-repeat="e in externals">
|
||||||
|
<span class="col-md-11 col-sm-11 col-xs-11">{{::e.name}}</span>
|
||||||
|
<input class="col-md-1 col-sm-1 col-xs-1" type="checkbox" ng-model="e.checked" ng-change="filterAvailabilities(filter)">
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
@ -27,7 +27,12 @@ class API::ICalendarController < API::ApiController
|
|||||||
end
|
end
|
||||||
|
|
||||||
def events
|
def events
|
||||||
@events = ICalendarEvent.where(i_calendar_id: params[:id]).joins(:i_calendar)
|
start_date = ActiveSupport::TimeZone[params[:timezone]]&.parse(params[:start])
|
||||||
|
end_date = ActiveSupport::TimeZone[params[:timezone]]&.parse(params[:end])&.end_of_day
|
||||||
|
|
||||||
|
@events = ICalendarEvent.where(i_calendar_id: params[:id])
|
||||||
|
.where('dtstart >= ? AND dtend <= ?', start_date, end_date)
|
||||||
|
.joins(:i_calendar)
|
||||||
end
|
end
|
||||||
|
|
||||||
def sync
|
def sync
|
||||||
|
@ -4,7 +4,7 @@
|
|||||||
class ICalendar < ActiveRecord::Base
|
class ICalendar < ActiveRecord::Base
|
||||||
has_many :i_calendar_events
|
has_many :i_calendar_events
|
||||||
|
|
||||||
after_create sync_events
|
after_create :sync_events
|
||||||
|
|
||||||
private
|
private
|
||||||
|
|
||||||
|
@ -306,6 +306,7 @@ fr:
|
|||||||
machines: "Machines"
|
machines: "Machines"
|
||||||
spaces: "Espaces"
|
spaces: "Espaces"
|
||||||
events: "Évènements"
|
events: "Évènements"
|
||||||
|
externals: "Autres calendriers"
|
||||||
|
|
||||||
spaces_list:
|
spaces_list:
|
||||||
# liste des espaces
|
# liste des espaces
|
||||||
|
Loading…
x
Reference in New Issue
Block a user