mirror of
https://github.com/LaCasemate/fab-manager.git
synced 2024-12-01 12:24:28 +01:00
filter spaces in client calendar
This commit is contained in:
parent
e1178df45b
commit
4a9fb5855f
@ -151,7 +151,8 @@ Application.Controllers.controller "CalendarController", ["$scope", "$state", "$
|
||||
getFilter = ->
|
||||
t = $scope.trainings.filter((t) -> t.checked).map((t) -> t.id)
|
||||
m = $scope.machines.filter((m) -> m.checked).map((m) -> m.id)
|
||||
{t: t, m: m, evt: $scope.filter.evt, dispo: $scope.filter.dispo}
|
||||
s = $scope.spaces.filter((s) -> s.checked).map((s) -> s.id)
|
||||
{t: t, m: m, s: s, evt: $scope.filter.evt, dispo: $scope.filter.dispo}
|
||||
|
||||
availabilitySourceUrl = ->
|
||||
"/api/availabilities/public?#{$.param(getFilter())}"
|
||||
|
@ -21,7 +21,7 @@
|
||||
<div class="m-t">
|
||||
<div class="row">
|
||||
<h3 class="col-md-11 col-sm-11 col-xs-11 text-cyan" translate>{{ 'calendar.spaces' }}</h3>
|
||||
<input class="col-md-1 col-sm-1 col-xs-1" type="checkbox" ng-model="filter.machines" ng-change="toggleFilter('spaces', filter)">
|
||||
<input class="col-md-1 col-sm-1 col-xs-1" type="checkbox" ng-model="filter.spaces" ng-change="toggleFilter('spaces', filter)">
|
||||
</div>
|
||||
<div ng-repeat="s in spaces" class="row">
|
||||
<span class="col-md-11 col-sm-11 col-xs-11">{{::s.name}}</span>
|
||||
|
@ -49,6 +49,11 @@ class API::AvailabilitiesController < API::ApiController
|
||||
# spaces
|
||||
@space_availabilities = Availability.includes(:tags, :spaces).where(available_type: 'space')
|
||||
.where('start_at >= ? AND end_at <= ?', start_date, end_date)
|
||||
|
||||
if params[:s]
|
||||
@space_availabilities.where(available_id: params[:s])
|
||||
end
|
||||
|
||||
@space_slots = []
|
||||
@space_availabilities.each do |a|
|
||||
space = a.spaces.first
|
||||
@ -331,8 +336,8 @@ class API::AvailabilitiesController < API::ApiController
|
||||
end
|
||||
end
|
||||
# space
|
||||
if params[:m] and a.available_type == 'space'
|
||||
if params[:t].include?(a.spaces.first.id.to_s)
|
||||
if params[:s] and a.available_type == 'space'
|
||||
if params[:s].include?(a.spaces.first.id.to_s)
|
||||
availabilities_filtered << a
|
||||
end
|
||||
end
|
||||
|
Loading…
Reference in New Issue
Block a user