Skip to content

Commit

Permalink
Merge pull request #1543 from bolt/bugfix/slugs-follow-localize-setting
Browse files Browse the repository at this point in the history
Slugs follow localize setting
  • Loading branch information
bobdenotter authored Jun 24, 2020
2 parents 0fd1b28 + 0182db2 commit 682b61e
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 2 deletions.
7 changes: 6 additions & 1 deletion assets/js/app/editor/Components/Slug.vue
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,8 @@ export default {
readonly: Boolean,
errormessage: String | Boolean, //string if errormessage is set, and false otherwise
pattern: String | Boolean,
localize: Boolean,
isNew: Boolean,
},
data() {
return {
Expand All @@ -83,7 +85,7 @@ export default {
title +
document.querySelector(`input[name='fields[${element}]']`).value;
});
if (title.length <= 0) {
if (this.shouldGenerateFromTitle(title)) {
this.icon = 'unlock';
this.buttonText = this.$props.labels.button_unlocked;
this.$root.$emit('generate-from-title', true);
Expand All @@ -92,6 +94,9 @@ export default {
this.$root.$on('slugify-from-title', () => this.generateSlug());
},
methods: {
shouldGenerateFromTitle(title) {
return this.isNew ? true : title.length <= 0 && this.localize;
},
editSlug() {
this.$root.$emit('generate-from-title', false);
this.edit = true;
Expand Down
2 changes: 1 addition & 1 deletion assets/js/app/toolbar/Components/Toolbar.vue
Original file line number Diff line number Diff line change
Expand Up @@ -42,11 +42,11 @@
class="toolbar-item toolbar-item__filter input-group"
>
<input
id="global-search"
type="text"
class="form-control"
:placeholder="labels['listing.placeholder_search']"
name="filter"
id="global-search"
:value="filterValue"
/>
<div class="input-group-append">
Expand Down
2 changes: 2 additions & 0 deletions templates/_partials/fields/slug.html.twig
Original file line number Diff line number Diff line change
Expand Up @@ -18,5 +18,7 @@
'button_edit': 'slug.button_edit'|trans,
'generate_from': 'slug.generate_from'|trans,
}|json_encode }}'
:localize='{{ field.definition.localize|json_encode }}'
:is-new='{{ field.new|json_encode }}'
></editor-slug>
{% endblock %}

0 comments on commit 682b61e

Please sign in to comment.