utiliser la barre latérale pour actions/navigation sur les pages d'index (#74651) #190

Merged
fpeters merged 9 commits from wip/74651-sidebar into main 2023-03-27 10:48:13 +02:00
20 changed files with 235 additions and 153 deletions

View File

@ -285,6 +285,7 @@ class BlocksDirectory(Directory):
def _q_index(self):
html_top(self.section, title=_('Fields Blocks'))
get_response().add_javascript(['popup.js'])
categories = BlockCategory.select()
BlockCategory.sort_by_position(categories)
blocks = BlockDef.select(order_by='name')
@ -295,7 +296,8 @@ class BlocksDirectory(Directory):
return template.QommonTemplateResponse(
templates=['wcs/backoffice/blocks.html'],
context={'view': self, 'blocks': blocks, 'categories': categories},
context={'view': self, 'blocks': blocks, 'categories': categories, 'has_sidebar': True},
is_django_native=True,
)
def new(self):

View File

@ -366,30 +366,22 @@ class CategoriesDirectory(Directory):
category_page_class = CategoryPage
category_explanation = _('Categories are used to sort the different forms.')
def _q_index(self):
get_response().add_javascript(['jquery.js', 'jquery-ui.js', 'biglist.js', 'qommon.wysiwyg.js'])
html_top('categories', title=_('Categories'))
r = TemplateIO(html=True)
do_not_call_in_templates = True
r += htmltext('<div id="appbar">')
r += htmltext('<h2>%s</h2>') % _('Categories')
r += htmltext('<span class="actions">')
r += htmltext('<a class="new-item" href="new" rel="popup">%s</a>') % _('New Category')
r += htmltext('</span>')
r += htmltext('</div>')
r += htmltext('<div class="explanation bo-block"><p>%s</p></div>') % self.category_explanation
def _q_index(self):
get_response().add_javascript(['biglist.js', 'qommon.wysiwyg.js', 'popup.js'])
html_top('categories', title=_('Categories'))
categories = self.category_class.select()
r += htmltext('<ul class="biglist sortable" id="category-list">')
self.category_class.sort_by_position(categories)
for category in categories:
r += htmltext('<li class="biglistitem" id="itemId_%s">') % category.id
r += htmltext('<strong class="label"><a href="%s/">%s</a></strong>') % (
category.id,
category.name,
)
r += htmltext('</li>')
r += htmltext('</ul>')
return r.getvalue()
return template.QommonTemplateResponse(
templates=['wcs/backoffice/categories.html'],
context={
'view': self,
'categories': categories,
'has_sidebar': True,
},
is_django_native=True,
)
def update_order(self):
request = get_request()

View File

@ -55,6 +55,7 @@ class CommentTemplatesDirectory(Directory):
def _q_index(self):
html_top('comment_templates', title=_('Comment Templates'))
get_response().add_javascript(['popup.js'])
categories = CommentTemplateCategory.select()
CommentTemplateCategory.sort_by_position(categories)
comment_templates = CommentTemplate.select(order_by='name')
@ -64,7 +65,13 @@ class CommentTemplatesDirectory(Directory):
category.comment_templates = [x for x in comment_templates if x.category_id == category.id]
return template.QommonTemplateResponse(
templates=['wcs/backoffice/comment-templates.html'],
context={'view': self, 'comment_templates': comment_templates, 'categories': categories},
context={
'view': self,
'comment_templates': comment_templates,
'categories': categories,
'has_sidebar': True,
},
is_django_native=True,
)
def new(self):

View File

@ -513,6 +513,7 @@ class NamedDataSourcesDirectory(Directory):
def _q_index(self):
html_top('datasources', title=_('Data Sources'))
get_response().add_javascript(['popup.js'])
data_sources = []
user_data_sources = []
agenda_data_sources = []
@ -541,7 +542,9 @@ class NamedDataSourcesDirectory(Directory):
'has_users': True,
'agenda_data_sources': agenda_data_sources,
'generated_data_sources': generated_data_sources,
'has_sidebar': True,
},
is_django_native=True,
)
def _new(self, url, breadcrumb, title, ds_type=None):

View File

@ -1749,7 +1749,7 @@ class FormsDirectory(AccessControlled, Directory):
def _q_index(self):
self.html_top(title=self.top_title)
get_response().add_javascript(['widget_list.js', 'select2.js'])
get_response().add_javascript(['widget_list.js', 'select2.js', 'popup.js'])
global_access = is_global_accessible(self.section)
@ -1782,10 +1782,13 @@ class FormsDirectory(AccessControlled, Directory):
'objects': formdefs,
'categories': categories,
'has_roles': bool(get_publisher().role_class.count()),
'has_sidebar': True,
}
context.update(self.get_extra_index_context_data())
return template.QommonTemplateResponse(templates=[self.index_template_name], context=context)
return template.QommonTemplateResponse(
templates=[self.index_template_name], context=context, is_django_native=True
)
def get_extra_index_context_data(self):
return {

View File

@ -55,6 +55,7 @@ class MailTemplatesDirectory(Directory):
def _q_index(self):
html_top('mail_templates', title=_('Mail Templates'))
get_response().add_javascript(['popup.js'])
categories = MailTemplateCategory.select()
MailTemplateCategory.sort_by_position(categories)
mail_templates = MailTemplate.select(order_by='name')
@ -64,7 +65,13 @@ class MailTemplatesDirectory(Directory):
category.mail_templates = [x for x in mail_templates if x.category_id == category.id]
return template.QommonTemplateResponse(
templates=['wcs/backoffice/mail-templates.html'],
context={'view': self, 'mail_templates': mail_templates, 'categories': categories},
context={
'view': self,
'mail_templates': mail_templates,
'categories': categories,
'has_sidebar': True,
},
is_django_native=True,
)
def new(self):

View File

@ -175,6 +175,7 @@ class TestsDirectory(Directory):
x.type in ('table', 'table-select', 'tablerows', 'ranked-items')
for x in self.objectdef.fields
),
'has_sidebar': True,
}
get_response().add_javascript(['popup.js'])
return template.QommonTemplateResponse(

View File

@ -1984,20 +1984,7 @@ class WorkflowsDirectory(Directory):
def _q_index(self):
self.html_top(title=_('Workflows'))
r = TemplateIO(html=True)
r += htmltext('<div id="appbar">')
r += htmltext('<h2>%s</h2>') % _('Workflows')
r += htmltext('<span class="actions">')
if is_global_accessible():
r += htmltext('<a href="comment-templates/">%s</a>') % _('Comment Templates')
r += htmltext('<a href="mail-templates/">%s</a>') % _('Mail Templates')
r += htmltext('<a href="data-sources/">%s</a>') % _('Data sources')
r += htmltext('<a href="categories/">%s</a>') % _('Categories')
r += htmltext('<a href="import" rel="popup">%s</a>') % _('Import')
r += htmltext('<a class="new-item" rel="popup" href="new">%s</a>') % _('New Workflow')
r += htmltext('</span>')
r += htmltext('</div>')
get_response().add_javascript(['popup.js'])
formdef_workflows = [Workflow.get_default_workflow()]
workflows_in_formdef_use = set(formdef_workflows[0].id)
@ -2037,63 +2024,57 @@ class WorkflowsDirectory(Directory):
self.category_class.sort_by_position(categories)
if categories:
default_category = WorkflowCategory('Default')
default_category.id = '_default_category'
for workflow in workflows:
if workflow.id in ('_default', '_carddef_default'):
workflow.category_id = default_category.id
categories = [default_category] + categories
default_category = WorkflowCategory()
default_category.id = '_default_category'
for workflow in workflows:
if workflow.id in ('_default', '_carddef_default'):
workflow.category_id = default_category.id
categories = [default_category] + categories
if is_global_accessible():
categories = categories + [None]
if len(categories) > 1:
# if there categorised workflows, add an explicit uncategorised
# category
uncategorised_category = WorkflowCategory(_('Uncategorised'))
uncategorised_category.id = '_uncategorised'
categories = categories + [uncategorised_category]
else:
# otherwise put them all in the default category
uncategorised_category = default_category
def workflow_section(r, workflows):
r += htmltext('<ul class="objects-list single-links">')
for workflow in workflows:
if workflow in shared_workflows:
css_class = 'shared-workflow'
usage_label = _('Forms and card models')
elif workflow in formdef_workflows:
css_class = 'formdef-workflow'
usage_label = _('Forms')
elif workflow in carddef_workflows:
css_class = 'carddef-workflow'
usage_label = _('Card models')
else:
css_class = 'unused-workflow'
usage_label = _('Unused')
r += htmltext('<li class="%s">' % css_class)
r += htmltext('<a href="%s/">%s</a>') % (
workflow.id,
workflow.name,
)
if usage_label and carddef_workflows:
r += htmltext('<span class="badge">%s</span>') % usage_label
r += htmltext('</li>')
r += htmltext('</ul>')
for workflow in workflows:
if workflow in shared_workflows:
workflow.css_class = 'shared-workflow'
workflow.usage_label = _('Forms and card models')
elif workflow in formdef_workflows:
workflow.css_class = 'formdef-workflow'
workflow.usage_label = _('Forms')
elif workflow in carddef_workflows:
workflow.css_class = 'carddef-workflow'
workflow.usage_label = _('Card models')
for workflow in unused_workflows:
workflow.css_class = 'unused-workflow'
if carddef_workflows:
workflow.usage_label = _('Unused')
for category in categories:
if category is None:
category_workflows = [x for x in workflows + unused_workflows if not x.category_id]
if category.id == '_uncategorised':
category.objects = [x for x in workflows + unused_workflows if not x.category_id]
else:
category_workflows = [
category.objects = [
x for x in workflows + unused_workflows if x.category_id == str(category.id)
]
if category_workflows:
if len(categories) > 1:
r += htmltext('<div class="section">')
if category is None:
r += htmltext('<h2>%s</h2>') % _('Uncategorised')
elif category.id == '_default_category':
pass # no title
else:
r += htmltext('<h2>%s</h2>') % category.name
workflow_section(r, category_workflows)
if len(categories) > 1:
r += htmltext('</div>')
return r.getvalue()
context = {
'categories': categories,
'view': self,
'has_sidebar': True,
'is_global_accessible': is_global_accessible(),
}
return template.QommonTemplateResponse(
templates=['wcs/backoffice/workflows.html'], context=context, is_django_native=True
)
def new(self):
get_response().breadcrumb.append(('new', _('New')))

View File

@ -189,9 +189,11 @@ class NamedWsCallsDirectory(Directory):
def _q_index(self):
html_top('wscalls', title=_('Webservice Calls'))
get_response().add_javascript(['popup.js'])
return template.QommonTemplateResponse(
templates=['wcs/backoffice/wscalls.html'],
context={'view': self, 'wscalls': NamedWsCall.select(order_by='name')},
context={'view': self, 'wscalls': NamedWsCall.select(order_by='name'), 'has_sidebar': True},
is_django_native=True,
)
def new(self):

View File

@ -2052,12 +2052,15 @@ a.button.button-paragraph {
display: block;
max-width: 100%;
margin-bottom: 1rem;
line-height: 150%;
padding-top: 0.8em;
padding-bottom: 0.8em;
}
a.button.button-paragraph p {
font-weight: normal;
color: #333;
margin: 0;
margin: 0.5em 0 0 0;
line-height: 150%;
}

View File

@ -1,12 +1,15 @@
{% extends "wcs/backoffice/base.html" %}
{% extends "wcs/backoffice.html" %}
{% load i18n %}
{% block appbar-title %}{% trans "Field Blocks" %}{% endblock %}
{% block appbar-actions %}
<a href="categories/">{% trans "Categories" %}</a>
<a rel="popup" href="import">{% trans "Import" %}</a>
<a rel="popup" href="new">{% trans "New field block" %}</a>
{% block sidebar-content %}
<h3>{% trans "Actions" %}</h3>
<a class="button button-paragraph" rel="popup" href="new">{% trans "New field block" %}</a>
<a class="button button-paragraph" rel="popup" href="import">{% trans "Import" %}</a>
<h3>{% trans "Navigation" %}</h3>
<a class="button button-paragraph" href="categories/">{% trans "Categories" %}</a>
{% endblock %}
{% block content %}

View File

@ -3,16 +3,21 @@
{% block appbar-title %}{% trans "Card Models" %}{% endblock %}
{% block appbar-actions %}
{% if is_global_accessible_forms %}
<a href="../forms/data-sources/">{% trans "Data sources" %}</a>
<a href="../forms/blocks/">{% trans "Fields blocks" %}</a>
{% block sidebar-content %}
{% if has_roles %}
<h3>{% trans "Actions" %}</h3>
<a class="button button-paragraph" rel="popup" href="new">{% trans "New Card Model" %}</a>
<a class="button button-paragraph" rel="popup" href="import">{% trans "Import" %}</a>
<h3>{% trans "Navigation" %}</h3>
{% if is_global_accessible_cards %}
<a class="button button-paragraph" href="categories/">{% trans "Categories" %}</a>
{% endif %}
{% if is_global_accessible_forms %}
<a class="button button-paragraph" href="../forms/blocks/">{% trans "Fields blocks" %}</a>
<a class="button button-paragraph" href="../forms/data-sources/">{% trans "Data sources" %}</a>
{% endif %}
{% endif %}
{% if is_global_accessible_cards %}
<a href="categories/">{% trans "Categories" %}</a>
{% endif %}
<a rel="popup" href="import">{% trans "Import" %}</a>
<a rel="popup" href="new">{% trans "New Card Model" %}</a>
{% endblock %}
{% block no-objects %}

View File

@ -0,0 +1,24 @@
{% extends "wcs/backoffice.html" %}
{% load i18n %}
{% block appbar-title %}{% trans "Categories" %}{% endblock %}
{% block sidebar-content %}
<h3>{% trans "Actions" %}</h3>
<a class="button button-paragraph" rel="popup" href="new">{% trans "New Category" %}</a>
{% endblock %}
{% block body %}
<div class="explanation bo-block"><p>{{ view.category_explanation }}</p></div>
{% if categories %}
<ul class="biglist sortable" id="category-list">
{% for category in categories %}
<li class="biglistitem" id="itemId_{{ category.id }}"><a href="{{ category.id }}/">{{ category.name }}</a></li>
{% endfor %}
</ul>
{% else %}
<div class="infonotice">
{% trans "There are no categories defined." %}
</div>
{% endif %}
{% endblock %}

View File

@ -1,15 +1,18 @@
{% extends "wcs/backoffice/base.html" %}
{% extends "wcs/backoffice.html" %}
{% load i18n %}
{% block appbar-title %}{% trans "Comment Templates" %}{% endblock %}
{% block appbar-actions %}
<a href="categories/">{% trans "Categories" %}</a>
<a rel="popup" href="import">{% trans "Import" %}</a>
<a rel="popup" href="new">{% trans "New comment template" %}</a>
{% block sidebar-content %}
<h3>{% trans "Actions" %}</h3>
<a class="button button-paragraph" rel="popup" href="new">{% trans "New comment template" %}</a>
<a class="button button-paragraph" rel="popup" href="import">{% trans "Import" %}</a>
<h3>{% trans "Navigation" %}</h3>
<a class="button button-paragraph" href="categories/">{% trans "Categories" %}</a>
{% endblock %}
{% block content %}
{% block body %}
{% if categories %}
{% for category in categories %}
{% if category.comment_templates %}

View File

@ -1,18 +1,21 @@
{% extends "wcs/backoffice/base.html" %}
{% extends "wcs/backoffice.html" %}
{% load i18n %}
{% block appbar-title %}{% trans "Data Sources" %}{% endblock %}
{% block appbar-actions %}
<a href="categories/">{% trans "Categories" %}</a>
{% if has_chrono %}
<a href="sync-agendas">{% trans "Refresh agendas" %}</a>
{% endif %}
<a data-popup href="import">{% trans "Import" %}</a>
{% block sidebar-content %}
<h3>{% trans "Actions" %}</h3>
<a class="button button-paragraph" href="new">{% trans "New Data Source" %}</a>
{% if has_users %}
<a href="new-users">{% trans "New User Data Source" %}</a>
<a class="button button-paragraph" href="new-users">{% trans "New User Data Source" %}</a>
{% endif %}
<a href="new">{% trans "New Data Source" %}</a>
<a class="button button-paragraph" data-popup href="import">{% trans "Import" %}</a>
{% if has_chrono %}
<a class="button button-paragraph" href="sync-agendas">{% trans "Refresh agendas" %}</a>
{% endif %}
<h3>{% trans "Navigation" %}</h3>
<a class="button button-paragraph" href="categories/">{% trans "Categories" %}</a>
{% endblock %}
{% block content %}

View File

@ -1,23 +1,9 @@
{% extends "wcs/backoffice/base.html" %}
{% extends "wcs/backoffice.html" %}
{% load i18n %}
{% block appbar-title %}{% trans "Forms" %}{% endblock %}
{% block appbar-actions %}
{% if has_roles %}
{% if is_global_accessible_forms %}
<a href="data-sources/">{% trans "Data sources" %}</a>
<a href="blocks/">{% trans "Fields blocks" %}</a>
{% if is_global_accessible_categories %}
<a href="categories/">{% trans "Categories" %}</a>
{% endif %}
{% endif %}
<a rel="popup" href="import">{% trans "Import" %}</a>
<a rel="popup" href="new">{% trans "New Form" %}</a>
{% endif %}
{% endblock %}
{% block content %}
{% block body %}
{% if not has_roles %}
<p>{% trans "You first have to define roles." %}</p>
{% elif objects %}
@ -46,3 +32,20 @@
</div>
{% endif %}
{% endblock %}
{% block sidebar-content %}
{% if has_roles %}
<h3>{% trans "Actions" %}</h3>
<a class="button button-paragraph" rel="popup" href="new">{% trans "New Form" %}</a>
<a class="button button-paragraph" rel="popup" href="import">{% trans "Import" %}</a>
<h3>{% trans "Navigation" %}</h3>
{% if is_global_accessible_forms %}
{% if is_global_accessible_categories %}
<a class="button button-paragraph" href="categories/">{% trans "Categories" %}</a>
{% endif %}
<a class="button button-paragraph" href="blocks/">{% trans "Fields blocks" %}</a>
<a class="button button-paragraph" href="data-sources/">{% trans "Data sources" %}</a>
{% endif %}
{% endif %}
{% endblock %}

View File

@ -1,15 +1,18 @@
{% extends "wcs/backoffice/base.html" %}
{% extends "wcs/backoffice.html" %}
{% load i18n %}
{% block appbar-title %}{% trans "Mail Templates" %}{% endblock %}
{% block appbar-actions %}
<a href="categories/">{% trans "Categories" %}</a>
<a rel="popup" href="import">{% trans "Import" %}</a>
<a rel="popup" href="new">{% trans "New mail template" %}</a>
{% block sidebar-content %}
<h3>{% trans "Actions" %}</h3>
<a class="button button-paragraph" rel="popup" href="new">{% trans "New mail template" %}</a>
<a class="button button-paragraph" rel="popup" href="import">{% trans "Import" %}</a>
<h3>{% trans "Navigation" %}</h3>
<a class="button button-paragraph" href="categories/">{% trans "Categories" %}</a>
{% endblock %}
{% block content %}
{% block body %}
{% if categories %}
{% for category in categories %}
{% if category.mail_templates %}

View File

@ -2,15 +2,15 @@
{% load i18n %}
{% block appbar-title %}{% trans "Tests" %}{% endblock %}
{% block appbar-actions %}
<a class="extra-actions-menu-opener"></a>
<a href="results/">{% trans "Test results" %}</a>
{% block sidebar-content %}
<h3>{% trans "Actions" %}</h3>
{% if formdata and not has_deprecated_fields %}
<a href="new" rel="popup">{% trans "New" %}</a>
<a class="button button-paragraph" href="new" rel="popup">{% trans "New" %}</a>
{% endif %}
<ul class="extra-actions-menu">
<li><a href="import" rel="popup">{% trans "Import" %}</a></li>
</ul>
<a class="button button-paragraph" href="import" rel="popup">{% trans "Import" %}</a>
<h3>{% trans "Navigation" %}</h3>
<a class="button button-paragraph" href="results/">{% trans "Test results" %}</a>
{% endblock %}
{% block body %}

View File

@ -0,0 +1,36 @@
{% extends "wcs/backoffice.html" %}
{% load i18n %}
{% block appbar-title %}{% trans "Workflows" %}{% endblock %}
{% block body %}
{% for category in categories %}
{% if category.objects %}
<div class="section">
{% if category.name %}<h2>{{ category.name }}</h2>{% endif %}
<ul class="objects-list single-links">
{% for item in category.objects %}
<li class="{{ item.css_class }}"><a href="{{ item.id }}/">{{ item.name }}
{% if item.usage_label %}<span class="badge">{{ item.usage_label }}</span>{% endif %}
</a>
</li>
{% endfor %}
</ul>
</div>
{% endif %}
{% endfor %}
{% endblock %}
{% block sidebar-content %}
<h3>{% trans "Actions" %}</h3>
<a class="button button-paragraph" rel="popup" href="new">{% trans "New Workflow" %}</a>
<a class="button button-paragraph" rel="popup" href="import">{% trans "Import" %}</a>
{% if is_global_accessible %}
<h3>{% trans "Navigation" %}</h3>
<a class="button button-paragraph" href="categories/">{% trans "Categories" %}</a>
<a class="button button-paragraph" href="data-sources/">{% trans "Data sources" %}</a>
<a class="button button-paragraph" href="mail-templates/">{% trans "Mail Templates" %}</a>
<a class="button button-paragraph" href="comment-templates/">{% trans "Comment Templates" %}</a>
{% endif %}
{% endblock %}

View File

@ -1,14 +1,15 @@
{% extends "wcs/backoffice/base.html" %}
{% extends "wcs/backoffice.html" %}
{% load i18n %}
{% block appbar-title %}{% trans "Webservice Calls" %}{% endblock %}
{% block appbar-actions %}
<a rel="popup" href="import">{% trans "Import" %}</a>
<a href="new">{% trans "New webservice call" %}</a>
{% block sidebar-content %}
<h3>{% trans "Actions" %}</h3>
<a class="button button-paragraph" href="new">{% trans "New webservice call" %}</a>
<a class="button button-paragraph" rel="popup" href="import">{% trans "Import" %}</a>
{% endblock %}
{% block content %}
{% block body %}
{% if wscalls %}
<ul class="objects-list single-links">
{% for wscall in wscalls %}