Skip to content

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

Fix form fields styles

Paweł Kowalewskidadc60a1b869
diff --git a/saleor/core/templates/materializecssform/field.html b/saleor/core/templates/materializecssform/field.html
index edc1559f1e..39ad00ede9 100644
--- a/saleor/core/templates/materializecssform/field.html
+++ b/saleor/core/templates/materializecssform/field.html
@@ -107,7 +107,7 @@
<div class="input-field col {{ classes.label }}">
<textarea id="{{ field.auto_id }}" class="materialize-textarea" name="{{field.name}}">{% if field.value %}{{ field.value }}{% endif %}</textarea>
{% if field.auto_id %}
- <label class="{{ classes.label }} {% if field.field.required %}{{ form.required_css_class }}{% endif %}" for="{{ field.auto_id }}">{{ field.label }}</label>
+ <label class="active {{ classes.label }}" for="{{ field.auto_id }}">{{ field.label }}</label>
{% endif %}
{% for error in field.errors %}
@@ -146,7 +146,7 @@
<div class="price-wrapper">
{{ field }}
{% if field.auto_id %}
- <label class="{% if field.field.required %}{% endif %}" for="{{ field.auto_id }}">{{ field.label }}</label>
+ <label class="active" for="{{ field.auto_id }}">{{ field.label }}</label>
{% endif %}
</div>
diff --git a/saleor/dashboard/product/forms.py b/saleor/dashboard/product/forms.py
index c4825ec55c..d2358718b8 100644
--- a/saleor/dashboard/product/forms.py
+++ b/saleor/dashboard/product/forms.py
@@ -75,6 +75,12 @@ class GenericProductForm(ProductForm):
model = GenericProduct
exclude = []
+ def __init__(self, *args, **kwargs):
+ super(GenericProductForm, self).__init__(*args, **kwargs)
+ self.fields['name'].widget.attrs['placeholder'] = pgettext_lazy('Product form labels', 'Give your awesome product a name')
+ self.fields['collection'].widget.attrs['placeholder'] = pgettext_lazy('Product form labels', 'e.g. Zombie apocalypse gear')
+ self.fields['categories'].widget.attrs['data-placeholder'] = pgettext_lazy('Product form labels', 'Search')
+
def save_base_variant(self, **kwargs):
return super(GenericProductForm, self).save_base_variant(
weight=self.instance.weight)
diff --git a/saleor/dashboard/templates/dashboard/customer/detail.html b/saleor/dashboard/templates/dashboard/customer/detail.html
index fedcc0f883..29329c2865 100644
--- a/saleor/dashboard/templates/dashboard/customer/detail.html
+++ b/saleor/dashboard/templates/dashboard/customer/detail.html
@@ -57,7 +57,7 @@
<div class="panel-body">
<div>
{% if customer.default_billing_address %}
- {% with customer.default_billing_address.address as address %}
+ {% with customer.default_billing_address as address %}
{% include 'dashboard/includes/_address.html' with address=address only %}
{% endwith %}
{% else %}
@@ -73,7 +73,7 @@
<div class="panel-body">
<div>
{% if customer.default_shipping_address %}
- {% with customer.default_shipping_address.address as address %}
+ {% with customer.default_shipping_address as address %}
{% include 'dashboard/includes/_address.html' with address=address only %}
{% endwith %}
{% else %}
diff --git a/saleor/dashboard/templates/dashboard/customer/list.html b/saleor/dashboard/templates/dashboard/customer/list.html
index 0afd929bf9..20f079e077 100644
--- a/saleor/dashboard/templates/dashboard/customer/list.html
+++ b/saleor/dashboard/templates/dashboard/customer/list.html
@@ -50,7 +50,7 @@
<tbody>
{% for customer in customers %}
<tr>
- {% with customer.default_billing_address.address as default_address %}
+ {% with customer.default_billing_address as default_address %}
<td>
<a href="{% url "dashboard:customer-details" pk=customer.pk %}">{{ customer.email }}</a>
</td>
diff --git a/saleor/dashboard/templates/dashboard/product/product_form.html b/saleor/dashboard/templates/dashboard/product/product_form.html
index 766853ef46..db7316f410 100644
--- a/saleor/dashboard/templates/dashboard/product/product_form.html
+++ b/saleor/dashboard/templates/dashboard/product/product_form.html
@@ -37,7 +37,7 @@
<div class="row" id="details">
<div class="col l8 offset-l2">
- <div class="row">
+ <div class="row" id="form-product">
{% csrf_token %}
{{ product_form|materializecss }}
</div>
@@ -96,9 +96,7 @@
<li class="col s6 m3 card product-gallery-item" data-id="{{ image.pk }}">
<div class="card-content">
<img class="responsive-img" src="{{ image.image.crop.300x300 }}" alt="">
- {% if image.alt %}
- <span class="product-gallery-item-text">{{ image.alt }}</span>
- {% endif %}
+ <span class="product-gallery-item-text">{{ image.alt|default:image.image.name }}</span>
<a class="product-gallery-item-create light-blue-text text-lighten-1" title="{% trans "Edit image" %}"
href="{% url 'dashboard:product-image-update' product_pk=product.pk img_pk=image.pk %}">
<i class="mdi-content-create"></i>
diff --git a/saleor/static/js_src/dashboard.js b/saleor/static/js_src/dashboard.js
index c4eb4531ea..ebfff39e0a 100644
--- a/saleor/static/js_src/dashboard.js
+++ b/saleor/static/js_src/dashboard.js
@@ -6,25 +6,27 @@ $('ul.tabs').find('.tab').on('click', function(e) {
window.history.pushState(null, null, e.target.hash);
});
var el = document.getElementById('product-gallery');
-var sortable = Sortable.create(el, {
- onUpdate: function() {
- $.ajax({
- dataType: 'json',
- contentType: "application/json",
- data: JSON.stringify({
- 'order': (function () {
- var postData = [];
- $(el).find('.product-gallery-item').each(function (i) {
- postData.push($(this).data('id'));
- });
- return postData;
- })()
- }),
- headers: {
- 'X-CSRFToken': $('[name=csrfmiddlewaretoken]').val()
- },
- method: 'post',
- url: $(el).data('post-url')
- });
- }
-});
+if (el) {
+ var sortable = Sortable.create(el, {
+ onUpdate: function () {
+ $.ajax({
+ dataType: 'json',
+ contentType: "application/json",
+ data: JSON.stringify({
+ 'order': (function () {
+ var postData = [];
+ $(el).find('.product-gallery-item').each(function (i) {
+ postData.push($(this).data('id'));
+ });
+ return postData;
+ })()
+ }),
+ headers: {
+ 'X-CSRFToken': $('[name=csrfmiddlewaretoken]').val()
+ },
+ method: 'post',
+ url: $(el).data('post-url')
+ });
+ }
+ });
+}
diff --git a/saleor/static/scss/_app.scss b/saleor/static/scss/_app.scss
index 2f37d65363..be3d9da041 100644
--- a/saleor/static/scss/_app.scss
+++ b/saleor/static/scss/_app.scss
@@ -198,6 +198,17 @@ table {
width: calc(100% - 40px);
}
+%input-lg {
+ font-size: 2.2rem;
+ height: 3.5rem;
+}
+
+#form-product {
+ #id_name {
+ @extend %input-lg;
+ }
+}
+
.input-text-suffix {
float: right;
line-height: 45px;
diff --git a/saleor/static/scss/widget/_form.scss b/saleor/static/scss/widget/_form.scss
index 10d70b3a5c..94a667f6a8 100644
--- a/saleor/static/scss/widget/_form.scss
+++ b/saleor/static/scss/widget/_form.scss
@@ -7,6 +7,14 @@
}
}
+ label {
+ @extend .active;
+ }
+
+ input[type=radio] {
+ @extend .with-gap;
+ }
+
.price-wrapper {
overflow: hidden;
}
diff --git a/saleor/static/scss/widget/_product-gallery.scss b/saleor/static/scss/widget/_product-gallery.scss
index ebf8b4d2d8..1eb1278632 100644
--- a/saleor/static/scss/widget/_product-gallery.scss
+++ b/saleor/static/scss/widget/_product-gallery.scss
@@ -49,6 +49,7 @@
&-remove {
bottom: auto;
+ text-shadow: 0 0 1px white;
top: 0;
}
}