PR comments.
This commit is contained in:
parent
2e8e21e5d2
commit
d3366a535b
|
@ -50,11 +50,15 @@ export const isSupportedUserSearch = (query: SearchQuery) => {
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
const fields = Object.keys(operation || {})
|
const fields = Object.keys(operation || {})
|
||||||
|
// this filter doesn't contain options - ignore
|
||||||
|
if (fields.length === 0) {
|
||||||
|
continue
|
||||||
|
}
|
||||||
const allowedOperation = allowed.find(
|
const allowedOperation = allowed.find(
|
||||||
allow =>
|
allow =>
|
||||||
allow.op === key && fields.length === 1 && fields[0] === allow.key
|
allow.op === key && fields.length === 1 && fields[0] === allow.key
|
||||||
)
|
)
|
||||||
if (!allowedOperation && fields.length > 0) {
|
if (!allowedOperation) {
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -25,7 +25,6 @@
|
||||||
let tableDefinition
|
let tableDefinition
|
||||||
let searchTerm
|
let searchTerm
|
||||||
let open
|
let open
|
||||||
let fetchedDefault
|
|
||||||
|
|
||||||
$: type =
|
$: type =
|
||||||
datasourceType === "table" ? FieldTypes.LINK : FieldTypes.BB_REFERENCE
|
datasourceType === "table" ? FieldTypes.LINK : FieldTypes.BB_REFERENCE
|
||||||
|
@ -76,8 +75,8 @@
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$: enrichedOptions = enrichOptions(optionsObj, $fetch.rows, fetchedDefault)
|
$: enrichedOptions = enrichOptions(optionsObj, $fetch.rows)
|
||||||
const enrichOptions = (optionsObj, fetchResults, fetchedDefault) => {
|
const enrichOptions = (optionsObj, fetchResults) => {
|
||||||
const result = (fetchResults || [])?.reduce((accumulator, row) => {
|
const result = (fetchResults || [])?.reduce((accumulator, row) => {
|
||||||
if (!accumulator[row._id]) {
|
if (!accumulator[row._id]) {
|
||||||
accumulator[row._id] = row
|
accumulator[row._id] = row
|
||||||
|
@ -85,11 +84,7 @@
|
||||||
return accumulator
|
return accumulator
|
||||||
}, optionsObj)
|
}, optionsObj)
|
||||||
|
|
||||||
const final = Object.values(result)
|
return Object.values(result)
|
||||||
if (fetchedDefault && !final.find(row => row._id === fetchedDefault._id)) {
|
|
||||||
final.push(fetchedDefault)
|
|
||||||
}
|
|
||||||
return final
|
|
||||||
}
|
}
|
||||||
$: {
|
$: {
|
||||||
// We don't want to reorder while the dropdown is open, to avoid UX jumps
|
// We don't want to reorder while the dropdown is open, to avoid UX jumps
|
||||||
|
@ -125,7 +120,10 @@
|
||||||
await fetch.update({
|
await fetch.update({
|
||||||
query: { equal: { _id: defaultValue } },
|
query: { equal: { _id: defaultValue } },
|
||||||
})
|
})
|
||||||
fetchedDefault = $fetch.rows?.[0]
|
const defaultRow = $fetch.rows?.[0]
|
||||||
|
if (defaultRow) {
|
||||||
|
optionsObj[defaultRow._id] = defaultRow
|
||||||
|
}
|
||||||
}
|
}
|
||||||
await fetch.update({
|
await fetch.update({
|
||||||
query: { string: { [primaryDisplay]: searchTerm } },
|
query: { string: { [primaryDisplay]: searchTerm } },
|
||||||
|
|
Loading…
Reference in New Issue