Audit buttons and selector controls
This commit is contained in:
+15
-6
@@ -371,6 +371,15 @@ function createOption(value, 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 {
|
||||
@@ -675,7 +684,7 @@ async function findSourcesForCurrentProduct() {
|
||||
|
||||
const supplierColorGroup = getFirstSupplierColorGroup();
|
||||
findSourcesButton.disabled = true;
|
||||
findSourcesButton.textContent = "Finding sources...";
|
||||
setButtonLabel(findSourcesButton, "Finding sources...");
|
||||
|
||||
try {
|
||||
const params = new URLSearchParams({
|
||||
@@ -725,7 +734,7 @@ async function getPicturesForCurrentProduct(sourceKey = "") {
|
||||
|
||||
const supplierColorGroup = getFirstSupplierColorGroup();
|
||||
getPicturesButton.disabled = true;
|
||||
getPicturesButton.textContent = "Loading pictures...";
|
||||
setButtonLabel(getPicturesButton, "Loading pictures...");
|
||||
|
||||
try {
|
||||
const params = new URLSearchParams({
|
||||
@@ -752,7 +761,7 @@ async function getPicturesForCurrentProduct(sourceKey = "") {
|
||||
setTableMessage(error.message || "Picture lookup failed.");
|
||||
} finally {
|
||||
getPicturesButton.disabled = false;
|
||||
getPicturesButton.textContent = "Get pictures";
|
||||
setButtonLabel(getPicturesButton, "Get pictures");
|
||||
updateNavigationState();
|
||||
}
|
||||
}
|
||||
@@ -900,7 +909,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;
|
||||
}
|
||||
|
||||
@@ -1328,7 +1337,7 @@ async function loadProductInfoForCurrentProduct() {
|
||||
}
|
||||
|
||||
loadProductButton.disabled = true;
|
||||
loadProductButton.textContent = "Loading info...";
|
||||
setButtonLabel(loadProductButton, "Loading info...");
|
||||
|
||||
try {
|
||||
const params = new URLSearchParams({
|
||||
@@ -1354,7 +1363,7 @@ async function loadProductInfoForCurrentProduct() {
|
||||
} catch (error) {
|
||||
setTableMessage(error.message);
|
||||
} finally {
|
||||
loadProductButton.textContent = "Get product info - 00";
|
||||
setButtonLabel(loadProductButton, "Get product info - 00");
|
||||
updateNavigationState();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user