Skip to content

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

Style, forms

Pacu261e13e033878
diff --git a/saleor/dashboard/category/forms.py b/saleor/dashboard/category/forms.py
index 4e6850333c..a36d786ff8 100644
--- a/saleor/dashboard/category/forms.py
+++ b/saleor/dashboard/category/forms.py
@@ -14,14 +14,14 @@ class CategoryForm(forms.ModelForm):
field_maxlength = self.fields['seo_description'].max_length
# Placeholder should be no longer than fields maximum size
placeholder = self.instance.description[:field_maxlength]
- self.fields['seo_description'].widget.attrs = {
+ self.fields['seo_description'].widget.attrs.update({
'id': 'seo_description',
'data-bind': self['description'].auto_id,
- 'placeholder': placeholder}
- self.fields['seo_title'].widget.attrs = {
+ 'placeholder': placeholder})
+ self.fields['seo_title'].widget.attrs.update({
'id': 'seo_title',
'data-bind': self['name'].auto_id,
- 'placeholder': self.instance.name}
+ 'placeholder': self.instance.name})
class Meta:
model = Category
diff --git a/saleor/dashboard/collection/forms.py b/saleor/dashboard/collection/forms.py
index b03e557252..4c9101fbd8 100644
--- a/saleor/dashboard/collection/forms.py
+++ b/saleor/dashboard/collection/forms.py
@@ -31,14 +31,14 @@ class CollectionForm(forms.ModelForm):
super().__init__(*args, **kwargs)
if self.instance.pk:
self.fields['products'].set_initial(self.instance.products.all())
- self.fields['seo_description'].widget.attrs = {
+ self.fields['seo_description'].widget.attrs.update({
'id': 'seo_description',
'data-bind': '',
- 'placeholder': ''}
- self.fields['seo_title'].widget.attrs = {
+ 'placeholder': ''})
+ self.fields['seo_title'].widget.attrs.update({
'id': 'seo_title',
'data-bind': self['name'].auto_id,
- 'placeholder': self.instance.name}
+ 'placeholder': self.instance.name})
def save(self, commit=True):
self.instance.slug = slugify(unidecode(self.instance.name))
diff --git a/saleor/dashboard/page/forms.py b/saleor/dashboard/page/forms.py
index 8f0f4500fe..09a8fd25c9 100644
--- a/saleor/dashboard/page/forms.py
+++ b/saleor/dashboard/page/forms.py
@@ -15,15 +15,15 @@ class PageForm(forms.ModelForm):
# Page's content contains htm tags which should be stripped
placeholder = generate_seo_description(
self.instance.content, field_maxlength)
- self.fields['seo_description'].widget.attrs = {
+ self.fields['seo_description'].widget.attrs.update({
'id': 'seo_description',
'data-bind': self['content'].auto_id,
'data-materialize': self['content'].html_name,
- 'placeholder': placeholder}
- self.fields['seo_title'].widget.attrs = {
+ 'placeholder': placeholder})
+ self.fields['seo_title'].widget.attrs.update({
'id': 'seo_title',
'data-bind': self['title'].auto_id,
- 'placeholder': self.instance.title}
+ 'placeholder': self.instance.title})
class Meta:
model = Page
diff --git a/saleor/static/dashboard/js/components/google-preview.js b/saleor/static/dashboard/js/components/google-preview.js
index a30e478790..a551786f48 100644
--- a/saleor/static/dashboard/js/components/google-preview.js
+++ b/saleor/static/dashboard/js/components/google-preview.js
@@ -29,19 +29,14 @@ function checkForErrors() {
$preview.hide();
$previewErrors.text(gettext('Please provide title and description to see how this product might appear in search engine results.'));
$previewErrors.show();
-
- // title and descriptions missing
} else if (!$descriptionText) {
$preview.hide();
- $previewErrors.show();
$previewErrors.text(gettext('Please provide description to see how this product might appear in search engine results.'));
-
- // description missing
+ $previewErrors.show();
} else if (!$titleText) {
- // title missing
$preview.hide();
- $previewErrors.show();
$previewErrors.text(gettext('Please provide title to see how this product might appear in search engine results.'));
+ $previewErrors.show();
}
}
@@ -80,6 +75,7 @@ function updatePreviewOnInput(seoField, previewField) {
checkForErrors();
});
}
+
checkForErrors();
updatePlaceholderOnInput($name, $seoTitle, $googleTitlePreview);
updatePlaceholderOnInput($description, $seoDescription, $googleDescriptionPreview);