Saleor Core: the high performance, composable, headless commerce API.
Python cartcheckoutcommercecomposablee-commerceecommercegraphqlheadlessheadless-commercemultichannelomsorder-managementpaymentspimpythonshopshopping-cartstore
Move as many modals as possible to separate tpls
Paweł Kowalewski4cd2e955c6ab
diff --git a/saleor/dashboard/category/views.py b/saleor/dashboard/category/views.pyindex 6e1ac0f6b5..9baa83a486 100644--- a/saleor/dashboard/category/views.py+++ b/saleor/dashboard/category/views.py@@ -73,5 +73,5 @@ def category_delete(request, pk):'descendants': list(category.get_descendants()),'products_count': len(category.products.all())}return TemplateResponse(request,- 'dashboard/category/category_confirm_delete.html',- ctx)\ No newline at end of file+ 'dashboard/category/modal_category_confirm_delete.html',+ ctx)diff --git a/saleor/dashboard/product/views.py b/saleor/dashboard/product/views.pyindex 202a94d206..176c68ee44 100644--- a/saleor/dashboard/product/views.py+++ b/saleor/dashboard/product/views.py@@ -71,9 +71,9 @@ def product_delete(request, pk):product.delete()messages.success(request, _('Deleted product %s') % product)return redirect('dashboard:product-list')- return TemplateResponse(request,- 'dashboard/product/product_confirm_delete.html',- {'product': product})+ return TemplateResponse(+ request, 'dashboard/product/modal_product_confirm_delete.html',+ {'product': product})@staff_member_required@@ -161,7 +161,8 @@ def product_image_delete(request, product_pk, img_pk):return redirect(success_url)ctx = {'product': product, 'product_image': product_image}return TemplateResponse(- request, 'dashboard/product/product_image_confirm_delete.html', ctx)+ request,+ 'dashboard/product/modal_product_image_confirm_delete.html', ctx)@staff_member_required@@ -208,7 +209,8 @@ def variant_delete(request, product_pk, variant_pk):ctx = {'is_only_variant': is_only_variant, 'product': product,'variant': variant}return TemplateResponse(- request, 'dashboard/product/product_variant_confirm_delete.html', ctx)+ request,+ 'dashboard/product/modal_product_variant_confirm_delete.html', ctx)@staff_member_required@@ -262,6 +264,5 @@ def attribute_delete(request, pk):messages.success(request, _('Deleted attribute %s' % attribute.display))return redirect('dashboard:product-attributes')ctx = {'attribute': attribute}- return TemplateResponse(request,- 'dashboard/product/attributes/confirm_delete.html',- ctx)+ return TemplateResponse(+ request, 'dashboard/product/attributes/modal_confirm_delete.html', ctx)diff --git a/saleor/dashboard/templates/dashboard/category/list.html b/saleor/dashboard/templates/dashboard/category/list.htmlindex 76a848b665..598234eaeb 100644--- a/saleor/dashboard/templates/dashboard/category/list.html+++ b/saleor/dashboard/templates/dashboard/category/list.html@@ -40,7 +40,7 @@</li><li>- <a class="modal-trigger" href="#modal-category-delete">+ <a class="modal-trigger-custom" data-href="{% url 'dashboard:category-delete' pk=root.pk %}" href="#base-modal">{% trans "Remove category" %}</a></li>@@ -109,24 +109,4 @@</ul></div></div>-- {% if root %}- <div id="modal-category-delete" class="modal">- <form action="{% url "dashboard:category-delete" pk=root.pk %}" method="post">- {% csrf_token %}- <div class="modal-content">- <h5>{% trans "Are you sure?" %}</h5>-- <p>- {% blocktrans %}If you remove <strong>{{ root }}</strong> you will lose all data related to this category.{% endblocktrans %}- </p>- </div>-- <div class="modal-footer">- <button type="submit" class="modal-action btn-flat blue-text">{% trans "Delete" %}</button>- <a href="#!" class="modal-action modal-close btn-flat blue-text">{% trans "Cancel" %}</a>- </div>- </form>- </div>- {% endif %}{% endblock %}diff --git a/saleor/dashboard/templates/dashboard/category/modal_category_confirm_delete.html b/saleor/dashboard/templates/dashboard/category/modal_category_confirm_delete.htmlnew file mode 100644index 0000000000..13544e7708--- /dev/null+++ b/saleor/dashboard/templates/dashboard/category/modal_category_confirm_delete.html@@ -0,0 +1,49 @@+{% load i18n %}+{% load mptt_tags %}++<form method="post" id="form-category" class="form-async" action="{% url 'dashboard:category-edit' root_pk=category.pk %}">+ {% csrf_token %}+ <div class="modal-content">+ <div class="row">+ <div class="col s12">+ <h5>+ {% blocktrans with category=category %}+ Are you sure you want to delete the category {{ category }}?+ {% endblocktrans %}+ </h5>+ </div>+ </div>++ {% if descendants %}+ <div class="row">+ <div class="col s12">+ {% trans 'The following child categories will be deleted:' %}+ <ul>+ {% recursetree descendants %}+ <li>{{ node.name }}+ {% if not node.is_leaf_node %}+ <ul class="children">+ {{ children }}+ </ul>+ {% endif %}+ </li>+ {% endrecursetree %}+ </ul>+ </div>+ </div>+ {% endif %}++ {% if products_count %}+ {% blocktrans count counter=products_count %}+ There is one product in this category that will be deleted.+ {% plural %}+ There are {{ counter }} products in this category that will be deleted.+ {% endblocktrans %}+ {% endif %}+ </div>++ <div class="modal-footer">+ <button type="submit" class="modal-action btn-flat blue-text">{% trans "Update" %}</button>+ <a href="#!" class="modal-action modal-close btn-flat blue-text">{% trans "Cancel" %}</a>+ </div>+</form>diff --git a/saleor/dashboard/templates/dashboard/category/modal_edit.html b/saleor/dashboard/templates/dashboard/category/modal_edit.htmlindex b22e245fbe..a273aeb390 100644--- a/saleor/dashboard/templates/dashboard/category/modal_edit.html+++ b/saleor/dashboard/templates/dashboard/category/modal_edit.html@@ -5,10 +5,13 @@<form method="post" id="form-category" class="form-async" action="{% url 'dashboard:category-edit' root_pk=category.pk %}">{% csrf_token %}<div class="modal-content">- <h5>{% trans "Edit" %} {{ category }}</h5>+ <div class="row">+ <div class="col s12">+ <h5>{% trans "Edit" %} {{ category }}</h5>+ </div>+ </div><div class="row">- {{ form.parent }}{{ form.name|materializecss:"s8 m10" }}{{ form.hidden|materializecss:"s4 m2" }}{{ form.description|materializecss }}diff --git a/saleor/dashboard/templates/dashboard/product/attributes/form.html b/saleor/dashboard/templates/dashboard/product/attributes/form.htmlindex 2536b08e3f..8a77e65657 100644--- a/saleor/dashboard/templates/dashboard/product/attributes/form.html+++ b/saleor/dashboard/templates/dashboard/product/attributes/form.html@@ -19,7 +19,8 @@</a><ul id="attribute-delete" class="dropdown-content"><li>- <a class="modal-trigger" href="#modal-attribute-delete">+ <a class="modal-trigger-custom" href="#base-modal"+ data-href="{% url 'dashboard:product-attribute-delete' pk=attribute.pk %}">{% trans "Remove attribute" %}</a></li>@@ -88,24 +89,4 @@</div></div></form>-- {% if attribute.pk %}- <div id="modal-attribute-delete" class="modal">- <form action="{% url "dashboard:product-attribute-delete" pk=attribute.pk %}" method="post">- {% csrf_token %}- <div class="modal-content">- <h5>{% trans "Are you sure?" %}</h5>-- <p>- {% blocktrans %}You are about to delete an attribute <strong>{{ attribute }}</strong>.{% endblocktrans %}- </p>- </div>-- <div class="modal-footer">- <button type="submit" class="modal-action btn-flat blue-text">{% trans "Delete" %}</button>- <a href="#!" class="modal-action modal-close btn-flat blue-text">{% trans "Cancel" %}</a>- </div>- </form>- </div>- {% endif %}{% endblock %}diff --git a/saleor/dashboard/templates/dashboard/product/attributes/list.html b/saleor/dashboard/templates/dashboard/product/attributes/list.htmlindex f3d3045295..cc8b8e63d4 100644--- a/saleor/dashboard/templates/dashboard/product/attributes/list.html+++ b/saleor/dashboard/templates/dashboard/product/attributes/list.html@@ -8,7 +8,7 @@{% block header_extra %}<div class="fixed-action-btn">- <a class="btn-fab btn-floating btn-large waves-effect waves-light teal modal-trigger"+ <a class="btn-fab btn-floating btn-large waves-effect waves-light teal"href="{% url 'dashboard:product-attribute-add' %}" title="{% trans "Add attribute" %}"><i class="mdi-content-add"></i></a>diff --git a/saleor/dashboard/templates/dashboard/product/attributes/modal_confirm_delete.html b/saleor/dashboard/templates/dashboard/product/attributes/modal_confirm_delete.htmlnew file mode 100644index 0000000000..30879e04b4--- /dev/null+++ b/saleor/dashboard/templates/dashboard/product/attributes/modal_confirm_delete.html@@ -0,0 +1,17 @@+{% load i18n %}++<form action="{% url "dashboard:product-attribute-delete" pk=attribute.pk %}" method="post">+ {% csrf_token %}+ <div class="modal-content">+ <h5>{% trans "Are you sure?" %}</h5>++ <p>+ {% blocktrans %}You are about to delete an attribute <strong>{{ attribute }}</strong>.{% endblocktrans %}+ </p>+ </div>++ <div class="modal-footer">+ <button type="submit" class="modal-action btn-flat blue-text">{% trans "Delete" %}</button>+ <a href="#!" class="modal-action modal-close btn-flat blue-text">{% trans "Cancel" %}</a>+ </div>+</form>diff --git a/saleor/dashboard/templates/dashboard/product/modal_product_confirm_delete.html b/saleor/dashboard/templates/dashboard/product/modal_product_confirm_delete.htmlnew file mode 100644index 0000000000..712fae6c55--- /dev/null+++ b/saleor/dashboard/templates/dashboard/product/modal_product_confirm_delete.html@@ -0,0 +1,33 @@+{% load i18n %}+{% load prices_i18n %}+{% load staticfiles %}++<form action="{% url "dashboard:product-delete" pk=product.pk %}" method="post">+ {% csrf_token %}+ <div class="modal-content">+ <div class="row">+ <div class="col s12">+ <h5>{% trans "Are you sure?" %}</h5>+ </div>+ </div>++ <div class="row">+ <div class="col s12 center-align">+ {% if product.images.exists %}+ <img src="{{ product.images.first.image.crop.400x400 }}" alt="" class="responsive-img">+ {% else %}+ <img src="{% static 'images/product-image-placeholder.png' %}" alt="" class="responsive-img">+ {% endif %}+ </div>+ </div>++ <p>+ {% blocktrans %}If you remove <strong>{{ product }}</strong> you will lose all data related to this product.{% endblocktrans %}+ </p>+ </div>++ <div class="modal-footer">+ <button type="submit" class="modal-action btn-flat blue-text">{% trans "Delete" %}</button>+ <a href="#!" class="modal-action modal-close btn-flat blue-text">{% trans "Cancel" %}</a>+ </div>+</form>diff --git a/saleor/dashboard/templates/dashboard/product/modal_product_image_confirm_delete.html b/saleor/dashboard/templates/dashboard/product/modal_product_image_confirm_delete.htmlnew file mode 100644index 0000000000..040e566f58--- /dev/null+++ b/saleor/dashboard/templates/dashboard/product/modal_product_image_confirm_delete.html@@ -0,0 +1,27 @@+{% load i18n %}++<form action="{% url 'dashboard:product-image-delete' product_pk=product.pk img_pk=product_image.pk %}" method="post">+ {% csrf_token %}+ <input type="hidden" name="success_url" value="{% url 'dashboard:product-update' pk=product.pk %}#images">++ <div class="modal-content">+ <div class="row">+ <div class="col s12">+ <h5>{% trans "Are you sure?" %}</h5>+ </div>+ </div>++ <div class="center-align">+ <img class="responsive-img" src="{{ product_image.image.crop.400x250 }}" alt="">+ </div>++ <p>+ {% blocktrans %}You are about to delete this image.{% endblocktrans %}+ </p>+ </div>++ <div class="modal-footer">+ <button type="submit" class="modal-action btn-flat blue-text">{% trans "Delete" %}</button>+ <a href="#!" class="modal-action modal-close btn-flat blue-text">{% trans "Cancel" %}</a>+ </div>+</form>diff --git a/saleor/dashboard/templates/dashboard/product/product_form.html b/saleor/dashboard/templates/dashboard/product/product_form.htmlindex be528153c5..3391cb6f5d 100644--- a/saleor/dashboard/templates/dashboard/product/product_form.html+++ b/saleor/dashboard/templates/dashboard/product/product_form.html@@ -21,7 +21,8 @@</a><ul id="product-delete" class="dropdown-content"><li>- <a class="modal-trigger" href="#modal-product-delete">+ <a href="#base-modal" data-href="{% url 'dashboard:product-delete' pk=product.pk %}"+ class="modal-trigger-custom">{% trans "Remove product" %}</a></li>@@ -297,7 +298,8 @@{% trans "Edit" %}</a>- <a href="#modal-product-image-delete-{{ image.pk }}" class="modal-trigger">+ <a href="#base-modal" class="modal-trigger-custom"+ data-href="{% url 'dashboard:product-image-delete' product_pk=product.pk img_pk=image.pk %}">{% trans "Delete" %}</a></div>@@ -313,30 +315,6 @@</li></ul></form>-- {% for image in images %}- <div class="modal" id="modal-product-image-delete-{{ image.pk }}">- <form action="{% url 'dashboard:product-image-delete' product_pk=product.pk img_pk=image.pk %}" method="post">- {% csrf_token %}- <input type="hidden" name="success_url" value="{% url 'dashboard:product-update' pk=product.pk %}#images">-- <div class="modal-content">- <h5>{% trans "Are you sure?" %}</h5>-- <img class="responsive-img" src="{{ image.image.crop.400x250 }}" alt="">-- <p>- {% blocktrans %}You are about to delete this image.{% endblocktrans %}- </p>- </div>-- <div class="modal-footer">- <button type="submit" class="modal-action btn-flat blue-text">{% trans "Delete" %}</button>- <a href="#!" class="modal-action modal-close btn-flat blue-text">{% trans "Cancel" %}</a>- </div>- </form>- </div>- {% endfor %}</div></div>{% else %}@@ -383,28 +361,6 @@<i class="mdi-content-add"></i></a></div>-- <div id="modal-product-delete" class="modal">- <form action="{% url "dashboard:product-delete" pk=product.pk %}" method="post">- {% csrf_token %}- <div class="modal-content">- <h5>{% trans "Are you sure?" %}</h5>-- {% if object.images.exists %}- <img src="{{ product.images.first.image.crop.600x600 }}" alt="" class="responsive-img">- {% endif %}-- <p>- {% blocktrans %}If you remove <strong>{{ product }}</strong> you will lose all data related to this product.{% endblocktrans %}- </p>- </div>-- <div class="modal-footer">- <button type="submit" class="modal-action btn-flat blue-text">{% trans "Delete" %}</button>- <a href="#!" class="modal-action modal-close btn-flat blue-text">{% trans "Cancel" %}</a>- </div>- </form>- </div>{% endif %}{% endblock %}diff --git a/saleor/static/js_src/dashboard.js b/saleor/static/js_src/dashboard.jsindex 49bb4c8fbf..422778d2fa 100644--- a/saleor/static/js_src/dashboard.js+++ b/saleor/static/js_src/dashboard.js@@ -105,7 +105,6 @@ Dropzone.options.productImageForm = {this.on('complete', function() {$dropzoneGhost.remove().appendTo($gallery);}).on('success', function(e, response) {- console.log(e, response);$(e.previewElement).find('.product-gallery-item-desc').html(e.name);$(e.previewElement).attr('data-id', response.id);var editLinkHref = $(e.previewElement).find('.card-action-edit').attr('href');diff --git a/saleor/static/scss/_app.scss b/saleor/static/scss/_app.scssindex be0cc3f716..b8ad406601 100644--- a/saleor/static/scss/_app.scss+++ b/saleor/static/scss/_app.scss@@ -192,6 +192,15 @@ $transition-duration: .2s;}}+.modal-content {+ .row {+ margin: {+ left: -.75rem;+ right: -.75rem;+ }+ }+}+.page-title {display: block;font-size: $h5-fontsize;