From 2e2eab7d6f98f12d500474dc48e5b55b4490da6d Mon Sep 17 00:00:00 2001 From: FrederikBaerentsen Date: Thu, 29 Feb 2024 13:30:25 -0500 Subject: [PATCH] Saving multiple sets works --- app.py | 3 +- static/style.css | 71 +++++++++++++++++++++++++++++++++- templates/bootstrap_table.html | 37 ++++++++++-------- 3 files changed, 92 insertions(+), 19 deletions(-) diff --git a/app.py b/app.py index bdc3c23..ef2242e 100644 --- a/app.py +++ b/app.py @@ -22,6 +22,7 @@ def index(): def save_number(): data1 = request.form.get('brick.part.part_num') data2 = request.form.get('brick.color.name') + data3 = request.form.get('index') number = request.form.get('numberInput') if number is not None: @@ -36,7 +37,7 @@ def save_number(): data = '{"brick" : {"ID":"' + data1 + '","color_name": "' + data2 + '","amount":"' + number + '"}}' - json_file['unit'][0]['bricks']['missing'].append(json.loads(data)) + json_file['unit'][int(data3)]['bricks']['missing'].append(json.loads(data)) with open('./info/'+tmp+'.json', 'w') as dump_file: json.dump(json_file,dump_file) diff --git a/static/style.css b/static/style.css index 30b09e8..dcb970e 100644 --- a/static/style.css +++ b/static/style.css @@ -1,6 +1,6 @@ body { font-family: Arial, sans-serif; - margin: 20px; + margin: 10px; } h1 { @@ -32,3 +32,72 @@ button:hover { background-color: #0056b3; } +/* The Modal (background) */ +.modal { + display: none; /* Hidden by default */ + position: fixed; /* Stay in place */ + z-index: 1; /* Sit on top */ + padding-top: 100px; /* Location of the box */ + left: 0; + top: 0; + width: 100%; /* Full width */ + height: 100%; /* Full height */ + overflow: auto; /* Enable scroll if needed */ + background-color: rgb(0,0,0); /* Fallback color */ + background-color: rgba(0,0,0,0.4); /* Black w/ opacity */ +} + +/* Modal Content */ +.modal-content { + position: relative; + background-color: #fefefe; + margin: auto; + padding: 0; + border: 1px solid #888; + width: 80%; + box-shadow: 0 4px 8px 0 rgba(0,0,0,0.2),0 6px 20px 0 rgba(0,0,0,0.19); + -webkit-animation-name: animatetop; + -webkit-animation-duration: 0.4s; + animation-name: animatetop; + animation-duration: 0.4s +} + +/* Add Animation */ +@-webkit-keyframes animatetop { + from {top:-300px; opacity:0} + to {top:0; opacity:1} +} + +@keyframes animatetop { + from {top:-300px; opacity:0} + to {top:0; opacity:1} +} + +/* The Close Button */ +.close { + color: white; + float: right; + font-size: 28px; + font-weight: bold; +} + +.close:hover, +.close:focus { + color: #000; + text-decoration: none; + cursor: pointer; +} + +.modal-header { + padding: 2px 16px; + background-color: #5cb85c; + color: white; +} + +.modal-body {padding: 2px 16px;} + +.modal-footer { + padding: 2px 16px; + background-color: #5cb85c; + color: white; +} \ No newline at end of file diff --git a/templates/bootstrap_table.html b/templates/bootstrap_table.html index 5b6ec2d..c16e0bf 100644 --- a/templates/bootstrap_table.html +++ b/templates/bootstrap_table.html @@ -13,7 +13,7 @@ qty is_spare {% for i in json_file['unit'] %} - Missing? + Missing ({{ loop.index }}) {% endfor %} @@ -28,24 +28,27 @@ {{ brick.color.name }} {{ brick.quantity }} {{ brick.is_spare }} - {% for i in json_file['unit'] %} - - {% set ns = namespace(count='') %} -
- - - - {% for j in i['bricks']['missing'] %} - {% if j['brick']['ID'] == brick.part.part_num and j['brick']['color_name'] == brick.color.name %} - {% set ns.count = j['brick']['amount'] %} - {% endif %} - {% endfor %} - -
- - {% endfor %} + {% for i in json_file['unit'] %} + + + {% set ns = namespace(count='') %} +
+ + + + + {% for j in json_file['unit'][loop.index0]['bricks']['missing'] %} + {% if j['brick']['ID'] == brick.part.part_num and j['brick']['color_name'] == brick.color.name %} + {% set ns.count = j['brick']['amount'] %} + {% endif %} + {% endfor %} + +
+ + {% endfor %} {% endfor %} + {% endblock %}