Merge pull request #15430 from Budibase/chore/fix-datasource-picker-selected
Fix datasource picker selected option
This commit is contained in:
commit
012bb4e1cc
|
@ -7,8 +7,21 @@
|
||||||
export let dataSet
|
export let dataSet
|
||||||
export let value
|
export let value
|
||||||
export let onSelect
|
export let onSelect
|
||||||
|
export let identifiers = ["resourceId"]
|
||||||
|
|
||||||
$: displayDatasourceName = $datasources.list.length > 1
|
$: 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>
|
</script>
|
||||||
|
|
||||||
{#if dividerState}
|
{#if dividerState}
|
||||||
|
@ -24,8 +37,7 @@
|
||||||
{#each dataSet as data}
|
{#each dataSet as data}
|
||||||
<li
|
<li
|
||||||
class="spectrum-Menu-item"
|
class="spectrum-Menu-item"
|
||||||
class:is-selected={value?.resourceId === data.resourceId &&
|
class:is-selected={isSelected(data) && value?.type === data.type}
|
||||||
value?.type === data.type}
|
|
||||||
role="option"
|
role="option"
|
||||||
aria-selected="true"
|
aria-selected="true"
|
||||||
tabindex="0"
|
tabindex="0"
|
||||||
|
|
|
@ -291,6 +291,7 @@
|
||||||
dataSet={views}
|
dataSet={views}
|
||||||
{value}
|
{value}
|
||||||
onSelect={handleSelected}
|
onSelect={handleSelected}
|
||||||
|
identifiers={["tableId", "name"]}
|
||||||
/>
|
/>
|
||||||
{/if}
|
{/if}
|
||||||
{#if queries?.length}
|
{#if queries?.length}
|
||||||
|
@ -300,6 +301,7 @@
|
||||||
dataSet={queries}
|
dataSet={queries}
|
||||||
{value}
|
{value}
|
||||||
onSelect={handleSelected}
|
onSelect={handleSelected}
|
||||||
|
identifiers={["_id"]}
|
||||||
/>
|
/>
|
||||||
{/if}
|
{/if}
|
||||||
{#if links?.length}
|
{#if links?.length}
|
||||||
|
@ -309,6 +311,7 @@
|
||||||
dataSet={links}
|
dataSet={links}
|
||||||
{value}
|
{value}
|
||||||
onSelect={handleSelected}
|
onSelect={handleSelected}
|
||||||
|
identifiers={["tableId", "fieldName"]}
|
||||||
/>
|
/>
|
||||||
{/if}
|
{/if}
|
||||||
{#if fields?.length}
|
{#if fields?.length}
|
||||||
|
@ -318,6 +321,7 @@
|
||||||
dataSet={fields}
|
dataSet={fields}
|
||||||
{value}
|
{value}
|
||||||
onSelect={handleSelected}
|
onSelect={handleSelected}
|
||||||
|
identifiers={["providerId", "tableId", "fieldName"]}
|
||||||
/>
|
/>
|
||||||
{/if}
|
{/if}
|
||||||
{#if jsonArrays?.length}
|
{#if jsonArrays?.length}
|
||||||
|
@ -327,6 +331,7 @@
|
||||||
dataSet={jsonArrays}
|
dataSet={jsonArrays}
|
||||||
{value}
|
{value}
|
||||||
onSelect={handleSelected}
|
onSelect={handleSelected}
|
||||||
|
identifiers={["providerId", "tableId", "fieldName"]}
|
||||||
/>
|
/>
|
||||||
{/if}
|
{/if}
|
||||||
{#if showDataProviders && dataProviders?.length}
|
{#if showDataProviders && dataProviders?.length}
|
||||||
|
@ -336,6 +341,7 @@
|
||||||
dataSet={dataProviders}
|
dataSet={dataProviders}
|
||||||
{value}
|
{value}
|
||||||
onSelect={handleSelected}
|
onSelect={handleSelected}
|
||||||
|
identifiers={["providerId"]}
|
||||||
/>
|
/>
|
||||||
{/if}
|
{/if}
|
||||||
<DataSourceCategory
|
<DataSourceCategory
|
||||||
|
|
Loading…
Reference in New Issue