taskflower/src/taskflower/templates/namespace/admin/_helpers.html
2025-11-28 13:09:21 -06:00

97 lines
No EOL
1.9 KiB
HTML

{% macro link_button_elem(obj_type, action_type, enabled, url, btn_icon, extra_cls='') %}
<td class="pad-even">
{% if enabled %}
<a
class="icon-only-btn {{extra_cls}}"
aria-label="{{action_type}} {{obj_type}}"
href="{{url}}"
>{{btn_icon|safe}}</a>
{% else %}
<a
class="icon-only-btn disabled"
aria-label="Can't {{action_type}} {{obj_type}}"
title="You don't have permission to {{action_type}} this {{obj_type}}"
>{{icon('not-allowed')|safe}}</a>
{% endif %}
</td>
{% endmacro %}
{% macro obj_entry(ns, obj, obj_type, edit_endpoint, delete_endpoint, tab, entries) %}
<tr>
{{
link_button_elem(
obj_type,
'edit',
obj.can_edit,
url_for(
edit_endpoint,
id=ns.id,
tid=obj.id,
next=cur_page_with_variables(
request,
active_tab=tab
)
),
icon('cog')
)
}}
{{
link_button_elem(
obj_type,
'delete',
obj.can_edit,
url_for(
delete_endpoint,
id=ns.id,
tid=obj.id,
next=cur_page_with_variables(
request,
active_tab=tab
)
),
icon('delete'),
'red'
)
}}
{% for entry in entries %}
<td>{{entry}}</td>
{% endfor %}
</tr>
{% endmacro %}
{% macro obj_colgroup(entries) %}
<colgroup>
<col span="1" style="width: 0;"/>
<col span="1" style="width: 0;"/>
{% for entry in entries %}
<col span="1"/>
{% endfor %}
</colgroup>
{% endmacro %}
{% macro obj_header(entries) %}
<tr>
<th>Edit</th>
<th>Del</th>
{% for entry in entries %}
<th>{{entry}}</th>
{% endfor %}
</tr>
{% endmacro %}
{% macro obj_add_row(obj_type, can_add, url, entries) %}
<tr>
<td colspan="{{len(entries) + 2}}">
{% if can_add %}
<a
class="link-btn icon-btn"
href="{{url}}"
>{{icon('add')|safe}} Add a new {{obj_type}}</a>
{% else %}
<a
class="link-btn icon-btn disabled"
>{{icon('not-allowed')|safe}} Add a new {{obj_type}}</a>
{% endif %}
</td>
</tr>
{% endmacro %}