From 72257f5097a0f9ff4ecf063915f6b781707ddb86 Mon Sep 17 00:00:00 2001 From: Rowan Seymour Date: Thu, 17 Oct 2024 22:00:20 +0000 Subject: [PATCH 1/3] Make some list pages use a common template --- templates/globals/global_list.html | 116 ++++++++++++--------------- templates/orgs/base/list.html | 35 ++++++++ templates/orgs/org_list.html | 98 ++++++++++------------ templates/orgs/user_list.html | 96 +++++++++------------- templates/tickets/shortcut_list.html | 79 ++++++++---------- 5 files changed, 196 insertions(+), 228 deletions(-) create mode 100644 templates/orgs/base/list.html diff --git a/templates/globals/global_list.html b/templates/globals/global_list.html index 78f1b6ec4b..c8d29c5579 100644 --- a/templates/globals/global_list.html +++ b/templates/globals/global_list.html @@ -1,7 +1,13 @@ -{% extends "smartmin/list.html" %} +{% extends "orgs/base/list.html" %} {% load smartmin temba i18n humanize %} -{% block content %} +{% block pre-table %} + + + + + +
{% blocktrans trimmed %} Globals are variables you can use across all of your flows but @@ -10,67 +16,49 @@ might change later. {% endblocktrans %}
- {% block pre-table %} - - - - - - - {% endblock pre-table %} -
- - - -
-
{% include "includes/short_pagination.html" %}
-
- - - {% for obj in object_list %} - - - - - - + + + + - - {% empty %} - - - - {% endfor %} - -
{{ obj.name }}@globals.{{ obj.key }} -
{{ obj.value|truncatechars:25 }}
-
-
- {% with usage_count=obj.usage_count %} - {% if usage_count %} -
-
- {% blocktrans trimmed count counter=usage_count %} - {{ counter }} use - {% plural %} - {{ counter }} uses - {% endblocktrans %} -
-
- {% endif %} - {% endwith %} -
-
- {% if org_perms.globals.global_delete %} -
{{ obj.name }}@globals.{{ obj.key }} +
{{ obj.value|truncatechars:25 }}
+
+
+ {% with usage_count=obj.usage_count %} + {% if usage_count %} +
+
+ {% blocktrans trimmed count counter=usage_count %} + {{ counter }} use + {% plural %} + {{ counter }} uses + {% endblocktrans %}
- {% endif %} -
{% trans "No globals" %}
-
-{% endblock content %} + + {% endif %} + {% endwith %} + + + + {% if org_perms.globals.global_delete %} + + {% endif %} + + + {% empty %} + + {% trans "No globals" %} + + {% endfor %} +{% endblock table-body %} {% block extra-script %} {{ block.super }} {% endblock extra-script %} -{% block extra-style %} - {{ block.super }} - -{% endblock extra-style %} diff --git a/templates/orgs/user_list.html b/templates/orgs/user_list.html index 992ad3971c..3a7acfcdec 100644 --- a/templates/orgs/user_list.html +++ b/templates/orgs/user_list.html @@ -1,7 +1,11 @@ -{% extends "smartmin/list.html" %} +{% extends "orgs/base/list.html" %} {% load smartmin temba i18n %} -{% block content %} +{% block pre-table %} + + + + {% if has_viewers %} {% blocktrans trimmed with cutoff="2024-12-31"|day %} @@ -10,54 +14,38 @@ {% endblocktrans %} {% endif %} - {% block pre-table %} - - - - - {% endblock pre-table %} -
- - - -
-
{% include "includes/short_pagination.html" %}
-
- - - - - - - - - - - {% for obj in object_list %} - - - - - - - {% empty %} - - - - {% endfor %} - -
{% trans "Email" %}{% trans "Name" %}{% trans "Role" %}
{{ obj.email }}{{ obj.name }}{{ obj.role.display }} - {% if obj.role.code != "A" or admin_count > 1 %} - - {% endif %} -
{% trans "No users" %}
-
-{% endblock content %} +{% endblock pre-table %} +{% block table-head %} + + {% trans "Email" %} + {% trans "Name" %} + {% trans "Role" %} + + +{% endblock table-head %} +{% block table-body %} + {% for obj in object_list %} + + {{ obj.email }} + {{ obj.name }} + {{ obj.role.display }} + + {% if obj.role.code != "A" or admin_count > 1 %} + + {% endif %} + + + {% empty %} + + {% trans "No users" %} + + {% endfor %} +{% endblock table-body %} {% block extra-script %} {{ block.super }} {% endblock extra-script %} -{% block extra-style %} - {{ block.super }} - -{% endblock extra-style %} diff --git a/templates/tickets/shortcut_list.html b/templates/tickets/shortcut_list.html index d168b0b6c2..be12b26247 100644 --- a/templates/tickets/shortcut_list.html +++ b/templates/tickets/shortcut_list.html @@ -1,48 +1,41 @@ -{% extends "smartmin/list.html" %} -{% load smartmin temba i18n humanize %} +{% extends "orgs/base/list.html" %} +{% load smartmin temba i18n %} -{% block content %} +{% block pre-table %} + + + +
{% blocktrans trimmed %} These are canned responses that agents can use to quickly reply to tickets. {% endblocktrans %}
- {% block pre-table %} - - - - - {% endblock pre-table %} -
{% include "includes/short_pagination.html" %}
-
- - - {% for obj in object_list %} - - - - - - {% empty %} - - - - {% endfor %} - -
{{ obj.name }} -
{{ obj.text|truncatechars:100 }}
-
- {% if org_perms.tickets.shortcut_delete %} - - {% endif %} -
{% trans "No shortcuts" %}
-
-{% endblock content %} +{% endblock pre-table %} +{% block table-body %} + {% for obj in object_list %} + + {{ obj.name }} + +
{{ obj.text|truncatechars:100 }}
+ + + {% if org_perms.tickets.shortcut_delete %} + + {% endif %} + + + {% empty %} + + {% trans "No shortcuts" %} + + {% endfor %} +{% endblock table-body %} {% block extra-script %} {{ block.super }} {% endblock extra-script %} -{% block extra-style %} - {{ block.super }} - -{% endblock extra-style %} From c70ffdea4ec2ed2d31c2947688a7fb77d76ae79c Mon Sep 17 00:00:00 2001 From: Rowan Seymour Date: Fri, 18 Oct 2024 19:47:42 +0000 Subject: [PATCH 2/3] Use bsae list template for flows as well --- templates/flows/flow_list.html | 194 +++++++++++++++------------------ templates/orgs/base/list.html | 2 +- 2 files changed, 90 insertions(+), 106 deletions(-) diff --git a/templates/flows/flow_list.html b/templates/flows/flow_list.html index a63b69fa43..ea1f69ae15 100644 --- a/templates/flows/flow_list.html +++ b/templates/flows/flow_list.html @@ -1,112 +1,96 @@ -{% extends "smartmin/list.html" %} +{% extends "orgs/base/list.html" %} {% load smartmin temba i18n humanize %} -{% block content %} - {% if org_perms.flows.flow_results %} - - - {% endif %} - {% if org_perms.flows.flowlabel_create %} - - - {% endif %} -
- - - -
-
{% include "includes/short_pagination.html" %}
-
- - {% if object_list %} - - - {% if org_perms.flows.flow_update %}{% endif %} - - - - +{% block pre-table %} + + + + +{% endblock pre-table %} +{% block table-head %} + + {% if actions %}{% endif %} + + + +{% endblock table-head %} +{% block table-body %} + {% for object in object_list %} + + {% if actions %} + {% endif %} - - {% for object in object_list %} - - {% if org_perms.flows.flow_update %} - - {% endif %} - - - - {% empty %} - - - - {% endfor %} - -
Runs / Completion
{% trans "Runs / Completion" %}
+ + +
- - - -
-
-
-
- {% if object.flow_type == 'V' %} - - - {% elif object.flow_type == 'S' %} - - - {% elif object.flow_type == 'B' %} - - - {% endif %} -
-
{{ object.name }}
-
-
-
- {% for label in object.labels.all %} - - - {{ label.name }} - - - {% endfor %} -
+
+
+
+
+
+ {% if object.flow_type == 'V' %} + + + {% elif object.flow_type == 'S' %} + + + {% elif object.flow_type == 'B' %} + + + {% endif %}
-
- {% if not object.is_archived %} -
- {% if object.has_issues %} -
- - - - -
- {% endif %} - {% if object.run_stats.total %} -
{{ object.run_stats.total|intcomma }}
- / -
{{ object.run_stats.completion }}%
- {% endif %} -
- {% endif %} -
{% trans "No flows" %}
-
-{% endblock content %} +
{{ object.name }}
+ + +
+ {% for label in object.labels.all %} + + + {{ label.name }} + + + {% endfor %} +
+ + + + {% if not object.is_archived %} +
+ {% if object.has_issues %} +
+ + + + +
+ {% endif %} + {% if object.run_stats.total %} +
{{ object.run_stats.total|intcomma }}
+ / +
{{ object.run_stats.completion }}%
+ {% endif %} +
+ {% endif %} + + + {% empty %} + + {% trans "No flows" %} + + {% endfor %} +{% endblock table-body %} {% block extra-script %} {{ block.super }}