Fixes for exported data UI. Filtered out unnecessary onEmptyFilter filter.
This commit is contained in:
parent
ce6de27714
commit
561778cf6a
1 changed files with 17 additions and 11 deletions
|
@ -17,6 +17,8 @@
|
||||||
export let selectedRows = []
|
export let selectedRows = []
|
||||||
export let formats
|
export let formats
|
||||||
|
|
||||||
|
$: appliedFilters = filters?.filter(filter => !filter.onEmptyFilter)
|
||||||
|
|
||||||
const FORMATS = [
|
const FORMATS = [
|
||||||
{
|
{
|
||||||
name: "CSV",
|
name: "CSV",
|
||||||
|
@ -46,8 +48,12 @@
|
||||||
exportFormat = Array.isArray(options) ? options[0]?.key : []
|
exportFormat = Array.isArray(options) ? options[0]?.key : []
|
||||||
}
|
}
|
||||||
|
|
||||||
$: luceneFilter = LuceneUtils.buildLuceneQuery(filters)
|
$: luceneFilter = LuceneUtils.buildLuceneQuery(appliedFilters)
|
||||||
$: exportOpDisplay = buildExportOpDisplay(sorting, filterDisplay, filters)
|
$: exportOpDisplay = buildExportOpDisplay(
|
||||||
|
sorting,
|
||||||
|
filterDisplay,
|
||||||
|
appliedFilters
|
||||||
|
)
|
||||||
|
|
||||||
const buildFilterLookup = () => {
|
const buildFilterLookup = () => {
|
||||||
return Object.keys(Constants.OperatorOptions).reduce((acc, key) => {
|
return Object.keys(Constants.OperatorOptions).reduce((acc, key) => {
|
||||||
|
@ -59,10 +65,10 @@
|
||||||
filterLookup = buildFilterLookup()
|
filterLookup = buildFilterLookup()
|
||||||
|
|
||||||
const filterDisplay = () => {
|
const filterDisplay = () => {
|
||||||
if (!filters) {
|
if (!appliedFilters) {
|
||||||
return []
|
return []
|
||||||
}
|
}
|
||||||
return filters.map(filter => {
|
return appliedFilters.map(filter => {
|
||||||
let newFieldName = filter.field + ""
|
let newFieldName = filter.field + ""
|
||||||
const parts = newFieldName.split(":")
|
const parts = newFieldName.split(":")
|
||||||
parts.shift()
|
parts.shift()
|
||||||
|
@ -77,7 +83,7 @@
|
||||||
|
|
||||||
const buildExportOpDisplay = (sorting, filterDisplay) => {
|
const buildExportOpDisplay = (sorting, filterDisplay) => {
|
||||||
let filterDisplayConfig = filterDisplay()
|
let filterDisplayConfig = filterDisplay()
|
||||||
if (sorting) {
|
if (sorting?.sortColumn) {
|
||||||
filterDisplayConfig = [
|
filterDisplayConfig = [
|
||||||
...filterDisplayConfig,
|
...filterDisplayConfig,
|
||||||
{
|
{
|
||||||
|
@ -132,7 +138,7 @@
|
||||||
format: exportFormat,
|
format: exportFormat,
|
||||||
})
|
})
|
||||||
downloadWithBlob(data, `export.${exportFormat}`)
|
downloadWithBlob(data, `export.${exportFormat}`)
|
||||||
} else if (filters || sorting) {
|
} else if (appliedFilters || sorting) {
|
||||||
let response
|
let response
|
||||||
try {
|
try {
|
||||||
response = await API.exportRows({
|
response = await API.exportRows({
|
||||||
|
@ -163,16 +169,16 @@
|
||||||
title="Export Data"
|
title="Export Data"
|
||||||
confirmText="Export"
|
confirmText="Export"
|
||||||
onConfirm={exportRows}
|
onConfirm={exportRows}
|
||||||
size={filters?.length || sorting ? "M" : "S"}
|
size={appliedFilters?.length || sorting ? "M" : "S"}
|
||||||
>
|
>
|
||||||
{#if selectedRows?.length}
|
{#if selectedRows?.length}
|
||||||
<Body size="S">
|
<Body size="S">
|
||||||
<strong>{selectedRows?.length}</strong>
|
<strong>{selectedRows?.length}</strong>
|
||||||
{`row${selectedRows?.length > 1 ? "s" : ""} will be exported`}
|
{`row${selectedRows?.length > 1 ? "s" : ""} will be exported`}
|
||||||
</Body>
|
</Body>
|
||||||
{:else if filters || (sorting?.sortOrder && sorting?.sortColumn)}
|
{:else if appliedFilters?.length || (sorting?.sortOrder && sorting?.sortColumn)}
|
||||||
<Body size="S">
|
<Body size="S">
|
||||||
{#if !filters}
|
{#if !appliedFilters}
|
||||||
Exporting <strong>all</strong> rows
|
Exporting <strong>all</strong> rows
|
||||||
{:else}
|
{:else}
|
||||||
Filters applied
|
Filters applied
|
||||||
|
@ -183,9 +189,9 @@
|
||||||
<Table
|
<Table
|
||||||
schema={displaySchema}
|
schema={displaySchema}
|
||||||
data={exportOpDisplay}
|
data={exportOpDisplay}
|
||||||
{filters}
|
{appliedFilters}
|
||||||
loading={false}
|
loading={false}
|
||||||
rowCount={filters?.length + 1}
|
rowCount={appliedFilters?.length + 1}
|
||||||
disableSorting={true}
|
disableSorting={true}
|
||||||
allowSelectRows={false}
|
allowSelectRows={false}
|
||||||
allowEditRows={false}
|
allowEditRows={false}
|
||||||
|
|
Loading…
Reference in a new issue