Skip to content

Saleor Core: the high performance, composable, headless commerce API.

Fix images in product edit

Krzysztof Białogłowicz4bf84af2c23b
diff --git a/saleor/static/js/dashboard.js b/saleor/static/js/dashboard.js
index aa335eeefe..8c73c44a36 100644
--- a/saleor/static/js/dashboard.js
+++ b/saleor/static/js/dashboard.js
@@ -125,12 +125,10 @@ Dropzone.options.productImageForm = {
previewTemplate: $('#template').html(),
clickable: false,
init: function() {
- let $dropzoneGhost = $('.dropzone-ghost');
+ let $dropzoneMessage = $('.dropzone-message');
let $gallery = $('.product-gallery');
- this.on('complete', function() {
- $dropzoneGhost.remove().appendTo($gallery);
- }).on('success', function(e, response) {
+ this.on('success', function(e, response) {
$(e.previewElement).find('.product-gallery-item-desc').html(response.image);
$(e.previewElement).attr('data-id', response.id);
let editLinkHref = $(e.previewElement).find('.card-action-edit').attr('href');
diff --git a/saleor/static/scss/dashboard/dashboard.scss b/saleor/static/scss/dashboard/dashboard.scss
index 98874926e5..4cac85baa7 100644
--- a/saleor/static/scss/dashboard/dashboard.scss
+++ b/saleor/static/scss/dashboard/dashboard.scss
@@ -197,6 +197,20 @@ $roboto-font-path: "~materialize-css/fonts/roboto/";
font-weight: normal;
}
+.dropzone {
+ .dz-preview {
+ &.dz-image-preview {
+ background: none;
+ }
+ }
+ &-message {
+ span {
+ font-size: 1.7rem;
+ text-transform: uppercase;
+ }
+ }
+}
+
html {
background: #f5f5f5;
@media only screen and (min-width: 0) {
diff --git a/templates/dashboard/product/product_form.html b/templates/dashboard/product/product_form.html
index 6f35bd9982..0233f0dc85 100644
--- a/templates/dashboard/product/product_form.html
+++ b/templates/dashboard/product/product_form.html
@@ -372,15 +372,13 @@
<p class="no-images">{% trans "This product has no images yet." context "Empty image gallery message" %}</p>
{% endif %}
- <div class="col s6 m3 product-gallery-item dropzone-ghost">
- <div class="card">
- <div class="card-content">
- <span class="product-gallery-item-title product-gallery-item-title--noclip card-title black-text">
- <span class="grey-text">
- {% trans "Drop images here to upload" context "Image gallery upload box text" %}
- </span>
+ <div class="col s6 m3 product-gallery-item dropzone-message">
+ <div class="row">
+ <span class="product-gallery-item-title product-gallery-item-title--noclip card-title black-text">
+ <span class="grey-text">
+ {% trans "Drop images here to upload" context "Image gallery upload box text" %}
</span>
- </div>
+ </span>
</div>
</div>
</div>
@@ -388,32 +386,34 @@
<script type="application/template" id="template">
<li class="col s6 m3 product-gallery-item dz-preview dz-file-preview" data-id="{{ image.pk }}">
- <div class="card">
- <div class="card-image product-gallery-item-image">
- <img data-dz-thumbnail />
- </div>
+ <div class="row">
+ <div class="card">
+ <div class="card-image product-gallery-item-image">
+ <img data-dz-thumbnail />
+ </div>
- <div class="dz-progress">
- <span class="dz-upload" data-dz-uploadprogress></span>
- </div>
+ <div class="dz-progress">
+ <span class="dz-upload" data-dz-uploadprogress></span>
+ </div>
- <div class="card-content">
- <span class="product-gallery-item-title card-title black-text">
- <span class="grey-text">{% trans "No description" context "Empty image gallery message" %}</span>
- </span>
- </div>
+ <div class="card-content">
+ <span class="product-gallery-item-title card-title black-text">
+ <span class="grey-text">{% trans "No description" context "Empty image gallery message" %}</span>
+ </span>
+ </div>
- <div class="sortable__drag-area"></div>
+ <div class="sortable__drag-area"></div>
- <div class="card-action">
- <a class="card-action-edit" href="{% url 'dashboard:product-image-update' product_pk=product.pk img_pk=0 %}">
- {% trans "Edit" context "Image card action" %}
- </a>
+ <div class="card-action">
+ <a class="card-action-edit" href="{% url 'dashboard:product-image-update' product_pk=product.pk img_pk=0 %}">
+ {% trans "Edit" context "Image card action" %}
+ </a>
- <a href="#base-modal" class="card-action-delete modal-trigger-custom"
- data-href="{% url 'dashboard:product-image-delete' product_pk=product.pk img_pk=0 %}">
- {% trans "Delete" context "Image card action" %}
- </a>
+ <a href="#base-modal" class="card-action-delete modal-trigger-custom"
+ data-href="{% url 'dashboard:product-image-delete' product_pk=product.pk img_pk=0 %}">
+ {% trans "Delete" context "Image card action" %}
+ </a>
+ </div>
</div>
</div>
</li>