Implemented error messages

Fixed window size for tablets
This commit is contained in:
Sviatoslav Tsariov Yurievich 2025-02-08 19:40:06 +03:00
parent 64e0bd0a51
commit 9219b863a0
9 changed files with 102 additions and 12 deletions

View File

@ -27,8 +27,9 @@ uuid="*res://addons/uuid/uuid.gd"
[display] [display]
window/size/viewport_width=1080 window/size/viewport_width=1920
window/size/viewport_height=2340 window/size/viewport_height=1000
window/stretch/mode="viewport"
window/stretch/aspect="keep_width" window/stretch/aspect="keep_width"
window/handheld/orientation=1 window/handheld/orientation=1

View File

@ -5,7 +5,7 @@ const ReservationScene = preload("res://scenes/board/reservation.tscn")
const ReservationIndent = preload("res://scenes/board/reservation_indent.tscn") const ReservationIndent = preload("res://scenes/board/reservation_indent.tscn")
const WorkingDayStart = 8 const WorkingDayStart = 8
const WorkingDayEnd = 21 const WorkingDayEnd = 20
const MinimalMinutesToShowTitle = 30 const MinimalMinutesToShowTitle = 30
@ -57,12 +57,12 @@ func _update_schedule():
var previous_finish_time = 0 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
var start_time_minutes = reservation.start_time['minutes'] var start_time_minutes = reservation.start_time.minutes
var start_time = (start_time_hours - WorkingDayStart)*60 + start_time_minutes var start_time = (start_time_hours - WorkingDayStart)*60 + start_time_minutes
var finish_time_hours = reservation.finish_time['hours'] var finish_time_hours = reservation.finish_time.hours
var finish_time_minutes = reservation.finish_time['minutes'] var finish_time_minutes = reservation.finish_time.minutes
var finish_time = (finish_time_hours - WorkingDayStart)*60 + finish_time_minutes var finish_time = (finish_time_hours - WorkingDayStart)*60 + finish_time_minutes
var reservation_time = finish_time - start_time var reservation_time = finish_time - start_time

View File

@ -0,0 +1,15 @@
extends HBoxContainer
@onready var _error_label := $ErrorLabel
var _text : String
func _ready():
set_message(String())
func get_message() -> String:
return _text
func set_message(value : String):
_error_label.text = _text
_error_label.text = value if value == "" else "" + value

View File

@ -0,0 +1,19 @@
[gd_scene load_steps=2 format=3 uid="uid://e73v63ysty2e"]
[ext_resource type="Theme" uid="uid://cmhwbyqu6nh38" path="res://assets/themes/big.tres" id="1_bo38g"]
[node name="ErrorBox" type="HBoxContainer"]
[node name="Control" type="Control" parent="."]
custom_minimum_size = Vector2(25, 0)
layout_mode = 2
[node name="ErrorLabel" type="Label" parent="."]
layout_mode = 2
size_flags_horizontal = 3
theme = ExtResource("1_bo38g")
theme_override_colors/font_color = Color(1, 0, 0, 1)
theme_override_colors/font_outline_color = Color(0, 0, 0, 1)
theme_override_constants/outline_size = 8
text = "❗ Время начала не может быть больше времени окончания"
autowrap_mode = 2

View File

@ -10,6 +10,11 @@ const BgColors = {
} }
const MinutesForTemporarilyFree := 15 const MinutesForTemporarilyFree := 15
enum Status {
FREE,
BUSY
}
@onready var _reservation_repo : AbstractReservationRepo = $Repos/Reservation @onready var _reservation_repo : AbstractReservationRepo = $Repos/Reservation
@export var current_page : Pages: @export var current_page : Pages:
@ -36,6 +41,7 @@ const MinutesForTemporarilyFree := 15
var _current_page := Pages.Board var _current_page := Pages.Board
var _previous_page : Pages var _previous_page : Pages
var _status : Status
func _ready(): func _ready():
initialize_signals() initialize_signals()
@ -72,20 +78,24 @@ func _process_status(time):
if current_time_in_minutes >= start_time_in_minutes \ if current_time_in_minutes >= start_time_in_minutes \
and current_time_in_minutes < finish_time_in_minutes: and current_time_in_minutes < finish_time_in_minutes:
_status = Status.BUSY
_status_label.text = "Занято" _status_label.text = "Занято"
_background.color = BgColors.busy _background.color = BgColors.busy
return return
elif current_time_in_minutes <= start_time_in_minutes \ elif current_time_in_minutes <= start_time_in_minutes \
and current_time_in_minutes + MinutesForTemporarilyFree > start_time_in_minutes: and current_time_in_minutes + MinutesForTemporarilyFree > start_time_in_minutes:
_status = Status.FREE
_status_label.text = "Свободно" _status_label.text = "Свободно"
_background.color = BgColors.temporarily_free _background.color = BgColors.temporarily_free
return return
if len(reservations) > 0: if len(reservations) > 0:
_status = Status.FREE
_status_label.text = "Свободно" _status_label.text = "Свободно"
_background.color = BgColors.free _background.color = BgColors.free
else: else:
_status = Status.FREE
_status_label.text = "Свободно" _status_label.text = "Свободно"
_background.color = BgColors.standart _background.color = BgColors.standart
@ -119,6 +129,9 @@ func _get_time_status_indent():
return _time_status_indent.custom_minimum_size.y return _time_status_indent.custom_minimum_size.y
func _create_default_reservation(minutes_of_reservation): func _create_default_reservation(minutes_of_reservation):
if _status == Status.BUSY:
return
var datetime = Time.get_datetime_dict_from_system() var datetime = Time.get_datetime_dict_from_system()
var start_time_in_minutes = datetime.hour * 60 + datetime.minute var start_time_in_minutes = datetime.hour * 60 + datetime.minute
var finish_time_in_minutes = start_time_in_minutes + minutes_of_reservation var finish_time_in_minutes = start_time_in_minutes + minutes_of_reservation

View File

@ -39,7 +39,7 @@ color = Color(0.133333, 0.14902, 0.176471, 1)
layout_mode = 1 layout_mode = 1
anchors_preset = 9 anchors_preset = 9
anchor_bottom = 1.0 anchor_bottom = 1.0
offset_right = 1576.0 offset_right = 1781.0
grow_vertical = 2 grow_vertical = 2
[node name="Pages" type="BoxContainer" parent="Left"] [node name="Pages" type="BoxContainer" parent="Left"]
@ -64,15 +64,18 @@ size_flags_horizontal = 3
[node name="TimeStatusContainer" type="VBoxContainer" parent="Left"] [node name="TimeStatusContainer" type="VBoxContainer" parent="Left"]
layout_mode = 2 layout_mode = 2
size_flags_horizontal = 10
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, 206.667) custom_minimum_size = Vector2(0, 277.333)
layout_mode = 2 layout_mode = 2
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 = "23:32" text = "17:52"
horizontal_alignment = 1 horizontal_alignment = 1
[node name="StatusLabel" type="Label" parent="Left/TimeStatusContainer"] [node name="StatusLabel" type="Label" parent="Left/TimeStatusContainer"]
@ -138,3 +141,17 @@ 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="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

View File

@ -1,8 +1,10 @@
[gd_scene load_steps=7 format=3 uid="uid://csfn8q6b5hj4y"] [gd_scene load_steps=9 format=3 uid="uid://csfn8q6b5hj4y"]
[ext_resource type="Theme" uid="uid://cmhwbyqu6nh38" path="res://assets/themes/big.tres" id="1_j1bkw"] [ext_resource type="Theme" uid="uid://cmhwbyqu6nh38" path="res://assets/themes/big.tres" id="1_j1bkw"]
[ext_resource type="Script" path="res://scenes/reservation/reservation_page.gd" id="1_prqr3"] [ext_resource type="Script" path="res://scenes/reservation/reservation_page.gd" id="1_prqr3"]
[ext_resource type="PackedScene" uid="uid://d0fdiesiaajlq" path="res://scenes/common/edit_field.tscn" id="2_qfs8j"] [ext_resource type="PackedScene" uid="uid://d0fdiesiaajlq" path="res://scenes/common/edit_field.tscn" id="2_qfs8j"]
[ext_resource type="PackedScene" uid="uid://e73v63ysty2e" path="res://scenes/common/error_box.tscn" id="4_ja64k"]
[ext_resource type="Script" path="res://scenes/common/error_box.gd" id="5_bbsyh"]
[sub_resource type="StyleBoxFlat" id="StyleBoxFlat_dlqbv"] [sub_resource type="StyleBoxFlat" id="StyleBoxFlat_dlqbv"]
bg_color = Color(0.6, 0.6, 0.6, 0) bg_color = Color(0.6, 0.6, 0.6, 0)
@ -120,6 +122,10 @@ custom_minimum_size = Vector2(0, 5)
layout_mode = 2 layout_mode = 2
theme_override_styles/panel = SubResource("StyleBoxFlat_r7q2r") theme_override_styles/panel = SubResource("StyleBoxFlat_r7q2r")
[node name="ErrorBox" parent="." instance=ExtResource("4_ja64k")]
layout_mode = 2
script = ExtResource("5_bbsyh")
[node name="BottomBar" type="BoxContainer" parent="."] [node name="BottomBar" type="BoxContainer" parent="."]
visible = false visible = false
layout_mode = 2 layout_mode = 2

View File

@ -1,8 +1,10 @@
[gd_scene load_steps=6 format=3 uid="uid://cu6e3hfdorwcg"] [gd_scene load_steps=8 format=3 uid="uid://cu6e3hfdorwcg"]
[ext_resource type="Script" path="res://scenes/reservation/reservation_page.gd" id="1_81iob"] [ext_resource type="Script" path="res://scenes/reservation/reservation_page.gd" id="1_81iob"]
[ext_resource type="Theme" uid="uid://cmhwbyqu6nh38" path="res://assets/themes/big.tres" id="2_57fpn"] [ext_resource type="Theme" uid="uid://cmhwbyqu6nh38" path="res://assets/themes/big.tres" id="2_57fpn"]
[ext_resource type="PackedScene" uid="uid://d0fdiesiaajlq" path="res://scenes/common/edit_field.tscn" id="3_lh5s8"] [ext_resource type="PackedScene" uid="uid://d0fdiesiaajlq" path="res://scenes/common/edit_field.tscn" id="3_lh5s8"]
[ext_resource type="PackedScene" uid="uid://e73v63ysty2e" path="res://scenes/common/error_box.tscn" id="4_vg752"]
[ext_resource type="Script" path="res://scenes/common/error_box.gd" id="5_xmu5c"]
[sub_resource type="StyleBoxFlat" id="StyleBoxFlat_dlqbv"] [sub_resource type="StyleBoxFlat" id="StyleBoxFlat_dlqbv"]
bg_color = Color(0.6, 0.6, 0.6, 0) bg_color = Color(0.6, 0.6, 0.6, 0)
@ -115,6 +117,10 @@ custom_minimum_size = Vector2(0, 5)
layout_mode = 2 layout_mode = 2
theme_override_styles/panel = SubResource("StyleBoxFlat_yafv8") theme_override_styles/panel = SubResource("StyleBoxFlat_yafv8")
[node name="ErrorBox" parent="." instance=ExtResource("4_vg752")]
layout_mode = 2
script = ExtResource("5_xmu5c")
[node name="BottomBar" type="BoxContainer" parent="."] [node name="BottomBar" type="BoxContainer" parent="."]
layout_mode = 2 layout_mode = 2
alignment = 2 alignment = 2

View File

@ -14,6 +14,7 @@ enum Types {
@onready var _back_button := $TopBar/BackButton @onready var _back_button := $TopBar/BackButton
@onready var _apply_button := $TopBar/ApplyButton @onready var _apply_button := $TopBar/ApplyButton
@onready var _delete_button := $BottomBar/DeleteButton @onready var _delete_button := $BottomBar/DeleteButton
@onready var _error_box := $ErrorBox
@onready var _title_field := $TitleField @onready var _title_field := $TitleField
@onready var _date_field := $DateField @onready var _date_field := $DateField
@ -25,6 +26,7 @@ enum Types {
func _ready(): func _ready():
initialize_signals() initialize_signals()
_error_box.set_message(String())
func initialize_signals(): func initialize_signals():
_back_button.pressed.connect(_on_back_button_pressed) _back_button.pressed.connect(_on_back_button_pressed)
@ -114,6 +116,7 @@ func _fields_are_correct():
if len(_title_field.get_value()) < 1: if len(_title_field.get_value()) < 1:
print("The title is not entered.") print("The title is not entered.")
_error_box.set_message("Не введено название встречи")
successful = false successful = false
if not _time_is_correct(): if not _time_is_correct():
@ -125,6 +128,14 @@ func _time_is_correct():
var start_time = _start_time_field.get_value() var start_time = _start_time_field.get_value()
var finish_time = _finish_time_field.get_value() var finish_time = _finish_time_field.get_value()
var time_is_not_entered = \
start_time["hours"] == 0 and start_time["minutes"] == 0 or \
finish_time["hours"] == 0 and finish_time["minutes"] == 0
if time_is_not_entered:
_error_box.set_message("Введите время начала и окончания встречи")
return false
var start_time_is_after_finish_time = \ var start_time_is_after_finish_time = \
start_time["hours"] > finish_time["hours"] or \ start_time["hours"] > finish_time["hours"] or \
(start_time["hours"] == finish_time["hours"] and \ (start_time["hours"] == finish_time["hours"] and \
@ -132,6 +143,7 @@ func _time_is_correct():
if start_time_is_after_finish_time: if start_time_is_after_finish_time:
print("Start time should not be more than or equal to finish time.") print("Start time should not be more than or equal to finish time.")
_error_box.set_message("Время начала не может быть больше времени окончания")
return false return false
var repo = _main.get_reservation_repo() var repo = _main.get_reservation_repo()
@ -168,6 +180,7 @@ func _time_is_correct():
if is_busy: if is_busy:
print("The selected time slot is busy.") print("The selected time slot is busy.")
_error_box.set_message("Выбранный временной интервал занят")
return false return false
return true return true