parcoursmob/renderer/vehicle-management.go

92 lines
3.7 KiB
Go

package renderer
import (
"net/http"
filestorage "git.coopgo.io/coopgo-apps/parcoursmob/utils/storage"
fleetsstorage "git.coopgo.io/coopgo-platform/fleets/storage"
)
const vehiclesmanagementMenu = "vehicles_management"
func (renderer *Renderer) VehiclesManagementOverview(w http.ResponseWriter, r *http.Request, vehicles []fleetsstorage.Vehicle, vehicles_map map[string]fleetsstorage.Vehicle, bookings []fleetsstorage.Booking) {
files := renderer.ThemeConfig.GetStringSlice("views.vehicles_management.overview.files")
state := NewState(r, renderer.ThemeConfig, vehiclesmanagementMenu)
state.ViewState = map[string]any{
"vehicles": vehicles,
"bookings": bookings,
"vehicles_map": vehicles_map,
}
renderer.Render("fleet overview", w, r, files, state)
}
func (renderer *Renderer) VehiclesManagementBookingsList(w http.ResponseWriter, r *http.Request, vehicles_map map[string]fleetsstorage.Vehicle, bookings []fleetsstorage.Booking, cacheid string) {
files := renderer.ThemeConfig.GetStringSlice("views.vehicles_management.bookings_list.files")
state := NewState(r, renderer.ThemeConfig, vehiclesmanagementMenu)
state.ViewState = map[string]any{
"bookings": bookings,
"vehicles_map": vehicles_map,
"cacheid": cacheid,
}
renderer.Render("fleet overview", w, r, files, state)
}
func (renderer *Renderer) VehiclesFleetAdd(w http.ResponseWriter, r *http.Request, vehicle_types []string) {
files := renderer.ThemeConfig.GetStringSlice("views.vehicles_management.fleet_add.files")
state := NewState(r, renderer.ThemeConfig, vehiclesmanagementMenu)
state.ViewState = map[string]any{
"vehicle_types": vehicle_types,
}
renderer.Render("fleet add vehicle", w, r, files, state)
}
func (renderer *Renderer) VehiclesFleetDisplay(w http.ResponseWriter, r *http.Request, vehicle any) {
files := renderer.ThemeConfig.GetStringSlice("views.vehicles_management.fleet_display.files")
state := NewState(r, renderer.ThemeConfig, vehiclesmanagementMenu)
state.ViewState = map[string]any{
"vehicle": vehicle,
}
renderer.Render("fleet display vehicle", w, r, files, state)
}
func (renderer *Renderer) VehiclesFleetUpdate(w http.ResponseWriter, r *http.Request, vehicle any, vehicle_types []string) {
files := renderer.ThemeConfig.GetStringSlice("views.vehicles_management.fleet_update.files")
state := NewState(r, renderer.ThemeConfig, vehiclesmanagementMenu)
state.ViewState = map[string]any{
"vehicle": vehicle,
"vehicle_types": vehicle_types,
}
renderer.Render("fleet display vehicle", w, r, files, state)
}
func (renderer *Renderer) VehicleManagementBookingDisplay(w http.ResponseWriter, r *http.Request, booking any, vehicle any, beneficiary any, group any, documents []filestorage.FileInfo, file_types_map map[string]string, alternative_vehicles []any) {
files := renderer.ThemeConfig.GetStringSlice("views.vehicles_management.booking_display.files")
state := NewState(r, renderer.ThemeConfig, vehiclesmanagementMenu)
state.ViewState = map[string]any{
"booking": booking,
"vehicle": vehicle,
"beneficiary": beneficiary,
"group": group,
"documents": documents,
"file_types_map": file_types_map,
"alternative_vehicles": alternative_vehicles,
}
renderer.Render("vehicles search", w, r, files, state)
}
func (renderer *Renderer) UnbookingVehicle(w http.ResponseWriter, r *http.Request, booking any) {
files := renderer.ThemeConfig.GetStringSlice("views.vehicles_management.delete_booking.files")
state := NewState(r, renderer.ThemeConfig, vehiclesmanagementMenu)
state.ViewState = map[string]any{
"booking": booking,
}
renderer.Render("vehicule unbooking", w, r, files, state)
}