Fix instance nav display prefs save in embed shell.
Re-bind save button when settings tab loads lazily; scope form lookup to settings pane. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -108,23 +108,11 @@
|
|||||||
if (!revisit && tab === "stats") {
|
if (!revisit && tab === "stats") {
|
||||||
if (typeof global.initStatsSegmentFromUrl === "function") global.initStatsSegmentFromUrl();
|
if (typeof global.initStatsSegmentFromUrl === "function") global.initStatsSegmentFromUrl();
|
||||||
}
|
}
|
||||||
if (!revisit && (tab === "settings" || tab === "env_config")) {
|
if (tab === "settings" || tab === "env_config") {
|
||||||
if (global.InstanceSettingsPrefs) {
|
if (global.InstanceSettingsPrefs) {
|
||||||
if (tab === "settings" && typeof global.InstanceSettingsPrefs.loadDisplayPrefsForm === "function") {
|
if (typeof global.InstanceSettingsPrefs.bindEvents === "function") {
|
||||||
global.InstanceSettingsPrefs.loadDisplayPrefsForm();
|
global.InstanceSettingsPrefs.bindEvents();
|
||||||
}
|
}
|
||||||
if (tab === "env_config") {
|
|
||||||
if (typeof global.InstanceSettingsPrefs.loadEnvConfig === "function") {
|
|
||||||
global.InstanceSettingsPrefs.loadEnvConfig();
|
|
||||||
}
|
|
||||||
if (typeof global.InstanceSettingsPrefs.bindEnvTabs === "function") {
|
|
||||||
global.InstanceSettingsPrefs.bindEnvTabs();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (revisit && (tab === "settings" || tab === "env_config")) {
|
|
||||||
if (global.InstanceSettingsPrefs) {
|
|
||||||
if (tab === "settings" && typeof global.InstanceSettingsPrefs.loadDisplayPrefsForm === "function") {
|
if (tab === "settings" && typeof global.InstanceSettingsPrefs.loadDisplayPrefsForm === "function") {
|
||||||
global.InstanceSettingsPrefs.loadDisplayPrefsForm();
|
global.InstanceSettingsPrefs.loadDisplayPrefsForm();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -57,6 +57,11 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
function displayPrefsRoot() {
|
function displayPrefsRoot() {
|
||||||
|
const settingsPane = document.querySelector('.embed-tab-pane[data-embed-pane="settings"]');
|
||||||
|
if (settingsPane) {
|
||||||
|
const inSettings = settingsPane.querySelector("#display-prefs-form");
|
||||||
|
if (inSettings) return inSettings;
|
||||||
|
}
|
||||||
const pane = document.querySelector(".embed-tab-pane.is-active-pane");
|
const pane = document.querySelector(".embed-tab-pane.is-active-pane");
|
||||||
if (pane) {
|
if (pane) {
|
||||||
const inPane = pane.querySelector("#display-prefs-form");
|
const inPane = pane.querySelector("#display-prefs-form");
|
||||||
@@ -65,6 +70,15 @@
|
|||||||
return document.getElementById("display-prefs-form");
|
return document.getElementById("display-prefs-form");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function displayPrefsStatusEl() {
|
||||||
|
const card = document.getElementById("display-prefs-card");
|
||||||
|
if (card) {
|
||||||
|
const el = card.querySelector("#display-prefs-status");
|
||||||
|
if (el) return el;
|
||||||
|
}
|
||||||
|
return document.getElementById("display-prefs-status");
|
||||||
|
}
|
||||||
|
|
||||||
function envConfigRoot() {
|
function envConfigRoot() {
|
||||||
const activePane = document.querySelector(".embed-tab-pane.is-active-pane");
|
const activePane = document.querySelector(".embed-tab-pane.is-active-pane");
|
||||||
if (activePane) {
|
if (activePane) {
|
||||||
@@ -122,10 +136,14 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
async function saveDisplayPrefs() {
|
async function saveDisplayPrefs() {
|
||||||
const status = document.getElementById("display-prefs-status");
|
const status = displayPrefsStatusEl();
|
||||||
const root = displayPrefsRoot();
|
const root = displayPrefsRoot();
|
||||||
|
if (!root) {
|
||||||
|
setStatus(status, "未找到导航设置表单", true);
|
||||||
|
return;
|
||||||
|
}
|
||||||
const display = {};
|
const display = {};
|
||||||
(root ? root.querySelectorAll("input[data-pref-key]") : []).forEach((cb) => {
|
root.querySelectorAll("input[data-pref-key]").forEach((cb) => {
|
||||||
display[cb.dataset.prefKey] = !!cb.checked;
|
display[cb.dataset.prefKey] = !!cb.checked;
|
||||||
});
|
});
|
||||||
try {
|
try {
|
||||||
@@ -355,17 +373,19 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function bindClickOnce(id, handler) {
|
||||||
|
const el = document.getElementById(id);
|
||||||
|
if (!el || el.dataset.bound === "1") return;
|
||||||
|
el.dataset.bound = "1";
|
||||||
|
el.addEventListener("click", handler);
|
||||||
|
}
|
||||||
|
|
||||||
function bindEvents() {
|
function bindEvents() {
|
||||||
const dSave = document.getElementById("display-prefs-save");
|
bindClickOnce("display-prefs-save", saveDisplayPrefs);
|
||||||
if (dSave) dSave.addEventListener("click", saveDisplayPrefs);
|
bindClickOnce("env-config-save", () => saveEnvConfig(false));
|
||||||
const eSave = document.getElementById("env-config-save");
|
bindClickOnce("env-config-save-restart", () => saveEnvConfig(true));
|
||||||
if (eSave) eSave.addEventListener("click", () => saveEnvConfig(false));
|
bindClickOnce("env-config-reload", () => loadEnvConfig(true));
|
||||||
const eRestart = document.getElementById("env-config-save-restart");
|
bindClickOnce("pwd-save-btn", savePassword);
|
||||||
if (eRestart) eRestart.addEventListener("click", () => saveEnvConfig(true));
|
|
||||||
const eReload = document.getElementById("env-config-reload");
|
|
||||||
if (eReload) eReload.addEventListener("click", () => loadEnvConfig(true));
|
|
||||||
const pSave = document.getElementById("pwd-save-btn");
|
|
||||||
if (pSave) pSave.addEventListener("click", savePassword);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function initPage() {
|
function initPage() {
|
||||||
@@ -381,6 +401,7 @@
|
|||||||
loadDisplayPrefsForm,
|
loadDisplayPrefsForm,
|
||||||
loadEnvConfig,
|
loadEnvConfig,
|
||||||
bindEnvTabs,
|
bindEnvTabs,
|
||||||
|
bindEvents,
|
||||||
restartInstance,
|
restartInstance,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -103,8 +103,8 @@ const ORDER_ENTRY_MODEL_CODE_TO_CATEGORY = {{ entry_model_code_to_category | toj
|
|||||||
<script>
|
<script>
|
||||||
window.__INSTANCE_DISPLAY__ = {{ display | tojson }};
|
window.__INSTANCE_DISPLAY__ = {{ display | tojson }};
|
||||||
</script>
|
</script>
|
||||||
<script src="/static/instance_settings_prefs.js?v=10"></script>
|
<script src="/static/instance_settings_prefs.js?v=11"></script>
|
||||||
<script src="/static/instance_live.js?v=4"></script>
|
<script src="/static/instance_live.js?v=4"></script>
|
||||||
<script src="/static/instance_embed.js?v=20"></script>
|
<script src="/static/instance_embed.js?v=21"></script>
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
|
|||||||
@@ -2038,6 +2038,6 @@ setInterval(refreshPriceSnapshotConditional, {{ price_refresh_seconds * 1000 }})
|
|||||||
<script>
|
<script>
|
||||||
window.__INSTANCE_DISPLAY__ = {{ display | tojson }};
|
window.__INSTANCE_DISPLAY__ = {{ display | tojson }};
|
||||||
</script>
|
</script>
|
||||||
<script src="/static/instance_settings_prefs.js?v=10"></script>
|
<script src="/static/instance_settings_prefs.js?v=11"></script>
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
Reference in New Issue
Block a user