Skip to content

Commit

Permalink
feat(apis_entities): surround navigation elements with block
Browse files Browse the repository at this point in the history
That way they can be overridden or extended
  • Loading branch information
b1rger committed Mar 22, 2024
1 parent 3307074 commit 6b2fb49
Show file tree
Hide file tree
Showing 3 changed files with 61 additions and 52 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,11 @@ <h2 style="text-align: center;">
</div>
{% endblock card-header-content %}

{% include "apis_entities/partials/entity_base_nav.html" %}
{% include "apis_entities/partials/entity_actions_nav.html" %}
{% block navigation %}
{% include "apis_entities/partials/entity_base_nav.html" %}
{% include "apis_entities/partials/entity_actions_nav.html" %}
{% endblock navigation %}

</div>
<div class="card-body">

Expand Down
Original file line number Diff line number Diff line change
@@ -1,41 +1,44 @@
{% load apiscore %}
{% with object|opts as opts %}
{% with opts.object_name|lower as modelname %}
{% with opts.app_label|add:"."|add:modelname|add:"_create" as object_create_perm %}
{% with opts.app_label|add:"."|add:modelname|add:"_delete" as object_delete_perm %}

{% if object_delete_perm in perms or object_create_perm in perms %}
<ul class="nav nav-tabs card-header-tabs float-right">
<li class="nav-item">
<a class="nav-link dropdown-toggle" data-toggle="dropdown" href="#">Actions</a>
<div class="dropdown-menu">
{% block action-nav %}
{% with object|opts as opts %}
{% with opts.object_name|lower as modelname %}
{% with opts.app_label|add:"."|add:modelname|add:"_create" as object_create_perm %}
{% with opts.app_label|add:"."|add:modelname|add:"_delete" as object_delete_perm %}

{% if object_delete_perm in perms %}
<a class="dropdown-item text-danger"
href="{% url "apis_core:apis_entities:generic_entities_delete_view" modelname object.id %}">
<span class="material-symbols-outlined material-symbols-align">delete</span> Delete
</a>
{% endif %}
{% if object_delete_perm in perms or object_create_perm in perms %}
<ul class="nav nav-tabs card-header-tabs float-right">
<li class="nav-item">
<a class="nav-link dropdown-toggle" data-toggle="dropdown" href="#">Actions</a>
<div class="dropdown-menu">

{% if object_create_perm in perms %}
<a class="dropdown-item"
style="color: blueviolet"
href="{% url "apis_core:apis_entities:generic_entities_duplicate_view" modelname object.id %}">
<span class="material-symbols-outlined material-symbols-align">content_copy</span> Duplicate
</a>
<a class="dropdown-item"
style="color: dodgerblue"
href="{% url "apis_core:apis_entities:generic_entities_merge_view" modelname object.id %}">
<span class="material-symbols-outlined material-symbols-align">cell_merge</span> Merge
</a>
{% endif %}
{% if object_delete_perm in perms %}
<a class="dropdown-item text-danger"
href="{% url "apis_core:apis_entities:generic_entities_delete_view" modelname object.id %}">
<span class="material-symbols-outlined material-symbols-align">delete</span> Delete
</a>
{% endif %}

</div>
</li>
</ul>
{% endif %}
{% if object_create_perm in perms %}
<a class="dropdown-item"
style="color: blueviolet"
href="{% url "apis_core:apis_entities:generic_entities_duplicate_view" modelname object.id %}">
<span class="material-symbols-outlined material-symbols-align">content_copy</span> Duplicate
</a>
<a class="dropdown-item"
style="color: dodgerblue"
href="{% url "apis_core:apis_entities:generic_entities_merge_view" modelname object.id %}">
<span class="material-symbols-outlined material-symbols-align">cell_merge</span> Merge
</a>
{% endif %}

</div>
</li>
</ul>
{% endif %}

{% endwith %}
{% endwith %}
{% endwith %}
{% endwith %}
{% endwith %}
{% endblock action-nav %}
Original file line number Diff line number Diff line change
@@ -1,23 +1,26 @@
{% load apiscore %}
{% with object|opts as opts %}
{% with opts.object_name|lower as modelname %}
{% with opts.app_label|add:"."|add:modelname|add:"_change" as object_change_perm %}

{% if object_change_perm in perms %}
<ul class="nav nav-tabs card-header-tabs float-left">
<li class="nav-item">
<a class="nav-link text-success
{% if request.path == object.get_absolute_url %}active{% endif %}
" href="{{ object.get_absolute_url }}"><span class="material-symbols-outlined material-symbols-align">visibility</span>View</a>
</li>
<li class="nav-item">
<a class="nav-link text-warning
{% if request.path == object.get_edit_url %}active{% endif %}
" href="{{ object.get_edit_url }}"><span class="material-symbols-outlined material-symbols-align">edit</span>Edit</a>
</li>
</ul>
{% endif %}
{% block base-nav %}
{% with object|opts as opts %}
{% with opts.object_name|lower as modelname %}
{% with opts.app_label|add:"."|add:modelname|add:"_change" as object_change_perm %}

{% if object_change_perm in perms %}
<ul class="nav nav-tabs card-header-tabs float-left">
<li class="nav-item">
<a class="nav-link text-success
{% if request.path == object.get_absolute_url %}active{% endif %}
" href="{{ object.get_absolute_url }}"><span class="material-symbols-outlined material-symbols-align">visibility</span>View</a>
</li>
<li class="nav-item">
<a class="nav-link text-warning
{% if request.path == object.get_edit_url %}active{% endif %}
" href="{{ object.get_edit_url }}"><span class="material-symbols-outlined material-symbols-align">edit</span>Edit</a>
</li>
</ul>
{% endif %}

{% endwith %}
{% endwith %}
{% endwith %}
{% endwith %}
{% endblock base-nav %}

0 comments on commit 6b2fb49

Please sign in to comment.