mirror of
https://github.com/baserow/baserow.git
synced 2026-12-04 08:18:42 +00:00
* feat: add an Enterprise static HTML element to the Application Builder * fix: validate widget markup across imports and browser rendering * test: refresh the E2E database fixture for the HTML element * fix: follow browser rules for duplicate attributes and URL lists * feat: show the embed preview hint on custom HTML elements * docs: explain how to add widget scripts in the HTML element form * chore: align HTML element changelog with repository conventions * feat(builder): render HTML in a sandboxed editor preview * fix(builder): remove excess HTML editor preview spacing * fix(builder): match empty HTML and iframe styling * fix(builder): flag empty HTML element sources * docs(builder): generalize HTML source helper text * docs(builder): clarify HTML helper script options * docs(builder): keep external script helper vendor neutral * feat(builder): validate HTML source immediately in the editor * refactor(builder): simplify HTML element as trusted custom code * docs(builder): shorten HTML source helper * feat(builder): support formulas in the HTML element * style(builder): format the HTML element migration * Tweak the FormulaField migration. Add a placeholder to the formula field in the frontend. * Bump the HTMLElement migration IDs. * fix(ci): align E2E fixture with renumbered HTML migration --------- Co-authored-by: peter_baserow <peter@baserow.io>
102 lines
2.7 KiB
JavaScript
102 lines
2.7 KiB
JavaScript
import { mapActions, mapGetters } from 'vuex'
|
|
import _ from 'lodash'
|
|
|
|
import { clone } from '@baserow/modules/core/utils/object'
|
|
import { notifyIf } from '@baserow/modules/core/utils/error'
|
|
import { DATA_PROVIDERS_ALLOWED_ELEMENTS } from '@baserow/modules/builder/enums'
|
|
|
|
export default {
|
|
inject: ['workspace', 'builder', 'applicationContext'],
|
|
provide() {
|
|
return {
|
|
applicationContext: {
|
|
...this.applicationContext,
|
|
element: this.element,
|
|
page: this.elementPage,
|
|
},
|
|
// We add the current element page
|
|
elementPage: this.elementPage,
|
|
dataProvidersAllowed: DATA_PROVIDERS_ALLOWED_ELEMENTS,
|
|
}
|
|
},
|
|
computed: {
|
|
...mapGetters({
|
|
getElementSelected: 'element/getSelected',
|
|
}),
|
|
element() {
|
|
return this.getElementSelected(this.builder)
|
|
},
|
|
elementType() {
|
|
if (this.element) {
|
|
return this.$registry.get('element', this.element.type)
|
|
}
|
|
return null
|
|
},
|
|
|
|
parentElement() {
|
|
return this.$store.getters['element/getParent'](
|
|
this.elementPage,
|
|
this.element
|
|
)
|
|
},
|
|
|
|
elementPage() {
|
|
// We use the page from the element itself
|
|
if (!this.element) return null
|
|
return this.$store.getters['page/getById'](
|
|
this.builder,
|
|
this.element.page_id
|
|
)
|
|
},
|
|
|
|
defaultValues() {
|
|
return this.element
|
|
},
|
|
},
|
|
methods: {
|
|
...mapActions({
|
|
actionDebouncedUpdateElement: 'element/debouncedUpdate',
|
|
}),
|
|
async onChange(newValues) {
|
|
if (
|
|
!this.$hasPermission(
|
|
'builder.page.element.update',
|
|
this.element,
|
|
this.workspace.id
|
|
) ||
|
|
(this.$refs.panelForm && !this.$refs.panelForm?.isFormValid(true))
|
|
) {
|
|
return
|
|
}
|
|
|
|
const differences = Object.fromEntries(
|
|
Object.entries(newValues).filter(
|
|
([key, value]) => !_.isEqual(value, this.element[key])
|
|
)
|
|
)
|
|
|
|
// The `place_in_container` property is not meant to be changed here.
|
|
// In the event that we've detected a difference here, remove it.
|
|
delete differences.place_in_container
|
|
|
|
if (Object.keys(differences).length > 0) {
|
|
const form = this.$refs.panelForm
|
|
try {
|
|
await this.actionDebouncedUpdateElement({
|
|
builder: this.builder,
|
|
page: this.elementPage,
|
|
element: this.element,
|
|
// Here we clone the values to prevent
|
|
// "modification outside of the store" error
|
|
values: clone(differences),
|
|
})
|
|
} catch (error) {
|
|
// Restore the previous saved values from the store
|
|
if (form === this.$refs.panelForm) form?.reset(true)
|
|
notifyIf(error)
|
|
}
|
|
}
|
|
},
|
|
},
|
|
}
|