minor admin portal changes

This commit is contained in:
dingo
2026-03-02 08:37:51 -05:00
parent 0a1796cd77
commit d3e39f9511
20 changed files with 869 additions and 587 deletions
@@ -1,24 +1,19 @@
[gd_scene load_steps=2 format=3]
[gd_scene load_steps=2 format=3 uid="uid://ca8qmqtdwyt1s"]
[ext_resource type="Script" path="res://scenes/collection/views/cars_view.gd" id="1_cv"]
[ext_resource type="Script" uid="uid://d26atv3dne7jl" path="res://scenes/collection/views/cards_view.gd" id="1_cv"]
[node name="CardsView" type="VBoxContainer"]
layout_mode = 2
script = ExtResource("1_cv")
[node name="FilterBar" type="VBoxContainer" parent="."]
layout_mode = 2
theme_override_constants/separation = 6
theme_override_constants/margin_left = 8
theme_override_constants/margin_right = 8
theme_override_constants/margin_top = 8
theme_override_constants/margin_bottom = 8
[node name="SearchInput" type="LineEdit" parent="FilterBar"]
unique_name_in_owner = true
layout_mode = 2
placeholder_text = "Search cards…"
theme_override_font_sizes/font_size = 14
placeholder_text = "Search cards…"
[node name="FilterRow" type="HBoxContainer" parent="FilterBar"]
layout_mode = 2
@@ -49,42 +44,42 @@ theme_override_constants/separation = 0
[node name="CardGridMargin" type="MarginContainer" parent="Scroll/ScrollInner"]
layout_mode = 2
theme_override_constants/margin_left = 8
theme_override_constants/margin_right = 8
theme_override_constants/margin_top = 8
theme_override_constants/margin_right = 8
theme_override_constants/margin_bottom = 8
[node name="CardGrid" type="GridContainer" parent="Scroll/ScrollInner/CardGridMargin"]
unique_name_in_owner = true
layout_mode = 2
size_flags_horizontal = 3
columns = 2
theme_override_constants/h_separation = 8
theme_override_constants/v_separation = 8
columns = 2
[node name="StatusRow" type="HBoxContainer" parent="Scroll/ScrollInner"]
layout_mode = 2
custom_minimum_size = Vector2(0, 44)
layout_mode = 2
alignment = 1
[node name="LoadingLabel" type="Label" parent="Scroll/ScrollInner/StatusRow"]
unique_name_in_owner = true
modulate = Color(0.75, 0.75, 0.8, 1)
layout_mode = 2
text = "Loading…"
modulate = Color(0.75, 0.75, 0.8, 1.0)
theme_override_font_sizes/font_size = 14
text = "Loading…"
[node name="EmptyLabel" type="Label" parent="Scroll/ScrollInner/StatusRow"]
unique_name_in_owner = true
layout_mode = 2
text = "No cards found."
visible = false
modulate = Color(0.6, 0.6, 0.65, 1.0)
modulate = Color(0.6, 0.6, 0.65, 1)
layout_mode = 2
theme_override_font_sizes/font_size = 14
text = "No cards found."
[node name="LoadMoreBtn" type="Button" parent="Scroll/ScrollInner/StatusRow"]
unique_name_in_owner = true
layout_mode = 2
custom_minimum_size = Vector2(120, 36)
text = "Load More"
visible = false
custom_minimum_size = Vector2(120, 36)
layout_mode = 2
theme_override_font_sizes/font_size = 14
text = "Load More"
@@ -1,6 +1,7 @@
[gd_scene load_steps=2 format=3]
[gd_scene load_steps=3 format=3]
[ext_resource type="Script" path="res://scenes/collection/views/decks_view.gd" id="1_dv"]
[ext_resource type="Script" path="res://scenes/collection/components/deck_editor_panel.gd" id="2_dep"]
[node name="DecksView" type="VBoxContainer"]
layout_mode = 2
@@ -142,6 +143,13 @@ visible = false
modulate = Color(0.6, 0.6, 0.65, 1.0)
theme_override_font_sizes/font_size = 14
[node name="DeckEditorPanel" type="VBoxContainer" parent="."]
unique_name_in_owner = true
layout_mode = 2
size_flags_vertical = 3
visible = false
script = ExtResource("2_dep")
[node name="ConfirmDialog" type="ConfirmationDialog" parent="."]
unique_name_in_owner = true
title = "Confirm Delete"
@@ -1,179 +0,0 @@
extends VBoxContainer
## Cards tab — paginated, filterable grid of the player's owned cards.
##
## Fetches from collection.get_cards (page, pageSize, nameFilter?,
## cardTypeFilter?, affinityFilter?). Displays results as CardWidget
## instances in a responsive GridContainer.
##
## Typing in the search box starts a 0.4 s debounce before reloading.
## "Load More" appends the next page without clearing the existing cards.
const CARD_WIDGET := preload("res://scenes/collection/components/CardWidget.tscn")
const PAGE_SIZE := 20
# ── Node references ───────────────────────────────────────────────────────────
@onready var search_input : LineEdit = %SearchInput
@onready var type_option : OptionButton = %TypeOption
@onready var affinity_option : OptionButton = %AffinityOption
@onready var card_grid : GridContainer = %CardGrid
@onready var loading_label : Label = %LoadingLabel
@onready var empty_label : Label = %EmptyLabel
@onready var load_more_btn : Button = %LoadMoreBtn
# ── State ─────────────────────────────────────────────────────────────────────
var _current_page : int = 1
var _total_count : int = 0
var _has_more : bool = false
var _loading : bool = false
var _search_timer : float = 0.0
const _SEARCH_DEBOUNCE := 0.4
# Emitted when the user taps a card — parent uses this to show the detail popup.
signal card_selected(dto: Dictionary, def: Dictionary)
# ── Lifecycle ─────────────────────────────────────────────────────────────────
func _ready() -> void:
_populate_type_options()
_populate_affinity_options()
_update_columns()
search_input.text_changed.connect(_on_search_changed)
type_option.item_selected.connect(func(_i): _reload())
affinity_option.item_selected.connect(func(_i): _reload())
load_more_btn.pressed.connect(_on_load_more)
get_viewport().size_changed.connect(_update_columns)
_reload()
func _exit_tree() -> void:
if get_viewport() and get_viewport().size_changed.is_connected(_update_columns):
get_viewport().size_changed.disconnect(_update_columns)
func _process(delta: float) -> void:
if _search_timer > 0.0:
_search_timer -= delta
if _search_timer <= 0.0:
_search_timer = 0.0
_reload()
# ── Option population ─────────────────────────────────────────────────────────
func _populate_type_options() -> void:
type_option.clear()
type_option.add_item("All Types")
for t in ["Creature", "Spell", "Item", "ArchSpirit"]:
type_option.add_item(t)
func _populate_affinity_options() -> void:
affinity_option.clear()
affinity_option.add_item("All Affinities")
for a in [
# Basic
"Void", "Aether", "Lake", "Hill", "Forest", "Field",
# Non-basic
"Ocean", "Island", "Marsh", "Swamp",
"Mountain", "Steppe", "Fort",
"Plains", "Grove", "Jungle",
"PerfectAether", "PureVoid",
]:
affinity_option.add_item(a)
# ── Responsive columns ────────────────────────────────────────────────────────
func _update_columns() -> void:
var vp_w := get_viewport_rect().size.x
card_grid.columns = max(2, int(vp_w / 160))
# ── Data fetching ─────────────────────────────────────────────────────────────
func _reload() -> void:
_current_page = 1
_total_count = 0
_has_more = false
for child in card_grid.get_children():
child.queue_free()
_fetch_page(1)
func _fetch_page(page: int) -> void:
if _loading:
return
_loading = true
_set_status("loading")
var payload := {
"page": page,
"pageSize": PAGE_SIZE,
}
var search := search_input.text.strip_edges()
if not search.is_empty():
payload["nameFilter"] = search
# Type filter — index 0 = "All Types" (skip)
var type_idx := type_option.selected
if type_idx > 0:
payload["cardTypeFilter"] = type_option.get_item_text(type_idx)
# Affinity filter — index 0 = "All Affinities" (skip)
var aff_idx := affinity_option.selected
if aff_idx > 0:
payload["affinityFilter"] = affinity_option.get_item_text(aff_idx)
Network.request(
"collection.get_cards",
payload,
func(_t: String, p: Variant): _on_cards_response(p, page),
func(_code: String, msg: String): _on_error(msg)
)
func _on_cards_response(payload: Variant, page: int) -> void:
_loading = false
var p := payload as Dictionary
var cards : Array = p.get("cards", [])
_total_count = int(p.get("totalCount", 0))
var page_size : int = int(p.get("pageSize", PAGE_SIZE))
_current_page = page
_has_more = (page * page_size) < _total_count
for dto in cards:
var def := ContentCache.get_definition(str(dto.get("cardDefinitionId", "")))
var widget = CARD_WIDGET.instantiate() as PanelContainer
widget.setup(dto, def)
widget.card_pressed.connect(func(_def_id: String):
card_selected.emit(dto, def))
card_grid.add_child(widget)
if cards.is_empty() and page == 1:
_set_status("empty")
else:
_set_status("done")
load_more_btn.visible = _has_more
func _on_error(msg: String) -> void:
_loading = false
_set_status("empty")
push_warning("CardsView: %s" % msg)
# ── Button handlers ───────────────────────────────────────────────────────────
func _on_search_changed(_text: String) -> void:
_search_timer = _SEARCH_DEBOUNCE
func _on_load_more() -> void:
_fetch_page(_current_page + 1)
# ── Status helper ─────────────────────────────────────────────────────────────
func _set_status(state: String) -> void:
loading_label.visible = (state == "loading")
empty_label.visible = (state == "empty")
if state != "loading":
load_more_btn.visible = _has_more
@@ -26,6 +26,10 @@ const CARD_WIDGET := preload("res://scenes/collection/components/CardWidget.t
@onready var loading_label : Label = %LoadingLabel
@onready var empty_label : Label = %EmptyLabel
@onready var confirm_dialog : ConfirmationDialog = %ConfirmDialog
@onready var deck_editor : VBoxContainer = %DeckEditorPanel
@onready var _header_margin : MarginContainer = $HeaderMargin
@onready var _scroll : ScrollContainer = $Scroll
@onready var _status_row : HBoxContainer = $StatusRow
# ── State ─────────────────────────────────────────────────────────────────────
@@ -41,6 +45,7 @@ func _ready() -> void:
create_btn.pressed.connect(_on_create_deck)
deck_name_input.text_changed.connect(_on_name_changed)
confirm_dialog.confirmed.connect(_on_delete_confirmed)
deck_editor.back_pressed.connect(_on_editor_back)
create_btn.disabled = true
_load_decks()
@@ -66,6 +71,7 @@ func _on_decks_response(payload: Variant) -> void:
for deck in decks:
var item = DECK_LIST_ITEM.instantiate()
item.setup(deck)
item.edit_requested.connect(_on_edit_requested)
item.rename_requested.connect(_on_rename_requested)
item.delete_requested.connect(_on_delete_requested)
item.clone_requested.connect(_on_clone_requested)
@@ -104,7 +110,7 @@ func _load_arch_spirits() -> void:
_clear_arch_spirit_grid()
Network.request(
"collection.get_cards",
{ "page": 1, "pageSize": 50, "cardTypeFilter": "ArchSpirit" },
{ "page": 1, "pageSize": 50, "cardTypeFilter": "ArchSpirit", "tierFilter": 1 },
func(_t: String, p: Variant): _on_arch_spirits(p),
func(_code: String, msg: String): push_warning("DecksView arch spirits: %s" % msg)
)
@@ -204,6 +210,24 @@ func _on_mutate_error(msg: String) -> void:
push_warning("DecksView mutate: %s" % msg)
_load_decks()
# ── Deck editor ───────────────────────────────────────────────────────────────
func _on_edit_requested(deck_id: String, deck_name: String) -> void:
_header_margin.visible = false
new_deck_form.visible = false
_scroll.visible = false
_status_row.visible = false
deck_editor.visible = true
deck_editor.open_deck(deck_id, deck_name)
func _on_editor_back() -> void:
deck_editor.visible = false
_header_margin.visible = true
_scroll.visible = true
_status_row.visible = true
_load_decks()
# ── Status helper ─────────────────────────────────────────────────────────────
## Pass a bool (is_empty) + the desired state string, or just a string "loading".