From 0ff8b5a8e30709599864c0543f276fa6ae60bd9b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20P=C3=A9ters?= Date: Tue, 10 May 2022 09:47:38 +0200 Subject: [PATCH] backoffice: redo workflow inspect page as a template (#65051) --- wcs/admin/workflows.py | 102 +---------------- wcs/qommon/static/css/dc2/admin.scss | 39 ++++++- .../wcs/backoffice/workflow-inspect.html | 107 ++++++++++++++++++ 3 files changed, 151 insertions(+), 97 deletions(-) create mode 100644 wcs/templates/wcs/backoffice/workflow-inspect.html diff --git a/wcs/admin/workflows.py b/wcs/admin/workflows.py index 9ae641540..ff3e76c0b 100644 --- a/wcs/admin/workflows.py +++ b/wcs/admin/workflows.py @@ -1669,110 +1669,20 @@ class WorkflowPage(Directory): if get_publisher().snapshot_class: r += htmltext('
  • %s
  • ') % _('Save snapshot') r += htmltext('
  • %s
  • ') % _('History') + r += htmltext('
  • %s
  • ') % _('Inspector') r += htmltext('') if not self.workflow.is_readonly(): r += self.get_new_status_form() r += LoggedErrorsDirectory.errors_block(workflow_id=self.workflow.id) return r.getvalue() - def expand_workflow_formdef(self, formdef): - r = TemplateIO(html=True) - r += htmltext('') - return r.getvalue() - def inspect(self): - self.html_top('%s - %s' % (_('Workflow'), self.workflow.name)) - r = TemplateIO(html=True) + self.html_top(self.workflow.name) get_response().breadcrumb.append(('inspect', _('Inspector'))) - r += htmltext('
    ') - r += htmltext('

    %s

    ') % _('Workflow Functions') - r += htmltext('') - r += htmltext('
    ') - - if self.workflow.variables_formdef: - r += htmltext('
    ') - r += htmltext('

    %s

    ') % _('Workflow Variables') - r += self.expand_workflow_formdef(self.workflow.variables_formdef) - r += htmltext('
    ') - - if self.workflow.backoffice_fields_formdef: - r += htmltext('
    ') - r += htmltext('

    %s

    ') % _('Backoffice Fields') - r += self.expand_workflow_formdef(self.workflow.backoffice_fields_formdef) - r += htmltext('
    ') - - if self.workflow.criticality_levels: - r += htmltext('
    ') - r += htmltext('

    %s

    ') % _('Criticality Levels') - r += htmltext('') - r += htmltext('
    ') - - r += htmltext('

    %s

    ') % _('Statuses') - r += htmltext('
    ') - for status in self.workflow.possible_status or []: - r += htmltext( - '
    ' - % (getattr(status, 'colour', None) or 'fff') - ) - r += htmltext('

    %s

    ') % ( - status.id, - status.id, - status.name, - ) - if status.backoffice_info_text: - r += htmltext('
    ') - r += htmltext(status.backoffice_info_text) - r += htmltext('
    ') - if not status.items: - r += htmltext('

    %s

    ') % _('No actions in this status.') - for item in status.items or []: - r += htmltext('

    %s

    ') % ( - status.id, - item.id, - item.description, - ) - r += item.get_parameters_view() - r += htmltext('
    ') - r += htmltext('
    ') - - if self.workflow.global_actions: - r += htmltext('

    %s

    ') % _('Global Actions') - r += htmltext('
    ') - for action in self.workflow.global_actions: - r += htmltext('
    ') - r += htmltext('

    %s

    ') % (action.id, action.name) - r += htmltext('
      ') - for trigger in action.triggers: - r += htmltext('
    • %s
    • ') % trigger.render_as_line() - r += htmltext('
    ') - r += htmltext('') - for item in action.items or []: - r += htmltext('

    %s

    ') % ( - action.id, - item.id, - item.description, - ) - r += item.get_parameters_view() - r += htmltext('
    ') - r += htmltext('
    ') - - return r.getvalue() + context = {'workflow': self.workflow, 'view': self} + return template.QommonTemplateResponse( + templates=['wcs/backoffice/workflow-inspect.html'], context=context + ) def svg(self): response = get_response() diff --git a/wcs/qommon/static/css/dc2/admin.scss b/wcs/qommon/static/css/dc2/admin.scss index 920baa18c..2107f9e11 100644 --- a/wcs/qommon/static/css/dc2/admin.scss +++ b/wcs/qommon/static/css/dc2/admin.scss @@ -1634,13 +1634,34 @@ div.expanded-status { } div.expanded-statuses div.status { - border-left: 5px solid transparent; border-bottom: 1px dotted #888; margin-bottom: 1em; counter-reset: items; counter-increment: status; } +.inspect-status--link { + display: flex; + align-items: center; +} + +.inspect-status--colour { + display: inline-block; + height: 1.5rem; + width: 1.5rem; + margin-right: 1rem; + border-radius: 3px; +} + +.inspect--quicknav { + display: flex; + align-items: baseline; +} + +.inspect--jumpto { + margin-right: 1em; +} + div.expanded-statuses div.status h3 { font-size: 150%; font-weight: normal; @@ -1743,6 +1764,22 @@ form div.page > div { color: #666; } } + .inspect--quicklinks { + display: flex; + flex-wrap: wrap; + margin: 0; + padding: 0; + list-style: none; + li { + margin-left: 0; + margin-right: 1em; + } + a.button { + margin-bottom: 1em; + padding-top: 0; + padding-bottom: 0; + } + } } ul.biglist.form-inspector { diff --git a/wcs/templates/wcs/backoffice/workflow-inspect.html b/wcs/templates/wcs/backoffice/workflow-inspect.html new file mode 100644 index 000000000..523921e61 --- /dev/null +++ b/wcs/templates/wcs/backoffice/workflow-inspect.html @@ -0,0 +1,107 @@ +{% extends "wcs/backoffice/base.html" %} +{% load i18n %} + +{% block appbar %}{% endblock %} + +{% block content %} + +
    +
    + + {% if workflow.global_actions %} + + {% endif %} + + {% if workflow.variables_formdef %} + + {% endif %} + {% if workflow.backoffice_fields_formdef %} + + {% endif %} + {% if workflow.criticality_levels %} + + {% endif %} +
    +
    + + + + + + + + + +
    + +
    +{% for status in workflow.possible_status %} +
    +

    + + {{ status.name }}

    +{% if status.backoffice_info_text %}
    {{ status.backoffice_info_text|safe }}
    {% endif %} +{% for item in status.items %} +

    {{ item.description }}

    +{{ item.get_parameters_view|safe }} +{% empty %} +

    {% trans "No actions in this status." %}

    +{% endfor %} +
    +{% endfor %} +
    +
    + + + +
    +
    +{% endblock %}