Skip to content

Commit

Permalink
button label
Browse files Browse the repository at this point in the history
  • Loading branch information
erikvw committed Jan 23, 2024
1 parent 4488fd1 commit a0ef36e
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 2 deletions.
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
{% load i18n %}

<div class="list-group-item list-group-item-{{ panel_color }}">
<a class="btn btn-sm btn-{% if reference_obj %}success{% else%}warning{% endif %}" title="{% if reference_obj %}{% if view_only %}View{% elif may_access_tmg_obj %}Edit{% else %}May only be edited by {{ reference_obj.user_created }}{% endif %}{% else %}Add{% endif %}" data-toggle="tooltip" role="button" id="reference_obj-{{ counter }}"
<a class="btn btn-sm btn-{% if reference_obj %}success{% else%}warning{% endif %}"
title="{% if reference_obj %}{% if view_only %}View{% elif may_access_tmg_obj %}Edit{% else %}May only be edited by {{ reference_obj.user_created }}{% endif %}{% else %}Add{% endif %}" data-toggle="tooltip" role="button" id="reference_obj-{{ counter }}"
{% if not disabled %} href="{{ reference_obj.get_absolute_url }}?next=edc_adverse_event:open_tmg_ae_listboard_url" {% endif %} {{ disabled }}>
{% if view_only %}<i class="fas fa-eye fa-fw"></i> View {% else %}<i class="fas fa-pencil-alt fa-fw"></i> Edit {% endif %}
<i class="fas {{ fa_icon }} fa-fw"></i> {{ label }}
</a>
&nbsp;{{ action_item.display_name|cut:"Submit"|cut:"pending" }} {{ action_item.identifier|default:"New" }}
&nbsp;{% if report_status == OPEN %}<span class="label label-danger">OPEN</span>{% endif %}
Expand Down
14 changes: 14 additions & 0 deletions edc_adverse_event/templatetags/edc_adverse_event_extras.py
Original file line number Diff line number Diff line change
Expand Up @@ -199,6 +199,17 @@ def render_tmg_panel(
by_user_created_only=by_user_created_only,
)
disabled = "disabled" if not may_access_tmg_obj else ""

if view_only:
label = "View"
fa_icon = "fa-eye"
elif not reference_obj:
label = "Add"
fa_icon = "fa-plus"
else:
label = "Edit" if reference_obj else "view"
fa_icon = "fa-pencil" if reference_obj else "fa-plus"

if view_only:
panel_color = "info"
else:
Expand All @@ -210,6 +221,8 @@ def render_tmg_panel(
counter=counter,
panel_color=panel_color,
disabled=disabled,
label=label,
fa_icon=fa_icon,
view_only=view_only,
report_status=report_status,
OPEN=OPEN,
Expand Down Expand Up @@ -250,6 +263,7 @@ def has_perms_for_obj(
has_perms = False

reference_obj = reference_obj or get_reference_obj(action_item)

if reference_obj:
app_label = reference_obj._meta.app_label
add_codename = get_permission_codename("add", reference_obj._meta)
Expand Down

0 comments on commit a0ef36e

Please sign in to comment.