step 2 with basic crud implemented
This commit is contained in:
@@ -0,0 +1,28 @@
|
||||
{% extends "base.html" %}
|
||||
|
||||
{% block content %}
|
||||
<div class="page-header">
|
||||
<h1>{{ page_title }}</h1>
|
||||
<a href="/boxes">返回箱子列表</a>
|
||||
</div>
|
||||
|
||||
<form method="post" action="{{ form_action }}" class="stack">
|
||||
<label>
|
||||
名称
|
||||
<input type="text" name="name" value="{{ box.name if box else '' }}" required>
|
||||
</label>
|
||||
<label>
|
||||
房间
|
||||
<input type="text" name="room" value="{{ box.room if box and box.room else '' }}">
|
||||
</label>
|
||||
<label>
|
||||
状态
|
||||
<input type="text" name="status" value="{{ box.status if box and box.status else '' }}">
|
||||
</label>
|
||||
<label>
|
||||
备注
|
||||
<textarea name="note" rows="4">{{ box.note if box and box.note else '' }}</textarea>
|
||||
</label>
|
||||
<button type="submit">{{ submit_label }}</button>
|
||||
</form>
|
||||
{% endblock %}
|
||||
@@ -0,0 +1,34 @@
|
||||
{% extends "base.html" %}
|
||||
|
||||
{% block content %}
|
||||
<div class="page-header">
|
||||
<div>
|
||||
<h1>箱子</h1>
|
||||
<p class="muted">这里管理顶层搬家容器,例如纸箱、行李箱或大收纳箱。</p>
|
||||
</div>
|
||||
<a class="button" href="/boxes/new">新建箱子</a>
|
||||
</div>
|
||||
|
||||
{% if boxes %}
|
||||
<div class="stack">
|
||||
{% for box in boxes %}
|
||||
<section class="card">
|
||||
<h2><a href="/boxes/{{ box.id }}">{{ box.name }}</a></h2>
|
||||
<p class="meta">物品数:{{ box.items|length }}</p>
|
||||
{% if box.room %}<p>房间:{{ box.room }}</p>{% endif %}
|
||||
{% if box.status %}<p>状态:{{ box.status }}</p>{% endif %}
|
||||
{% if box.note %}<p>{{ box.note }}</p>{% endif %}
|
||||
<div class="actions">
|
||||
<a href="/boxes/{{ box.id }}">查看详情</a>
|
||||
<a href="/boxes/{{ box.id }}/edit">编辑</a>
|
||||
</div>
|
||||
</section>
|
||||
{% endfor %}
|
||||
</div>
|
||||
{% else %}
|
||||
<section class="card">
|
||||
<p>还没有箱子。</p>
|
||||
<a href="/boxes/new">创建第一个箱子</a>
|
||||
</section>
|
||||
{% endif %}
|
||||
{% endblock %}
|
||||
@@ -0,0 +1,54 @@
|
||||
{% extends "base.html" %}
|
||||
|
||||
{% block content %}
|
||||
<div class="page-header">
|
||||
<div>
|
||||
<h1>{{ box.name }}</h1>
|
||||
<p class="muted">查看这个箱子的基本信息,以及它下面的直接物品。</p>
|
||||
</div>
|
||||
<div class="actions">
|
||||
<a href="/boxes">返回箱子列表</a>
|
||||
<a class="button" href="/boxes/{{ box.id }}/items/new">添加物品</a>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<section class="card">
|
||||
<p><strong>房间:</strong> {{ box.room or '-' }}</p>
|
||||
<p><strong>状态:</strong> {{ box.status or '-' }}</p>
|
||||
<p><strong>备注:</strong> {{ box.note or '-' }}</p>
|
||||
<div class="actions">
|
||||
<a href="/boxes/{{ box.id }}/edit">编辑箱子</a>
|
||||
<form method="post" action="/boxes/{{ box.id }}/delete">
|
||||
<button type="submit" class="link-button">删除箱子</button>
|
||||
</form>
|
||||
</div>
|
||||
</section>
|
||||
|
||||
<section class="stack">
|
||||
<h2>物品</h2>
|
||||
{% if box.items %}
|
||||
{% for item in box.items %}
|
||||
<article class="card">
|
||||
<h3><a href="/items/{{ item.id }}">{{ item.name }}</a></h3>
|
||||
<p><strong>是否容器:</strong> {{ "是" if item.is_container else "否" }}</p>
|
||||
{% if item.quantity is not none %}<p><strong>数量:</strong> {{ item.quantity }}</p>{% endif %}
|
||||
{% if item.note %}<p><strong>备注:</strong> {{ item.note }}</p>{% endif %}
|
||||
<div class="actions">
|
||||
<a href="/items/{{ item.id }}">查看详情</a>
|
||||
<a href="/items/{{ item.id }}/edit">编辑</a>
|
||||
{% if item.is_container %}
|
||||
<a href="/items/{{ item.id }}">查看内部内容</a>
|
||||
{% endif %}
|
||||
<form method="post" action="/items/{{ item.id }}/delete">
|
||||
<button type="submit" class="link-button">删除</button>
|
||||
</form>
|
||||
</div>
|
||||
</article>
|
||||
{% endfor %}
|
||||
{% else %}
|
||||
<section class="card">
|
||||
<p>这个箱子里还没有物品。</p>
|
||||
</section>
|
||||
{% endif %}
|
||||
</section>
|
||||
{% endblock %}
|
||||
Reference in New Issue
Block a user