about summary refs log tree commit diff
path: root/uploader/static/js/populations.js
diff options
context:
space:
mode:
authorFrederick Muriuki Muriithi2025-03-11 16:50:04 -0500
committerFrederick Muriuki Muriithi2025-03-11 16:58:43 -0500
commitcfa33d211372d40edcd35d2c0d74daf261fe6bf3 (patch)
tree9de7a84e4e87c693d7b54ca2ac4271e720313a7d /uploader/static/js/populations.js
parentef71af77671669531bbc07c7363511117b7d13e9 (diff)
downloadgn-uploader-cfa33d211372d40edcd35d2c0d74daf261fe6bf3.tar.gz
Extract common DataTables into a reusable function.
Diffstat (limited to 'uploader/static/js/populations.js')
-rw-r--r--uploader/static/js/populations.js33
1 files changed, 8 insertions, 25 deletions
diff --git a/uploader/static/js/populations.js b/uploader/static/js/populations.js
index 5c1f848..73e298a 100644
--- a/uploader/static/js/populations.js
+++ b/uploader/static/js/populations.js
@@ -1,19 +1,10 @@
-var populationDataTable = (populationdata) => {
-    var lengthMenu = [10, 25, 50, 100, 1000];
-    if(populationdata.length > 1000) {
-        lengthMenu.push(populationdata.length)
-    }
-    $("#tbl-select-population").DataTable({
-        responsive: true,
-        lengthMenu: lengthMenu,
-        language: {
-            processing: "Processing… Please wait.",
-            loadingRecords: "Loading population — Please wait.",
-            lengthMenu: "Show _MENU_ populations",
-            info: "Showing _START_ to _END_ of _TOTAL_ populations"
-        },
-        data: populationdata,
-        columns: [
+$(() => {
+    dtAddCommonHandlers("#tbl-select-population");
+    var populationsDataTable = buildDataTable(
+        "#tbl-select-population",
+        JSON.parse(
+            $("#tbl-select-population").attr("data-populations-list")),
+        [
             {
                 data: (apopulation) => {
                     return `<input type="radio" name="population_id"`
@@ -27,13 +18,5 @@ var populationDataTable = (populationdata) => {
                     return `${apopulation.FullName} (${apopulation.InbredSetName})`;
                 }
             }
-        ]
-    });
-};
-
-
-$(() => {
-    dtAddCommonHandlers("#tbl-select-population");
-    populationDataTable(JSON.parse(
-        $("#tbl-select-population").attr("data-populations-list")));
+        ]);
 });