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

View file

@ -10,7 +10,7 @@
<h1 class="page_title">__MSG_menu_order_title__</h1>
<p class="info_text">__MSG_menu_order_info__</p>
<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>
</div>
<div id="lists_container">

View file

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