backoffice: allow table fields in management tables (#4245)
gitea/wcs/pipeline/head This commit looks good
Details
gitea/wcs/pipeline/head This commit looks good
Details
This commit is contained in:
parent
626cd83cbd
commit
5533f461aa
|
@ -1517,7 +1517,7 @@ class FormPage(Directory, TempfileDirectoryMixin):
|
|||
|
||||
seen_parents = set()
|
||||
for field in sorted(self.get_formdef_fields(), key=get_column_position):
|
||||
if not hasattr(field, 'get_view_value'):
|
||||
if not field.can_include_in_listing:
|
||||
continue
|
||||
classnames = ''
|
||||
attrs = ''
|
||||
|
@ -1821,7 +1821,7 @@ class FormPage(Directory, TempfileDirectoryMixin):
|
|||
# using a sql join clause.
|
||||
yield UserLabelRelatedField()
|
||||
for field in get_publisher().user_class.get_fields():
|
||||
if not hasattr(field, 'get_view_value'):
|
||||
if not field.can_include_in_listing:
|
||||
continue
|
||||
field.has_relations = True
|
||||
yield UserRelatedField(field)
|
||||
|
@ -1847,7 +1847,7 @@ class FormPage(Directory, TempfileDirectoryMixin):
|
|||
except KeyError:
|
||||
continue
|
||||
for card_field in carddef.get_all_fields():
|
||||
if not hasattr(card_field, 'get_view_value'):
|
||||
if not card_field.can_include_in_listing:
|
||||
continue
|
||||
field.has_relations = True
|
||||
yield RelatedField(carddef, card_field, field)
|
||||
|
@ -1861,7 +1861,7 @@ class FormPage(Directory, TempfileDirectoryMixin):
|
|||
else:
|
||||
field_ids = ['id', 'time', 'last_update_time', 'user-label']
|
||||
for field in self.formdef.get_all_fields():
|
||||
if hasattr(field, 'get_view_value') and field.include_in_listing:
|
||||
if field.can_include_in_listing and field.include_in_listing:
|
||||
field_ids.append(field.id)
|
||||
field_ids.append('status')
|
||||
return field_ids
|
||||
|
@ -1873,7 +1873,7 @@ class FormPage(Directory, TempfileDirectoryMixin):
|
|||
|
||||
fields = []
|
||||
for field in self.get_formdef_fields():
|
||||
if not hasattr(field, 'get_view_value'):
|
||||
if not field.can_include_in_listing:
|
||||
# skip fields that cannot be displayed in columns (computed fields)
|
||||
continue
|
||||
if field.contextual_id in field_ids:
|
||||
|
@ -4079,6 +4079,8 @@ class FormBackOfficeStatusPage(FormStatusPage):
|
|||
|
||||
|
||||
class FakeField:
|
||||
can_include_in_listing = True
|
||||
|
||||
def __init__(self, id, type_key, label, addable=True, include_in_statistics=False):
|
||||
self.id = id
|
||||
self.contextual_id = self.id
|
||||
|
@ -4112,6 +4114,7 @@ class RelatedField:
|
|||
key = 'related-field'
|
||||
varname = None
|
||||
related_field = None
|
||||
can_include_in_listing = True
|
||||
|
||||
def __init__(self, carddef, field, parent_field):
|
||||
self.carddef = carddef
|
||||
|
|
|
@ -219,6 +219,7 @@ class Field:
|
|||
get_opendocument_node_value = None
|
||||
condition = None
|
||||
is_no_data_field = False
|
||||
can_include_in_listing = False
|
||||
|
||||
# flag a field for removal by AnonymiseWorkflowStatusItem
|
||||
# possible values are final, intermediate, no.
|
||||
|
@ -268,6 +269,19 @@ class Field:
|
|||
def get_admin_attributes(self):
|
||||
return ['label', 'condition']
|
||||
|
||||
def get_display_locations_options(self):
|
||||
options = [
|
||||
('validation', _('Validation Page')),
|
||||
('summary', _('Summary Page')),
|
||||
]
|
||||
if self.can_include_in_listing:
|
||||
options.append(('listings', _('Management Listings')))
|
||||
|
||||
if self.allow_statistics:
|
||||
options.append(('statistics', _('Statistics')))
|
||||
|
||||
return options
|
||||
|
||||
def export_to_json(self, include_id=False):
|
||||
field = {}
|
||||
if include_id:
|
||||
|
@ -819,6 +833,7 @@ class WidgetField(Field):
|
|||
|
||||
widget_class = None
|
||||
use_live_server_validation = False
|
||||
can_include_in_listing = True
|
||||
|
||||
def add_to_form(self, form, value=None):
|
||||
kwargs = {'required': self.required, 'render_br': False}
|
||||
|
@ -876,18 +891,6 @@ class WidgetField(Field):
|
|||
widget.extra_css_class = self.extra_css_class
|
||||
return widget
|
||||
|
||||
def get_display_locations_options(self):
|
||||
options = [
|
||||
('validation', _('Validation Page')),
|
||||
('summary', _('Summary Page')),
|
||||
('listings', _('Management Listings')),
|
||||
]
|
||||
|
||||
if self.allow_statistics:
|
||||
options.append(('statistics', _('Statistics')))
|
||||
|
||||
return options
|
||||
|
||||
def get_anonymise_options(self):
|
||||
if get_publisher().has_site_option('enable-intermediate-anonymisation', True):
|
||||
return [
|
||||
|
|
|
@ -70,9 +70,6 @@ class CommentField(Field):
|
|||
return '<p>' + label + '</p>'
|
||||
return '<p>%s</p>' % str(htmlescape(label))
|
||||
|
||||
def get_display_locations_options(self):
|
||||
return [('validation', _('Validation Page')), ('summary', _('Summary Page'))]
|
||||
|
||||
def fill_admin_form(self, form):
|
||||
if self.label and (self.label[0] != '<' and '[end]' in self.label):
|
||||
form.add(
|
||||
|
|
|
@ -45,9 +45,6 @@ class TableField(WidgetField):
|
|||
kwargs['rows'] = self.rows
|
||||
kwargs['columns'] = self.columns
|
||||
|
||||
def get_display_locations_options(self):
|
||||
return [('validation', _('Validation Page')), ('summary', _('Summary Page'))]
|
||||
|
||||
def fill_admin_form(self, form):
|
||||
WidgetField.fill_admin_form(self, form)
|
||||
try:
|
||||
|
|
|
@ -41,9 +41,6 @@ class TableRowsField(WidgetField):
|
|||
kwargs['columns'] = self.columns
|
||||
kwargs['add_element_label'] = _('Add row')
|
||||
|
||||
def get_display_locations_options(self):
|
||||
return [('validation', _('Validation Page')), ('summary', _('Summary Page'))]
|
||||
|
||||
def fill_admin_form(self, form):
|
||||
WidgetField.fill_admin_form(self, form)
|
||||
try:
|
||||
|
|
|
@ -52,9 +52,6 @@ class TitleField(Field):
|
|||
|
||||
add_to_view_form = add_to_form
|
||||
|
||||
def get_display_locations_options(self):
|
||||
return [('validation', _('Validation Page')), ('summary', _('Summary Page'))]
|
||||
|
||||
def fill_admin_form(self, form):
|
||||
form.add(StringWidget, 'label', title=_('Label'), value=self.label, required=True, size=50)
|
||||
form.add(
|
||||
|
|
Loading…
Reference in New Issue