feat: wire as-of date into organization and seatmap views
This commit is contained in:
@@ -155,6 +155,10 @@ const globalDateState = {
|
||||
endDate: "2026-01-31",
|
||||
};
|
||||
|
||||
function getGlobalAsOfDate() {
|
||||
return globalDateState.endDate || "";
|
||||
}
|
||||
|
||||
function getSession() {
|
||||
try {
|
||||
return JSON.parse(sessionStorage.getItem(sessionKey) || "null");
|
||||
@@ -181,7 +185,12 @@ function buildAuthHeaders(headers) {
|
||||
}
|
||||
|
||||
function shouldShowGlobalDateControls() {
|
||||
return currentView === "ledger" || currentView === "project" || currentView === "team" || currentView === "organization";
|
||||
return currentView === "ledger"
|
||||
|| currentView === "project"
|
||||
|| currentView === "team"
|
||||
|| currentView === "organization"
|
||||
|| currentView === "seatmap-admin"
|
||||
|| currentView === "seatmap-readonly";
|
||||
}
|
||||
|
||||
function syncGlobalDateControlVisibility() {
|
||||
@@ -208,6 +217,12 @@ function postGlobalDateRangeToFrame(frame) {
|
||||
frame.contentWindow.postMessage(getGlobalDateRangePayload(), window.location.origin);
|
||||
}
|
||||
|
||||
function buildAsOfQuery() {
|
||||
const asOf = getGlobalAsOfDate();
|
||||
if (!asOf) return "";
|
||||
return `?as_of=${encodeURIComponent(asOf)}`;
|
||||
}
|
||||
|
||||
function notifyEmbeddedTabActivated() {
|
||||
if (currentView === "project" && projectFrame?.contentWindow) {
|
||||
projectFrame.contentWindow.postMessage({ source: "total-control", type: "tab-activated", tab: "project" }, window.location.origin);
|
||||
@@ -229,6 +244,7 @@ async function ensureGlobalDateRangeLoaded() {
|
||||
globalDateState.endDate = ends.length ? String(ends[ends.length - 1]).slice(0, 10) : "";
|
||||
globalDateState.loaded = true;
|
||||
syncGlobalDateControlInputs();
|
||||
postGlobalDateRangeToFrame(organizationFrame);
|
||||
postGlobalDateRangeToFrame(projectFrame);
|
||||
postGlobalDateRangeToFrame(teamFrame);
|
||||
} catch (error) {
|
||||
@@ -858,7 +874,7 @@ function renderDxfSeatMapBoard() {
|
||||
seatMapBoard.innerHTML = `<div class="seatmap-empty-card"><strong>DXF 뷰어 데이터를 준비하지 못했습니다.</strong></div>`;
|
||||
return;
|
||||
}
|
||||
const viewerUrl = resolveAppUrl(`/api/seat-maps/${seatMapState.seatMap.id}/viewer`);
|
||||
const viewerUrl = resolveAppUrl(`/api/seat-maps/${seatMapState.seatMap.id}/viewer${buildAsOfQuery()}`);
|
||||
seatMapBoard.innerHTML = `
|
||||
<div class="seatmap-dxf-frame-shell">
|
||||
<div class="seatmap-dxf-drop-overlay" data-seatmap-drop-overlay></div>
|
||||
@@ -1201,7 +1217,7 @@ async function loadSeatMapData(force = false) {
|
||||
const office = getCurrentSeatMapOffice();
|
||||
const activePayload = await fetchJson(`/api/seat-maps/active?office_key=${encodeURIComponent(office.key)}`);
|
||||
const activeSeatMap = activePayload.item;
|
||||
const layoutPayload = await fetchJson(`/api/seat-maps/${activeSeatMap.id}/layout`);
|
||||
const layoutPayload = await fetchJson(`/api/seat-maps/${activeSeatMap.id}/layout${buildAsOfQuery()}`);
|
||||
seatMapState.seatMap = {
|
||||
...(layoutPayload.seat_map || {}),
|
||||
viewer_data: layoutPayload.viewer_data || null,
|
||||
@@ -1531,6 +1547,7 @@ if (logoutBtn) {
|
||||
if (globalStartDateInput) {
|
||||
globalStartDateInput.addEventListener("change", () => {
|
||||
globalDateState.startDate = globalStartDateInput.value || "";
|
||||
postGlobalDateRangeToFrame(organizationFrame);
|
||||
postGlobalDateRangeToFrame(projectFrame);
|
||||
postGlobalDateRangeToFrame(teamFrame);
|
||||
});
|
||||
@@ -1539,11 +1556,20 @@ if (globalStartDateInput) {
|
||||
if (globalEndDateInput) {
|
||||
globalEndDateInput.addEventListener("change", () => {
|
||||
globalDateState.endDate = globalEndDateInput.value || "";
|
||||
postGlobalDateRangeToFrame(organizationFrame);
|
||||
postGlobalDateRangeToFrame(projectFrame);
|
||||
postGlobalDateRangeToFrame(teamFrame);
|
||||
if (currentView === "seatmap-admin" || currentView === "seatmap-readonly") {
|
||||
seatMapState.loaded = false;
|
||||
loadSeatMapData(true);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
organizationFrame?.addEventListener("load", () => {
|
||||
postGlobalDateRangeToFrame(organizationFrame);
|
||||
});
|
||||
|
||||
projectFrame?.addEventListener("load", () => {
|
||||
postGlobalDateRangeToFrame(projectFrame);
|
||||
if (currentView === "project") {
|
||||
|
||||
Reference in New Issue
Block a user