Skip to content

Commit

Permalink
Fix interface default settings, fix autoupdate when empty values.
Browse files Browse the repository at this point in the history
  • Loading branch information
dimitrov-adrian committed Jan 16, 2022
1 parent c46c8d4 commit 9d1cc1b
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 9 deletions.
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
2 changes: 1 addition & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 1 addition & 2 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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' },
Expand All @@ -92,7 +91,7 @@ export default {
},
},
schema: {
default_value: '',
default_value: ['create'],
},
},
];
Expand Down
6 changes: 3 additions & 3 deletions src/slug.vue
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ export default defineComponent({
},
update: {
type: Array as PropType<string[]>,
default: () => [],
default: () => ['create'],
},
},
emits: ['input'],
Expand All @@ -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);
});
Expand Down Expand Up @@ -180,7 +180,7 @@ export default defineComponent({
function emitter(values: Record<string, any>) {
const newValue = transform(render(props.template, values));
if (newValue === props.value) return;
if (newValue === (props.value || '')) return;
emit('input', newValue);
}
Expand Down

0 comments on commit 9d1cc1b

Please sign in to comment.