Skip to content

Commit

Permalink
Fixes #17 - Better check for edite mode
Browse files Browse the repository at this point in the history
  • Loading branch information
benjaminhirsch committed Apr 27, 2019
1 parent 1d1a3b6 commit 4c5cee9
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 6 deletions.
2 changes: 1 addition & 1 deletion dist/js/field.js

Large diffs are not rendered by default.

5 changes: 3 additions & 2 deletions resources/js/components/Slug/FormField.vue
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,10 @@ export default {
*/
mounted() {
Nova.$on('field-update-' + this.field.attribute, ({value}) => {
if (this.field.disableAutoUpdateWhenUpdating === false) {
this.value = slugify(value, this.field.slugifyOptions || {});
if (this.field.disableAutoUpdateWhenUpdating === true && this.$router.currentRoute.name !== 'create') {
return;
}
this.value = slugify(value, this.field.slugifyOptions || {});
})
},
Expand Down
4 changes: 1 addition & 3 deletions src/Slug.php
Original file line number Diff line number Diff line change
Expand Up @@ -57,9 +57,7 @@ public function slugifyOptions(array $options): Element
*/
public function disableAutoUpdateWhenUpdating(): Element
{
if (request()->get('editMode') !== 'create') {
$this->disableAutoUpdateWhenUpdating = true;
}
$this->disableAutoUpdateWhenUpdating = true;
return $this;
}

Expand Down

0 comments on commit 4c5cee9

Please sign in to comment.