diff options
author | Frederick Yin <fkfd@fkfd.me> | 2021-10-25 00:09:03 +0800 |
---|---|---|
committer | Frederick Yin <fkfd@fkfd.me> | 2021-10-25 00:09:03 +0800 |
commit | ab7b7f9b24e6bfdf231e142db64e7ae52cbe7fd3 (patch) | |
tree | 2158d8c7b4633bc020b3e0a9eab9b8f73a87eb29 /jimbrella | |
parent | 46e8097001aa29c27a5acce59f5c2ad83e850630 (diff) |
Mobile view for database edit
Diffstat (limited to 'jimbrella')
-rw-r--r-- | jimbrella/templates/admin/umbrellas.html | 66 |
1 files changed, 49 insertions, 17 deletions
diff --git a/jimbrella/templates/admin/umbrellas.html b/jimbrella/templates/admin/umbrellas.html index 15b6f02..8c92b4d 100644 --- a/jimbrella/templates/admin/umbrellas.html +++ b/jimbrella/templates/admin/umbrellas.html @@ -1,3 +1,17 @@ +{% macro status_dropdown(umb) -%} +{# A dropdown for umbrella status #} +<select name="status"> + {% for status in ["available", "lent", "overdue"] %} + <option value="{{ status }}" + {% if umb.status == status %} + selected + {% endif %}> + {{ status }} + </option> + {% endfor %} +</select> +{%- endmacro %} + <!DOCTYPE html> <html> <head> @@ -13,6 +27,33 @@ <div class="data-table-container"> <table class="data"> {% for umb in umbrellas %} + {% if umb.serial == edit %} + <form method="post" action="/admin/umbrellas/edit"> + <input name="serial" type="number" value="{{ umb.serial }}" hidden /> + <tr class="{{ umb.status }}"> + <th rowspan=5> + {{ umb.serial }} <br /> + {{ status_dropdown(umb) }} <br /> + <input type="submit" value="Submit" /> + </th> + <td><input name="tenant_name" value="{{ umb.tenant_name }}" /></td> + </tr> + <tr class="{{ umb.status }}"> + <td><input name="tenant_id" type="number" value="{{ umb.tenant_id }}" /></td> + </tr> + <tr class="{{ umb.status }}"> + <td><input name="tenant_phone" type="tel" value="{{ umb.tenant_phone }}" /></td> + </tr> + <tr class="{{ umb.status }}"> + <td><input name="lent_at" type="datetime-local" value="{{ umb.lent_at_str }}" /></td> + </tr> + <tr class="{{ umb.status }}"><td> + {{ umb.lent_time_ago_str }} + {% if umb.status in ["lent", "overdue"] %} ago {% endif %} + </td></tr> + </form> + {% else %} + {# not edit mode #} {% if umb.status in ["lent", "overdue"] %} <tr class="{{ umb.status }}"> <th rowspan=5> @@ -31,13 +72,19 @@ </td></tr> {% else %} <tr class="{{ umb.status }}"> - <th colspan=2>{{ umb.serial }} <br /> {{ umb.status }}</th> + <th colspan=2> + {{ umb.serial }} <br /> + {{ umb.status }} <br /> + <a href="/admin/umbrellas?edit={{ umb.serial }}">Edit</a> + </th> </tr> {% endif %} + {% endif %} {% endfor %} </table> </div> {% else %} + {# not mobile #} <div class="data-table-container"> <table class="data"> <thead> @@ -51,28 +98,13 @@ </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>{{ status_dropdown(umb) }}</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> |