Added back button
Fixed creating and updating reservation
This commit is contained in:
parent
6e6a86379b
commit
cea005967b
@ -98,7 +98,7 @@ body {
|
||||
|
||||
<script src="Talkpal.js"></script>
|
||||
<script>
|
||||
const GODOT_CONFIG = {"args":[],"canvasResizePolicy":2,"ensureCrossOriginIsolationHeaders":true,"executable":"Talkpal","experimentalVK":true,"fileSizes":{"Talkpal.pck":6411808,"Talkpal.wasm":43016933},"focusCanvas":true,"gdextensionLibs":[],"serviceWorker":"Talkpal.service.worker.js"};
|
||||
const GODOT_CONFIG = {"args":[],"canvasResizePolicy":2,"ensureCrossOriginIsolationHeaders":true,"executable":"Talkpal","experimentalVK":true,"fileSizes":{"Talkpal.pck":6412800,"Talkpal.wasm":43016933},"focusCanvas":true,"gdextensionLibs":[],"serviceWorker":"Talkpal.service.worker.js"};
|
||||
const GODOT_THREADS_ENABLED = false;
|
||||
const engine = new Engine(GODOT_CONFIG);
|
||||
|
||||
|
Binary file not shown.
@ -4,7 +4,7 @@
|
||||
// Incrementing CACHE_VERSION will kick off the install event and force
|
||||
// previously cached resources to be updated from the network.
|
||||
/** @type {string} */
|
||||
const CACHE_VERSION = '1743076500|1018147123';
|
||||
const CACHE_VERSION = '1743107090|18821095';
|
||||
/** @type {string} */
|
||||
const CACHE_PREFIX = 'Talkpal-sw-cache-';
|
||||
const CACHE_NAME = CACHE_PREFIX + CACHE_VERSION;
|
||||
|
@ -14,7 +14,7 @@ script = ExtResource("1_2wxyg")
|
||||
[node name="TimeEdit" type="LineEdit" parent="."]
|
||||
visible = false
|
||||
layout_mode = 2
|
||||
text = "14:38 "
|
||||
text = "21:34 "
|
||||
placeholder_text = "hh:mm (a/p)m"
|
||||
script = ExtResource("2_7d4ae")
|
||||
current_time = true
|
||||
|
@ -41,6 +41,8 @@ enum Status {
|
||||
@onready var _will_be_available_label := $Left/TimeStatusContainer/WillBeAvailableLabel
|
||||
@onready var _background := $Background
|
||||
|
||||
@onready var _back_button := $LeftBottom/BackButton
|
||||
|
||||
@onready var _create_reservation_button := $RightBottom/CreateReservationButton
|
||||
@onready var _reserve_now_label := $Left/TimeStatusContainer/ReserveNowBox/ReserveNowLabel
|
||||
@onready var _15_min_button := $Left/TimeStatusContainer/ReserveNowBox/InstantButtons/_15min
|
||||
@ -62,6 +64,7 @@ func _ready():
|
||||
func initialize_signals():
|
||||
_event_handler.reservations_updated.connect(_on_reservations_updated)
|
||||
_create_reservation_button.pressed.connect(_on_create_reservation_button_pressed)
|
||||
_back_button.pressed.connect(_on_back_button_pressed)
|
||||
_15_min_button.pressed.connect(_on_15_min_button_pressed)
|
||||
_30_min_button.pressed.connect(_on_30_min_button_pressed)
|
||||
_45_min_button.pressed.connect(_on_45_min_button_pressed)
|
||||
@ -139,7 +142,8 @@ func _update_ui_status(status: Status, text: String, color: Color):
|
||||
_background.color = color
|
||||
|
||||
func _process_fonts():
|
||||
_process_font_size(_create_reservation_button, 35)
|
||||
_process_font_size(_back_button, 25)
|
||||
_process_font_size(_create_reservation_button, 25)
|
||||
|
||||
func _process_font_size(obj, k):
|
||||
var font_size = obj.get_theme_default_font_size()
|
||||
@ -168,6 +172,7 @@ func load_page(value, with_update=true):
|
||||
_change_page_with_delay(previous_page)
|
||||
_change_create_reservation_button_visibility(_current_page)
|
||||
_update_reserve_now_label_text()
|
||||
_update_back_button()
|
||||
|
||||
return _pages[_current_page]
|
||||
|
||||
@ -281,6 +286,9 @@ func _on_reservations_updated(reservations):
|
||||
func _on_create_reservation_button_pressed():
|
||||
load_page(Pages.ReservationCreation)
|
||||
|
||||
func _on_back_button_pressed():
|
||||
go_to_previous_page(false)
|
||||
|
||||
func _on_15_min_button_pressed():
|
||||
_create_default_reservation(15)
|
||||
|
||||
@ -305,3 +313,10 @@ func _update_reserve_now_label_text():
|
||||
_reserve_now_label.text = "Продлить на"
|
||||
else:
|
||||
_reserve_now_label.text = "Забронировать сейчас на"
|
||||
|
||||
func _update_back_button():
|
||||
await get_tree().create_timer(0.1, false).timeout
|
||||
if _current_page in [Pages.TimeSetting, Pages.CalendarSetting, Pages.RoomSelection]:
|
||||
_back_button.show()
|
||||
else:
|
||||
_back_button.hide()
|
||||
|
@ -85,14 +85,14 @@ size_flags_horizontal = 10
|
||||
size_flags_vertical = 0
|
||||
|
||||
[node name="Indent" type="BoxContainer" parent="Left/TimeStatusContainer"]
|
||||
custom_minimum_size = Vector2(0, 0.666667)
|
||||
custom_minimum_size = Vector2(0, 195)
|
||||
layout_mode = 2
|
||||
size_flags_vertical = 3
|
||||
|
||||
[node name="TimeLabel" type="Label" parent="Left/TimeStatusContainer"]
|
||||
layout_mode = 2
|
||||
theme = ExtResource("5_atujq")
|
||||
text = "14:44"
|
||||
text = "23:18"
|
||||
horizontal_alignment = 1
|
||||
|
||||
[node name="StatusLabel" type="Label" parent="Left/TimeStatusContainer"]
|
||||
@ -142,6 +142,22 @@ text = "45 мин"
|
||||
layout_mode = 2
|
||||
text = "1 час"
|
||||
|
||||
[node name="LeftBottom" type="BoxContainer" parent="."]
|
||||
layout_mode = 1
|
||||
anchors_preset = 2
|
||||
anchor_top = 1.0
|
||||
anchor_bottom = 1.0
|
||||
offset_top = -40.0
|
||||
offset_right = 160.0
|
||||
grow_vertical = 0
|
||||
|
||||
[node name="BackButton" type="Button" parent="LeftBottom"]
|
||||
visible = false
|
||||
layout_mode = 2
|
||||
theme = ExtResource("9_wpf8g")
|
||||
theme_override_font_sizes/font_size = 23
|
||||
text = " Назад "
|
||||
|
||||
[node name="RightBottom" type="BoxContainer" parent="."]
|
||||
layout_mode = 1
|
||||
anchors_preset = 3
|
||||
@ -157,7 +173,7 @@ grow_vertical = 0
|
||||
[node name="CreateReservationButton" type="Button" parent="RightBottom"]
|
||||
layout_mode = 2
|
||||
theme = ExtResource("9_wpf8g")
|
||||
theme_override_font_sizes/font_size = 0
|
||||
theme_override_font_sizes/font_size = 23
|
||||
text = " Забронировать "
|
||||
|
||||
[node name="Repos" type="Node" parent="."]
|
||||
|
@ -181,6 +181,9 @@ func _time_is_correct():
|
||||
if _time_or_date_is_before_now(start_time):
|
||||
return false
|
||||
|
||||
if _finish_time_is_before_now(finish_time):
|
||||
return false
|
||||
|
||||
if _start_time_is_after_finish_time(start_time, finish_time):
|
||||
return false
|
||||
|
||||
@ -201,28 +204,53 @@ func _time_is_not_entered(start_time: Dictionary, finish_time: Dictionary):
|
||||
return false
|
||||
|
||||
func _time_or_date_is_before_now(start_time: Dictionary):
|
||||
var time_is_before_now = _time_is_before_current_time(start_time)
|
||||
var start_time_is_before_now = _time_is_before_current_time(start_time)
|
||||
var date_is_before_now = _main.date_is_before_current_date(_date_field.get_value())
|
||||
|
||||
if time_is_before_now or date_is_before_now:
|
||||
var time_and_date_are_not_updated = \
|
||||
_main.get_current_page() == Main.Pages.ReservationEdit \
|
||||
and _time_and_date_are_not_updated()
|
||||
|
||||
if (start_time_is_before_now and time_and_date_are_not_updated and _date_is_today()) \
|
||||
or date_is_before_now:
|
||||
_error_box.set_message("Нельзя зарезервировать на прошедшее время")
|
||||
return true
|
||||
|
||||
return false
|
||||
|
||||
func _time_is_before_current_time(time) -> bool:
|
||||
if _main.get_current_page() == Main.Pages.ReservationEdit and _reservation:
|
||||
var selected_start_time = get_start_time()
|
||||
if selected_start_time.hours == _reservation.start_time.hours and \
|
||||
selected_start_time.minutes == _reservation.start_time.minutes:
|
||||
return false
|
||||
func _finish_time_is_before_now(finish_time: Dictionary):
|
||||
var finish_time_is_before_now = _time_is_before_current_time(finish_time)
|
||||
|
||||
if finish_time_is_before_now and _date_is_today():
|
||||
_error_box.set_message("Время окончания должно быть позже текущего времени")
|
||||
return true
|
||||
|
||||
func _date_is_today():
|
||||
var current_date = Utils._date_to_number(_main.get_current_date())
|
||||
var selected_date = Utils._date_to_number(_date_field.get_value())
|
||||
return current_date == selected_date
|
||||
|
||||
func _time_is_before_current_time(time) -> bool:
|
||||
var current_time = Time.get_time_dict_from_system()
|
||||
var time_in_minutes = time.hours*60 + time.minutes
|
||||
var current_time_in_minutes = current_time.hour*60 + current_time.minute
|
||||
print(time_in_minutes, ' ', current_time_in_minutes)
|
||||
|
||||
return time_in_minutes < current_time_in_minutes
|
||||
|
||||
func _time_and_date_are_not_updated():
|
||||
if _reservation:
|
||||
var reservation_date = Utils._date_to_number(_reservation.date)
|
||||
var selected_date = Utils._date_to_number(_date_field.get_value())
|
||||
|
||||
var selected_start_time = get_start_time()
|
||||
if selected_start_time.hours == _reservation.start_time.hours and \
|
||||
selected_start_time.minutes == _reservation.start_time.minutes and \
|
||||
reservation_date == selected_date:
|
||||
return true
|
||||
|
||||
return false
|
||||
|
||||
func _start_time_is_after_finish_time(start_time: Dictionary, finish_time: Dictionary):
|
||||
var start_time_is_after_finish_time = \
|
||||
start_time["hours"] > finish_time["hours"] or \
|
||||
|
@ -2,7 +2,7 @@
|
||||
extends AbstractRoomRepo
|
||||
class_name RoomRepoHTTP
|
||||
|
||||
const BASE_URL = "http://-localhost:5004"
|
||||
const BASE_URL = "http://localhost:5004"
|
||||
|
||||
signal rooms_loaded(rooms: Array[RoomEntity])
|
||||
signal request_failed(error_message: String)
|
||||
|
Loading…
x
Reference in New Issue
Block a user