feat: inline rename for profiles, dashboard stats grid UI
This commit is contained in:
@@ -16,13 +16,18 @@
|
||||
<tbody>
|
||||
{% for p in profiles %}
|
||||
<tr>
|
||||
<td><a href="/profiles/{{ p.id }}/postcards">{{ p.nickname }}</a></td>
|
||||
<td>
|
||||
<span class="nickname-display" id="name-display-{{ p.id }}">{{ p.nickname }}</span>
|
||||
<form method="post" action="/profiles/{{ p.id }}/rename" class="inline nickname-edit" id="name-edit-{{ p.id }}" style="display:none">
|
||||
<input type="text" name="nickname" value="{{ p.nickname }}" required>
|
||||
<button type="submit" class="btn btn-primary btn-sm">确定</button>
|
||||
<button type="button" class="btn btn-sm" onclick="cancelRename({{ p.id }})">取消</button>
|
||||
</form>
|
||||
</td>
|
||||
<td>{{ p.created_at.strftime('%Y-%m-%d %H:%M') }}</td>
|
||||
<td>
|
||||
<form method="post" action="/profiles/{{ p.id }}/rename" class="inline rename-form">
|
||||
<input type="text" name="nickname" value="{{ p.nickname }}" required>
|
||||
<button type="submit" class="btn btn-sm">改名</button>
|
||||
</form>
|
||||
<a href="/profiles/{{ p.id }}/postcards" class="btn btn-sm">查看</a>
|
||||
<button type="button" class="btn btn-sm" onclick="startRename({{ p.id }})">改名</button>
|
||||
<form method="post" action="/profiles/{{ p.id }}/delete" class="inline">
|
||||
<button type="submit" class="btn btn-danger btn-sm" onclick="return confirm('确定删除该 Profile 及其所有明信片?')">删除</button>
|
||||
</form>
|
||||
@@ -34,4 +39,16 @@
|
||||
{% else %}
|
||||
<p class="empty">还没有 Profile。</p>
|
||||
{% endif %}
|
||||
<script>
|
||||
function startRename(id) {
|
||||
document.getElementById('name-display-' + id).style.display = 'none';
|
||||
var edit = document.getElementById('name-edit-' + id);
|
||||
edit.style.display = 'inline-flex';
|
||||
edit.querySelector('input').focus();
|
||||
}
|
||||
function cancelRename(id) {
|
||||
document.getElementById('name-display-' + id).style.display = '';
|
||||
document.getElementById('name-edit-' + id).style.display = 'none';
|
||||
}
|
||||
</script>
|
||||
{% endblock %}
|
||||
|
||||
Reference in New Issue
Block a user