diff --git a/README.md b/README.md index c11ec11..6a31099 100644 --- a/README.md +++ b/README.md @@ -25,12 +25,12 @@ Restart directus Simply these options enables/disables the automatic update based on content change. -- Having "Create" will enable automattic updating when creating new item. -- Having "Update" will enable automattic updating when editing existing item. +- Having "On Create" will enable automattic updating when creating new item. +- Having "On Update" will enable automattic updating when editing existing item. It's possible to have both, one or none, depending of your needs. -### There is magick stick appearing +### There is magic wand appearing The magic stick button appears when the automatic updates are disabled, but there is content change so the field is differing from the template. When clicked, the automatic update will be executed. diff --git a/package-lock.json b/package-lock.json index 7ecc32c..f084b14 100644 --- a/package-lock.json +++ b/package-lock.json @@ -14766,7 +14766,7 @@ "directus-codestyle": { "version": "git+ssh://git@github.com/dimitrov-adrian/directus-codestyle.git#31e3c1d415034b3a87c99302f4dbd882afab0ec9", "dev": true, - "from": "directus-codestyle@dimitrov-adrian/directus-codestyle", + "from": "directus-codestyle@github:dimitrov-adrian/directus-codestyle", "requires": { "@typescript-eslint/eslint-plugin": "^5.9.0", "@typescript-eslint/parser": "^5.9.0", diff --git a/src/index.ts b/src/index.ts index c599040..b58cf5c 100644 --- a/src/index.ts +++ b/src/index.ts @@ -83,7 +83,6 @@ export default { meta: { width: 'half', interface: 'select-multiple-checkbox', - default_value: ['create', 'update'], options: { choices: [ { text: '$t:on_create', value: 'create' }, @@ -92,7 +91,7 @@ export default { }, }, schema: { - default_value: '', + default_value: ['create'], }, }, ]; diff --git a/src/slug.vue b/src/slug.vue index 92c1110..cc7cadd 100644 --- a/src/slug.vue +++ b/src/slug.vue @@ -108,7 +108,7 @@ export default defineComponent({ }, update: { type: Array as PropType, - default: () => [], + default: () => ['create'], }, }, emits: ['input'], @@ -132,7 +132,7 @@ export default defineComponent({ if (!(props.primaryKey !== '+' ? props.update.includes('update') : props.update.includes('create'))) return; // Avoid self update. - if (values[props.field] && values[props.field] !== props.value) return; + if (values[props.field] && values[props.field] !== (props.value || '')) return; emitter(values); }); @@ -180,7 +180,7 @@ export default defineComponent({ function emitter(values: Record) { const newValue = transform(render(props.template, values)); - if (newValue === props.value) return; + if (newValue === (props.value || '')) return; emit('input', newValue); }