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
PRODUCT_COLOR = "{{PRODUCT_COLOR}}", // Farbe Grün/Blau/Orange
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",
PRODUCT_COLOR = "Farbe Grün/Blau/Orange",
@ -9,7 +13,7 @@ const PRODUCT_NAME = "Gizmo die Eidechse",
PRODUCT_ID = "#32420"; */
window.onload = () => {
for (let i = 0; i < 12; i++) {
for (let i = 1; i <= 12; i++) {
let labels = document.getElementById("labels");
/* CONTAINER */
@ -17,6 +21,7 @@ window.onload = () => {
const label = document.createElement("div");
label.className = "label";
if (labelPaperPosition.indexOf(i.toString()) !== -1) {
/* FIRST */
const backgroundImage = document.createElement("div");
@ -95,6 +100,7 @@ window.onload = () => {
label.appendChild(backgroundImage);
label.appendChild(content);
}
labels.appendChild(label);
}

View File

@ -10,6 +10,11 @@
"repeatPossible": true,
"scriptPath": "script.py",
"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",
"type": "select",

View File

@ -9,12 +9,14 @@ from libs.utils import utils
json_object = json.loads(sys.argv[1])
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")
sys.exit(1)
product_type_id = product_type_id["value"]
label_paper_position = label_paper_position["value"]
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:
content = json.load(file)
products = content["tasks"][0]["parameters"][0]["options"]
products = content["tasks"][0]["parameters"][1]["options"]
for product in products:
data = product.split("; ")
@ -80,6 +82,7 @@ if __name__ == "__main__":
indexjs = indexjs.replace("{{PRODUCT_NAME}}", product["product_name"])
indexjs = indexjs.replace("{{PRODUCT_COLOR}}", product["product_color"])
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:
file.write(indexjs)