Fixed wrong reservaiton time view
Redone reservation indent logic Web build added
This commit is contained in:
parent
9219b863a0
commit
db273bab0b
@ -203,3 +203,44 @@ permissions/write_user_dictionary=false
|
|||||||
dotnet/include_scripts_content=false
|
dotnet/include_scripts_content=false
|
||||||
dotnet/include_debug_symbols=false
|
dotnet/include_debug_symbols=false
|
||||||
dotnet/embed_build_outputs=false
|
dotnet/embed_build_outputs=false
|
||||||
|
|
||||||
|
[preset.1]
|
||||||
|
|
||||||
|
name="Web"
|
||||||
|
platform="Web"
|
||||||
|
runnable=true
|
||||||
|
dedicated_server=false
|
||||||
|
custom_features=""
|
||||||
|
export_filter="all_resources"
|
||||||
|
include_filter=""
|
||||||
|
exclude_filter=""
|
||||||
|
export_path=""
|
||||||
|
encryption_include_filters=""
|
||||||
|
encryption_exclude_filters=""
|
||||||
|
encrypt_pck=false
|
||||||
|
encrypt_directory=false
|
||||||
|
|
||||||
|
[preset.1.options]
|
||||||
|
|
||||||
|
custom_template/debug=""
|
||||||
|
custom_template/release=""
|
||||||
|
variant/extensions_support=false
|
||||||
|
vram_texture_compression/for_desktop=true
|
||||||
|
vram_texture_compression/for_mobile=false
|
||||||
|
html/export_icon=true
|
||||||
|
html/custom_html_shell=""
|
||||||
|
html/head_include=""
|
||||||
|
html/canvas_resize_policy=2
|
||||||
|
html/focus_canvas_on_start=true
|
||||||
|
html/experimental_virtual_keyboard=false
|
||||||
|
progressive_web_app/enabled=false
|
||||||
|
progressive_web_app/offline_page=""
|
||||||
|
progressive_web_app/display=1
|
||||||
|
progressive_web_app/orientation=0
|
||||||
|
progressive_web_app/icon_144x144=""
|
||||||
|
progressive_web_app/icon_180x180=""
|
||||||
|
progressive_web_app/icon_512x512=""
|
||||||
|
progressive_web_app/background_color=Color(0, 0, 0, 1)
|
||||||
|
dotnet/include_scripts_content=false
|
||||||
|
dotnet/include_debug_symbols=true
|
||||||
|
dotnet/embed_build_outputs=false
|
||||||
|
@ -2,12 +2,12 @@ extends VBoxContainer
|
|||||||
|
|
||||||
const TimeSlot = preload("res://scenes/board/time_slot.tscn")
|
const TimeSlot = preload("res://scenes/board/time_slot.tscn")
|
||||||
const ReservationScene = preload("res://scenes/board/reservation.tscn")
|
const ReservationScene = preload("res://scenes/board/reservation.tscn")
|
||||||
const ReservationIndent = preload("res://scenes/board/reservation_indent.tscn")
|
|
||||||
|
|
||||||
const WorkingDayStart = 8
|
const WorkingDayStart = 8
|
||||||
const WorkingDayEnd = 20
|
const WorkingDayEnd = 20
|
||||||
|
|
||||||
const MinimalMinutesToShowTitle = 30
|
const MinimalMinutesToShowTitle = 30
|
||||||
|
const MinimalMinutesForBigSize = 60
|
||||||
|
|
||||||
@onready var _main: Main = get_tree().get_current_scene()
|
@onready var _main: Main = get_tree().get_current_scene()
|
||||||
@onready var _timeline = $Panel/Timeline
|
@onready var _timeline = $Panel/Timeline
|
||||||
@ -54,7 +54,6 @@ func _update_schedule():
|
|||||||
await _main.ready
|
await _main.ready
|
||||||
|
|
||||||
var repo = _main.get_reservation_repo()
|
var repo = _main.get_reservation_repo()
|
||||||
var previous_finish_time = 0
|
|
||||||
|
|
||||||
for reservation in repo.list_reservations():
|
for reservation in repo.list_reservations():
|
||||||
var start_time_hours = reservation.start_time.hours
|
var start_time_hours = reservation.start_time.hours
|
||||||
@ -67,27 +66,24 @@ func _update_schedule():
|
|||||||
|
|
||||||
var reservation_time = finish_time - start_time
|
var reservation_time = finish_time - start_time
|
||||||
|
|
||||||
_compose_indent(start_time - previous_finish_time)
|
_compose_reservation(start_time, reservation_time, \
|
||||||
_compose_reservation(reservation_time, reservation.title, reservation.color, reservation.id)
|
reservation.title, reservation.color, reservation.id)
|
||||||
|
|
||||||
previous_finish_time = finish_time
|
func _compose_reservation(start_time, duration_time, title, color, id):
|
||||||
|
if duration_time < MinimalMinutesToShowTitle:
|
||||||
func _compose_indent(minutes):
|
|
||||||
var indent = ReservationIndent.instantiate()
|
|
||||||
_reservations.add_child(indent)
|
|
||||||
indent.set_minutes(minutes)
|
|
||||||
|
|
||||||
func _compose_reservation(minutes, title, color, id):
|
|
||||||
if minutes < MinimalMinutesToShowTitle:
|
|
||||||
title = ""
|
title = ""
|
||||||
|
|
||||||
var reservation = ReservationScene.instantiate()
|
var reservation = ReservationScene.instantiate()
|
||||||
_reservations.add_child(reservation)
|
_reservations.add_child(reservation)
|
||||||
reservation.set_minutes(minutes)
|
reservation.set_start_time(start_time)
|
||||||
|
reservation.set_duration_time(duration_time)
|
||||||
reservation.set_title(title)
|
reservation.set_title(title)
|
||||||
reservation.set_color(color)
|
reservation.set_color(color)
|
||||||
reservation.set_id(id)
|
reservation.set_id(id)
|
||||||
|
|
||||||
|
if duration_time < MinimalMinutesForBigSize:
|
||||||
|
reservation.set_font(reservation.Fonts.MEDIUM)
|
||||||
|
|
||||||
func _input(event):
|
func _input(event):
|
||||||
if not _main.get_current_page() == Main.Pages.Board:
|
if not _main.get_current_page() == Main.Pages.Board:
|
||||||
return
|
return
|
||||||
|
@ -1,9 +1,8 @@
|
|||||||
[gd_scene load_steps=7 format=3 uid="uid://c431r28ef5edp"]
|
[gd_scene load_steps=6 format=3 uid="uid://c431r28ef5edp"]
|
||||||
|
|
||||||
[ext_resource type="Script" path="res://scenes/board/board.gd" id="1_2wgc4"]
|
[ext_resource type="Script" path="res://scenes/board/board.gd" id="1_2wgc4"]
|
||||||
[ext_resource type="Theme" uid="uid://cmhwbyqu6nh38" path="res://assets/themes/big.tres" id="1_na0ey"]
|
[ext_resource type="Theme" uid="uid://cmhwbyqu6nh38" path="res://assets/themes/big.tres" id="1_na0ey"]
|
||||||
[ext_resource type="PackedScene" uid="uid://cnr23ry08ntv4" path="res://scenes/board/time_slot.tscn" id="2_kklmx"]
|
[ext_resource type="PackedScene" uid="uid://cnr23ry08ntv4" path="res://scenes/board/time_slot.tscn" id="2_kklmx"]
|
||||||
[ext_resource type="PackedScene" uid="uid://blv30rxduydmw" path="res://scenes/board/reservation_indent.tscn" id="3_mltgm"]
|
|
||||||
[ext_resource type="PackedScene" uid="uid://dpi5ft4r8sfwb" path="res://scenes/board/reservation.tscn" id="4_o5rhy"]
|
[ext_resource type="PackedScene" uid="uid://dpi5ft4r8sfwb" path="res://scenes/board/reservation.tscn" id="4_o5rhy"]
|
||||||
[ext_resource type="Script" path="res://scenes/board/current_time.gd" id="6_8jgig"]
|
[ext_resource type="Script" path="res://scenes/board/current_time.gd" id="6_8jgig"]
|
||||||
|
|
||||||
@ -76,15 +75,14 @@ size_flags_horizontal = 3
|
|||||||
size_flags_vertical = 0
|
size_flags_vertical = 0
|
||||||
color = Color(1, 1, 1, 0.556863)
|
color = Color(1, 1, 1, 0.556863)
|
||||||
|
|
||||||
[node name="Reservations" type="VBoxContainer" parent="Panel"]
|
[node name="Reservations" type="Control" parent="Panel"]
|
||||||
layout_mode = 2
|
layout_mode = 2
|
||||||
|
anchors_preset = 0
|
||||||
offset_top = 50.0
|
offset_top = 50.0
|
||||||
offset_right = 1036.0
|
offset_right = 1036.0
|
||||||
offset_bottom = 117.0
|
offset_bottom = 117.0
|
||||||
grow_horizontal = 2
|
grow_horizontal = 2
|
||||||
|
|
||||||
[node name="Indent" parent="Panel/Reservations" instance=ExtResource("3_mltgm")]
|
|
||||||
layout_mode = 2
|
|
||||||
|
|
||||||
[node name="Reservation" parent="Panel/Reservations" instance=ExtResource("4_o5rhy")]
|
[node name="Reservation" parent="Panel/Reservations" instance=ExtResource("4_o5rhy")]
|
||||||
layout_mode = 2
|
layout_mode = 2
|
||||||
|
offset_right = 1036.0
|
||||||
|
@ -21,5 +21,6 @@ func _set_current_time(minutes):
|
|||||||
if minutes == 0:
|
if minutes == 0:
|
||||||
_bg.custom_minimum_size.y = 0
|
_bg.custom_minimum_size.y = 0
|
||||||
else:
|
else:
|
||||||
var hour_size = get_viewport_rect().size.y/15
|
var hour_size := get_viewport_rect().size.y/15
|
||||||
_bg.custom_minimum_size.y = minutes * hour_size / 60
|
var additional_height = 0.65*floor(minutes/12)
|
||||||
|
_bg.custom_minimum_size.y = minutes * hour_size / 60 + additional_height
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
extends HBoxContainer
|
extends Control
|
||||||
class_name Reservation
|
class_name Reservation
|
||||||
|
|
||||||
const Colors = {
|
const Colors = {
|
||||||
@ -7,9 +7,15 @@ const Colors = {
|
|||||||
3: Color("eb7130d6")
|
3: Color("eb7130d6")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
enum Fonts {
|
||||||
|
BIG,
|
||||||
|
MEDIUM
|
||||||
|
}
|
||||||
|
|
||||||
@onready var _main: Main = get_tree().get_current_scene()
|
@onready var _main: Main = get_tree().get_current_scene()
|
||||||
@onready var _title = $Section/SectionLabel
|
@onready var _title = $Vertical/Horizontal/Section/SectionPanel/SectionLabel
|
||||||
@onready var _panel = $Section/SectionPanel
|
@onready var _panel = $Vertical/Horizontal/Section/SectionPanel
|
||||||
|
@onready var _indent = $Vertical/Indent
|
||||||
|
|
||||||
var _hour_size : int
|
var _hour_size : int
|
||||||
var _minutes : int
|
var _minutes : int
|
||||||
@ -32,7 +38,10 @@ func initialize_signals():
|
|||||||
func set_title(title):
|
func set_title(title):
|
||||||
_title.text = title
|
_title.text = title
|
||||||
|
|
||||||
func set_minutes(minutes):
|
func set_start_time(minutes):
|
||||||
|
_indent.set_minutes(minutes)
|
||||||
|
|
||||||
|
func set_duration_time(minutes):
|
||||||
_minutes = minutes
|
_minutes = minutes
|
||||||
|
|
||||||
func set_color(color):
|
func set_color(color):
|
||||||
@ -40,6 +49,13 @@ func set_color(color):
|
|||||||
new_style_box.bg_color = Colors[color]
|
new_style_box.bg_color = Colors[color]
|
||||||
_panel.set("theme_override_styles/panel", new_style_box)
|
_panel.set("theme_override_styles/panel", new_style_box)
|
||||||
|
|
||||||
|
func set_font(font: Fonts):
|
||||||
|
match font:
|
||||||
|
Fonts.BIG:
|
||||||
|
_title.theme = load("res://assets/themes/big.tres")
|
||||||
|
Fonts.MEDIUM:
|
||||||
|
_title.theme = load("res://assets/themes/medium.tres")
|
||||||
|
|
||||||
func set_id(id):
|
func set_id(id):
|
||||||
_id = id
|
_id = id
|
||||||
|
|
||||||
|
@ -1,39 +1,53 @@
|
|||||||
[gd_scene load_steps=4 format=3 uid="uid://dpi5ft4r8sfwb"]
|
[gd_scene load_steps=5 format=3 uid="uid://dpi5ft4r8sfwb"]
|
||||||
|
|
||||||
[ext_resource type="Script" path="res://scenes/board/reservation.gd" id="1_drhpx"]
|
[ext_resource type="Script" path="res://scenes/board/reservation.gd" id="1_drhpx"]
|
||||||
[ext_resource type="Theme" uid="uid://cmhwbyqu6nh38" path="res://assets/themes/big.tres" id="2_vfg04"]
|
[ext_resource type="Theme" uid="uid://cmhwbyqu6nh38" path="res://assets/themes/big.tres" id="2_vfg04"]
|
||||||
|
[ext_resource type="PackedScene" uid="uid://blv30rxduydmw" path="res://scenes/board/reservation_indent.tscn" id="2_wxy5l"]
|
||||||
[ext_resource type="StyleBox" uid="uid://crantichmjy77" path="res://assets/themes/panel_cyan.tres" id="3_xwx35"]
|
[ext_resource type="StyleBox" uid="uid://crantichmjy77" path="res://assets/themes/panel_cyan.tres" id="3_xwx35"]
|
||||||
|
|
||||||
[node name="Reservation" type="HBoxContainer"]
|
[node name="Reservation" type="Control"]
|
||||||
custom_minimum_size = Vector2(0, 200)
|
custom_minimum_size = Vector2(0, 200)
|
||||||
|
layout_mode = 3
|
||||||
|
anchors_preset = 0
|
||||||
offset_right = 157.0
|
offset_right = 157.0
|
||||||
offset_bottom = 200.0
|
offset_bottom = 200.0
|
||||||
script = ExtResource("1_drhpx")
|
script = ExtResource("1_drhpx")
|
||||||
|
|
||||||
[node name="Indent" type="Label" parent="."]
|
[node name="Vertical" type="VBoxContainer" parent="."]
|
||||||
|
layout_mode = 0
|
||||||
|
offset_right = 40.0
|
||||||
|
offset_bottom = 40.0
|
||||||
|
|
||||||
|
[node name="Indent" parent="Vertical" instance=ExtResource("2_wxy5l")]
|
||||||
|
layout_mode = 2
|
||||||
|
|
||||||
|
[node name="Horizontal" type="HBoxContainer" parent="Vertical"]
|
||||||
|
layout_mode = 2
|
||||||
|
|
||||||
|
[node name="Indent" type="Label" parent="Vertical/Horizontal"]
|
||||||
layout_mode = 2
|
layout_mode = 2
|
||||||
theme = ExtResource("2_vfg04")
|
theme = ExtResource("2_vfg04")
|
||||||
theme_override_colors/font_color = Color(0, 0, 0, 0)
|
theme_override_colors/font_color = Color(0, 0, 0, 0)
|
||||||
text = "11:00 "
|
text = "11:00 "
|
||||||
|
|
||||||
[node name="Section" type="Control" parent="."]
|
[node name="Section" type="Control" parent="Vertical/Horizontal"]
|
||||||
layout_mode = 2
|
layout_mode = 2
|
||||||
|
|
||||||
[node name="SectionPanel" type="Panel" parent="Section"]
|
[node name="SectionPanel" type="Panel" parent="Vertical/Horizontal/Section"]
|
||||||
layout_mode = 1
|
layout_mode = 1
|
||||||
offset_right = 883.0
|
offset_right = 883.0
|
||||||
offset_bottom = 200.0
|
offset_bottom = 200.0
|
||||||
size_flags_horizontal = 3
|
size_flags_horizontal = 3
|
||||||
theme_override_styles/panel = ExtResource("3_xwx35")
|
theme_override_styles/panel = ExtResource("3_xwx35")
|
||||||
|
|
||||||
[node name="SectionLabel" type="Label" parent="Section"]
|
[node name="SectionLabel" type="Label" parent="Vertical/Horizontal/Section/SectionPanel"]
|
||||||
layout_mode = 1
|
layout_mode = 1
|
||||||
anchors_preset = 4
|
anchors_preset = 4
|
||||||
anchor_top = 0.5
|
anchor_top = 0.5
|
||||||
anchor_bottom = 0.5
|
anchor_bottom = 0.5
|
||||||
offset_left = 50.0
|
offset_left = 20.0
|
||||||
offset_top = -33.5
|
offset_top = -33.5
|
||||||
offset_right = 396.0
|
offset_right = 366.0
|
||||||
offset_bottom = 33.5
|
offset_bottom = 33.5
|
||||||
grow_vertical = 2
|
grow_vertical = 2
|
||||||
theme = ExtResource("2_vfg04")
|
theme = ExtResource("2_vfg04")
|
||||||
|
@ -4,7 +4,7 @@ var _minutes : int
|
|||||||
|
|
||||||
func _process(delta):
|
func _process(delta):
|
||||||
var hour_size = get_viewport_rect().size.y/15
|
var hour_size = get_viewport_rect().size.y/15
|
||||||
var additional_height = get_viewport_rect().size.y/468
|
var additional_height = 0.65*floor(_minutes/12)
|
||||||
custom_minimum_size.y = _minutes * hour_size / 60 + additional_height
|
custom_minimum_size.y = _minutes * hour_size / 60 + additional_height
|
||||||
|
|
||||||
func set_minutes(minutes):
|
func set_minutes(minutes):
|
||||||
|
163
scenes/main/maiC545.tmp
Normal file
163
scenes/main/maiC545.tmp
Normal file
@ -0,0 +1,163 @@
|
|||||||
|
[gd_scene load_steps=13 format=3 uid="uid://bkrvh8vjpgqot"]
|
||||||
|
|
||||||
|
[ext_resource type="Script" path="res://scenes/main/main_tablet.gd" id="1_fr6s5"]
|
||||||
|
[ext_resource type="PackedScene" uid="uid://c431r28ef5edp" path="res://scenes/board/board.tscn" id="2_n47h4"]
|
||||||
|
[ext_resource type="PackedScene" uid="uid://csfn8q6b5hj4y" path="res://scenes/reservation/reservation_creation.tscn" id="3_j6x1g"]
|
||||||
|
[ext_resource type="PackedScene" uid="uid://cu6e3hfdorwcg" path="res://scenes/reservation/reservation_edit.tscn" id="4_hyj5n"]
|
||||||
|
[ext_resource type="PackedScene" uid="uid://cxs8xe5w32jo4" path="res://scenes/common/time/time_setting.tscn" id="4_wyf5q"]
|
||||||
|
[ext_resource type="Script" path="res://src/infra/repos/local/reservation.gd" id="5_6h0eq"]
|
||||||
|
[ext_resource type="Theme" uid="uid://byopik87nb8vv" path="res://assets/themes/status_font.tres" id="5_atujq"]
|
||||||
|
[ext_resource type="Theme" uid="uid://yn1nbokvmv6n" path="res://assets/themes/small.tres" id="6_nde4h"]
|
||||||
|
[ext_resource type="Theme" uid="uid://b8tbd62jtmgdx" path="res://assets/themes/instant_button_font.tres" id="8_bmn8p"]
|
||||||
|
[ext_resource type="Theme" uid="uid://cmhwbyqu6nh38" path="res://assets/themes/big.tres" id="9_wpf8g"]
|
||||||
|
[ext_resource type="Script" path="res://src/domain/services/reservation.gd" id="11_5xy2x"]
|
||||||
|
|
||||||
|
[sub_resource type="StyleBoxFlat" id="StyleBoxFlat_uus54"]
|
||||||
|
bg_color = Color(0.6, 0.6, 0.6, 0)
|
||||||
|
border_width_top = 3
|
||||||
|
border_color = Color(0.8, 0.8, 0.8, 0.392157)
|
||||||
|
|
||||||
|
[node name="Main" type="Control"]
|
||||||
|
layout_mode = 3
|
||||||
|
anchor_left = 0.02
|
||||||
|
anchor_top = 0.01
|
||||||
|
anchor_right = 0.98
|
||||||
|
anchor_bottom = 0.99
|
||||||
|
grow_horizontal = 2
|
||||||
|
grow_vertical = 2
|
||||||
|
script = ExtResource("1_fr6s5")
|
||||||
|
|
||||||
|
[node name="Background" type="ColorRect" parent="."]
|
||||||
|
layout_mode = 1
|
||||||
|
anchors_preset = 15
|
||||||
|
anchor_right = 1.0
|
||||||
|
anchor_bottom = 1.0
|
||||||
|
grow_horizontal = 2
|
||||||
|
grow_vertical = 2
|
||||||
|
color = Color(0.133333, 0.14902, 0.176471, 1)
|
||||||
|
|
||||||
|
[node name="Left" type="HBoxContainer" parent="."]
|
||||||
|
layout_mode = 1
|
||||||
|
anchors_preset = 9
|
||||||
|
anchor_bottom = 1.0
|
||||||
|
offset_right = 1781.0
|
||||||
|
grow_vertical = 2
|
||||||
|
|
||||||
|
[node name="Pages" type="BoxContainer" parent="Left"]
|
||||||
|
custom_minimum_size = Vector2(1200, 0)
|
||||||
|
layout_mode = 2
|
||||||
|
|
||||||
|
[node name="Board" parent="Left/Pages" instance=ExtResource("2_n47h4")]
|
||||||
|
layout_mode = 2
|
||||||
|
|
||||||
|
[node name="ReservationCreation" parent="Left/Pages" instance=ExtResource("3_j6x1g")]
|
||||||
|
visible = false
|
||||||
|
layout_mode = 2
|
||||||
|
|
||||||
|
[node name="ReservationEdit" parent="Left/Pages" instance=ExtResource("4_hyj5n")]
|
||||||
|
visible = false
|
||||||
|
layout_mode = 2
|
||||||
|
|
||||||
|
[node name="TimeSetting" parent="Left/Pages" instance=ExtResource("4_wyf5q")]
|
||||||
|
visible = false
|
||||||
|
layout_mode = 2
|
||||||
|
size_flags_horizontal = 3
|
||||||
|
|
||||||
|
[node name="TimeStatusContainer" type="VBoxContainer" parent="Left"]
|
||||||
|
layout_mode = 2
|
||||||
|
size_flags_horizontal = 10
|
||||||
|
size_flags_vertical = 0
|
||||||
|
|
||||||
|
[node name="Indent" type="BoxContainer" parent="Left/TimeStatusContainer"]
|
||||||
|
custom_minimum_size = Vector2(0, 0.666667)
|
||||||
|
layout_mode = 2
|
||||||
|
size_flags_vertical = 3
|
||||||
|
|
||||||
|
[node name="TimeLabel" type="Label" parent="Left/TimeStatusContainer"]
|
||||||
|
layout_mode = 2
|
||||||
|
theme = ExtResource("5_atujq")
|
||||||
|
text = "12:35"
|
||||||
|
horizontal_alignment = 1
|
||||||
|
|
||||||
|
[node name="StatusLabel" type="Label" parent="Left/TimeStatusContainer"]
|
||||||
|
layout_mode = 2
|
||||||
|
theme = ExtResource("5_atujq")
|
||||||
|
text = "Свободно"
|
||||||
|
horizontal_alignment = 1
|
||||||
|
|
||||||
|
[node name="ReserveNowBox" type="VBoxContainer" parent="Left/TimeStatusContainer"]
|
||||||
|
layout_mode = 2
|
||||||
|
theme_override_constants/separation = 20
|
||||||
|
|
||||||
|
[node name="Splitter3" type="Panel" parent="Left/TimeStatusContainer/ReserveNowBox"]
|
||||||
|
custom_minimum_size = Vector2(0, 5)
|
||||||
|
layout_mode = 2
|
||||||
|
theme_override_styles/panel = SubResource("StyleBoxFlat_uus54")
|
||||||
|
|
||||||
|
[node name="ReserveNowLabel" type="Label" parent="Left/TimeStatusContainer/ReserveNowBox"]
|
||||||
|
layout_mode = 2
|
||||||
|
theme = ExtResource("6_nde4h")
|
||||||
|
text = "Забронировать сейчас на"
|
||||||
|
horizontal_alignment = 1
|
||||||
|
|
||||||
|
[node name="InstantButtons" type="HBoxContainer" parent="Left/TimeStatusContainer/ReserveNowBox"]
|
||||||
|
layout_mode = 2
|
||||||
|
theme = ExtResource("8_bmn8p")
|
||||||
|
theme_override_constants/separation = 25
|
||||||
|
|
||||||
|
[node name="_15min" type="Button" parent="Left/TimeStatusContainer/ReserveNowBox/InstantButtons"]
|
||||||
|
layout_mode = 2
|
||||||
|
text = "15 мин"
|
||||||
|
|
||||||
|
[node name="_30min" type="Button" parent="Left/TimeStatusContainer/ReserveNowBox/InstantButtons"]
|
||||||
|
layout_mode = 2
|
||||||
|
text = "30 мин"
|
||||||
|
|
||||||
|
[node name="_45min" type="Button" parent="Left/TimeStatusContainer/ReserveNowBox/InstantButtons"]
|
||||||
|
layout_mode = 2
|
||||||
|
text = "45 мин"
|
||||||
|
|
||||||
|
[node name="_1h" type="Button" parent="Left/TimeStatusContainer/ReserveNowBox/InstantButtons"]
|
||||||
|
layout_mode = 2
|
||||||
|
text = "1 час"
|
||||||
|
|
||||||
|
[node name="RightBottom" type="BoxContainer" parent="."]
|
||||||
|
layout_mode = 1
|
||||||
|
anchors_preset = 3
|
||||||
|
anchor_left = 1.0
|
||||||
|
anchor_top = 1.0
|
||||||
|
anchor_right = 1.0
|
||||||
|
anchor_bottom = 1.0
|
||||||
|
offset_left = -40.0
|
||||||
|
offset_top = -40.0
|
||||||
|
grow_horizontal = 0
|
||||||
|
grow_vertical = 0
|
||||||
|
|
||||||
|
[node name="CreateReservationButton" type="Button" parent="RightBottom"]
|
||||||
|
layout_mode = 2
|
||||||
|
theme = ExtResource("9_wpf8g")
|
||||||
|
text = "Забронировать"
|
||||||
|
|
||||||
|
[node name="Repos" type="Node" parent="."]
|
||||||
|
|
||||||
|
[node name="Reservation" type="Node" parent="Repos"]
|
||||||
|
script = ExtResource("5_6h0eq")
|
||||||
|
|
||||||
|
[node name="Services" type="Node" parent="."]
|
||||||
|
|
||||||
|
[node name="ReservationService" type="Node" parent="Services"]
|
||||||
|
script = ExtResource("11_5xy2x")
|
||||||
|
|
||||||
|
[node name="DialogBox" type="VBoxContainer" parent="."]
|
||||||
|
layout_mode = 1
|
||||||
|
anchors_preset = 8
|
||||||
|
anchor_left = 0.5
|
||||||
|
anchor_top = 0.5
|
||||||
|
anchor_right = 0.5
|
||||||
|
anchor_bottom = 0.5
|
||||||
|
offset_left = -20.0
|
||||||
|
offset_top = -20.0
|
||||||
|
offset_right = 20.0
|
||||||
|
offset_bottom = 20.0
|
||||||
|
grow_horizontal = 2
|
||||||
|
grow_vertical = 2
|
@ -19,3 +19,6 @@ func go_to_previous_page(with_update=true):
|
|||||||
|
|
||||||
func get_reservation_repo() -> AbstractReservationRepo:
|
func get_reservation_repo() -> AbstractReservationRepo:
|
||||||
return AbstractReservationRepo.new()
|
return AbstractReservationRepo.new()
|
||||||
|
|
||||||
|
func get_reservation_service() -> ReservationService:
|
||||||
|
return ReservationService.new()
|
||||||
|
@ -16,6 +16,7 @@ enum Status {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@onready var _reservation_repo : AbstractReservationRepo = $Repos/Reservation
|
@onready var _reservation_repo : AbstractReservationRepo = $Repos/Reservation
|
||||||
|
@onready var _reservation_service : ReservationService = $Services/ReservationService
|
||||||
|
|
||||||
@export var current_page : Pages:
|
@export var current_page : Pages:
|
||||||
set(value):
|
set(value):
|
||||||
@ -122,6 +123,9 @@ func go_to_previous_page(with_update=true):
|
|||||||
func get_reservation_repo() -> AbstractReservationRepo:
|
func get_reservation_repo() -> AbstractReservationRepo:
|
||||||
return _reservation_repo
|
return _reservation_repo
|
||||||
|
|
||||||
|
func get_reservation_service() -> ReservationService:
|
||||||
|
return _reservation_service
|
||||||
|
|
||||||
func _set_time_status_indent(value):
|
func _set_time_status_indent(value):
|
||||||
_time_status_indent.custom_minimum_size.y = value
|
_time_status_indent.custom_minimum_size.y = value
|
||||||
|
|
||||||
@ -138,6 +142,9 @@ func _create_default_reservation(minutes_of_reservation):
|
|||||||
var finish_time_hours = floor(finish_time_in_minutes/60)
|
var finish_time_hours = floor(finish_time_in_minutes/60)
|
||||||
var finish_time_minutes = finish_time_in_minutes - finish_time_hours * 60
|
var finish_time_minutes = finish_time_in_minutes - finish_time_hours * 60
|
||||||
|
|
||||||
|
if get_reservation_service().is_time_busy(start_time_in_minutes, finish_time_in_minutes):
|
||||||
|
return
|
||||||
|
|
||||||
var dto = CreateReservationDTO.new()
|
var dto = CreateReservationDTO.new()
|
||||||
dto.title = ""
|
dto.title = ""
|
||||||
dto.date = "%02d.%02d.%04d" % [datetime.day, datetime.month, datetime.year]
|
dto.date = "%02d.%02d.%04d" % [datetime.day, datetime.month, datetime.year]
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
[gd_scene load_steps=12 format=3 uid="uid://bkrvh8vjpgqot"]
|
[gd_scene load_steps=13 format=3 uid="uid://bkrvh8vjpgqot"]
|
||||||
|
|
||||||
[ext_resource type="Script" path="res://scenes/main/main_tablet.gd" id="1_fr6s5"]
|
[ext_resource type="Script" path="res://scenes/main/main_tablet.gd" id="1_fr6s5"]
|
||||||
[ext_resource type="PackedScene" uid="uid://c431r28ef5edp" path="res://scenes/board/board.tscn" id="2_n47h4"]
|
[ext_resource type="PackedScene" uid="uid://c431r28ef5edp" path="res://scenes/board/board.tscn" id="2_n47h4"]
|
||||||
@ -10,6 +10,7 @@
|
|||||||
[ext_resource type="Theme" uid="uid://yn1nbokvmv6n" path="res://assets/themes/small.tres" id="6_nde4h"]
|
[ext_resource type="Theme" uid="uid://yn1nbokvmv6n" path="res://assets/themes/small.tres" id="6_nde4h"]
|
||||||
[ext_resource type="Theme" uid="uid://b8tbd62jtmgdx" path="res://assets/themes/instant_button_font.tres" id="8_bmn8p"]
|
[ext_resource type="Theme" uid="uid://b8tbd62jtmgdx" path="res://assets/themes/instant_button_font.tres" id="8_bmn8p"]
|
||||||
[ext_resource type="Theme" uid="uid://cmhwbyqu6nh38" path="res://assets/themes/big.tres" id="9_wpf8g"]
|
[ext_resource type="Theme" uid="uid://cmhwbyqu6nh38" path="res://assets/themes/big.tres" id="9_wpf8g"]
|
||||||
|
[ext_resource type="Script" path="res://src/domain/services/reservation.gd" id="11_5xy2x"]
|
||||||
|
|
||||||
[sub_resource type="StyleBoxFlat" id="StyleBoxFlat_uus54"]
|
[sub_resource type="StyleBoxFlat" id="StyleBoxFlat_uus54"]
|
||||||
bg_color = Color(0.6, 0.6, 0.6, 0)
|
bg_color = Color(0.6, 0.6, 0.6, 0)
|
||||||
@ -68,14 +69,14 @@ size_flags_horizontal = 10
|
|||||||
size_flags_vertical = 0
|
size_flags_vertical = 0
|
||||||
|
|
||||||
[node name="Indent" type="BoxContainer" parent="Left/TimeStatusContainer"]
|
[node name="Indent" type="BoxContainer" parent="Left/TimeStatusContainer"]
|
||||||
custom_minimum_size = Vector2(0, 277.333)
|
custom_minimum_size = Vector2(0, 206.667)
|
||||||
layout_mode = 2
|
layout_mode = 2
|
||||||
size_flags_vertical = 3
|
size_flags_vertical = 3
|
||||||
|
|
||||||
[node name="TimeLabel" type="Label" parent="Left/TimeStatusContainer"]
|
[node name="TimeLabel" type="Label" parent="Left/TimeStatusContainer"]
|
||||||
layout_mode = 2
|
layout_mode = 2
|
||||||
theme = ExtResource("5_atujq")
|
theme = ExtResource("5_atujq")
|
||||||
text = "17:52"
|
text = "16:21"
|
||||||
horizontal_alignment = 1
|
horizontal_alignment = 1
|
||||||
|
|
||||||
[node name="StatusLabel" type="Label" parent="Left/TimeStatusContainer"]
|
[node name="StatusLabel" type="Label" parent="Left/TimeStatusContainer"]
|
||||||
@ -142,6 +143,11 @@ text = "Забронировать"
|
|||||||
[node name="Reservation" type="Node" parent="Repos"]
|
[node name="Reservation" type="Node" parent="Repos"]
|
||||||
script = ExtResource("5_6h0eq")
|
script = ExtResource("5_6h0eq")
|
||||||
|
|
||||||
|
[node name="Services" type="Node" parent="."]
|
||||||
|
|
||||||
|
[node name="ReservationService" type="Node" parent="Services"]
|
||||||
|
script = ExtResource("11_5xy2x")
|
||||||
|
|
||||||
[node name="DialogBox" type="VBoxContainer" parent="."]
|
[node name="DialogBox" type="VBoxContainer" parent="."]
|
||||||
layout_mode = 1
|
layout_mode = 1
|
||||||
anchors_preset = 8
|
anchors_preset = 8
|
||||||
|
@ -146,42 +146,15 @@ func _time_is_correct():
|
|||||||
_error_box.set_message("Время начала не может быть больше времени окончания")
|
_error_box.set_message("Время начала не может быть больше времени окончания")
|
||||||
return false
|
return false
|
||||||
|
|
||||||
var repo = _main.get_reservation_repo()
|
var start_time_in_minutes = start_time.hours*60 + start_time.minutes
|
||||||
var reservations = repo.list_reservations()
|
var finish_time_in_minutes = finish_time.hours*60 + finish_time.minutes
|
||||||
var current_reservation_id = repo.get_current_reservation_id()
|
var service = _main.get_reservation_service()
|
||||||
|
var is_busy = service.is_time_busy(start_time_in_minutes, finish_time_in_minutes)
|
||||||
|
|
||||||
var new_start_time_minutes = start_time["hours"]*60 + start_time["minutes"]
|
if is_busy:
|
||||||
var new_finish_time_minutes = finish_time["hours"]*60 + finish_time["minutes"]
|
print("The selected time slot is busy.")
|
||||||
|
_error_box.set_message("Выбранный временной интервал занят")
|
||||||
for reservation in reservations:
|
return false
|
||||||
if reservation.id == current_reservation_id:
|
|
||||||
continue
|
|
||||||
|
|
||||||
var other_start_time = reservation.start_time
|
|
||||||
var other_finish_time = reservation.finish_time
|
|
||||||
var other_start_time_minutes = other_start_time["hours"]*60 + other_start_time["minutes"]
|
|
||||||
var other_finish_time_minutes = other_finish_time["hours"]*60 + other_finish_time["minutes"]
|
|
||||||
|
|
||||||
var is_busy = (
|
|
||||||
(
|
|
||||||
new_start_time_minutes >= other_start_time_minutes and
|
|
||||||
new_start_time_minutes < other_finish_time_minutes
|
|
||||||
) or (
|
|
||||||
new_finish_time_minutes > other_start_time_minutes and
|
|
||||||
new_finish_time_minutes <= other_finish_time_minutes
|
|
||||||
) or (
|
|
||||||
new_start_time_minutes >= other_start_time_minutes and
|
|
||||||
new_finish_time_minutes <= other_finish_time_minutes
|
|
||||||
) or (
|
|
||||||
new_start_time_minutes <= other_start_time_minutes and
|
|
||||||
new_finish_time_minutes >= other_finish_time_minutes
|
|
||||||
)
|
|
||||||
)
|
|
||||||
|
|
||||||
if is_busy:
|
|
||||||
print("The selected time slot is busy.")
|
|
||||||
_error_box.set_message("Выбранный временной интервал занят")
|
|
||||||
return false
|
|
||||||
|
|
||||||
return true
|
return true
|
||||||
|
|
||||||
|
39
src/domain/services/reservation.gd
Normal file
39
src/domain/services/reservation.gd
Normal file
@ -0,0 +1,39 @@
|
|||||||
|
extends Node
|
||||||
|
class_name ReservationService
|
||||||
|
|
||||||
|
@onready var _main: Main = get_tree().get_current_scene()
|
||||||
|
|
||||||
|
func is_time_busy(new_start_time_minutes, new_finish_time_minutes):
|
||||||
|
var repo = _main.get_reservation_repo()
|
||||||
|
var reservations = repo.list_reservations()
|
||||||
|
var current_reservation_id = repo.get_current_reservation_id()
|
||||||
|
|
||||||
|
for reservation in reservations:
|
||||||
|
if reservation.id == current_reservation_id:
|
||||||
|
continue
|
||||||
|
|
||||||
|
var other_start_time = reservation.start_time
|
||||||
|
var other_finish_time = reservation.finish_time
|
||||||
|
var other_start_time_minutes = other_start_time.hours*60 + other_start_time.minutes
|
||||||
|
var other_finish_time_minutes = other_finish_time.hours*60 + other_finish_time.minutes
|
||||||
|
|
||||||
|
var is_busy = (
|
||||||
|
(
|
||||||
|
new_start_time_minutes >= other_start_time_minutes and
|
||||||
|
new_start_time_minutes < other_finish_time_minutes
|
||||||
|
) or (
|
||||||
|
new_finish_time_minutes > other_start_time_minutes and
|
||||||
|
new_finish_time_minutes <= other_finish_time_minutes
|
||||||
|
) or (
|
||||||
|
new_start_time_minutes >= other_start_time_minutes and
|
||||||
|
new_finish_time_minutes <= other_finish_time_minutes
|
||||||
|
) or (
|
||||||
|
new_start_time_minutes <= other_start_time_minutes and
|
||||||
|
new_finish_time_minutes >= other_finish_time_minutes
|
||||||
|
)
|
||||||
|
)
|
||||||
|
|
||||||
|
if is_busy:
|
||||||
|
return true
|
||||||
|
|
||||||
|
return false
|
Loading…
x
Reference in New Issue
Block a user