backoffice: add history sidebar in snapshot inspect view (#61724) #1008
|
@ -583,8 +583,11 @@ def test_card_snapshot_browse(pub):
|
|||
assert [x[0].name for x in resp.form.fields.values() if x[0].tag == 'button'] == ['cancel']
|
||||
assert pub.custom_view_class.count() == 0 # custom views are not restore on preview
|
||||
|
||||
# check navigation between inspect pages
|
||||
resp = app.get('/backoffice/cards/%s/history/%s/view/' % (carddef.id, snapshot.id))
|
||||
resp.click(href='inspect')
|
||||
resp = resp.click(href='inspect')
|
||||
assert resp.pyquery('.snapshots-navigation') # check snapshot navigation is visible
|
||||
resp.click('>') # go to inspect view of previous snapshot
|
||||
|
||||
|
||||
def test_datasource_snapshot_browse(pub):
|
||||
|
|
|
@ -1710,7 +1710,7 @@ class FormDefPage(Directory, TempfileDirectoryMixin):
|
|||
return self.render_inspect()
|
||||
|
||||
def render_inspect(self):
|
||||
context = {'formdef': self.formdef, 'view': self}
|
||||
context = {'formdef': self.formdef, 'view': self, 'has_sidebar': self.formdef.is_readonly()}
|
||||
if self.formdef.workflow.variables_formdef:
|
||||
context['workflow_options'] = {}
|
||||
variables_form_data = self.formdef.get_variable_options_for_form()
|
||||
|
@ -1761,7 +1761,16 @@ class FormDefPage(Directory, TempfileDirectoryMixin):
|
|||
f'{self.formdef.xml_root_node}:{self.formdef.id}'
|
||||
)
|
||||
context['deprecation_titles'] = deprecations.titles
|
||||
return template.QommonTemplateResponse(templates=[self.inspect_template_name], context=context)
|
||||
return template.QommonTemplateResponse(
|
||||
templates=[self.inspect_template_name],
|
||||
context=context,
|
||||
is_django_native=True,
|
||||
)
|
||||
|
||||
def snapshot_info_inspect_block(self):
|
||||
return utils.snapshot_info_block(
|
||||
snapshot=self.formdef.snapshot_object, url_name='inspect', url_prefix='../'
|
||||
)
|
||||
|
||||
|
||||
class NamedDataSourcesDirectoryInForms(NamedDataSourcesDirectory):
|
||||
|
|
|
@ -48,7 +48,7 @@ def last_modification_block(obj):
|
|||
return r.getvalue()
|
||||
|
||||
|
||||
def snapshot_info_block(snapshot, url_prefix='../../', url_suffix=''):
|
||||
def snapshot_info_block(snapshot, url_name='view/', url_prefix='../../', url_suffix=''):
|
||||
r = TemplateIO(html=True)
|
||||
r += htmltext('<p>')
|
||||
parts = []
|
||||
|
@ -66,11 +66,10 @@ def snapshot_info_block(snapshot, url_prefix='../../', url_suffix=''):
|
|||
r += htmltext('<p class="snapshots-navigation">')
|
||||
if snapshot.id != snapshot.first:
|
||||
r += htmltext(
|
||||
' <a class="button" href="%s%s/view/%s">≪</a>' % (url_prefix, snapshot.first, url_suffix)
|
||||
f' <a class="button" href="{url_prefix}{snapshot.first}/{url_name}{url_suffix}">≪</a>'
|
||||
)
|
||||
r += htmltext(
|
||||
' <a class="button" href="%s%s/view/%s"><</a>'
|
||||
% (url_prefix, snapshot.previous, url_suffix)
|
||||
f' <a class="button" href="{url_prefix}{snapshot.previous}/{url_name}{url_suffix}"><</a>'
|
||||
)
|
||||
else:
|
||||
# currently browsing the first snapshot, display links as disabled
|
||||
|
@ -78,10 +77,10 @@ def snapshot_info_block(snapshot, url_prefix='../../', url_suffix=''):
|
|||
r += htmltext(' <a class="button disabled" href="#"><</a>')
|
||||
if snapshot.id != snapshot.last:
|
||||
r += htmltext(
|
||||
' <a class="button" href="%s%s/view/%s">></a>' % (url_prefix, snapshot.next, url_suffix)
|
||||
f' <a class="button" href="{url_prefix}{snapshot.next}/{url_name}{url_suffix}">></a>'
|
||||
)
|
||||
r += htmltext(
|
||||
' <a class="button" href="%s%s/view/%s">≫</a>' % (url_prefix, snapshot.last, url_suffix)
|
||||
f' <a class="button" href="{url_prefix}{snapshot.last}/{url_name}{url_suffix}">≫</a>'
|
||||
)
|
||||
else:
|
||||
# currently browsing the last snapshot, display links as disabled
|
||||
|
@ -101,7 +100,7 @@ def snapshot_info_block(snapshot, url_prefix='../../', url_suffix=''):
|
|||
klass = snapshot.get_object_class()
|
||||
backoffice_class = import_string(klass.backoffice_class)
|
||||
has_inspect = hasattr(backoffice_class, 'render_inspect')
|
||||
if has_inspect:
|
||||
if has_inspect and url_name != 'inspect':
|
||||
r += htmltext('<a class="button button-paragraph" href="%s%s/inspect" role="button">%s</a>') % (
|
||||
url_prefix,
|
||||
snapshot.id,
|
||||
|
|
|
@ -1783,6 +1783,7 @@ class WorkflowPage(Directory):
|
|||
context = {
|
||||
'workflow': self.workflow,
|
||||
'view': self,
|
||||
'has_sidebar': self.workflow.is_readonly() and not self.workflow.is_default(),
|
||||
}
|
||||
if not hasattr(self.workflow, 'snapshot_object'):
|
||||
context.update(
|
||||
|
@ -1792,7 +1793,14 @@ class WorkflowPage(Directory):
|
|||
}
|
||||
)
|
||||
return template.QommonTemplateResponse(
|
||||
templates=['wcs/backoffice/workflow-inspect.html'], context=context
|
||||
templates=['wcs/backoffice/workflow-inspect.html'],
|
||||
context=context,
|
||||
is_django_native=True,
|
||||
)
|
||||
|
||||
def snapshot_info_inspect_block(self):
|
||||
return utils.snapshot_info_block(
|
||||
snapshot=self.workflow.snapshot_object, url_name='inspect', url_prefix='../'
|
||||
)
|
||||
|
||||
def svg(self):
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
{% extends "wcs/backoffice/base.html" %}
|
||||
{% extends "wcs/backoffice.html" %}
|
||||
{% load i18n %}
|
||||
|
||||
{% block appbar %}{% endblock %}
|
||||
|
@ -136,3 +136,7 @@
|
|||
|
||||
</div>
|
||||
{% endblock %}
|
||||
|
||||
{% block sidebar-content %}
|
||||
{{ view.snapshot_info_inspect_block|safe }}
|
||||
{% endblock %}
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
{% extends "wcs/backoffice/base.html" %}
|
||||
{% extends "wcs/backoffice.html" %}
|
||||
{% load i18n %}
|
||||
|
||||
{% block appbar %}{% endblock %}
|
||||
|
@ -139,3 +139,7 @@
|
|||
</div> <!-- pk-tabs-container -->
|
||||
</div> <!-- pk-tabs -->
|
||||
{% endblock %}
|
||||
|
||||
{% block sidebar-content %}
|
||||
{{ view.snapshot_info_inspect_block|safe }}
|
||||
{% endblock %}
|
||||
|
|
Loading…
Reference in New Issue