1
0
Fork 0
mirror of synced 2024-10-04 03:54:37 +13:00

PR comments.

This commit is contained in:
mike12345567 2023-10-13 10:22:29 +01:00
parent 2e8e21e5d2
commit d3366a535b
2 changed files with 12 additions and 10 deletions

View file

@ -50,11 +50,15 @@ export const isSupportedUserSearch = (query: SearchQuery) => {
return false
}
const fields = Object.keys(operation || {})
// this filter doesn't contain options - ignore
if (fields.length === 0) {
continue
}
const allowedOperation = allowed.find(
allow =>
allow.op === key && fields.length === 1 && fields[0] === allow.key
)
if (!allowedOperation && fields.length > 0) {
if (!allowedOperation) {
return false
}
}

View file

@ -25,7 +25,6 @@
let tableDefinition
let searchTerm
let open
let fetchedDefault
$: type =
datasourceType === "table" ? FieldTypes.LINK : FieldTypes.BB_REFERENCE
@ -76,8 +75,8 @@
}
}
$: enrichedOptions = enrichOptions(optionsObj, $fetch.rows, fetchedDefault)
const enrichOptions = (optionsObj, fetchResults, fetchedDefault) => {
$: enrichedOptions = enrichOptions(optionsObj, $fetch.rows)
const enrichOptions = (optionsObj, fetchResults) => {
const result = (fetchResults || [])?.reduce((accumulator, row) => {
if (!accumulator[row._id]) {
accumulator[row._id] = row
@ -85,11 +84,7 @@
return accumulator
}, optionsObj)
const final = Object.values(result)
if (fetchedDefault && !final.find(row => row._id === fetchedDefault._id)) {
final.push(fetchedDefault)
}
return final
return Object.values(result)
}
$: {
// We don't want to reorder while the dropdown is open, to avoid UX jumps
@ -125,7 +120,10 @@
await fetch.update({
query: { equal: { _id: defaultValue } },
})
fetchedDefault = $fetch.rows?.[0]
const defaultRow = $fetch.rows?.[0]
if (defaultRow) {
optionsObj[defaultRow._id] = defaultRow
}
}
await fetch.update({
query: { string: { [primaryDisplay]: searchTerm } },