Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[3.x] #1957: Fix keepalive. #2043

Merged
merged 2 commits into from
Jan 10, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions frontend/js/components/BrowserField.vue
Original file line number Diff line number Diff line change
Expand Up @@ -195,6 +195,9 @@
} else {
this.$root.$refs.browser.open(this.endpoints.length <= 0)
}
},
destroyValue: function () {
this.deleteAll()
}
},
watch: {
Expand Down
28 changes: 27 additions & 1 deletion frontend/js/components/ConnectorField.vue
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<template>
<div>
<template v-if="!keepAlive">
<div v-if="open">
<div v-if="open" ref="fieldContainer">
<slot></slot>
</div>
</template>
Expand Down Expand Up @@ -81,6 +81,32 @@
},
methods: {
toggleVisibility: function (value) {

if (this.$refs.fieldContainer) {
this.$slots.default.forEach((child) => {
// Base input fields.
if (
child.componentInstance !== undefined &&
child.componentInstance.$refs &&
child.componentInstance.$refs.field
) {
if (child.componentInstance.$refs.field[0]) {
child.componentInstance.$refs.field[0].destroyValue()
}
}
// Special fields such as browsers.
else if (
child.componentInstance !== undefined
) {
child.componentInstance.$slots.default.forEach((subChild) => {
if (subChild.componentInstance.destroyValue) {
subChild.componentInstance.destroyValue()
}
})
}
})
}

if (this.isBrowser) {
const browserLength = (value && value.length) ?? 0
if (this.matchEmptyBrowser && (browserLength === 0)) {
Expand Down
2 changes: 2 additions & 0 deletions frontend/js/components/LocaleField.vue
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
:name="`${attributes.name}[${language.value}]`"
:fieldName="attributes.name"
:locale="language"
ref="field"
@localize="updateLocale"
@change="updateValue(language.value, ...arguments)"
@blur="$emit('blur')"
Expand All @@ -22,6 +23,7 @@
<template v-else>
<component v-bind:is="`${type}`"
:name="attributes.name"
ref="field"
v-bind="attributesNoLang()"
@change="updateValue(false, ...arguments)"
@blur="$emit('blur')"
Expand Down
4 changes: 4 additions & 0 deletions frontend/js/components/MediaField.vue
Original file line number Diff line number Diff line change
Expand Up @@ -523,6 +523,10 @@
metadatasInfos: function () {
this.metadatas.active = !this.metadatas.active
this.metadatas.text = this.metadatas.active ? this.metadatas.textClose : this.metadatas.textOpen
},
destroyValue: function () {
if (this.isSlide) return // for Slideshows : the medias are deleted when the slideshow component is destroyed (so no need to do it here)
if (!this.isDestroyed) this.deleteMedia()
}
},
beforeMount: function () {
Expand Down
4 changes: 4 additions & 0 deletions frontend/js/components/Slideshow.vue
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,10 @@
deleteSlideshow: function () {
// destroy all the medias of the slideshow
this.$store.commit(MEDIA_LIBRARY.DESTROY_MEDIAS, this.name)
},
destroyValue: function () {
if (this.isSlide) return // for Slideshows : the medias are deleted when the slideshow component is destroyed (so no need to do it here)
if (!this.isDestroyed) this.deleteMedia()
}
}
}
Expand Down
3 changes: 3 additions & 0 deletions frontend/js/components/files/FileField.vue
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,9 @@
name: this.name,
index: index
})
},
destroyValue: function () {
this.deleteAll()
}
}
}
Expand Down
7 changes: 7 additions & 0 deletions frontend/js/mixins/formStore.js
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,13 @@ export default {
},
allowSubmit: function () {
this.$store.commit(FORM.ALLOW_SUBMIT)
},
destroyValue: function () {
if (this.inStore !== '') {
// Delete form field from store because the field has been removed
if (this.inModal) this.$store.commit(FORM.REMOVE_MODAL_FIELD, this.getFieldName())
else this.$store.commit(FORM.REMOVE_FORM_FIELD, this.getFieldName())
}
}
},
beforeMount: function () {
Expand Down