Audit buttons and selector controls

This commit is contained in:
2026-08-05 17:53:44 +02:00
parent 310e1e239f
commit 5882edb994
7 changed files with 39 additions and 18 deletions
+15 -6
View File
@@ -351,6 +351,15 @@ function createOption(value, label) {
option.textContent = label;
return option;
}
function setButtonLabel(button, label) {
const labelElement = button.querySelector(":scope > span");
if (labelElement) {
labelElement.textContent = label;
}
else {
button.textContent = label;
}
}
async function loadLanguages() {
languageSelect.replaceChildren(createOption("", "Select language"));
try {
@@ -621,7 +630,7 @@ async function findSourcesForCurrentProduct() {
}
const supplierColorGroup = getFirstSupplierColorGroup();
findSourcesButton.disabled = true;
findSourcesButton.textContent = "Finding sources...";
setButtonLabel(findSourcesButton, "Finding sources...");
try {
const params = new URLSearchParams({
manufacturerId: manufacturerSelect.value,
@@ -667,7 +676,7 @@ async function getPicturesForCurrentProduct(sourceKey = "") {
}
const supplierColorGroup = getFirstSupplierColorGroup();
getPicturesButton.disabled = true;
getPicturesButton.textContent = "Loading pictures...";
setButtonLabel(getPicturesButton, "Loading pictures...");
try {
const params = new URLSearchParams({
manufacturerId: manufacturerSelect.value,
@@ -695,7 +704,7 @@ async function getPicturesForCurrentProduct(sourceKey = "") {
}
finally {
getPicturesButton.disabled = false;
getPicturesButton.textContent = "Get pictures";
setButtonLabel(getPicturesButton, "Get pictures");
updateNavigationState();
}
}
@@ -820,7 +829,7 @@ function clearLocalDraft() {
}
function updateFindSourcesButtonState() {
const hasSources = Boolean(readLocalDraft()?.sources);
findSourcesButton.textContent = hasSources ? "Find sources ✓" : "Find sources";
setButtonLabel(findSourcesButton, hasSources ? "Find sources ✓" : "Find sources");
findSourcesButton.disabled = !manufacturerSelect.value || !currentProduct;
}
function renderSourceCandidateRow(candidate) {
@@ -1212,7 +1221,7 @@ async function loadProductInfoForCurrentProduct() {
return;
}
loadProductButton.disabled = true;
loadProductButton.textContent = "Loading info...";
setButtonLabel(loadProductButton, "Loading info...");
try {
const params = new URLSearchParams({
productId: currentProduct.idProduct,
@@ -1235,7 +1244,7 @@ async function loadProductInfoForCurrentProduct() {
setTableMessage(error.message);
}
finally {
loadProductButton.textContent = "Get product info - 00";
setButtonLabel(loadProductButton, "Get product info - 00");
updateNavigationState();
}
}