crud with conditions

This commit is contained in:
null
2024-02-28 21:02:23 +01:00
parent 99b78c9bd1
commit a56cf12c2a
6 changed files with 82 additions and 35 deletions
+11 -4
View File
@@ -14,12 +14,19 @@
<h2>Create a condition</h2>
<form method="POST" action="/conditions">
<fieldset>
<label for="itemDescription">Beschreibung</label>
<input type="text" name="itemDescription">
<label for="symbol">Symbol</label>
<input type="text" name="symbol">
<label for="itemName">Name</label>
<input type="text" name="itemName">
<label for="condition">Condition</label>
<select name="condition">
<option value="gt">Greater than</option>
<option value="lt">Lower than</option>
</select>
<label for="value">Value</label>
<input type="number" step="any" name="value">
</fieldset>
<fieldset>
<button value="cancel" formmethod="dialog" onclick="window.top.postMessage('close', '*')">Cancel</button>
<button type="submit">Submit</button>
+10 -4
View File
@@ -17,11 +17,17 @@
<label>ID</label>
<div>{{ data.id }}</div>
<label for="itemDescription">Beschreibung</label>
<input type="text" name="itemDescription" value="{{ data.itemDescription }}">
<label for="symbol">Symbol</label>
<input type="text" name="symbol" value="{{ data.symbol }}">
<label for="itemName">Name</label>
<input type="text" name="itemName" value="{{ data.itemName }}">
<label for="condition">Condition</label>
<select name="condition">
<option value="gt" {% if data.condition == "gt" %}selected{% endif %}>Greater than</option>
<option value="lt" {% if data.condition == "lt" %}selected{% endif %}>Lower than</option>
</select>
<label for="value">Value</label>
<input type="number" step="any" name="value" value="{{ data.value }}">
</fieldset>
<fieldset>
<button value="cancel" formmethod="dialog" onclick="window.top.postMessage('close', '*')">Cancel</button>
+19 -8
View File
@@ -11,30 +11,41 @@
<body>
<div class="container">
<h1>Conditions</h1>
<dialog>
<iframe frameborder="0"></iframe>
</dialog>
<table id="conditionTable">
<thead>
<tr>
{% for key, value in data.conditions.model.items() %}
<th>{{ value.name }}</th>
{% endfor %}
<td colspan="5"><h2>Conditions</h2></td>
</tr>
{% if data.conditions %}
<tr>
<th>ID</th>
<th>Symbol</th>
<th>Condition</th>
<th>Value</th>
</tr>
{% else %}
<tr>
<th class="nodata">No Data</th>
</tr>
{% endif %}
</thead>
<tbody>
{% for item in data.conditions.data %}
{% for item in data.conditions %}
<tr onclick="document.querySelector('dialog iframe').contentWindow.location='/conditions/{{ item.id }}'">
{% for key, value in item.items() %}
<td>{{ value }}</td>
{% set order = ["id", "symbol", "condition", "value"] %}
{% for key in order %}
<td>{{ item[key] }}</td>
{% endfor %}
</tr>
{% endfor %}
</tbody>
<tfoot>
<tr>
<td colspan="3" style="text-align: right;"> <!-- Adjust colspan as per your total columns -->
<td colspan="5" style="text-align: right;"> <!-- Adjust colspan as per your total columns -->
<button onclick="document.querySelector('dialog iframe').contentWindow.location='/conditions/create'">Add Item</button>
</td>
</tr>