refactor(admin/templates): remove unused template and inline storefront link logic

Removed `submit_line_with_storefront_link.html` as it is no longer needed. Moved storefront link rendering logic directly into `change_form_with_storefront_link.html` for better maintainability and reduced template complexity.
This commit is contained in:
Egor Pavlovich Gorbunov 2026-03-09 19:24:09 +03:00
parent f9d479c37c
commit dc1d97478e
2 changed files with 27 additions and 80 deletions

View file

@ -1,5 +1,31 @@
{% extends "admin/change_form.html" %}
{% load i18n %}
{% block submit_buttons_bottom %}
{% include "admin/core/submit_line_with_storefront_link.html" %}
{{ block.super }}
{% if storefront_url %}
<template id="storefront-link-tpl">
<a href="{{ storefront_url }}"
target="_blank"
rel="noopener"
class="storefront-link font-medium inline-flex items-center gap-2 px-3 py-2 rounded-default justify-center whitespace-nowrap cursor-pointer text-white text-sm w-full lg:w-auto"
style="background:linear-gradient(135deg,#6366f1,#8b5cf6);box-shadow:0 0 14px rgba(99,102,241,.35);">
<span class="material-symbols-outlined text-base">open_in_new</span>
{% trans "See on site" %}
</a>
</template>
<script>
(function() {
var tpl = document.getElementById("storefront-link-tpl");
if (!tpl) return;
var link = tpl.content.firstElementChild.cloneNode(true);
var save = document.querySelector('#submit-row button[name="_save"]');
if (save) {
save.insertAdjacentElement("afterend", link);
}
tpl.remove();
})();
</script>
{% endif %}
{% endblock %}

View file

@ -1,79 +0,0 @@
{% load i18n admin_urls unfold %}
<div {% if not is_popup %}id="submit-row"{% endif %} class="relative lg:sticky lg:bottom-0 z-40">
<div class="backdrop-blur-xs bg-white/80 rounded-b-default pb-4 px-4 dark:bg-base-900/80 lg:border-t lg:border-base-200 relative lg:scrollable-top lg:py-0 dark:border-base-800">
<div class="flex flex-col-reverse gap-3 items-center mx-auto lg:flex-row-reverse container lg:h-[64px]">
{% block submit-row %}
{% if show_save %}
{% component "unfold/components/button.html" with submit=1 form=opts.model_name|add:"_form" name="_save" class="w-full lg:w-auto" %}
{% trans "Save" %}
{% endcomponent %}
{% endif %}
{% for action in actions_submit_line %}
{% component "unfold/components/button.html" with submit=1 form=opts.model_name|add:"_form" name=action.attrs.name|default:action.action_name variant="default" class="w-full lg:w-auto" attrs=action.attrs %}
{% if action.icon %}
<span class="material-symbols-outlined">
{{ action.icon }}
</span>
{% endif %}
{{ action.description }}
{% endcomponent %}
{% endfor %}
{% if show_save_and_continue %}
{% component "unfold/components/button.html" with submit=1 form=opts.model_name|add:"_form" name="_continue" variant="default" class="w-full lg:w-auto" %}
{% if can_change %}
{% trans "Save and continue editing" %}
{% else %}
{% trans "Save and view" %}
{% endif %}
{% endcomponent %}
{% endif %}
{% if show_save_and_add_another %}
{% component "unfold/components/button.html" with submit=1 form=opts.model_name|add:"_form" name="_addanother" variant="default" class="w-full lg:w-auto" %}
{% trans "Save and add another" %}
{% endcomponent %}
{% endif %}
{% if show_save_as_new %}
{% component "unfold/components/button.html" with submit=1 form=opts.model_name|add:"_form" name="_saveasnew" variant="default" class="w-full lg:w-auto" %}
{% trans "Save as new" %}
{% endcomponent %}
{% endif %}
{% if original and storefront_url %}
<a href="{{ storefront_url }}"
target="_blank"
rel="noopener"
class="font-medium inline-flex group items-center gap-2 px-3 py-2 rounded-default justify-center whitespace-nowrap cursor-pointer border border-base-200 bg-white shadow-xs text-important dark:border-base-700 dark:bg-transparent hover:bg-base-100/80 dark:hover:bg-base-800/80 w-full lg:w-auto">
<span class="material-symbols-outlined text-base">open_in_new</span>
{% trans "See on site" %}
</a>
{% endif %}
<div class="flex flex-col gap-3 mr-auto w-full lg:flex-row lg:w-auto">
{% if show_close or adminform.model_admin.change_form_show_cancel_button %}
{% url opts|admin_urlname:'changelist' as changelist_url %}
{% add_preserved_filters changelist_url as link %}
{% component "unfold/components/button.html" with href=link variant="default" class="w-full lg:w-auto"%}
{% trans "Close" %}
{% endcomponent %}
{% endif %}
{% if show_delete_link and original %}
{% url opts|admin_urlname:'delete' original.pk|admin_urlquote as delete_url %}
{% add_preserved_filters delete_url as link %}
{% component "unfold/components/button.html" with href=delete_url variant="danger" class="mr-auto w-full lg:w-auto" %}
{% trans "Delete" %} {{ opts.verbose_name }}
{% endcomponent %}
{% endif %}
</div>
{% endblock %}
</div>
</div>
</div>