Merge pull request #15430 from Budibase/chore/fix-datasource-picker-selected

Fix datasource picker selected option
This commit is contained in:
Adria Navarro 2025-01-23 16:10:49 +01:00 committed by GitHub
commit 012bb4e1cc
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 20 additions and 2 deletions

View File

@ -7,8 +7,21 @@
export let dataSet
export let value
export let onSelect
export let identifiers = ["resourceId"]
$: displayDatasourceName = $datasources.list.length > 1
function isSelected(entry) {
if (!identifiers.length) {
return false
}
for (const identifier of identifiers) {
if (entry[identifier] !== value?.[identifier]) {
return false
}
}
return true
}
</script>
{#if dividerState}
@ -24,8 +37,7 @@
{#each dataSet as data}
<li
class="spectrum-Menu-item"
class:is-selected={value?.resourceId === data.resourceId &&
value?.type === data.type}
class:is-selected={isSelected(data) && value?.type === data.type}
role="option"
aria-selected="true"
tabindex="0"

View File

@ -291,6 +291,7 @@
dataSet={views}
{value}
onSelect={handleSelected}
identifiers={["tableId", "name"]}
/>
{/if}
{#if queries?.length}
@ -300,6 +301,7 @@
dataSet={queries}
{value}
onSelect={handleSelected}
identifiers={["_id"]}
/>
{/if}
{#if links?.length}
@ -309,6 +311,7 @@
dataSet={links}
{value}
onSelect={handleSelected}
identifiers={["tableId", "fieldName"]}
/>
{/if}
{#if fields?.length}
@ -318,6 +321,7 @@
dataSet={fields}
{value}
onSelect={handleSelected}
identifiers={["providerId", "tableId", "fieldName"]}
/>
{/if}
{#if jsonArrays?.length}
@ -327,6 +331,7 @@
dataSet={jsonArrays}
{value}
onSelect={handleSelected}
identifiers={["providerId", "tableId", "fieldName"]}
/>
{/if}
{#if showDataProviders && dataProviders?.length}
@ -336,6 +341,7 @@
dataSet={dataProviders}
{value}
onSelect={handleSelected}
identifiers={["providerId"]}
/>
{/if}
<DataSourceCategory