Use <b-select> for theme picker

instead of webhelpers2.html.tags.select() which seems to break for me
in dev now with python 3.10
This commit is contained in:
Lance Edgar 2023-10-25 10:45:33 -05:00
parent 72dda3771e
commit 70cc754f3e
3 changed files with 17 additions and 11 deletions

View file

@ -57,10 +57,6 @@ header span.header-text {
margin-right: 10px; margin-right: 10px;
} }
header .level .theme-picker {
display: inline-flex;
}
#content-title h1 { #content-title h1 {
margin-bottom: 0; margin-bottom: 0;
margin-right: 1rem; margin-right: 1rem;

View file

@ -158,7 +158,7 @@ def before_render(event):
default=['falafel']) default=['falafel'])
if 'default' not in available: if 'default' not in available:
available.insert(0, 'default') available.insert(0, 'default')
options = [tags.Option(theme) for theme in available] options = [tags.Option(theme, value=theme) for theme in available]
renderer_globals['theme_picker_options'] = options renderer_globals['theme_picker_options'] = options
# heck while we're assuming the classic web app here... # heck while we're assuming the classic web app here...

View file

@ -392,13 +392,19 @@
% if expose_theme_picker and request.has_perm('common.change_app_theme'): % if expose_theme_picker and request.has_perm('common.change_app_theme'):
<div class="level-item"> <div class="level-item">
${h.form(url('change_theme'), method="post", ref='themePickerForm')} ${h.form(url('change_theme'), method="post", ref='themePickerForm')}
${h.csrf_token(request)} ${h.csrf_token(request)}
Theme: <div style="display: flex; align-items: center; gap: 0.5rem;">
<div class="theme-picker"> <span>Theme:</span>
<div class="select"> <b-select name="theme"
${h.select('theme', theme, theme_picker_options, **{'@change': 'changeTheme()'})} v-model="globalTheme"
@change="changeTheme()">
% for option in theme_picker_options:
<option value="${option.value}">
${option.label}
</option>
% endfor
</b-select>
</div> </div>
</div>
${h.end_form()} ${h.end_form()}
</div> </div>
% endif % endif
@ -840,6 +846,10 @@
contentTitleHTML: ${json.dumps(capture(self.content_title))|n}, contentTitleHTML: ${json.dumps(capture(self.content_title))|n},
feedbackMessage: "", feedbackMessage: "",
% if expose_theme_picker and request.has_perm('common.change_app_theme'):
globalTheme: ${json.dumps(theme)|n},
% endif
% if can_edit_help: % if can_edit_help:
configureFieldsHelp: false, configureFieldsHelp: false,
% endif % endif