Enhance ApplicantsDialog by integrating game status fetching and updating card rendering logic. Introduced swarm configuration handling and improved person card rendering with tab support, ensuring a more dynamic user experience.
ci / server (push) Failing after 3m42s
ci / client (push) Failing after 15s

This commit is contained in:
Leonid Pershin
2026-08-20 04:17:40 +03:00
parent 3b9bfc0b9e
commit d0e9f4a9d3
+25 -10
View File
@@ -1,4 +1,5 @@
import { import {
fetchGameStatus,
fetchPerson, fetchPerson,
hireStaff, hireStaff,
type PersonCard, type PersonCard,
@@ -9,8 +10,7 @@ import { getLocale } from '../i18n/locale.ts';
import { t, type MessageKey } from '../i18n/strings.ts'; import { t, type MessageKey } from '../i18n/strings.ts';
import { clear, el } from './dom.ts'; import { clear, el } from './dom.ts';
import { Modal } from './modal.ts'; import { Modal } from './modal.ts';
import { formatPersonPlace } from './personCard.ts'; import { formatPersonPlace, renderPersonCard, type PersonCardTab } from './personCard.ts';
import { PersonCardHost } from './personCardHost.ts';
import { import {
actionError, actionError,
fillSelect, fillSelect,
@@ -68,13 +68,20 @@ export class ApplicantsDialog {
private sort: ApplicantSort = 'name'; private sort: ApplicantSort = 'name';
private dir: 'asc' | 'desc' = 'asc'; private dir: 'asc' | 'desc' = 'asc';
private busy = false; private busy = false;
private readonly cardHost = new PersonCardHost(); private cardTab: PersonCardTab = 'overview';
private swarmConfigured = false;
private painted: PersonCard | null = null; private painted: PersonCard | null = null;
constructor(private readonly options: ApplicantsDialogOptions) { constructor(private readonly options: ApplicantsDialogOptions) {
this.staffing = options.staffing; this.staffing = options.staffing;
this.selectedId = options.selectedId ?? null; this.selectedId = options.selectedId ?? null;
this.cardHost.attach(options.schoolId); void fetchGameStatus()
.then((status) => {
this.swarmConfigured = status.swarmUiConfigured;
})
.catch(() => {
this.swarmConfigured = false;
});
this.error.hidden = true; this.error.hidden = true;
this.ageMinInput.min = '0'; this.ageMinInput.min = '0';
this.ageMaxInput.min = '0'; this.ageMaxInput.min = '0';
@@ -310,12 +317,20 @@ export class ApplicantsDialog {
return; return;
} }
this.cardHost.paint( clear(this.card);
this.card, renderPersonCard(this.card, card, {
card, onRelative: (id) => this.openRelative(id),
(id) => this.openRelative(id), place: this.placeOf(card.id),
this.placeOf(card.id), schoolId: this.options.schoolId,
); tab: this.cardTab,
onTabChange: (tab) => {
this.cardTab = tab;
if (this.painted !== null) {
this.paintCard(this.painted);
}
},
swarmConfigured: this.swarmConfigured,
});
this.appendHireIfNeeded(this.card); this.appendHireIfNeeded(this.card);
} }