directus-extension-api-trigger-interface icon indicating copy to clipboard operation
directus-extension-api-trigger-interface copied to clipboard

navigate the browser to the collection list page

Open xu4wang opened this issue 2 years ago • 6 comments

Hi , Thanks for the wonderful extension. we are exploring to use it heavily for our business logic implementaiton.

One question, Instead of reload the page after the API call, are we able to navigate the browser to the collection list page inside the onClick function?

I tried modify the reload logic

router.go(0);

into:

router.push('/content/collection1');

However, directus APP will ask the user to confirm leave for the unsaved changes. Actually the changes was already saved inside the API call, is it possible to navigate silently without user confirmation?

xu4wang avatar May 07 '23 04:05 xu4wang

It's possible if you can modify the source code of Directus, edit this line to:

useEditsGuard(hasEdits, { ignorePrefix: '/content/collection1' });

It will bypass the confirm dialog if the path to go to starts with this string.

This is the only solution I can think of. I hope this can help you.

duydvu avatar May 08 '23 03:05 duydvu

It's possible if you can modify the source code of Directus, edit this line to:

useEditsGuard(hasEdits, { ignorePrefix: '/content/collection1' });

It will bypass the confirm dialog if the path to go to starts with this string.

This is the only solution I can think of. I hope this can help you.

Thanks for the workaround. I don't want to touch Directus source code.

Is it possible to change every field into it's original value? Or issue a save command inside the OnClick?

xu4wang avatar May 08 '23 08:05 xu4wang

Ah, yes. You can use emit('setFieldValue', { field, value }); to set all fields to their original value. After that, there will be no change that needs to be saved.

duydvu avatar May 08 '23 09:05 duydvu

Yes. I tried with no luck.

So strange, I set all of them to initial value, I even set all of them to undefined... but still Directus APP thinks there are changes.

xu4wang avatar May 08 '23 10:05 xu4wang

Do you have any m2o, o2m, m2m, json field? Because even if you set them to their initial values, Directus still considers them as different values if they do not contain reference to the same object.

duydvu avatar May 08 '23 11:05 duydvu

I see. Yes there is m2o field. Thanks for the clarification.

xu4wang avatar May 08 '23 12:05 xu4wang