save button improved. see #680

This commit is contained in:
Mic 2026-04-16 21:41:56 +02:00
parent fa54572279
commit 156a0fa9a8
3 changed files with 26 additions and 18 deletions

View file

@ -21,20 +21,12 @@ body {
gap: 12px; gap: 12px;
} }
#btnSave { #btnSaveAll {
padding: 6px 20px; float: left;
font-size: 1em;
cursor: pointer;
}
#btnSave:disabled {
opacity: 0.5;
cursor: default;
} }
#msgDisplay { #msgDisplay {
font-size: 0.9em; padding-left: 40px;
color: #2a7e2a;
} }
#lists_container { #lists_container {
@ -61,6 +53,9 @@ body {
display: flex; display: flex;
gap: 4px; gap: 4px;
margin-bottom: 12px; margin-bottom: 12px;
border-bottom: 1px solid #ccc;
padding-bottom: 0;
padding-left: 12px;
} }
.sub_tab { .sub_tab {
@ -70,6 +65,7 @@ body {
cursor: pointer; cursor: pointer;
border-radius: 4px 4px 0 0; border-radius: 4px 4px 0 0;
font-size: 0.9em; font-size: 0.9em;
margin-bottom: -1px;
} }
.sub_tab.active { .sub_tab.active {
@ -218,6 +214,10 @@ body {
background: #2a2a30; background: #2a2a30;
} }
.sub_tabs {
border-bottom-color: #555;
}
.sub_tab { .sub_tab {
border-color: #555; border-color: #555;
background: #333; background: #333;

View file

@ -10,7 +10,7 @@
<h1 class="page_title">__MSG_menu_order_title__</h1> <h1 class="page_title">__MSG_menu_order_title__</h1>
<p class="info_text">__MSG_menu_order_info__</p> <p class="info_text">__MSG_menu_order_info__</p>
<div id="command_palette"> <div id="command_palette">
<button id="btnSave" disabled>__MSG_menu_order_save__</button> <button id="btnSaveAll" disabled>__MSG_btnSaveAll_string__</button>
<span id="msgDisplay"></span> <span id="msgDisplay"></span>
</div> </div>
<div id="lists_container"> <div id="lists_container">

View file

@ -60,7 +60,7 @@ document.addEventListener('DOMContentLoaded', async () => {
renderContextList(); renderContextList();
initSubTabs(); initSubTabs();
document.getElementById('btnSave').addEventListener('click', saveAll); document.getElementById('btnSaveAll').addEventListener('click', saveAll);
i18n.updateDocument(); i18n.updateDocument();
}); });
@ -301,9 +301,9 @@ function updatePositionsFromDOM(listEl, positionKey) {
// ==================== Save ==================== // ==================== Save ====================
async function saveAll() { async function saveAll() {
const btnSave = document.getElementById('btnSave'); const btnSaveAll = document.getElementById('btnSaveAll');
const msgDisplay = document.getElementById('msgDisplay'); const msgDisplay = document.getElementById('msgDisplay');
btnSave.disabled = true; btnSaveAll.disabled = true;
const defaultPromptsToSave = allPrompts.filter(p => String(p.is_default) === '1' && String(p.is_special) !== '1'); const defaultPromptsToSave = allPrompts.filter(p => String(p.is_default) === '1' && String(p.is_special) !== '1');
const customPromptsToSave = allPrompts.filter(p => String(p.is_default) === '0' && String(p.is_special) !== '1'); const customPromptsToSave = allPrompts.filter(p => String(p.is_default) === '0' && String(p.is_special) !== '1');
@ -317,11 +317,19 @@ async function saveAll() {
hasUnsavedChanges = false; hasUnsavedChanges = false;
msgDisplay.textContent = browser.i18n.getMessage('menu_order_saved'); msgDisplay.textContent = browser.i18n.getMessage('menu_order_saved');
setTimeout(() => { msgDisplay.textContent = ''; }, 3000); msgDisplay.style.display = 'inline';
msgDisplay.style.color = 'green';
setTimeout(() => {
msgDisplay.textContent = '';
msgDisplay.style.display = 'none';
}, 3000);
} }
function markUnsaved() { function markUnsaved() {
hasUnsavedChanges = true; hasUnsavedChanges = true;
document.getElementById('btnSave').disabled = false; document.getElementById('btnSaveAll').disabled = false;
document.getElementById('msgDisplay').textContent = ''; const msgDisplay = document.getElementById('msgDisplay');
msgDisplay.textContent = browser.i18n.getMessage('customPrompts_unsaved_changes');
msgDisplay.style.display = 'inline';
msgDisplay.style.color = 'red';
} }