Feedback: Rename set/not set to not empty/empty, remove cell rendering
This commit is contained in:
parent
d915400c0a
commit
99b42c7083
|
@ -28,27 +28,9 @@
|
|||
$: type = schema?.type ?? "string"
|
||||
$: customRenderer = customRenderers?.find(x => x.column === schema?.name)
|
||||
$: renderer = customRenderer?.component ?? typeMap[type] ?? StringRenderer
|
||||
|
||||
/**
|
||||
* Don't use falsy here as we want to:
|
||||
* - include empty arrays
|
||||
* - exclude 0 and booleans
|
||||
*
|
||||
* If updated, the corresponding view expression should be updated in 'server/viewBuilder.js'
|
||||
*/
|
||||
const isNotSet = value => {
|
||||
return (
|
||||
value === undefined ||
|
||||
value === null ||
|
||||
value === "" ||
|
||||
(Array.isArray(value) && value.length === 0)
|
||||
)
|
||||
}
|
||||
</script>
|
||||
|
||||
{#if !customRenderer && isNotSet(value)}
|
||||
<svelte:component this={StringRenderer} value={"Not Set"} secondary={true} />
|
||||
{:else if renderer}
|
||||
{#if renderer && (customRenderer || (value != null && value !== ""))}
|
||||
<svelte:component this={renderer} {row} {schema} {value} on:clickrelationship>
|
||||
<slot />
|
||||
</svelte:component>
|
||||
|
|
|
@ -1,11 +1,8 @@
|
|||
<script>
|
||||
export let value
|
||||
export let secondary
|
||||
</script>
|
||||
|
||||
<div class={secondary ? "secondary" : ""}>
|
||||
{typeof value === "object" ? JSON.stringify(value) : value}
|
||||
</div>
|
||||
<div>{value}</div>
|
||||
|
||||
<style>
|
||||
div {
|
||||
|
@ -13,8 +10,4 @@
|
|||
text-overflow: ellipsis;
|
||||
width: 150px;
|
||||
}
|
||||
.secondary {
|
||||
font-style: italic;
|
||||
color: var(--grey-5);
|
||||
}
|
||||
</style>
|
||||
|
|
|
@ -43,12 +43,12 @@
|
|||
key: "CONTAINS",
|
||||
},
|
||||
{
|
||||
name: "Is Set",
|
||||
key: "SET",
|
||||
name: "Is Not Empty",
|
||||
key: "NOT_EMPTY",
|
||||
},
|
||||
{
|
||||
name: "Is Not Set",
|
||||
key: "NOT_SET",
|
||||
name: "Is Empty",
|
||||
key: "EMPTY",
|
||||
},
|
||||
]
|
||||
|
||||
|
@ -122,7 +122,7 @@
|
|||
const getOptionValue = x => x.key
|
||||
|
||||
const showValue = filter => {
|
||||
return !(filter.condition === "SET" || filter.condition === "NOT_SET")
|
||||
return !(filter.condition === "EMPTY" || filter.condition === "NOT_EMPTY")
|
||||
}
|
||||
</script>
|
||||
|
||||
|
|
|
@ -10,14 +10,7 @@ const TOKEN_MAP = {
|
|||
OR: "||",
|
||||
}
|
||||
|
||||
/**
|
||||
* Don't use falsy here as we want to:
|
||||
* - include empty arrays
|
||||
* - exclude 0 and booleans
|
||||
*
|
||||
* If updated, the corresponding rendering condition should be updated in 'bbui/CellRenderer.svelte'
|
||||
*/
|
||||
const isNotSetExpression = key => {
|
||||
const isEmptyExpression = key => {
|
||||
return `(
|
||||
doc["${key}"] === undefined ||
|
||||
doc["${key}"] === null ||
|
||||
|
@ -88,10 +81,10 @@ function parseFilterExpression(filters) {
|
|||
expression.push(
|
||||
`doc["${filter.key}"].${TOKEN_MAP[filter.condition]}("${filter.value}")`
|
||||
)
|
||||
} else if (filter.condition === "NOT_SET") {
|
||||
expression.push(isNotSetExpression(filter.key))
|
||||
} else if (filter.condition === "SET") {
|
||||
expression.push(`!${isNotSetExpression(filter.key)}`)
|
||||
} else if (filter.condition === "EMPTY") {
|
||||
expression.push(isEmptyExpression(filter.key))
|
||||
} else if (filter.condition === "NOT_EMPTY") {
|
||||
expression.push(`!${isEmptyExpression(filter.key)}`)
|
||||
} else {
|
||||
const value =
|
||||
typeof filter.value == "string" ? `"${filter.value}"` : filter.value
|
||||
|
|
Loading…
Reference in New Issue