diff --git a/frontend/vue/components/Stations/Podcasts/EpisodeEditModal.vue b/frontend/vue/components/Stations/Podcasts/EpisodeEditModal.vue index 398ee971b..bba11e95f 100644 --- a/frontend/vue/components/Stations/Podcasts/EpisodeEditModal.vue +++ b/frontend/vue/components/Stations/Podcasts/EpisodeEditModal.vue @@ -1,10 +1,10 @@ - diff --git a/frontend/vue/components/Stations/Podcasts/PodcastEditModal.vue b/frontend/vue/components/Stations/Podcasts/PodcastEditModal.vue index 180b77893..9d56b065d 100644 --- a/frontend/vue/components/Stations/Podcasts/PodcastEditModal.vue +++ b/frontend/vue/components/Stations/Podcasts/PodcastEditModal.vue @@ -1,10 +1,10 @@ - diff --git a/frontend/vue/components/Stations/SftpUsers/EditModal.vue b/frontend/vue/components/Stations/SftpUsers/EditModal.vue index 62511f1ed..31b74169e 100644 --- a/frontend/vue/components/Stations/SftpUsers/EditModal.vue +++ b/frontend/vue/components/Stations/SftpUsers/EditModal.vue @@ -45,11 +45,13 @@ const { props, emit, $modal, - { - username: {required}, - password: isEditMode.value ? {} : {required}, - publicKeys: {} - }, + (formIsEditMode) => computed(() => { + return { + username: {required}, + password: formIsEditMode.value ? {} : {required}, + publicKeys: {} + } + }), { username: '', password: null, diff --git a/frontend/vue/components/Stations/Streamers/EditModal.vue b/frontend/vue/components/Stations/Streamers/EditModal.vue index 424058a95..c72b0ec0d 100644 --- a/frontend/vue/components/Stations/Streamers/EditModal.vue +++ b/frontend/vue/components/Stations/Streamers/EditModal.vue @@ -1,10 +1,10 @@ - diff --git a/frontend/vue/functions/useBaseEditModal.js b/frontend/vue/functions/useBaseEditModal.js index 3868b64d2..176cae3d6 100644 --- a/frontend/vue/functions/useBaseEditModal.js +++ b/frontend/vue/functions/useBaseEditModal.js @@ -15,11 +15,12 @@ export function useBaseEditModal( props, emit, $modal, - validations, - blankForm, + originalValidations, + originalBlankForm, userOptions = {} ) { const options = { + resetForm: null, clearContents: null, populateForm: null, getSubmittableFormData: null, @@ -39,11 +40,27 @@ export function useBaseEditModal( return editUrl.value !== null; }); - const {form, v$, resetForm, ifValid} = useVuelidateOnForm(validations, blankForm); + const validations = (typeof originalValidations === 'function') + ? originalValidations(isEditMode) + : originalValidations; + + const blankForm = (typeof originalBlankForm === 'function') + ? originalBlankForm(isEditMode) + : originalBlankForm; + + const {form, v$, resetForm: originalResetForm, ifValid} = useVuelidateOnForm(validations, blankForm); + + const resetForm = () => { + if (typeof options.resetForm === 'function') { + return options.resetForm(originalResetForm); + } + + originalResetForm(); + }; const clearContents = () => { if (typeof options.clearContents === 'function') { - return options.clearContents(); + return options.clearContents(resetForm); } resetForm();