diff --git a/static/scripts/changer.js b/static/scripts/changer.js
index 31177d5..224e24b 100644
--- a/static/scripts/changer.js
+++ b/static/scripts/changer.js
@@ -115,13 +115,11 @@ class BrickChanger {
}
// Helper to setup the changer
-const setup_changers = () => {
- document.querySelectorAll("*[data-changer-id]").forEach(el => {
- new BrickChanger(
- el.dataset.changerPrefix,
- el.dataset.changerId,
- el.dataset.changerUrl,
- el.dataset.changerParent
- );
- });
-}
\ No newline at end of file
+const setup_changers = () => document.querySelectorAll("*[data-changer-id]").forEach(
+ el => new BrickChanger(
+ el.dataset.changerPrefix,
+ el.dataset.changerId,
+ el.dataset.changerUrl,
+ el.dataset.changerParent
+ )
+);
\ No newline at end of file
diff --git a/static/scripts/grid.js b/static/scripts/grid.js
index 6246817..42b8ac3 100644
--- a/static/scripts/grid.js
+++ b/static/scripts/grid.js
@@ -50,15 +50,15 @@ class BrickGridSortButton {
// Grid class
class BrickGrid {
- constructor(id) {
- this.id = id;
+ constructor(grid) {
+ this.id = grid.id;
// Grid elements (built based on the initial id)
- this.html_grid = document.getElementById(id);
- this.html_sort = document.getElementById(`${id}-sort`);
- this.html_search = document.getElementById(`${id}-search`);
- this.html_filter = document.getElementById(`${id}-filter`);
- this.html_theme = document.getElementById(`${id}-theme`);
+ this.html_grid = document.getElementById(this.id);
+ this.html_sort = document.getElementById(`${this.id}-sort`);
+ this.html_search = document.getElementById(`${this.id}-search`);
+ this.html_filter = document.getElementById(`${this.id}-filter`);
+ this.html_theme = document.getElementById(`${this.id}-theme`);
// Sort buttons
this.html_sort_buttons = {};
@@ -251,3 +251,8 @@ class BrickGrid {
}
}
}
+
+// Helper to setup the grids
+const setup_grids = () => document.querySelectorAll('*[data-grid="true"]').forEach(
+ el => new BrickGrid(el)
+);
diff --git a/static/scripts/table.js b/static/scripts/table.js
index 68179af..669afc5 100644
--- a/static/scripts/table.js
+++ b/static/scripts/table.js
@@ -1,6 +1,19 @@
class BrickTable {
- constructor(id, per_page, no_sort = [], number = []) {
- const columns = [];
+ constructor(table, per_page) {
+ const columns = []
+ const no_sort = [];
+ const number = [];
+
+ // Read the table header for parameters
+ table.querySelectorAll('th').forEach((th, index) => {
+ if (th.dataset.tableNoSort) {
+ no_sort.push(index);
+ }
+
+ if (th.dataset.tableNumber) {
+ number.push(index);
+ }
+ });
if (no_sort.length) {
columns.push({ select: no_sort, sortable: false, searchable: false });
@@ -10,7 +23,7 @@ class BrickTable {
columns.push({ select: number, type: "number", searchable: false });
}
- this.table = new simpleDatatables.DataTable(`#${id}`, {
+ this.table = new simpleDatatables.DataTable(`#${table.id}`, {
columns: columns,
pagerDelta: 1,
perPage: per_page,
@@ -67,3 +80,8 @@ class BrickTable {
return search;
}
}
+
+// Helper to setup the tables
+const setup_tables = (per_page) => document.querySelectorAll('table[data-table="true"]').forEach(
+ el => new BrickTable(el, per_page)
+);
diff --git a/templates/add.html b/templates/add.html
index 8fff618..140eec6 100644
--- a/templates/add.html
+++ b/templates/add.html
@@ -70,7 +70,3 @@
{% include 'set/socket.html' %}
{% endblock %}
-
-{% block scripts %}
-
-{% endblock %}
\ No newline at end of file
diff --git a/templates/admin.html b/templates/admin.html
index 860d99f..dc87256 100644
--- a/templates/admin.html
+++ b/templates/admin.html
@@ -42,7 +42,3 @@
{% endblock %}
-
-{% block scripts %}
-
-{% endblock %}
\ No newline at end of file
diff --git a/templates/admin/checkbox.html b/templates/admin/checkbox.html
index 7cbd59d..b71cc2a 100644
--- a/templates/admin/checkbox.html
+++ b/templates/admin/checkbox.html
@@ -60,8 +60,3 @@
{{ accordion.footer() }}
-
diff --git a/templates/base.html b/templates/base.html
index 23badab..1132f2b 100644
--- a/templates/base.html
+++ b/templates/base.html
@@ -78,11 +78,25 @@
+
+
+
+
+
+
+
+
- {% block scripts %}{% endblock %}