1
0
mirror of https://github.com/LaCasemate/fab-manager.git synced 2025-02-19 13:54:25 +01:00

UI to configure the spaces module

This commit is contained in:
Sylvain 2020-05-26 10:53:49 +02:00
parent acefc325f6
commit fd93093f0d
9 changed files with 52 additions and 16 deletions

View File

@ -1018,13 +1018,13 @@ angular.module('application.router', ['ui.router'])
resolve: {
settingsPromise: ['Setting', function (Setting) {
return Setting.query({
names: `['twitter_name', 'about_title', 'about_body', 'tracking_id',\
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', 'slot_duration', \
'training_information_message', 'subscription_explications_alert', 'event_explications_alert', \
'space_explications_alert', 'booking_window_start', 'booking_window_end', 'events_in_calendar', \
'booking_move_enable', 'booking_move_delay', 'booking_cancel_enable', \
'booking_cancel_delay', 'main_color', 'secondary_color', \
'booking_cancel_delay', 'main_color', 'secondary_color', 'spaces_module', \
'fablab_name', 'name_genre', 'reminder_enable', \
'reminder_delay', 'visibility_yearly', 'visibility_others', \
'display_name_enable', 'machines_sort_by', 'fab_analytics', \

View File

@ -347,3 +347,21 @@
</div>
</div>
</div>
<div class="panel panel-default m-t-lg">
<div class="panel-heading">
<span class="font-sbold" translate>{{ 'app.admin.settings.modules' }}</span>
</div>
<div class="panel-body">
<div class="row">
<h3 class="m-l" translate>{{ 'app.admin.settings.spaces' }}</h3>
<p class="alert alert-warning m-h-md" ng-bind-html="'app.admin.settings.spaces_info_html' | translate"></p>
<boolean-setting name="spaces_module"
settings="allSettings"
label="app.admin.settings.enable_spaces"
classes="m-l"
yes-label="app.shared.buttons.yes"
no-label="app.shared.buttons.no"></boolean-setting>
</div>
</div>
</div>

View File

@ -41,9 +41,7 @@
<boolean-setting
name="fab_analytics"
settings="allSettings"
label="app.admin.settings.fab_analytics"
yes-label="app.shared.buttons.yes"
no-label="app.shared.buttons.no">
label="app.admin.settings.fab_analytics">
</boolean-setting>
<p>
<span translate>{{ 'app.admin.settings.privacy.about_analytics' }}</span>

View File

@ -132,7 +132,7 @@
<boolean-setting name="display_name_enable" settings="allSettings" label="app.admin.settings.display_name" classes="m-l"></boolean-setting>
</div>
<div class="row">
<h3 class="m-l" translate>{{ 'app.admin.settings.events_in_calendar' }}</h3>
<h3 class="m-l" translate>{{ 'app.admin.settings.events_in_the_calendar' }}</h3>
<p class="alert alert-warning m-h-md" translate>{{ 'app.admin.settings.events_in_calendar_info' }}</p>
<boolean-setting name="events_in_calendar" settings="allSettings" label="app.admin.settings.show_event" classes="m-l"></boolean-setting>
</div>

View File

@ -13,7 +13,7 @@ module ApplicationHelper
attributes.try(:include?, attribute)
end
def bootstrap_class_for flash_type
def bootstrap_class_for(flash_type)
{ flash: 'alert-success', alert: 'alert-danger', notice: 'alert-info' }[flash_type.to_sym] || flash_type.to_s
end
@ -57,6 +57,10 @@ module ApplicationHelper
bool ? :true : :false # rubocop:disable Lint/BooleanSymbol
end
def str_to_bool(str, default = 'true')
str.to_s.casecmp(default).zero?
end
def amount_to_f(amount)
amount / 100.00
end

View File

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

View File

@ -1040,6 +1040,10 @@ en:
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."
modules: "Modules"
spaces: "Spaces"
spaces_info_html: "<p>A space can be, for example, a woodshop or a meeting room. Their particularity is that they can be booked by several people at the same time.</p><p><strong>Warning:</strong> It is not recommended to disable spaces if at least one space reservation was made on the system.</p>"
enable_spaces: "Enable the spaces"
sort_by:
default: "Default"
name: "Name"

View File

@ -1040,6 +1040,10 @@ fr:
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é."
modules: "Modules"
spaces: "Espaces"
spaces_info_html: "<p>Un espace peut-être, par exemple, un atelier bois ou une salle de réunion. Leur particularité est qu'ils peuvent être réservés par plusieurs personnes en même temps.</p><p><strong>Attention :</strong> Il n'est pas recommandé de désactiver les espaces is au moins une réservation est en cours sur un espace.</p>"
enable_spaces: "Activer les espaces"
sort_by:
default: "Défaut"
name: "Nom"

View File

@ -103,18 +103,25 @@ namespace :fablab do
desc 'migrate environment variables to the database (settings)'
task env_to_db: :environment do
include ApplicationHelper
mapping = [
%w[PHONE_REQUIRED phone_required true],
%w[GA_ID tracking_id],
%w[BOOK_SLOT_AT_SAME_TIME book_overlapping_slots true],
%w[SLOT_DURATION slot_duration 60],
%w[EVENTS_IN_CALENDAR events_in_calendar false]
%w[_ PHONE_REQUIRED phone_required true],
%w[_ GA_ID tracking_id],
%w[_ BOOK_SLOT_AT_SAME_TIME book_overlapping_slots true],
%w[_ SLOT_DURATION slot_duration 60],
%w[_ EVENTS_IN_CALENDAR events_in_calendar false],
%w[! FABLAB_WITHOUT_SPACES spaces_module]
]
mapping.each do |m|
setting = Setting.find_or_initialize_by(name: m[1])
setting.value = ENV.fetch(m[0], m[2])
setting.save if setting.value
setting = Setting.find_or_initialize_by(name: m[2])
value = ENV.fetch(m[1], m[3])
next unless value
value = (!str_to_bool(value)).to_s if m[0] == '!'
setting.value = value
setting.save
end
end
end