diff options
author | Frederick Yin <fkfd@fkfd.me> | 2021-10-24 23:12:27 +0800 |
---|---|---|
committer | Frederick Yin <fkfd@fkfd.me> | 2021-10-24 23:12:27 +0800 |
commit | 18b4424faba782e136202ab4d41086e79ace1bd7 (patch) | |
tree | e003e292e3626332b54e7bb79444d3b0c467d713 /jimbrella/templates/admin/umbrellas.html | |
parent | 0ed10326a182d6d37845cf5eb074e3e505d403cf (diff) |
Admin can now modify database from web console
Diffstat (limited to 'jimbrella/templates/admin/umbrellas.html')
-rw-r--r-- | jimbrella/templates/admin/umbrellas.html | 42 |
1 files changed, 41 insertions, 1 deletions
diff --git a/jimbrella/templates/admin/umbrellas.html b/jimbrella/templates/admin/umbrellas.html index 6bb4af5..15b6f02 100644 --- a/jimbrella/templates/admin/umbrellas.html +++ b/jimbrella/templates/admin/umbrellas.html @@ -15,7 +15,11 @@ {% for umb in umbrellas %} {% if umb.status in ["lent", "overdue"] %} <tr class="{{ umb.status }}"> - <th rowspan=5>{{ umb.serial }} <br /> {{ umb.status }}</th> + <th rowspan=5> + {{ umb.serial }} <br /> + {{ umb.status }} <br /> + <a href="/admin/umbrellas?edit={{ umb.serial }}">Edit</a> + </th> <td>{{ umb.tenant_name }}</td> </tr> <tr class="{{ umb.status }}"><td>{{ umb.tenant_id }}</td></tr> @@ -47,8 +51,40 @@ </tr> </thead> <tbody> + {% macro status_opt(umb, status) -%} + <option value="{{ status }}" + {% if umb.status == status %} + selected + {% endif %}> + {{ status }} + </option> + {%- endmacro %} + {% for umb in umbrellas %} <tr class="{{ umb.status }}"> + {% if umb.serial == edit %} + <form method="post" action="/admin/umbrellas/edit"> + <input name="serial" type="number" value="{{ umb.serial }}" hidden/> + <td>{{ umb.serial }}</td> + <td> + <select name="status"> + {% for status in ["available", "lent", "overdue"] %} + {{ status_opt(umb, status) }} + {% endfor %} + </select> + </td> + <td><input name="tenant_name" value="{{ umb.tenant_name }}" class="db-edit" /></td> + <td><input name="tenant_id" type="number" value="{{ umb.tenant_id }}" class="db-edit" /></td> + <td><input name="tenant_phone" type="tel" value="{{ umb.tenant_phone }}" class="db-edit" /></td> + <td><input name="lent_at" type="datetime-local" value="{{ umb.lent_at_str }}"/></td> + <td>{{ umb.lent_time_ago_str }} + {% if umb.status in ["lent", "overdue"] %} ago {% endif %} + </td> + <td> + <input type="submit" value="Submit" /> + </td> + </form> + {% else %} <td>{{ umb.serial }}</td> <td>{{ umb.status }}</td> <td>{{ umb.tenant_name }}</td> @@ -58,6 +94,10 @@ <td>{{ umb.lent_time_ago_str }} {% if umb.status in ["lent", "overdue"] %} ago {% endif %} </td> + <td> + <a href="/admin/umbrellas?edit={{ umb.serial }}">Edit</a> + </td> + {% endif %} </tr> {% endfor %} </tbody> |