Saleor Core: the high performance, composable, headless commerce API.
Python cartcheckoutcommercecomposablee-commerceecommercegraphqlheadlessheadless-commercemultichannelomsorder-managementpaymentspimpythonshopshopping-cartstore
Help texts, labels
Pacu2488998063e27
diff --git a/saleor/dashboard/category/forms.py b/saleor/dashboard/category/forms.pyindex a36d786ff8..01683fe9ca 100644--- a/saleor/dashboard/category/forms.py+++ b/saleor/dashboard/category/forms.py@@ -5,6 +5,7 @@ from django.utils.translation import pgettext_lazyfrom text_unidecode import unidecodefrom ...product.models import Category+from ..seo.utils import SEO_HELP_TEXTS, SEO_LABELSclass CategoryForm(forms.ModelForm):@@ -32,7 +33,9 @@ class CategoryForm(forms.ModelForm):'Name'),'description': pgettext_lazy('Description',- 'Description')}+ 'Description'),+ **SEO_LABELS}+ help_texts = SEO_HELP_TEXTSdef save(self, commit=True):self.instance.slug = slugify(unidecode(self.instance.name))diff --git a/saleor/dashboard/collection/forms.py b/saleor/dashboard/collection/forms.pyindex c7f0fba890..d577c55332 100644--- a/saleor/dashboard/collection/forms.py+++ b/saleor/dashboard/collection/forms.py@@ -7,6 +7,7 @@ from text_unidecode import unidecodefrom ...product.models import Collection, Productfrom ..forms import AjaxSelect2MultipleChoiceFieldfrom ..widgets import CharsLeftWidget+from ..seo.utils import SEO_HELP_TEXTS, SEO_LABELSclass CollectionForm(forms.ModelForm):@@ -26,15 +27,12 @@ class CollectionForm(forms.ModelForm):'Products'),'background_image': pgettext_lazy('Products selection',- 'Background Image')}+ 'Background Image'),+ **SEO_LABELS}widgets = {'seo_description': CharsLeftWidget,'seo_title': CharsLeftWidget}- help_texts = {- 'seo_description': pgettext_lazy(- 'Form field help text',- 'Slug is being used to create page URL'),- 'seo_title': 'Example help text'}+ help_texts = SEO_HELP_TEXTSdef __init__(self, *args, **kwargs):super().__init__(*args, **kwargs)@@ -48,8 +46,8 @@ class CollectionForm(forms.ModelForm):self.fields['seo_title'].widget.attrs.update({'id': 'seo_title','data-bind': self['name'].auto_id,- 'placeholder': self.instance.name,- 'min-recommended-length': 40})+ 'placeholder': self.instance.name[:70],+ 'min-recommended-length': 25})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.pyindex 09a8fd25c9..e52a9b5006 100644--- a/saleor/dashboard/page/forms.py+++ b/saleor/dashboard/page/forms.py@@ -4,6 +4,7 @@ from django.utils.translation import pgettext_lazyfrom ...core.utils.text import generate_seo_descriptionfrom ...page.models import Pagefrom ..product.forms import RichTextField+from ..seo.utils import SEO_HELP_TEXTS, SEO_LABELSclass PageForm(forms.ModelForm):@@ -32,11 +33,13 @@ class PageForm(forms.ModelForm):'slug': forms.TextInput(attrs={'placeholder': 'example-slug'})}labels = {'is_visible': pgettext_lazy(- 'Visibility status indicator', 'Publish')}+ 'Visibility status indicator', 'Publish'),+ **SEO_LABELS}help_texts = {'slug': pgettext_lazy('Form field help text',- 'Slug is being used to create page URL')}+ 'Slug is being used to create page URL'),+ **SEO_HELP_TEXTS}content = RichTextField()diff --git a/saleor/dashboard/product/forms.py b/saleor/dashboard/product/forms.pyindex f35a20d9cf..04e2bbe4f8 100644--- a/saleor/dashboard/product/forms.py+++ b/saleor/dashboard/product/forms.py@@ -18,6 +18,7 @@ from ..forms import OrderedModelMultipleChoiceField, ModelChoiceOrCreationFieldfrom ..widgets import RichTextEditorWidgetfrom .widgets import ImagePreviewWidgetfrom . import ProductBulkAction+from ..seo.utils import SEO_HELP_TEXTS, SEO_LABELSclass RichTextField(forms.CharField):@@ -201,7 +202,9 @@ class ProductForm(forms.ModelForm, AttributesMixin):'is_featured': pgettext_lazy('Featured product toggle', 'Feature this product on homepage'),'collections': pgettext_lazy(- 'Add to collection select', 'Collections')}+ 'Add to collection select', 'Collections'),+ **SEO_LABELS}+ help_texts = SEO_HELP_TEXTScategory = TreeNodeChoiceField(queryset=Category.objects.all())collections = forms.ModelMultipleChoiceField(diff --git a/saleor/static/dashboard/js/components/google-preview.js b/saleor/static/dashboard/js/components/google-preview.jsindex de246b5217..3fc786bb79 100644--- a/saleor/static/dashboard/js/components/google-preview.js+++ b/saleor/static/dashboard/js/components/google-preview.js@@ -31,7 +31,7 @@ function updateCharsCount(field) {if ($fieldLength < $minRecommendedLength) {$charCountWrapper.addClass('red-text');$charCountWrapper.removeClass('green-text');- } else if ($charCountWrapper.hasClass('red-text')) {+ } else {$charCountWrapper.removeClass('red-text');$charCountWrapper.addClass('green-text');}diff --git a/templates/materializecssform/field.html b/templates/materializecssform/field.htmlindex b6b5a5354b..bac8d7b657 100644--- a/templates/materializecssform/field.html+++ b/templates/materializecssform/field.html@@ -345,7 +345,7 @@</label><span class="chars-left__count"><span class="chars-left__count__current" data-bind="{{ field.field.widget.attrs.id }}">- {% blocktrans with current_chars_count=field.value|length max_chars_count=field.field.max_length %}+ {% blocktrans with current_chars_count=field.value|length max_chars_count=field.field.max_length context "Message showing how many chars were used out of maximum field's length" %}{{ current_chars_count }}</span> of {{ max_chars_count }} characters used{% endblocktrans %}</span>