From bcaec1c2dec5e5a74c6f495ae2b60d0e21fd3974 Mon Sep 17 00:00:00 2001 From: Tsering Paljor <20007514-paljort@users.noreply.gitlab.com> Date: Mon, 23 Sep 2024 05:07:53 +0000 Subject: [PATCH] Ensure `propertySelectorAvailable()` doesn't throw an error when Data Source isn't selected --- ...afely_check_if_property_selector_is_available.json | 7 +++++++ .../modules/builder/mixins/collectionElementForm.js | 11 +++++------ 2 files changed, 12 insertions(+), 6 deletions(-) create mode 100644 changelog/entries/unreleased/bug/3033_builder_safely_check_if_property_selector_is_available.json diff --git a/changelog/entries/unreleased/bug/3033_builder_safely_check_if_property_selector_is_available.json b/changelog/entries/unreleased/bug/3033_builder_safely_check_if_property_selector_is_available.json new file mode 100644 index 000000000..c4807d221 --- /dev/null +++ b/changelog/entries/unreleased/bug/3033_builder_safely_check_if_property_selector_is_available.json @@ -0,0 +1,7 @@ +{ + "type": "bug", + "message": "[Builder] Safely check if property selector is available.", + "issue_number": 3033, + "bullet_points": [], + "created_at": "2024-09-20" +} \ No newline at end of file diff --git a/web-frontend/modules/builder/mixins/collectionElementForm.js b/web-frontend/modules/builder/mixins/collectionElementForm.js index 0d34f5ac9..6e5106428 100644 --- a/web-frontend/modules/builder/mixins/collectionElementForm.js +++ b/web-frontend/modules/builder/mixins/collectionElementForm.js @@ -49,7 +49,7 @@ export default { * @returns {boolean} - Whether the paging options are available. */ pagingOptionsAvailable() { - return this.selectedDataSourceType?.returnsList + return this.selectedDataSourceReturnsList }, /** * In collection element forms, the ability to choose a data source @@ -76,10 +76,7 @@ export default { if (!this.hasCollectionAncestor) { // If we don't have a data source, or // We do, and it returns a list, then the schema selector isn't available. - if ( - !this.selectedDataSource || - this.selectedDataSourceType.returnsList - ) { + if (!this.selectedDataSource || this.selectedDataSourceReturnsList) { return false } } @@ -90,7 +87,9 @@ export default { * @returns {Array} - The data sources the page designer can choose from. */ dataSources() { - return this.$store.getters['dataSource/getPageDataSources'](this.page) + return this.$store.getters['dataSource/getPageDataSources']( + this.page + ).filter((dataSource) => dataSource.type) }, selectedDataSource() { if (!this.values.data_source_id) {