From 0b975df3e498853a4dbf85cc197e0e147fbc1315 Mon Sep 17 00:00:00 2001 From: "Riley L." Date: Thu, 2 Jan 2025 00:40:33 +0100 Subject: [PATCH] fix delete barcode functionality; fix styling of product menus --- abrechenbarkeit.lua | 37 +++++++++++++++++++++++++------------ locale/en.ini | 1 + style.css | 5 +---- 3 files changed, 27 insertions(+), 16 deletions(-) diff --git a/abrechenbarkeit.lua b/abrechenbarkeit.lua index 2ebafc3..dee8b4d 100755 --- a/abrechenbarkeit.lua +++ b/abrechenbarkeit.lua @@ -698,6 +698,26 @@ end local function r_products_post() local data = form_data() + + if data.deletebarcode then + local barcode = data.barcode + + -- remove barcode + local new_barcodes = io.open("barcodes.new", "w+") + if new_barcodes == nil then + return error_box("{+error.open_new_barcodes}") + end + for name, a_barcode in read_barcodes() do + if barcode ~= a_barcode then + new_barcodes:write(string.format("%s,%s\n", name, a_barcode)) + end + end + new_barcodes:flush() + new_barcodes:close() + os.rename("barcodes.new", "barcodes") + return + end + local name = data.name if name == nil or name:match("^[%w_-]*$") == nil then return error_box("{+error.invalid_name}") @@ -710,7 +730,7 @@ local function r_products_post() end for price, user, a_name in read_products() do if name ~= a_name then - new_products:write(string.format("%d,%s,%s\n", price, user, name)) + new_products:write(string.format("%d,%s,%s\n", price, user, a_name)) end end new_products:flush() @@ -785,7 +805,7 @@ local function r_products() currency = config.unit or "€", })) for _, _, name in read_products() do - print(format([[]], { + print(format([[]], { name = name, })) end @@ -804,7 +824,7 @@ local function r_products() currency = config.unit or "€", })) for _, _, name in read_products() do - print(format([[]], { + print(format([[]], { name = name, })) end @@ -814,7 +834,7 @@ local function r_products()

{+products.form.removebarcode}

- +
diff --git a/locale/en.ini b/locale/en.ini index d051b50..9d210ba 100644 --- a/locale/en.ini +++ b/locale/en.ini @@ -67,6 +67,7 @@ error.invalid_user=Username invalid error.open_log=Failed to open log file error.invalid_barcode=Barcode invalid error.open_new_products=Failed to open new products file +error.open_new_barcodes=Failed to open new barcodes file error.invalid_price=Price invalid error.invalid_name=Name invalid error.open_products=Failed to open products file diff --git a/style.css b/style.css index 9599c84..3082d31 100644 --- a/style.css +++ b/style.css @@ -31,10 +31,7 @@ body>* { } .container { - display: grid; - flex-direction: column; - justify-content: left; - grid-template-columns: auto auto; + display: ruby; list-style-type: none; }