submit position for label

main
alex 2024-05-14 19:25:51 +02:00
parent 38afcfd242
commit 7ae95c9291
3 changed files with 74 additions and 60 deletions

View File

@ -1,7 +1,11 @@
const PRODUCT_NAME = "{{PRODUCT_NAME}}", // Gizmo die Eidechse const PRODUCT_NAME = "{{PRODUCT_NAME}}", // Gizmo die Eidechse
PRODUCT_COLOR = "{{PRODUCT_COLOR}}", // Farbe Grün/Blau/Orange PRODUCT_COLOR = "{{PRODUCT_COLOR}}", // Farbe Grün/Blau/Orange
PRODUCT_COLOR_CHARACTERISTICS = "{{PRODUCT_COLOR_CHARACTERISTICS}}", // (Glänzend) PRODUCT_COLOR_CHARACTERISTICS = "{{PRODUCT_COLOR_CHARACTERISTICS}}", // (Glänzend)
PRODUCT_ID = "{{PRODUCT_ID}}"; // #32420 PRODUCT_ID = "{{PRODUCT_ID}}", // #32420
LABEL_PAPER_POSITION = "{{LABEL_PAPER_POSITION}}"; // could be a number between 1 and 12 or combination like 1,3,7
const labelPaperPosition = LABEL_PAPER_POSITION.split(",");
/* /*
const PRODUCT_NAME = "Gizmo die Eidechse", const PRODUCT_NAME = "Gizmo die Eidechse",
PRODUCT_COLOR = "Farbe Grün/Blau/Orange", PRODUCT_COLOR = "Farbe Grün/Blau/Orange",
@ -9,7 +13,7 @@ const PRODUCT_NAME = "Gizmo die Eidechse",
PRODUCT_ID = "#32420"; */ PRODUCT_ID = "#32420"; */
window.onload = () => { window.onload = () => {
for (let i = 0; i < 12; i++) { for (let i = 1; i <= 12; i++) {
let labels = document.getElementById("labels"); let labels = document.getElementById("labels");
/* CONTAINER */ /* CONTAINER */
@ -17,84 +21,86 @@ window.onload = () => {
const label = document.createElement("div"); const label = document.createElement("div");
label.className = "label"; label.className = "label";
/* FIRST */ if (labelPaperPosition.indexOf(i.toString()) !== -1) {
/* FIRST */
const backgroundImage = document.createElement("div"); const backgroundImage = document.createElement("div");
backgroundImage.className = "background-image"; backgroundImage.className = "background-image";
const content = document.createElement("div"); const content = document.createElement("div");
content.className = "content"; content.className = "content";
const productName = PRODUCT_NAME.split(" "); const productName = PRODUCT_NAME.split(" ");
const productNameFirst = document.createElement("h1"); const productNameFirst = document.createElement("h1");
productNameFirst.innerHTML = productName[0]; productNameFirst.innerHTML = productName[0];
const productNameRemainingPart = document.createElement("h1"); const productNameRemainingPart = document.createElement("h1");
productNameRemainingPart.innerHTML = productName.slice(1).join(" "); productNameRemainingPart.innerHTML = productName.slice(1).join(" ");
productNameRemainingPart.style = "margin: 0"; productNameRemainingPart.style = "margin: 0";
const productColor = document.createElement("p"); const productColor = document.createElement("p");
productColor.innerHTML = PRODUCT_COLOR; productColor.innerHTML = PRODUCT_COLOR;
productColor.className = "product-color"; productColor.className = "product-color";
const productColorCharacteristics = document.createElement("p"); const productColorCharacteristics = document.createElement("p");
productColorCharacteristics.innerHTML = PRODUCT_COLOR_CHARACTERISTICS; productColorCharacteristics.innerHTML = PRODUCT_COLOR_CHARACTERISTICS;
productColorCharacteristics.className = "product-color"; productColorCharacteristics.className = "product-color";
const productId = document.createElement("p"); const productId = document.createElement("p");
productId.innerHTML = PRODUCT_ID; productId.innerHTML = PRODUCT_ID;
productId.className = "product-id"; productId.className = "product-id";
content.appendChild(productNameFirst); content.appendChild(productNameFirst);
content.appendChild(productNameRemainingPart); content.appendChild(productNameRemainingPart);
content.appendChild(productColor); content.appendChild(productColor);
content.appendChild(productColorCharacteristics); content.appendChild(productColorCharacteristics);
content.appendChild(productId); content.appendChild(productId);
/* container */ /* container */
const container = document.createElement("div"); const container = document.createElement("div");
container.className = "container"; container.className = "container";
const childrenImg = document.createElement("img"); const childrenImg = document.createElement("img");
childrenImg.src = "../../groupsData/shx-product-label/children.png"; childrenImg.src = "../../groupsData/shx-product-label/children.png";
childrenImg.alt = "children"; childrenImg.alt = "children";
childrenImg.className = "children"; childrenImg.className = "children";
const manufacturerInfo = document.createElement("div"); const manufacturerInfo = document.createElement("div");
manufacturerInfo.className = "manufacturer-info"; manufacturerInfo.className = "manufacturer-info";
const manufacturer = document.createElement("p"); const manufacturer = document.createElement("p");
manufacturer.innerHTML = "Hersteller:"; manufacturer.innerHTML = "Hersteller:";
const manufacturer2 = document.createElement("p"); const manufacturer2 = document.createElement("p");
manufacturer2.innerHTML = "Jan Umbach"; manufacturer2.innerHTML = "Jan Umbach";
const manufacturer3 = document.createElement("p"); const manufacturer3 = document.createElement("p");
manufacturer3.innerHTML = "Klosterstraße 10"; manufacturer3.innerHTML = "Klosterstraße 10";
const manufacturer4 = document.createElement("p"); const manufacturer4 = document.createElement("p");
manufacturer4.innerHTML = "D-34286 Spangenberg"; manufacturer4.innerHTML = "D-34286 Spangenberg";
manufacturerInfo.appendChild(manufacturer); manufacturerInfo.appendChild(manufacturer);
manufacturerInfo.appendChild(manufacturer2); manufacturerInfo.appendChild(manufacturer2);
manufacturerInfo.appendChild(manufacturer3); manufacturerInfo.appendChild(manufacturer3);
manufacturerInfo.appendChild(manufacturer4); manufacturerInfo.appendChild(manufacturer4);
const ceImg = document.createElement("img"); const ceImg = document.createElement("img");
ceImg.src = "../../groupsData/shx-product-label/ce.svg"; ceImg.src = "../../groupsData/shx-product-label/ce.svg";
ceImg.alt = "ce"; ceImg.alt = "ce";
ceImg.className = "ce"; ceImg.className = "ce";
container.appendChild(childrenImg); container.appendChild(childrenImg);
container.appendChild(manufacturerInfo); container.appendChild(manufacturerInfo);
container.appendChild(ceImg); container.appendChild(ceImg);
content.appendChild(container); content.appendChild(container);
label.appendChild(backgroundImage); label.appendChild(backgroundImage);
label.appendChild(content); label.appendChild(content);
}
labels.appendChild(label); labels.appendChild(label);
} }

View File

@ -10,6 +10,11 @@
"repeatPossible": true, "repeatPossible": true,
"scriptPath": "script.py", "scriptPath": "script.py",
"parameters": [ "parameters": [
{
"parameterName": "label_paper_position",
"type": "text",
"displayName": "Position auf dem A4 Blatt (Beginnend mit 1 von oben links) (Mit Komma trennbar wie z. B. 1,3,7)"
},
{ {
"parameterName": "product_type_id", "parameterName": "product_type_id",
"type": "select", "type": "select",

View File

@ -9,12 +9,14 @@ from libs.utils import utils
json_object = json.loads(sys.argv[1]) json_object = json.loads(sys.argv[1])
product_type_id = json_object["product_type_id"] product_type_id = json_object["product_type_id"]
label_paper_position = json_object["label_paper_position"]
if product_type_id is None: if product_type_id is None or label_paper_position is None:
print("Missing required parameters") print("Missing required parameters")
sys.exit(1) sys.exit(1)
product_type_id = product_type_id["value"] product_type_id = product_type_id["value"]
label_paper_position = label_paper_position["value"]
product_type_ids = {} product_type_ids = {}
@ -30,7 +32,7 @@ def add_product_type_id(product_type_id, product_name, product_color, product_co
with open("../../groups/shx-product-label/index.json", "r") as file: with open("../../groups/shx-product-label/index.json", "r") as file:
content = json.load(file) content = json.load(file)
products = content["tasks"][0]["parameters"][0]["options"] products = content["tasks"][0]["parameters"][1]["options"]
for product in products: for product in products:
data = product.split("; ") data = product.split("; ")
@ -80,6 +82,7 @@ if __name__ == "__main__":
indexjs = indexjs.replace("{{PRODUCT_NAME}}", product["product_name"]) indexjs = indexjs.replace("{{PRODUCT_NAME}}", product["product_name"])
indexjs = indexjs.replace("{{PRODUCT_COLOR}}", product["product_color"]) indexjs = indexjs.replace("{{PRODUCT_COLOR}}", product["product_color"])
indexjs = indexjs.replace("{{PRODUCT_COLOR_CHARACTERISTICS}}", product["product_color_characteristics"]) indexjs = indexjs.replace("{{PRODUCT_COLOR_CHARACTERISTICS}}", product["product_color_characteristics"])
indexjs = indexjs.replace("{{LABEL_PAPER_POSITION}}", label_paper_position)
with open("index.js", "w") as file: with open("index.js", "w") as file:
file.write(indexjs) file.write(indexjs)