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"
|
$: type = schema?.type ?? "string"
|
||||||
$: customRenderer = customRenderers?.find(x => x.column === schema?.name)
|
$: customRenderer = customRenderers?.find(x => x.column === schema?.name)
|
||||||
$: renderer = customRenderer?.component ?? typeMap[type] ?? StringRenderer
|
$: 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>
|
</script>
|
||||||
|
|
||||||
{#if !customRenderer && isNotSet(value)}
|
{#if renderer && (customRenderer || (value != null && value !== ""))}
|
||||||
<svelte:component this={StringRenderer} value={"Not Set"} secondary={true} />
|
|
||||||
{:else if renderer}
|
|
||||||
<svelte:component this={renderer} {row} {schema} {value} on:clickrelationship>
|
<svelte:component this={renderer} {row} {schema} {value} on:clickrelationship>
|
||||||
<slot />
|
<slot />
|
||||||
</svelte:component>
|
</svelte:component>
|
||||||
|
|
|
@ -1,11 +1,8 @@
|
||||||
<script>
|
<script>
|
||||||
export let value
|
export let value
|
||||||
export let secondary
|
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<div class={secondary ? "secondary" : ""}>
|
<div>{value}</div>
|
||||||
{typeof value === "object" ? JSON.stringify(value) : value}
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<style>
|
<style>
|
||||||
div {
|
div {
|
||||||
|
@ -13,8 +10,4 @@
|
||||||
text-overflow: ellipsis;
|
text-overflow: ellipsis;
|
||||||
width: 150px;
|
width: 150px;
|
||||||
}
|
}
|
||||||
.secondary {
|
|
||||||
font-style: italic;
|
|
||||||
color: var(--grey-5);
|
|
||||||
}
|
|
||||||
</style>
|
</style>
|
||||||
|
|
|
@ -43,12 +43,12 @@
|
||||||
key: "CONTAINS",
|
key: "CONTAINS",
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: "Is Set",
|
name: "Is Not Empty",
|
||||||
key: "SET",
|
key: "NOT_EMPTY",
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: "Is Not Set",
|
name: "Is Empty",
|
||||||
key: "NOT_SET",
|
key: "EMPTY",
|
||||||
},
|
},
|
||||||
]
|
]
|
||||||
|
|
||||||
|
@ -122,7 +122,7 @@
|
||||||
const getOptionValue = x => x.key
|
const getOptionValue = x => x.key
|
||||||
|
|
||||||
const showValue = filter => {
|
const showValue = filter => {
|
||||||
return !(filter.condition === "SET" || filter.condition === "NOT_SET")
|
return !(filter.condition === "EMPTY" || filter.condition === "NOT_EMPTY")
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
|
|
@ -10,14 +10,7 @@ const TOKEN_MAP = {
|
||||||
OR: "||",
|
OR: "||",
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
const isEmptyExpression = key => {
|
||||||
* 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 => {
|
|
||||||
return `(
|
return `(
|
||||||
doc["${key}"] === undefined ||
|
doc["${key}"] === undefined ||
|
||||||
doc["${key}"] === null ||
|
doc["${key}"] === null ||
|
||||||
|
@ -88,10 +81,10 @@ function parseFilterExpression(filters) {
|
||||||
expression.push(
|
expression.push(
|
||||||
`doc["${filter.key}"].${TOKEN_MAP[filter.condition]}("${filter.value}")`
|
`doc["${filter.key}"].${TOKEN_MAP[filter.condition]}("${filter.value}")`
|
||||||
)
|
)
|
||||||
} else if (filter.condition === "NOT_SET") {
|
} else if (filter.condition === "EMPTY") {
|
||||||
expression.push(isNotSetExpression(filter.key))
|
expression.push(isEmptyExpression(filter.key))
|
||||||
} else if (filter.condition === "SET") {
|
} else if (filter.condition === "NOT_EMPTY") {
|
||||||
expression.push(`!${isNotSetExpression(filter.key)}`)
|
expression.push(`!${isEmptyExpression(filter.key)}`)
|
||||||
} else {
|
} else {
|
||||||
const value =
|
const value =
|
||||||
typeof filter.value == "string" ? `"${filter.value}"` : filter.value
|
typeof filter.value == "string" ? `"${filter.value}"` : filter.value
|
||||||
|
|
Loading…
Reference in New Issue