From 3d625d86a7118fb6722b053e3d7afa5988fc592d Mon Sep 17 00:00:00 2001 From: "Karl O. Pinc" Date: Mon, 30 Sep 2024 11:51:06 -0500 Subject: [PATCH] Visually show that zip file downloads always include the executed SQL Check, disable, and grey-out the Include SQL checkbox when downloading a zip file. --- src/pgwui_sql/static/pgwui_sql.css | 5 +++++ src/pgwui_sql/static/sql_edit.js | 19 +++++++++++++++++++ src/pgwui_sql/templates/sql_edit.mak | 2 +- 3 files changed, 25 insertions(+), 1 deletion(-) diff --git a/src/pgwui_sql/static/pgwui_sql.css b/src/pgwui_sql/static/pgwui_sql.css index 29d7632..c1ea714 100644 --- a/src/pgwui_sql/static/pgwui_sql.css +++ b/src/pgwui_sql/static/pgwui_sql.css @@ -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; +} diff --git a/src/pgwui_sql/static/sql_edit.js b/src/pgwui_sql/static/sql_edit.js index 0cbb272..0b31452 100644 --- a/src/pgwui_sql/static/sql_edit.js +++ b/src/pgwui_sql/static/sql_edit.js @@ -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(); diff --git a/src/pgwui_sql/templates/sql_edit.mak b/src/pgwui_sql/templates/sql_edit.mak index 45fc195..b7c3f2b 100644 --- a/src/pgwui_sql/templates/sql_edit.mak +++ b/src/pgwui_sql/templates/sql_edit.mak @@ -264,7 +264,7 @@ ## 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_input tab_index="${tab_index}"> -- 2.34.1