--- /dev/null
+/* Copyright (C) 2024 The Meme Factory, Inc. http://www.karlpinc.com/
+ *
+ * This file is part of PGWUI_SQL.
+ *
+ * This program is free software: you can redistribute it and/or
+ * modify it under the terms of the GNU Affero General Public License
+ * as published by the Free Software Foundation, either version 3 of
+ * the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Affero General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public
+ * License along with this program. If not, see
+ * <http://www.gnu.org/licenses/>.
+ *
+ * Turned on and off to put "rules" in the container background.
+ *
+ * Karl O. Pinc <kop@karlpinc.com>
+ */
+
+div.stickycontainer {
+ background: repeating-linear-gradient(white 0 4em, lightcyan 0 8em);
+}
So don't try. Instead, set the background to "white", the same that
we set in the body's background. And then assume that all the backgrounds
in-between are transparent. */
-.stickyheading { position: sticky; /* attach to heading */
+.stickyheading { position: sticky; /* attach to heading */
top: 0;
- background-color: white; /* kludge, see above */
+ background-color: white; /* kludge, see above */
+ border-collapse: collapse; /* cover tbody background */
text-align: left; }
.stickycontainer { overflow-y: clip; } /* attach to heading's container */
.stickyfooting { position: sticky; /* attach to footer */
}
}
+function rulesDisplay(checked) {
+ if (checked) {
+ globalThis.horizontalRuleSheet.disabled = false;
+ } else {
+ globalThis.horizontalRuleSheet.disabled = true;
+ }
+}
+
/* Functions for initialization */
function getSheet(url) {
for (const sheet of document.styleSheets) {
}
}
applyCheckbox('show_spaces_id', whitespaceDisplay);
+ applyCheckbox('show_rules_id', rulesDisplay);
}
/* Initialization */
globalThis.tdSqltextSheet = getSheet(pgwuiSqlShowWhitespaceURL());
+globalThis.horizontalRuleSheet = getSheet(pgwuiSqlBackgroundRulesURL());
initializeStyling();
search_path The requested search_path
sql Text of the sql command(s)
result_rows List of SQLResult objects
+ show_rules HTML attribute of input element indicating checked checkbox
+ of the "Show rules" checkbox
show_spaces HTML attribute of input element indicating checked checkbox
of the "Show spaces" checkbox
</%doc>
return '${request.static_url(
"pgwui_sql:static/show_whitespace.css")}';
}
+ function pgwuiSqlBackgroundRulesURL() {
+ return '${request.static_url(
+ "pgwui_sql:static/background_rules.css")}';
+ }
// Set window name so that the sql_edit window can vary the target
// by db/user/etc. and have multiple result windows open at once.
window.name='${self.sql_results_target()}';
<link rel="stylesheet"
href="${request.static_url('pgwui_sql:static/show_whitespace.css')}"
type="text/css" />
+ <link rel="stylesheet"
+ href="${request.static_url('pgwui_sql:static/background_rules.css')}"
+ type="text/css" />
</%block>
<%block name="action_success">
% endfor
<div class="stickyfooting">
<hr>
+ <self.lib:td_label for_id="show_rules_id">
+ Show rules
+ </self.lib:td_label>
+ <self.lib:td_input tab_index="${tab_index}">
+ <input name="show_rules"
+ id="show_rules_id"
+ tabindex="${tab_index.val}"
+ type="checkbox"
+ ${show_rules | n}
+ onchange="rulesDisplay(this.checked)"
+ />
+ </self.lib:td_input>
+
<self.lib:td_label for_id="show_spaces_id">
Show spaces
</self.lib:td_label>
@attrs.define(slots=False)
class SQLInitialPost(pgwui_sql.views.base.SQLBaseInitialPost):
show_spaces = attrs.field(default=False)
+ show_rules = attrs.field(default=False)
class SQLWTForm(pgwui_sql.views.base.SQLBaseWTForm):
# just to keep my hand in.
show_spaces = wtforms.fields.BooleanField(
'Show spaces', id='show_spaces_id')
+ show_rules = wtforms.fields.BooleanField(
+ 'Show rules', id='show_rules_id')
@attrs.define(slots=False)
uh The UploadHandler instance using the form
'''
show_spaces = attrs.field(default=False)
+ show_rules = attrs.field(default=False)
def read(self):
'''
# Read our own data
self['show_spaces'] = self._form.show_spaces.data
+ self['show_rules'] = self._form.show_rules.data
def write(self, result, errors):
'''
Produces the dict pyramid will use to render the form.
'''
response = super().write(result, errors)
+
if self['show_spaces']:
response['show_spaces'] = CHECKED
else:
response['show_spaces'] = UNCHECKED
+
+ if self['show_rules']:
+ response['show_rules'] = CHECKED
+ else:
+ response['show_rules'] = UNCHECKED
+
return response