From 6860a73dff244a1e4f1d3463f33405b6f55179fa Mon Sep 17 00:00:00 2001 From: Rowan Seymour Date: Wed, 18 Oct 2023 18:32:41 +0000 Subject: [PATCH 1/2] Improve display of triggers on list pages --- temba/triggers/types.py | 9 +++ templates/flows/flow_list.html | 15 ++-- templates/triggers/trigger_list.html | 76 ++++++++----------- templates/triggers/types/catch_all.html | 5 ++ templates/triggers/types/closed_ticket.html | 5 ++ templates/triggers/types/inbound_call.html | 5 ++ templates/triggers/types/missed_call.html | 5 ++ .../triggers/types/new_conversation.html | 5 ++ templates/triggers/types/opt_in.html | 5 ++ templates/triggers/types/opt_out.html | 5 ++ templates/triggers/types/referral.html | 5 ++ templates/triggers/types/schedule.html | 7 ++ 12 files changed, 96 insertions(+), 51 deletions(-) create mode 100644 templates/triggers/types/catch_all.html create mode 100644 templates/triggers/types/closed_ticket.html create mode 100644 templates/triggers/types/inbound_call.html create mode 100644 templates/triggers/types/missed_call.html create mode 100644 templates/triggers/types/new_conversation.html create mode 100644 templates/triggers/types/opt_in.html create mode 100644 templates/triggers/types/opt_out.html create mode 100644 templates/triggers/types/referral.html create mode 100644 templates/triggers/types/schedule.html diff --git a/temba/triggers/types.py b/temba/triggers/types.py index e4ebe1a5632..26d20fd613e 100644 --- a/temba/triggers/types.py +++ b/temba/triggers/types.py @@ -74,6 +74,7 @@ class Meta(BaseChannelTriggerForm.Meta): code = Trigger.TYPE_KEYWORD slug = "keyword" name = _("Keyword") + icon = "message" allowed_flow_types = (Flow.TYPE_MESSAGE, Flow.TYPE_VOICE) allowed_channel_role = Channel.ROLE_RECEIVE export_fields = ChannelTriggerType.export_fields + ("keywords", "match_type") @@ -114,6 +115,7 @@ class Meta(BaseChannelTriggerForm.Meta): code = Trigger.TYPE_CATCH_ALL slug = "catch_all" name = _("Catch All") + icon = "message" allowed_flow_types = (Flow.TYPE_MESSAGE, Flow.TYPE_VOICE) allowed_channel_role = Channel.ROLE_RECEIVE form = Form @@ -161,6 +163,7 @@ class Meta(BaseTriggerForm.Meta): code = Trigger.TYPE_SCHEDULE slug = "schedule" name = _("Schedule") + icon = "calendar" allowed_flow_types = (Flow.TYPE_MESSAGE, Flow.TYPE_VOICE, Flow.TYPE_BACKGROUND) exportable = False form = Form @@ -227,6 +230,7 @@ class Meta(BaseTriggerForm.Meta): code = Trigger.TYPE_INBOUND_CALL slug = "inbound_call" name = _("Inbound Call") + icon = "incoming_call" allowed_flow_types = (Flow.TYPE_VOICE, Flow.TYPE_MESSAGE, Flow.TYPE_BACKGROUND) allowed_channel_role = Channel.ROLE_ANSWER form = Form @@ -260,6 +264,7 @@ def __init__(self, org, user, *args, **kwargs): code = Trigger.TYPE_NEW_CONVERSATION slug = "new_conversation" name = _("New Conversation") + icon = "conversation" allowed_flow_types = (Flow.TYPE_MESSAGE,) allowed_channel_schemes = ContactURN.SCHEMES_SUPPORTING_NEW_CONVERSATION form = Form @@ -289,6 +294,7 @@ class Meta(BaseChannelTriggerForm.Meta): code = Trigger.TYPE_REFERRAL slug = "referral" name = _("Referral") + icon = "referral" allowed_flow_types = (Flow.TYPE_MESSAGE,) allowed_channel_schemes = ContactURN.SCHEMES_SUPPORTING_REFERRALS form = Form @@ -306,6 +312,7 @@ def __init__(self, org, user, *args, **kwargs): code = Trigger.TYPE_CLOSED_TICKET slug = "closed_ticket" name = _("Closed Ticket") + icon = "agent" allowed_flow_types = (Flow.TYPE_MESSAGE, Flow.TYPE_VOICE, Flow.TYPE_BACKGROUND) form = Form @@ -322,6 +329,7 @@ def __init__(self, org, user, *args, **kwargs): code = Trigger.TYPE_OPT_IN slug = "opt_in" name = _("Opt-In") + icon = "optin" allowed_flow_types = (Flow.TYPE_MESSAGE, Flow.TYPE_BACKGROUND) allowed_channel_schemes = ContactURN.SCHEMES_SUPPORTING_OPTINS form = Form @@ -339,6 +347,7 @@ def __init__(self, org, user, *args, **kwargs): code = Trigger.TYPE_OPT_OUT slug = "opt_out" name = _("Opt-Out") + icon = "optout" allowed_flow_types = (Flow.TYPE_MESSAGE, Flow.TYPE_BACKGROUND) allowed_channel_schemes = ContactURN.SCHEMES_SUPPORTING_OPTINS form = Form diff --git a/templates/flows/flow_list.html b/templates/flows/flow_list.html index fb98e56ff8a..bb65e487d91 100644 --- a/templates/flows/flow_list.html +++ b/templates/flows/flow_list.html @@ -49,8 +49,8 @@
-
-
+
+
{% if object.flow_type == 'V' %} @@ -80,11 +80,12 @@ {% if not object.is_archived %}
{% if object.has_issues %} -
- - - -
+
+ + + + +
{% endif %} {% if object.run_stats.total %}
{% if org_perms.triggers.trigger_update %} - + {% endif %} - - {% if obj.trigger_type == 'K' %} - {% include "triggers/types/keyword.html" with trigger=obj %} - {% elif obj.trigger_type == 'M' %} - {% trans "A missed call" %} - {% elif obj.trigger_type == 'C' %} - {% trans "An uncaught message" %} - {% elif obj.trigger_type == 'V' %} - {% trans "An inbound call" %} - {% elif obj.trigger_type == 'I' %} - {% trans "An opt in event" %} - {% elif obj.trigger_type == 'O' %} - {% trans "An opt out event" %} - {% elif obj.trigger_type == 'N' %} - {% trans "A new conversation" %} - {% elif obj.trigger_type == 'R' %} - {% trans "The referrer id" %} - - {{ obj.referrer_id }} - - {% elif obj.trigger_type == 'T' %} - {% trans "A closed ticket" %} - {% endif %} - {% if obj.channel %} - {% trans "on the channel" %} -
{{ obj.channel }}
- {% endif %} - {% if obj.schedule %} - {% trans "Start" %} - {% else %} - {% trans "starts" %} - {% endif %} -
{{ obj.flow }}
- {% if obj.schedule %} - {% if obj.schedule.next_fire and not obj.is_archived %} - {{ obj.schedule.get_display }} - {% else %} - {% trans "is not scheduled" %} + +
+
+
+ + +
+
+ {% with "triggers/types/"|add:obj.type.slug|add:".html" as type_template %} + {% include type_template with trigger=obj %} + {% endwith %} +
+
+ {% if obj.channel or obj.contacts.all or obj.groups.all or obj.exclude_groups.all %} +
+ {% if obj.channel %} + {# djlint:off #} + {{ obj.channel }} + {# djlint:on #} + {% endif %} + {% include "includes/recipients.html" with contacts=obj.contacts.all groups=obj.groups.all exclude_groups=obj.exclude_groups.all groups_as_filters=True %} +
{% endif %} - {% endif %} +
- - {% include "includes/recipients.html" with contacts=obj.contacts.all groups=obj.groups.all exclude_groups=obj.exclude_groups.all groups_as_filters=True %} + + {% empty %} diff --git a/templates/triggers/types/catch_all.html b/templates/triggers/types/catch_all.html new file mode 100644 index 00000000000..593309d0643 --- /dev/null +++ b/templates/triggers/types/catch_all.html @@ -0,0 +1,5 @@ +{% load i18n %} + +{% blocktrans trimmed %} + A message that doesn't match any keyword triggers +{% endblocktrans %} diff --git a/templates/triggers/types/closed_ticket.html b/templates/triggers/types/closed_ticket.html new file mode 100644 index 00000000000..a1e2d2c9d68 --- /dev/null +++ b/templates/triggers/types/closed_ticket.html @@ -0,0 +1,5 @@ +{% load i18n %} + +{% blocktrans trimmed %} + A ticket being closed +{% endblocktrans %} diff --git a/templates/triggers/types/inbound_call.html b/templates/triggers/types/inbound_call.html new file mode 100644 index 00000000000..0e0bccfc702 --- /dev/null +++ b/templates/triggers/types/inbound_call.html @@ -0,0 +1,5 @@ +{% load i18n %} + +{% blocktrans trimmed %} + An incoming call +{% endblocktrans %} diff --git a/templates/triggers/types/missed_call.html b/templates/triggers/types/missed_call.html new file mode 100644 index 00000000000..975ad393bd5 --- /dev/null +++ b/templates/triggers/types/missed_call.html @@ -0,0 +1,5 @@ +{% load i18n %} + +{% blocktrans trimmed %} + A missed call on an Android device +{% endblocktrans %} diff --git a/templates/triggers/types/new_conversation.html b/templates/triggers/types/new_conversation.html new file mode 100644 index 00000000000..c841b4969ee --- /dev/null +++ b/templates/triggers/types/new_conversation.html @@ -0,0 +1,5 @@ +{% load i18n %} + +{% blocktrans trimmed %} + A new conversation +{% endblocktrans %} diff --git a/templates/triggers/types/opt_in.html b/templates/triggers/types/opt_in.html new file mode 100644 index 00000000000..f1e9b84f558 --- /dev/null +++ b/templates/triggers/types/opt_in.html @@ -0,0 +1,5 @@ +{% load i18n %} + +{% blocktrans trimmed %} + A contact opting in +{% endblocktrans %} diff --git a/templates/triggers/types/opt_out.html b/templates/triggers/types/opt_out.html new file mode 100644 index 00000000000..09abe1eca0d --- /dev/null +++ b/templates/triggers/types/opt_out.html @@ -0,0 +1,5 @@ +{% load i18n %} + +{% blocktrans trimmed %} + A contact opting out +{% endblocktrans %} diff --git a/templates/triggers/types/referral.html b/templates/triggers/types/referral.html new file mode 100644 index 00000000000..6f3f6e1d9cb --- /dev/null +++ b/templates/triggers/types/referral.html @@ -0,0 +1,5 @@ +{% load i18n %} + +{% blocktrans trimmed with referrer=obj.referrer_id %} + A referral from {{ referrer }} +{% endblocktrans %} diff --git a/templates/triggers/types/schedule.html b/templates/triggers/types/schedule.html new file mode 100644 index 00000000000..15eb9cb8cd0 --- /dev/null +++ b/templates/triggers/types/schedule.html @@ -0,0 +1,7 @@ +{% load i18n %} + +{% if obj.schedule.next_fire and not obj.is_archived %} + {{ obj.schedule.get_display|capfirst }} +{% else %} + {% trans "is not scheduled" %} +{% endif %} From 3a5441869cf790bfc85ed3fb24d260f6d4402f56 Mon Sep 17 00:00:00 2001 From: Rowan Seymour Date: Wed, 18 Oct 2023 20:09:17 +0000 Subject: [PATCH 2/2] Fix using djlint:off --- templates/includes/recipients_contact.html | 3 ++- templates/includes/recipients_group.html | 7 +++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/templates/includes/recipients_contact.html b/templates/includes/recipients_contact.html index e35a5a1014f..0154b9d37cf 100644 --- a/templates/includes/recipients_contact.html +++ b/templates/includes/recipients_contact.html @@ -1,8 +1,9 @@ {% load contacts i18n %} {% if contact.is_active %} - + {# djlint:off #} {{ contact|name_or_urn:user_org }} + {# djlint:on #} {% else %}
{% trans "Deleted" %}
diff --git a/templates/includes/recipients_group.html b/templates/includes/recipients_group.html index 264d7392ac9..fba9764c5b9 100644 --- a/templates/includes/recipients_group.html +++ b/templates/includes/recipients_group.html @@ -1,4 +1,3 @@ - -{{ group.name }} +{# djlint:off #} +{{ group.name }} +{# djlint:on #}