Hide the "configure field help" icons until user requests access
user can technically "request access" on "any page" and not just those with configurable fields..but who cares for now i think..
This commit is contained in:
parent
dc90abcf09
commit
cfc92ac9e7
6 changed files with 117 additions and 62 deletions
|
@ -900,11 +900,17 @@ class Form(object):
|
|||
not for "readonly" fields.
|
||||
"""
|
||||
dform = self.make_deform_form()
|
||||
field = dform[fieldname]
|
||||
label = self.get_label(fieldname)
|
||||
markdowns = self.get_field_markdowns()
|
||||
field = dform[fieldname] if fieldname in dform else None
|
||||
|
||||
include = bool(field)
|
||||
if self.readonly or (not field and fieldname in self.readonly_fields):
|
||||
include = True
|
||||
if not include:
|
||||
return
|
||||
|
||||
if self.field_visible(fieldname):
|
||||
label = self.get_label(fieldname)
|
||||
markdowns = self.get_field_markdowns()
|
||||
|
||||
# these attrs will be for the <b-field> (*not* the widget)
|
||||
attrs = {
|
||||
|
@ -912,15 +918,17 @@ class Form(object):
|
|||
}
|
||||
|
||||
# add some magic for file input fields
|
||||
if isinstance(field.schema.typ, deform.FileData):
|
||||
if field and isinstance(field.schema.typ, deform.FileData):
|
||||
attrs['class_'] = 'file'
|
||||
|
||||
# show helptext if present
|
||||
# TODO: older logic did this only if field was *not*
|
||||
# readonly, perhaps should add that back..
|
||||
if self.has_helptext(fieldname):
|
||||
attrs['message'] = self.render_helptext(fieldname)
|
||||
|
||||
# show errors if present
|
||||
error_messages = self.get_error_messages(field)
|
||||
error_messages = self.get_error_messages(field) if field else None
|
||||
if error_messages:
|
||||
|
||||
# TODO: this surely can't be what we ought to do
|
||||
|
@ -941,22 +949,16 @@ class Form(object):
|
|||
attrs.update(bfield_attrs)
|
||||
|
||||
# render the field widget or whatever
|
||||
html = field.serialize(use_buefy=True,
|
||||
**self.get_renderer_kwargs(fieldname))
|
||||
html = HTML.literal(html)
|
||||
if self.readonly or fieldname in self.readonly_fields:
|
||||
html = self.render_field_value(fieldname) or HTML.tag('span')
|
||||
elif field:
|
||||
html = field.serialize(use_buefy=True,
|
||||
**self.get_renderer_kwargs(fieldname))
|
||||
html = HTML.literal(html)
|
||||
|
||||
# may need a complex label
|
||||
label_contents = [label]
|
||||
|
||||
# add 'configure' icon if allowed
|
||||
if self.can_edit_help:
|
||||
icon = HTML.tag('b-icon', size='is-small', pack='fas',
|
||||
icon='cog')
|
||||
icon = HTML.tag('a', title="Configure field", c=[icon],
|
||||
**{'@click.prevent': "configureFieldInit('{}')".format(fieldname)})
|
||||
label_contents.append(HTML.literal(' '))
|
||||
label_contents.append(icon)
|
||||
|
||||
# add 'help' icon/tooltip if defined
|
||||
if markdowns.get(fieldname):
|
||||
icon = HTML.tag('b-icon', size='is-small', pack='fas',
|
||||
|
@ -978,6 +980,16 @@ class Form(object):
|
|||
label_contents.append(HTML.literal(' '))
|
||||
label_contents.append(tooltip)
|
||||
|
||||
# add 'configure' icon if allowed
|
||||
if self.can_edit_help:
|
||||
icon = HTML.tag('b-icon', size='is-small', pack='fas',
|
||||
icon='cog')
|
||||
icon = HTML.tag('a', title="Configure field", c=[icon],
|
||||
**{'@click.prevent': "configureFieldInit('{}')".format(fieldname),
|
||||
'v-show': 'configureFieldsHelp'})
|
||||
label_contents.append(HTML.literal(' '))
|
||||
label_contents.append(icon)
|
||||
|
||||
# nb. must apply hack to get <template #label> as final result
|
||||
label_template = HTML.tag('template', c=label_contents,
|
||||
**{'#label': 1})
|
||||
|
@ -988,7 +1000,7 @@ class Form(object):
|
|||
# and finally wrap it all in a <b-field>
|
||||
return HTML.tag('b-field', c=[label_template, html], **attrs)
|
||||
|
||||
else: # hidden field
|
||||
elif field: # hidden field
|
||||
|
||||
# can just do normal thing for these
|
||||
# TODO: again, why does serialize() not return literal?
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue