Update samy.js
This commit is contained in:
34
samy.js
34
samy.js
@@ -347,7 +347,9 @@ function renderPrintersForClient(clientCode) {
|
|||||||
const id = `printer_${clientCode}_${idx}`;
|
const id = `printer_${clientCode}_${idx}`;
|
||||||
const label = document.createElement("label");
|
const label = document.createElement("label");
|
||||||
label.style.display = "block";
|
label.style.display = "block";
|
||||||
|
label.style.marginBottom = "4px";
|
||||||
|
|
||||||
|
//Install-Checkbox
|
||||||
const cb = document.createElement("input");
|
const cb = document.createElement("input");
|
||||||
cb.type = "checkbox";
|
cb.type = "checkbox";
|
||||||
cb.id = id;
|
cb.id = id;
|
||||||
@@ -363,16 +365,36 @@ function renderPrintersForClient(clientCode) {
|
|||||||
cb.dataset.driverName = p.DriverName;
|
cb.dataset.driverName = p.DriverName;
|
||||||
cb.dataset.driverInfPath = p.DriverInfPath;
|
cb.dataset.driverInfPath = p.DriverInfPath;
|
||||||
|
|
||||||
const nameText =
|
const nameText = p.DisplayName || p.ProfileName || "Unnamed printer";
|
||||||
p.DisplayName || p.ProfileName || "Unnamed printer";
|
|
||||||
const locText = p.Location || "Unknown location";
|
const locText = p.Location || "Unknown location";
|
||||||
|
|
||||||
|
// Line 1: install checkbox + printer label
|
||||||
label.appendChild(cb);
|
label.appendChild(cb);
|
||||||
label.appendChild(document.createTextNode(" "));
|
label.appendChild(document.createTextNode(" "));
|
||||||
label.appendChild(
|
label.appendChild(
|
||||||
document.createTextNode(`${nameText} (${locText})`)
|
document.createTextNode(`${nameText} (${locText})`)
|
||||||
);
|
);
|
||||||
|
|
||||||
|
// Line 2: radio for "Make default"
|
||||||
|
const defaultWrapper = document.createElement("div");
|
||||||
|
defaultWrapper.style.marginLeft = "24px";
|
||||||
|
defaultWrapper.style.fontSize = "0.85em";
|
||||||
|
defaultWrapper.style.opacity = "0.9";
|
||||||
|
|
||||||
|
const radio = document.createElement("input");
|
||||||
|
radio.type = "radio";
|
||||||
|
radio.name = "defaultPrinter";
|
||||||
|
radio.value = id; // associate default choice with this checkbox/printer
|
||||||
|
|
||||||
|
const radioLabel = document.createElement("span");
|
||||||
|
radioLabel.textContent = " Make default";
|
||||||
|
|
||||||
|
defaultWrapper.appendChild(radio);
|
||||||
|
defaultWrapper.appendChild(radioLabel);
|
||||||
|
|
||||||
|
label.appendChild(document.createElement("br"));
|
||||||
|
label.appendChild(defaultWrapper);
|
||||||
|
|
||||||
container.appendChild(label);
|
container.appendChild(label);
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -389,6 +411,12 @@ async function installSelectedPrinters() {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// See which radio is checked for "Make default"
|
||||||
|
const defaultRadio = container.querySelector(
|
||||||
|
'input[type=radio][name="defaultPrinter"]:checked'
|
||||||
|
);
|
||||||
|
const defaultId = defaultRadio ? defaultRadio.value : null;
|
||||||
|
|
||||||
const selected = Array.from(checked).map((cb) => ({
|
const selected = Array.from(checked).map((cb) => ({
|
||||||
ClientCode: cb.dataset.clientCode,
|
ClientCode: cb.dataset.clientCode,
|
||||||
ProfileName: cb.dataset.profileName,
|
ProfileName: cb.dataset.profileName,
|
||||||
@@ -399,6 +427,8 @@ async function installSelectedPrinters() {
|
|||||||
ShareName: cb.dataset.shareName,
|
ShareName: cb.dataset.shareName,
|
||||||
DriverName: cb.dataset.driverName,
|
DriverName: cb.dataset.driverName,
|
||||||
DriverInfPath: cb.dataset.driverInfPath,
|
DriverInfPath: cb.dataset.driverInfPath,
|
||||||
|
// Only the printer whose checkbox id matches the selected radio gets SetAsDefault=true
|
||||||
|
SetAsDefault: defaultId !== null && cb.id === defaultId,
|
||||||
}));
|
}));
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
|||||||
Reference in New Issue
Block a user