1
0
mirror of https://github.com/LaCasemate/fab-manager.git synced 2025-01-29 18:52:22 +01:00

configure default slot duration from settings panel

This commit is contained in:
Sylvain 2020-05-20 17:18:19 +02:00
parent 1ad0720711
commit a63340188b
10 changed files with 43 additions and 14 deletions

View File

@ -1011,7 +1011,7 @@ angular.module('application.router', ['ui.router'])
return Setting.query({
names: `['twitter_name', 'about_title', 'about_body', 'tracking_id',\
'privacy_body', 'privacy_dpo', 'about_contacts', 'book_overlapping_slots', \
'home_blogpost', 'machine_explications_alert', 'training_explications_alert', \
'home_blogpost', 'machine_explications_alert', 'training_explications_alert', 'slot_duration', \
'training_information_message', 'subscription_explications_alert', 'event_explications_alert', \
'space_explications_alert', 'booking_window_start', 'booking_window_end', \
'booking_move_enable', 'booking_move_delay', 'booking_cancel_enable', \

View File

@ -67,4 +67,10 @@
}
}
}
.section-separator {
background: radial-gradient(#dddddd, transparent);
height: 1px;
margin: 24px 33% 12px 33%;
}
}

View File

@ -21,6 +21,7 @@
<button name="button" class="btn btn-warning m-l" ng-click="save(windowEnd)" translate>{{ 'app.shared.buttons.save' }}</button>
</div>
</div>
<div class="section-separator"></div>
<div class="row">
<h3 class="m-l m-t-lg" translate>{{ 'app.admin.settings.max_visibility' }}</h3>
<number-setting name="visibility_yearly"
@ -34,12 +35,13 @@
<number-setting name="visibility_others"
settings="allSettings"
label="app.admin.settings.visibility_for_other_members"
classes="col-md-4"
classes="col-md-4 col-md-offset-2"
fa-icon="fa-calendar"
min="1"
required="required">
</number-setting>
</div>
<div class="section-separator"></div>
<div class="row">
<h3 class="m-l m-t-lg" translate>{{ 'app.admin.settings.ability_for_the_users_to_move_their_reservations' }}</h3>
<boolean-setting name="booking_move_enable" settings="allSettings" label="app.admin.settings.reservations_shifting" classes="m-l"></boolean-setting>
@ -68,10 +70,24 @@
required="allSettings.booking_cancel_enable === 'true'">
</number-setting>
</div>
<div class="section-separator"></div>
<div class="row">
<h3 class="m-l m-t-lg" translate>{{ 'app.admin.settings.book_overlapping_slots_info' }}</h3>
<boolean-setting name="book_overlapping_slots" settings="allSettings" label="app.admin.settings.allow_booking" classes="m-l"></boolean-setting>
</div>
<div class="section-separator"></div>
<div class="row">
<h3 class="m-l m-t-lg" translate>{{ 'app.admin.settings.default_slot_duration' }}</h3>
<p class="alert alert-warning m-h-md" translate>{{ 'app.admin.settings.default_slot_duration_info' }}</p>
<number-setting name="slot_duration"
settings="allSettings"
label="app.admin.settings.duration_minutes"
classes="col-md-4"
fa-icon="fa-clock-o"
min="1"
required="required">
</number-setting>
</div>
</div>
</div>
</div>

View File

@ -5,7 +5,7 @@ module ApplicationHelper
require 'message_format'
## machine/spaces availabilities are divided in multiple slots of 60 minutes
SLOT_DURATION ||= Rails.application.secrets.slot_duration || 60
SLOT_DURATION ||= Setting.get('slot_duration') || 60
##
# Verify if the provided attribute is in the provided attributes array, whatever it exists or not

View File

@ -78,7 +78,8 @@ class Setting < ApplicationRecord
uuid
phone_required
tracking_id
book_overlapping_slots] }
book_overlapping_slots
slot_duration] }
def value
last_value = history_values.order(HistoryValue.arel_table['created_at'].desc).first
last_value&.value

View File

@ -1022,6 +1022,7 @@ en:
phone_required: "phone required"
tracking_id: "tracking ID"
book_overlapping_slots: "book overlapping slots"
slot_duration: "slots duration"
elements_ordering: "Elements ordering"
machines_order: "Machines order"
display_machines_sorted_by: "Display machines sorted by"
@ -1031,6 +1032,9 @@ en:
an_error_occurred_saving_the_setting: "An error occurred while saving the setting. Please try again later."
book_overlapping_slots_info: "Allow / prevent the reservation of overlapping slots"
allow_booking: "Allow booking"
default_slot_duration: "Default duration for slots"
duration_minutes: "Duration (in minutes)"
default_slot_duration_info: "Machine and space availabilities are divided in multiple slots of this duration. This value can be overridden per availability."
sort_by:
default: "Default"
name: "Name"

View File

@ -1022,6 +1022,7 @@ fr:
phone_required: "téléphone requis"
tracking_id: "ID de suivi"
book_overlapping_slots: "réservation de créneaux simultanés"
slot_duration: "durée des créneaux"
elements_ordering: "Ordre d'affichage des éléments"
machines_order: "Ordre des machines"
display_machines_sorted_by: "Afficher les machines triées par"
@ -1031,6 +1032,9 @@ fr:
an_error_occurred_saving_the_setting: "Une erreur est survenue pendant l'enregistrement du paramètre. Veuillez réessayer plus tard."
book_overlapping_slots_info: "Autoriser / empêcher la réservation de créneaux qui se chevauchent"
allow_booking: "Autoriser la réservation"
default_slot_duration: "Durée par défaut pour les créneaux"
duration_minutes: "Durée (en minutes)"
default_slot_duration_info: "Les disponibilités des machines et des espaces sont divisées en plusieurs créneaux de cette durée. Cette valeur peur être changée pour chaque disponibilité."
sort_by:
default: "Défaut"
name: "Nom"

View File

@ -951,6 +951,12 @@ unless Setting.find_by(name: 'home_content').try(:value)
setting.save
end
unless Setting.find_by(name: 'slot_duration').try(:value)
setting = Setting.find_or_initialize_by(name: 'slot_duration')
setting.value = '60'
setting.save
end
if StatisticCustomAggregation.count.zero?
# available reservations hours for machines
machine_hours = StatisticType.find_by(key: 'hour', statistic_index_id: 2)

View File

@ -123,15 +123,6 @@ Set to 'false' if you don't want this behaviour.
EVENTS_IN_CALENDAR
If set to 'true', the admin calendar will display the scheduled events in the current view, as read-only items.
<a name="SLOT_DURATION"></a>
SLOT_DURATION
Machine and space availabilities are divided in multiple slots of the duration set by this variable.
Default value is 60 minutes (1 hour).
⚠ Changing this value during the application life may cause serious issues.
Please ensure there's no machine/space availabilities opened to reservation or already reserved **in the future** when you change this value.
<a name="DEFAULT_MAIL_FROM"></a>
DEFAULT_MAIL_FROM

View File

@ -106,7 +106,8 @@ namespace :fablab do
mapping = [
%w[PHONE_REQUIRED phone_required true],
%w[GA_ID tracking_id],
%w[BOOK_SLOT_AT_SAME_TIME book_overlapping_slots true]
%w[BOOK_SLOT_AT_SAME_TIME book_overlapping_slots true],
%w[SLOT_DURATION slot_duration 60]
]
mapping.each do |m|