Revised the accounting reordering to handle the cases with only one account or no account.
This commit is contained in:
parent
589da0c1c6
commit
1c1be87f3e
@ -24,14 +24,16 @@
|
|||||||
// Initializes the page JavaScript.
|
// Initializes the page JavaScript.
|
||||||
document.addEventListener("DOMContentLoaded", function () {
|
document.addEventListener("DOMContentLoaded", function () {
|
||||||
const list = document.getElementById("account-order-list");
|
const list = document.getElementById("account-order-list");
|
||||||
const onReorder = function () {
|
if (list !== null) {
|
||||||
const accounts = Array.from(list.children);
|
const onReorder = function () {
|
||||||
for (let i = 0; i < accounts.length; i++) {
|
const accounts = Array.from(list.children);
|
||||||
const no = document.getElementById("account-order-" + accounts[i].dataset.id + "-no");
|
for (let i = 0; i < accounts.length; i++) {
|
||||||
const code = document.getElementById("account-order-" + accounts[i].dataset.id + "-code");
|
const no = document.getElementById("account-order-" + accounts[i].dataset.id + "-no");
|
||||||
no.value = String(i + 1);
|
const code = document.getElementById("account-order-" + accounts[i].dataset.id + "-code");
|
||||||
code.innerText = list.dataset.baseCode + "-" + ("000" + (i + 1)).slice(-3);
|
no.value = String(i + 1);
|
||||||
}
|
code.innerText = list.dataset.baseCode + "-" + ("000" + (i + 1)).slice(-3);
|
||||||
};
|
}
|
||||||
initializeDragAndDropReordering(list, onReorder);
|
};
|
||||||
|
initializeDragAndDropReordering(list, onReorder);
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
@ -37,36 +37,46 @@ First written: 2023/2/2
|
|||||||
</a>
|
</a>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<form action="{{ url_for("accounting.account.sort", base=base) }}" method="post">
|
{% if base.accounts|length > 1 %}
|
||||||
<input id="csrf_token" type="hidden" name="csrf_token" value="{{ csrf_token() }}">
|
<form action="{{ url_for("accounting.account.sort", base=base) }}" method="post">
|
||||||
{% if "next" in request.args %}
|
<input id="csrf_token" type="hidden" name="csrf_token" value="{{ csrf_token() }}">
|
||||||
<input type="hidden" name="next" value="{{ request.args["next"] }}">
|
{% if "next" in request.args %}
|
||||||
{% endif %}
|
<input type="hidden" name="next" value="{{ request.args["next"] }}">
|
||||||
<ul id="account-order-list" class="list-group mb-3" data-base-code="{{ base.code }}">
|
{% endif %}
|
||||||
{% for account in base.accounts|sort(attribute="no") %}
|
<ul id="account-order-list" class="list-group mb-3" data-base-code="{{ base.code }}">
|
||||||
<li class="list-group-item d-flex justify-content-between" data-id="{{ account.id }}">
|
{% for account in base.accounts|sort(attribute="no") %}
|
||||||
<input id="account-order-{{ account.id }}-no" type="hidden" name="{{ account.id }}-no" value="{{ loop.index }}">
|
<li class="list-group-item d-flex justify-content-between" data-id="{{ account.id }}">
|
||||||
<div>
|
<input id="account-order-{{ account.id }}-no" type="hidden" name="{{ account.id }}-no" value="{{ loop.index }}">
|
||||||
<span id="account-order-{{ account.id }}-code">{{ account.code }}</span>
|
<div>
|
||||||
{{ account.title }}
|
<span id="account-order-{{ account.id }}-code">{{ account.code }}</span>
|
||||||
</div>
|
{{ account.title }}
|
||||||
<i class="fa-solid fa-bars"></i>
|
</div>
|
||||||
</li>
|
<i class="fa-solid fa-bars"></i>
|
||||||
{% endfor %}
|
</li>
|
||||||
|
{% endfor %}
|
||||||
|
</ul>
|
||||||
|
|
||||||
|
<div class="d-none d-md-block">
|
||||||
|
<button class="btn btn-primary" type="submit">
|
||||||
|
<i class="fa-solid fa-floppy-disk"></i>
|
||||||
|
{{ A_("Save") }}
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="d-md-none material-fab">
|
||||||
|
<button class="btn btn-primary" type="submit">
|
||||||
|
<i class="fa-solid fa-floppy-disk"></i>
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
</form>
|
||||||
|
{% elif base.accounts|length == 1 %}
|
||||||
|
<ul class="list-group mb-3">
|
||||||
|
<li class="list-group-item">
|
||||||
|
{{ base.accounts[0] }}
|
||||||
|
</li>
|
||||||
</ul>
|
</ul>
|
||||||
|
{% else %}
|
||||||
<div class="d-none d-md-block">
|
<p>{{ A_("There is no data.") }}</p>
|
||||||
<button class="btn btn-primary" type="submit">
|
{% endif %}
|
||||||
<i class="fa-solid fa-floppy-disk"></i>
|
|
||||||
{{ A_("Save") }}
|
|
||||||
</button>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div class="d-md-none material-fab">
|
|
||||||
<button class="btn btn-primary" type="submit">
|
|
||||||
<i class="fa-solid fa-floppy-disk"></i>
|
|
||||||
</button>
|
|
||||||
</div>
|
|
||||||
</form>
|
|
||||||
|
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
|
Loading…
Reference in New Issue
Block a user