Visually show that zip file downloads always include the executed SQL
authorKarl O. Pinc <kop@karlpinc.com>
Mon, 30 Sep 2024 16:51:06 +0000 (11:51 -0500)
committerKarl O. Pinc <kop@karlpinc.com>
Mon, 30 Sep 2024 16:51:16 +0000 (11:51 -0500)
Check, disable, and grey-out the Include SQL checkbox when downloading
a zip file.

src/pgwui_sql/static/pgwui_sql.css
src/pgwui_sql/static/sql_edit.js
src/pgwui_sql/templates/sql_edit.mak

index 29d76328b89e2c6a480c56dc690cd668a9083a75..c1ea714b31642140898fd703bea80cd1877be2e0 100644 (file)
@@ -70,3 +70,8 @@ textarea.sqltext { height: 40em;
 tr.eol_info > td > span > p { cursor: pointer; }
 tr.eol_info > td > span > p + p { margin-left: 10%;
                                   margin-right: 10%; }
+
+/* Dim controls that are "turned off" */
+[inert] {
+  opacity: 0.5;
+}
index 0cbb272205da96f4841720300f24e581c194245d..0b3145225562fd6b987d106f03768c317a9c7921 100644 (file)
@@ -69,6 +69,19 @@ function toggleDownload() {
     }
 }
 
+function toggleIncludeSqlInert() {
+    const include_sql = document.getElementById('include_sql_id');
+    const include_sql_label = document.getElementById('include_sql_label_id');
+    if (document.getElementById('download_as_many_files_id').checked) {
+        include_sql.checked = true;
+        include_sql.inert = true;
+        include_sql_label.inert = true;
+    } else {
+        include_sql.inert = false;
+        include_sql_label.inert = false;
+    }
+}
+
 /* Initialization */
 
 function attachEvents() {
@@ -112,6 +125,12 @@ function attachEvents() {
     const dl_ckbox = document.getElementById('download_label_id');
     dl_ckbox.addEventListener("click", toggleDownload);
     dl_ckbox.addEventListener("keydown", toggleDownload);
+
+    /* Download as zip file onchange */
+    document.getElementById('download_as_many_files_id')
+        .addEventListener("change", toggleIncludeSqlInert);
+    document.getElementById('download_as_one_file_id')
+        .addEventListener("change", toggleIncludeSqlInert);
 }
 
 attachEvents();
index 45fc195aa5b19451d47aefc914daa3ce35dacf4f..b7c3f2b8deae42bb2673c4af5af9c2a9e4b3f863 100644 (file)
         </%self.lib:td_input>
 
         ## Include SQL
-        <%self.lib:td_label for_id="include_sql_id">
+        <%self.lib:td_label for_id="include_sql_id" id="include_sql_label_id">
           Include SQL in the download
         </%self.lib:td_label>
         <%self.lib:td_input tab_index="${tab_index}">