aligned "Neu" button with datatables search field
This commit is contained in:
parent
75984984dd
commit
ad6af25a48
@ -2,7 +2,8 @@
|
|||||||
|
|
||||||
{% block title %}Texte{% endblock title %}
|
{% block title %}Texte{% endblock title %}
|
||||||
|
|
||||||
{% block script %}<script>
|
{% block script %}
|
||||||
|
<script>
|
||||||
const SCRIPT_ROOT = {{ request.script_root | tojson }};
|
const SCRIPT_ROOT = {{ request.script_root | tojson }};
|
||||||
const textValues = ["Titel", "Untertitel"];
|
const textValues = ["Titel", "Untertitel"];
|
||||||
const selectValues = ["Reihe", "Textform", "Sprache"];
|
const selectValues = ["Reihe", "Textform", "Sprache"];
|
||||||
@ -51,18 +52,26 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
window.onload = function () {
|
window.onload = function () {
|
||||||
// add event listeners
|
|
||||||
document.getElementById ("create-button").addEventListener("click", showCreateModal, false);
|
|
||||||
for (const el of document.querySelectorAll('.action-update') ) {
|
|
||||||
el.addEventListener("click", showUpdateModal, false);
|
|
||||||
}
|
|
||||||
|
|
||||||
// initialise DataTable
|
// initialise DataTable
|
||||||
let table = new DataTable('#text-table', {
|
let table = new DataTable('#text-table', {
|
||||||
paging: false,
|
paging: false,
|
||||||
order: []
|
order: []
|
||||||
});
|
});
|
||||||
deRole("#text-table");
|
deRole("#text-table");
|
||||||
|
|
||||||
|
// create and append "New"-button to
|
||||||
|
let button = document.createElement("button");
|
||||||
|
button.id = "create-button";
|
||||||
|
button.setAttribute("title", "Text hinzufügen");
|
||||||
|
button.innerHTML = "Neu …";
|
||||||
|
button.addEventListener("click", showCreateModal, false);
|
||||||
|
document.getElementById("text-table_wrapper").firstElementChild.firstElementChild.appendChild(button);
|
||||||
|
|
||||||
|
// add event listeners
|
||||||
|
document.getElementById ("create-button").addEventListener("click", showCreateModal, false);
|
||||||
|
for (const el of document.querySelectorAll('.action-update') ) {
|
||||||
|
el.addEventListener("click", showUpdateModal, false);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
</script>{% endblock script %}
|
</script>{% endblock script %}
|
||||||
|
|
||||||
@ -72,13 +81,6 @@
|
|||||||
|
|
||||||
{% include "_icons.svg" %}
|
{% include "_icons.svg" %}
|
||||||
|
|
||||||
<section>
|
|
||||||
<button id="create-button" onclick="showCreateModal()" title="Text hinzufügen">
|
|
||||||
<!-- <svg viewbox="0 0 24 24"><use href="#create" /></svg> -->
|
|
||||||
Neu …
|
|
||||||
</button>
|
|
||||||
</section>
|
|
||||||
|
|
||||||
<table id="text-table">
|
<table id="text-table">
|
||||||
<thead>
|
<thead>
|
||||||
<tr>
|
<tr>
|
||||||
|
|||||||
@ -2,7 +2,8 @@
|
|||||||
|
|
||||||
{% block title %}Werke{% endblock title %}
|
{% block title %}Werke{% endblock title %}
|
||||||
|
|
||||||
{% block script %}<script>
|
{% block script %}
|
||||||
|
<script>
|
||||||
const SCRIPT_ROOT = {{ request.script_root | tojson }};
|
const SCRIPT_ROOT = {{ request.script_root | tojson }};
|
||||||
const textValues = ["Titel", "Untertitel", "Reihennummer", "Erscheinungsdatum", "ISBN_13", "ISBN_10", "ISSN", "Preis", "Klappentext", "Anmerkungen"];
|
const textValues = ["Titel", "Untertitel", "Reihennummer", "Erscheinungsdatum", "ISBN_13", "ISBN_10", "ISSN", "Preis", "Klappentext", "Anmerkungen"];
|
||||||
const selectValues = ["Werksform", "Verlag", "Reihe"];
|
const selectValues = ["Werksform", "Verlag", "Reihe"];
|
||||||
@ -11,18 +12,18 @@
|
|||||||
function showCreateModal() {
|
function showCreateModal() {
|
||||||
// set modal heading
|
// set modal heading
|
||||||
document.getElementById("dialog-heading").textContent = "Werk hinzufügen";
|
document.getElementById("dialog-heading").textContent = "Werk hinzufügen";
|
||||||
// empty text inputs
|
// empty text inputs
|
||||||
for (const v of textValues) { document.getElementById(`form_${v}`).value = ""; }
|
for (const v of textValues) { document.getElementById(`form_${v}`).value = ""; }
|
||||||
// empty select inputs
|
// empty select inputs
|
||||||
for (const v of selectValues) { document.getElementById(`form_${v}`).selectedIndex = ""; }
|
for (const v of selectValues) { document.getElementById(`form_${v}`).selectedIndex = ""; }
|
||||||
// empty file inputs
|
// empty file inputs
|
||||||
for (const v of blobValues) {} //document.getElementById(`form_${v}`).value = "";
|
for (const v of blobValues) {} //document.getElementById(`form_${v}`).value = "";
|
||||||
// set form action
|
// set form action
|
||||||
document.getElementById("form_submit").formAction = "{{ url_for('werk.create') }}";
|
document.getElementById("form_submit").formAction = "{{ url_for('werk.create') }}";
|
||||||
// show modal
|
// show modal
|
||||||
document.getElementById("werkmodal").showModal();
|
document.getElementById("werkmodal").showModal();
|
||||||
}
|
}
|
||||||
|
|
||||||
function showUpdateModal() {
|
function showUpdateModal() {
|
||||||
let id = this.dataset.id;
|
let id = this.dataset.id;
|
||||||
let url = `${SCRIPT_ROOT}/werk/read/${id}`;
|
let url = `${SCRIPT_ROOT}/werk/read/${id}`;
|
||||||
@ -39,12 +40,12 @@
|
|||||||
function (response) {
|
function (response) {
|
||||||
// set modal heading
|
// set modal heading
|
||||||
document.getElementById("dialog-heading").textContent = "Werk ansehen / bearbeiten";
|
document.getElementById("dialog-heading").textContent = "Werk ansehen / bearbeiten";
|
||||||
// populate text inputs
|
// populate text inputs
|
||||||
for (const v of textValues) { document.getElementById(`form_${v}`).value = response[v]; }
|
for (const v of textValues) { document.getElementById(`form_${v}`).value = response[v]; }
|
||||||
// populate select imputs
|
// populate select imputs
|
||||||
for (const v of selectValues) { document.getElementById(`form_${v}`).selectedIndex = response[v]; }
|
for (const v of selectValues) { document.getElementById(`form_${v}`).selectedIndex = response[v]; }
|
||||||
// populate file inputs
|
// populate file inputs
|
||||||
for (const v of blobValues) {} //document.getElementById(`form_${v}`).value = response[v];
|
for (const v of blobValues) {} //document.getElementById(`form_${v}`).value = response[v];
|
||||||
// set form action
|
// set form action
|
||||||
document.getElementById("form_submit").formAction = `${SCRIPT_ROOT}/werk/update/${id}`;
|
document.getElementById("form_submit").formAction = `${SCRIPT_ROOT}/werk/update/${id}`;
|
||||||
// show modal
|
// show modal
|
||||||
@ -53,22 +54,30 @@
|
|||||||
)
|
)
|
||||||
.catch((error) => console.log(error));
|
.catch((error) => console.log(error));
|
||||||
}
|
}
|
||||||
|
|
||||||
window.onload = function () {
|
|
||||||
// add event listeners
|
|
||||||
document.getElementById ("create-button").addEventListener("click", showCreateModal, false);
|
|
||||||
for (const el of document.querySelectorAll('.action-update') ) {
|
|
||||||
el.addEventListener("click", showUpdateModal, false);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
window.onload = function () {
|
||||||
// initialise DataTable
|
// initialise DataTable
|
||||||
let table = new DataTable('#werk-table', {
|
let table = new DataTable('#werk-table', {
|
||||||
paging: false,
|
paging: false,
|
||||||
order: []
|
order: []
|
||||||
});
|
});
|
||||||
deRole("#werk-table");
|
deRole("#werk-table");
|
||||||
|
|
||||||
|
// create and append "New"-button to
|
||||||
|
let button = document.createElement("button");
|
||||||
|
button.id = "create-button";
|
||||||
|
button.setAttribute("title", "Werk hinzufügen");
|
||||||
|
button.innerHTML = "Neu …";
|
||||||
|
button.addEventListener("click", showCreateModal, false);
|
||||||
|
document.getElementById("werk-table_wrapper").firstElementChild.firstElementChild.appendChild(button);
|
||||||
|
|
||||||
|
// add event listeners
|
||||||
|
for (const el of document.querySelectorAll('.action-update') ) {
|
||||||
|
el.addEventListener("click", showUpdateModal, false);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
</script>{% endblock script %}
|
</script>
|
||||||
|
{% endblock script %}
|
||||||
|
|
||||||
{% block heading %}Werke{% endblock heading %}
|
{% block heading %}Werke{% endblock heading %}
|
||||||
|
|
||||||
@ -76,13 +85,6 @@
|
|||||||
|
|
||||||
{% include "_icons.svg" %}
|
{% include "_icons.svg" %}
|
||||||
|
|
||||||
<section>
|
|
||||||
<button id="create-button" href="#" title="Werk hinzufügen">
|
|
||||||
<!-- <svg viewbox="0 0 24 24"><use href="#create" /></svg> -->
|
|
||||||
Neu …
|
|
||||||
</button>
|
|
||||||
</section>
|
|
||||||
|
|
||||||
<table id="werk-table">
|
<table id="werk-table">
|
||||||
<thead>
|
<thead>
|
||||||
<tr>
|
<tr>
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user