Refactor inventory and layout templates: streamline script handling and improve toast message display
This commit is contained in:
parent
ebd2060fd8
commit
3492358645
3 changed files with 94 additions and 91 deletions
|
@ -130,17 +130,9 @@
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
|
|
||||||
{% block script %}
|
{% block script %}
|
||||||
document.addEventListener("DOMContentLoaded", () => {
|
|
||||||
const saveButton = document.getElementById("saveButton");
|
const saveButton = document.getElementById("saveButton");
|
||||||
const deleteButton = document.getElementById("deleteButton");
|
const deleteButton = document.getElementById("deleteButton");
|
||||||
|
|
||||||
const toastData = localStorage.getItem("toastMessage");
|
|
||||||
if (toastData) {
|
|
||||||
const { message, type } = JSON.parse(toastData);
|
|
||||||
renderToast({ message, type });
|
|
||||||
localStorage.removeItem("toastMessage");
|
|
||||||
}
|
|
||||||
|
|
||||||
if (saveButton) {
|
if (saveButton) {
|
||||||
saveButton.addEventListener("click", async (e) => {
|
saveButton.addEventListener("click", async (e) => {
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
|
@ -228,5 +220,4 @@
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
});
|
|
||||||
{% endblock %}
|
{% endblock %}
|
|
@ -78,7 +78,16 @@
|
||||||
searchInput.addEventListener('input', () => {
|
searchInput.addEventListener('input', () => {
|
||||||
searchButton.disabled = searchInput.value.trim() === '';
|
searchButton.disabled = searchInput.value.trim() === '';
|
||||||
});
|
});
|
||||||
|
|
||||||
|
document.addEventListener("DOMContentLoaded", () => {
|
||||||
|
const toastData = localStorage.getItem("toastMessage");
|
||||||
|
if (toastData) {
|
||||||
|
const { message, type } = JSON.parse(toastData);
|
||||||
|
renderToast({ message, type });
|
||||||
|
localStorage.removeItem("toastMessage");
|
||||||
|
}
|
||||||
{% block script %} {% endblock %}
|
{% block script %} {% endblock %}
|
||||||
|
});
|
||||||
</script>
|
</script>
|
||||||
</body>
|
</body>
|
||||||
|
|
||||||
|
|
|
@ -12,3 +12,6 @@
|
||||||
|
|
||||||
{{ tables.render_table(headers=header, rows=rows, id='table', entry_route=entry_route) }}
|
{{ tables.render_table(headers=header, rows=rows, id='table', entry_route=entry_route) }}
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
|
|
||||||
|
{% block script %}
|
||||||
|
{% endblock %}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue