backoffice: use a template to render workflow status page (#47154)
This commit is contained in:
parent
d6816b90ad
commit
e424eebbba
|
@ -1863,7 +1863,7 @@ def test_workflows_global_actions_external_workflow_action(pub):
|
|||
resp = resp.forms[0].submit('submit')
|
||||
resp.forms[0]['trigger_id'] = 'action:%s' % trigger.identifier
|
||||
resp = resp.forms[0].submit('submit').follow().follow()
|
||||
assert 'External workflow (action "Global action" on external)' in resp.text
|
||||
assert 'External workflow (action "Global action" on external)' in resp.text
|
||||
assert Workflow.get(workflow.id).possible_status[0].items[0].target_mode == 'all'
|
||||
assert Workflow.get(workflow.id).possible_status[0].items[0].target_id is None
|
||||
|
||||
|
|
|
@ -514,6 +514,7 @@ class WorkflowStatusPage(Directory):
|
|||
('schema.svg', 'svg'),
|
||||
'svg',
|
||||
]
|
||||
do_not_call_in_templates = True
|
||||
|
||||
def __init__(self, workflow, status_id, html_top):
|
||||
self.html_top = html_top
|
||||
|
@ -528,82 +529,36 @@ class WorkflowStatusPage(Directory):
|
|||
|
||||
def _q_index(self):
|
||||
self.html_top('%s - %s' % (_('Workflow'), self.workflow.name))
|
||||
r = TemplateIO(html=True)
|
||||
get_response().add_javascript(
|
||||
['jquery.js', 'jquery-ui.js', 'biglist.js', 'svg-pan-zoom.js', 'qommon.wysiwyg.js']
|
||||
[
|
||||
'jquery.js',
|
||||
'jquery-ui.js',
|
||||
'biglist.js',
|
||||
'svg-pan-zoom.js',
|
||||
'qommon.wysiwyg.js',
|
||||
'popup.js',
|
||||
'jquery.colourpicker.js',
|
||||
]
|
||||
)
|
||||
return template.QommonTemplateResponse(
|
||||
templates=['wcs/backoffice/workflow-status.html'],
|
||||
context={'view': self, 'workflow': self.workflow, 'status': self.status, 'has_sidebar': True},
|
||||
is_django_native=True,
|
||||
)
|
||||
|
||||
r += htmltext('<h2>%s</h2>') % self.status.name
|
||||
r += get_session().display_message()
|
||||
|
||||
if self.status.get_visibility_restricted_roles():
|
||||
r += htmltext('<div class="bo-block">')
|
||||
r += _('This status is hidden from the user.')
|
||||
if not self.workflow.is_readonly():
|
||||
r += ' '
|
||||
r += htmltext('(<a href="display" rel="popup">%s</a>)') % _('change')
|
||||
r += htmltext('</div>')
|
||||
|
||||
if not self.status.items:
|
||||
r += htmltext('<div class="infonotice">%s</div>') % _(
|
||||
'There are not yet any items in this status.'
|
||||
)
|
||||
else:
|
||||
r += htmltext('<div class="bo-block">')
|
||||
if self.workflow.is_readonly():
|
||||
r += htmltext('<ul id="items-list" class="biglist">')
|
||||
else:
|
||||
r += htmltext('<p class="hint">')
|
||||
r += _('Use drag and drop with the handles to reorder items.')
|
||||
r += htmltext('</p>')
|
||||
r += htmltext('<ul id="items-list" class="biglist sortable">')
|
||||
for item in self.status.items:
|
||||
r += htmltext('<li class="biglistitem" id="itemId_%s">') % item.id
|
||||
if hasattr(item, str('fill_admin_form')):
|
||||
r += htmltext('<a href="items/%s/">%s</a>') % (item.id, item.render_as_line())
|
||||
else:
|
||||
r += item.render_as_line()
|
||||
r += htmltext('<p class="commands">')
|
||||
if not self.workflow.is_readonly():
|
||||
if hasattr(item, 'fill_admin_form'):
|
||||
r += command_icon('items/%s/' % item.id, 'edit')
|
||||
r += command_icon('items/%s/delete' % item.id, 'remove', popup=True)
|
||||
r += htmltext('</p>')
|
||||
r += htmltext('</li>')
|
||||
r += htmltext('</ul>')
|
||||
r += htmltext('</div>') # bo-block
|
||||
|
||||
source_status = []
|
||||
def get_source_statuses(self):
|
||||
statuses = []
|
||||
for status in self.workflow.possible_status:
|
||||
if status is self.status:
|
||||
continue
|
||||
for item in status.items:
|
||||
if self.status in item.get_target_status():
|
||||
source_status.append(status)
|
||||
statuses.append(status)
|
||||
break
|
||||
return statuses
|
||||
|
||||
if source_status:
|
||||
r += htmltext('<div class="bo-block">')
|
||||
r += htmltext('<h3>%s</h3>') % _('Jumps')
|
||||
r += htmltext('<p>%s ') % _('This status is reachable from the following status:')
|
||||
r += htmltext(', ').join(
|
||||
[htmltext('<a href="../%s/">%s</a>') % (x.id, x.name) for x in source_status]
|
||||
)
|
||||
r += htmltext('.</p>')
|
||||
r += htmltext('</div>')
|
||||
|
||||
r += htmltext('<p><a href="../../">%s</a></p>') % _('Back to workflow main page')
|
||||
|
||||
r += htmltext('<div class="bo-block">')
|
||||
r += htmltext(
|
||||
graphviz(self.workflow, url_prefix='../../', include=True, select='%s' % self.status.id)
|
||||
)
|
||||
r += htmltext('<div class="full-screen-link"><a href="schema.svg">%s</a></div>') % _('Full Screen')
|
||||
r += htmltext('</div>')
|
||||
|
||||
get_response().filter['sidebar'] = self.get_sidebar()
|
||||
|
||||
return r.getvalue()
|
||||
def graphviz(self):
|
||||
return graphviz(self.workflow, url_prefix='../../', include=True, select='%s' % self.status.id)
|
||||
|
||||
def svg(self):
|
||||
response = get_response()
|
||||
|
@ -614,34 +569,6 @@ class WorkflowStatusPage(Directory):
|
|||
self.workflow, url_prefix='../../', include=False, select='%s' % self.status.id
|
||||
).replace('?>', '?>\n<?xml-stylesheet href="%s" type="text/css"?>\n' % css)
|
||||
|
||||
def get_sidebar(self):
|
||||
get_response().add_javascript(['popup.js', 'jquery.colourpicker.js'])
|
||||
r = TemplateIO(html=True)
|
||||
if self.workflow.is_default():
|
||||
r += htmltext('<p>')
|
||||
r += _(
|
||||
'''This is the default workflow, you cannot edit it but you can
|
||||
duplicate it to base your own workflow on it.'''
|
||||
)
|
||||
r += htmltext('</p>')
|
||||
elif self.workflow.is_readonly():
|
||||
r += htmltext('<div class="infonotice"><p>%s</p></div>') % _('This workflow is readonly.')
|
||||
else:
|
||||
r += htmltext('<ul id="sidebar-actions">')
|
||||
r += htmltext('<li><a href="edit" rel="popup">%s</a></li>') % _('Change Status Name')
|
||||
r += htmltext('<li><a href="display" rel="popup">%s</a></li>') % _('Change Display Settings')
|
||||
r += htmltext('<li><a href="endpoint" rel="popup">%s</a></li>') % _('Change Terminal Status')
|
||||
r += htmltext('<li><a href="backoffice-info-text" rel="popup">%s</a></li>') % _(
|
||||
'Change Backoffice Information Text'
|
||||
)
|
||||
r += htmltext('<li><a href="delete" rel="popup">%s</a></li>') % _('Delete')
|
||||
r += htmltext('</ul>')
|
||||
r += htmltext('<div id="new-field">')
|
||||
r += htmltext('<h3>%s</h3>') % _('New Action')
|
||||
r += self.get_new_item_form().render()
|
||||
r += htmltext('</div>')
|
||||
return r.getvalue()
|
||||
|
||||
def is_item_available(self, item):
|
||||
return item.is_available(workflow=self.workflow)
|
||||
|
||||
|
|
|
@ -0,0 +1,93 @@
|
|||
{% extends "wcs/backoffice.html" %}
|
||||
{% load i18n %}
|
||||
|
||||
{% block appbar-title %}{{ status.name }}{% endblock %}
|
||||
|
||||
{% block content %}
|
||||
{{ block.super }}
|
||||
|
||||
{% if status.get_visibility_restricted_roles %}
|
||||
<div class="bo-block">
|
||||
{% trans "This status is hidden from the user." %}
|
||||
{% if not workflow.is_readonly %}
|
||||
(<a href="display" rel="popup">{% trans "change" %}</a>)
|
||||
{% endif %}
|
||||
</div>
|
||||
{% endif %}
|
||||
|
||||
{% if not status.items %}
|
||||
<div class="infonotice">
|
||||
{% trans "There are not yet any items in this status." %}
|
||||
</div>
|
||||
{% else %}
|
||||
{% spaceless %}
|
||||
<div class="bo-block">
|
||||
{% if workflow.is_readonly %}
|
||||
<ul id="items-list" class="biglist">
|
||||
{% else %}
|
||||
<p class="hint">{% trans "Use drag and drop with the handles to reorder items." %}</p>
|
||||
<ul id="items-list" class="biglist sortable">
|
||||
{% endif %}
|
||||
{% for item in status.items %}
|
||||
<li class="biglistitem" id="itemId_{{ item.id }}">
|
||||
<a href="items/{{ item.id }}/">{{ item.render_as_line|safe }}</a>
|
||||
<p class="commands">
|
||||
{% if not workflow.is_readonly %}
|
||||
<span class="edit"><a href="items/{{ item.id }}/" title="{% trans "Edit" %}">{% trans "Edit" %}</a></span>
|
||||
<span class="remove"><a href="items/{{ item.id }}/delete" rel="popup" title="{% trans "Delete" %}">{% trans "Delete" %}</a></span>
|
||||
{% endif %}
|
||||
</p>
|
||||
</li>
|
||||
{% endfor %}
|
||||
</ul>
|
||||
</div>
|
||||
{% endspaceless %}
|
||||
{% endif %}
|
||||
|
||||
{% with source_statuses=view.get_source_statuses %}
|
||||
{% if source_statuses %}
|
||||
<div class="bo-block">
|
||||
<h3>{% trans "Jumps" %}</h3>
|
||||
<p>{% trans "This status is reachable from the following status:" %}
|
||||
{% for source in source_statuses %}
|
||||
<a href="../{{ source.id }}/">{{ source.name }}</a>{% if not forloop.last %}, {% endif %}
|
||||
{% endfor %}
|
||||
</p>
|
||||
</div>
|
||||
{% endif %}
|
||||
{% endwith %}
|
||||
|
||||
<p><a href="../../">{% trans "Back to workflow main page" %}</a></p>
|
||||
|
||||
<div class="bo-block">
|
||||
{{ view.graphviz|safe }}
|
||||
<div class="full-screen-link"><a href="schema.svg">{% trans "Full Screen" %}</a></div>
|
||||
</div>
|
||||
|
||||
{% endblock %}
|
||||
|
||||
{% block sidebar-content %}
|
||||
{% if workflow.is_default %}
|
||||
<p>
|
||||
{% blocktrans %}
|
||||
This is the default workflow, you cannot edit it but you can
|
||||
duplicate it to base your own workflow on it.
|
||||
{% endblocktrans %}
|
||||
</p>
|
||||
{% elif workflow.is_readonly %}
|
||||
<div class="infonotice"><p>{% trans "This workflow is readonly." %}</p></div>
|
||||
{% else %}
|
||||
<ul id="sidebar-actions">
|
||||
<li><a href="edit" rel="popup">{% trans "Change Status Name" %}</a></li>
|
||||
<li><a href="display" rel="popup">{% trans "Change Display Settings" %}</a></li>
|
||||
<li><a href="endpoint" rel="popup">{% trans "Change Terminal Status" %}</a></li>
|
||||
<li><a href="backoffice-info-text" rel="popup">{% trans "Change Backoffice Information Text" %}</a></li>
|
||||
<li><a href="delete" rel="popup">{% trans "Delete" %}</a></li>
|
||||
</ul>
|
||||
<div id="new-field">
|
||||
<h3>{% trans "New Action" %}</h3>
|
||||
{{ view.get_new_item_form.render|safe }}
|
||||
</div>
|
||||
{% endif %}
|
||||
|
||||
{% endblock %}
|
Loading…
Reference in New Issue