removing soft delete where
This commit is contained in:
parent
01e65b4858
commit
c30dee6181
|
|
@ -1,14 +1,12 @@
|
||||||
import { GFCol, parseGenField } from "lib/gen/utils";
|
import { GFCol, parseGenField } from "lib/gen/utils";
|
||||||
import { getFilter } from "../utils/get-filter";
|
import { getFilter } from "../utils/get-filter";
|
||||||
import { parseSingleFilter } from "./single-filter";
|
import { parseSingleFilter } from "./single-filter";
|
||||||
import { softDeleteFilter } from "./soft-delete-filter";
|
|
||||||
|
|
||||||
export const filterWhere = (filter_name: string, p: any) => {
|
export const filterWhere = (filter_name: string, p: any) => {
|
||||||
const f = getFilter(filter_name);
|
const f = getFilter(filter_name);
|
||||||
let where: any = {};
|
let where: any = {};
|
||||||
if (f) {
|
if (f) {
|
||||||
let fields: GFCol[] = [];
|
let fields: GFCol[] = [];
|
||||||
//
|
|
||||||
if (p.gen__fields) {
|
if (p.gen__fields) {
|
||||||
fields = parseGenField(p.gen__fields);
|
fields = parseGenField(p.gen__fields);
|
||||||
}
|
}
|
||||||
|
|
@ -27,12 +25,5 @@ export const filterWhere = (filter_name: string, p: any) => {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (p && p.opt__feature && p.sft__fields && p.sft__type) {
|
|
||||||
where = softDeleteFilter(where, {
|
|
||||||
feature: p.opt_feature,
|
|
||||||
field: p.sft__fields,
|
|
||||||
type: p.sft__type,
|
|
||||||
});
|
|
||||||
}
|
|
||||||
return where;
|
return where;
|
||||||
};
|
};
|
||||||
|
|
|
||||||
|
|
@ -175,6 +175,7 @@ export const TableList: FC<TableListProp> = ({
|
||||||
},
|
},
|
||||||
collapsed: new Set<number>(),
|
collapsed: new Set<number>(),
|
||||||
cached_row: new WeakMap<any, ReactElement>(),
|
cached_row: new WeakMap<any, ReactElement>(),
|
||||||
|
filtering: "" as ReactNode | string | true,
|
||||||
sort: {
|
sort: {
|
||||||
columns: (ls_sort?.columns || []) as SortColumn[],
|
columns: (ls_sort?.columns || []) as SortColumn[],
|
||||||
on_change: (cols: SortColumn[]) => {
|
on_change: (cols: SortColumn[]) => {
|
||||||
|
|
@ -260,6 +261,7 @@ export const TableList: FC<TableListProp> = ({
|
||||||
if (arg?.toast === false) should_toast = false;
|
if (arg?.toast === false) should_toast = false;
|
||||||
local.should_toast = should_toast;
|
local.should_toast = should_toast;
|
||||||
|
|
||||||
|
local.filtering = "";
|
||||||
if (typeof on_load === "function") {
|
if (typeof on_load === "function") {
|
||||||
local.status = "loading";
|
local.status = "loading";
|
||||||
local.render();
|
local.render();
|
||||||
|
|
@ -267,6 +269,26 @@ export const TableList: FC<TableListProp> = ({
|
||||||
const orderBy = local.sort.orderBy || undefined;
|
const orderBy = local.sort.orderBy || undefined;
|
||||||
const where = filterWhere(filter_name, __props);
|
const where = filterWhere(filter_name, __props);
|
||||||
|
|
||||||
|
if (where?.OR?.length > 0) {
|
||||||
|
const key = Object.keys(where.OR[0])[0];
|
||||||
|
if (key && where.OR[0][key]) {
|
||||||
|
let filtering = where.OR[0][key].contains;
|
||||||
|
if (typeof local.filtering === "string") {
|
||||||
|
filtering = filtering.slice(1, -1);
|
||||||
|
} else {
|
||||||
|
filtering = "";
|
||||||
|
}
|
||||||
|
|
||||||
|
if (filtering) {
|
||||||
|
local.filtering = (
|
||||||
|
<div className="c-pt-2">
|
||||||
|
Searching for: <pre>"{filtering.trim()}"</pre>
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (md) {
|
if (md) {
|
||||||
const last = md.params.links[md.params.links.length - 1];
|
const last = md.params.links[md.params.links.length - 1];
|
||||||
if (last && last.where) {
|
if (last && last.where) {
|
||||||
|
|
@ -846,7 +868,21 @@ export const TableList: FC<TableListProp> = ({
|
||||||
<div className="c-flex-1 c-w-full absolute inset-0 c-flex c-flex-col c-items-center c-justify-center">
|
<div className="c-flex-1 c-w-full absolute inset-0 c-flex c-flex-col c-items-center c-justify-center">
|
||||||
<div className="c-max-w-[15%] c-flex c-flex-col c-items-center">
|
<div className="c-max-w-[15%] c-flex c-flex-col c-items-center">
|
||||||
<Sticker size={35} strokeWidth={1} />
|
<Sticker size={35} strokeWidth={1} />
|
||||||
<div className="c-pt-1">No Data</div>
|
<div className="c-pt-1 c-text-center">
|
||||||
|
No Data
|
||||||
|
<br />
|
||||||
|
{local.filtering && (
|
||||||
|
<div
|
||||||
|
className={css`
|
||||||
|
color: gray;
|
||||||
|
font-style: italic;
|
||||||
|
font-size: 90%;
|
||||||
|
`}
|
||||||
|
>
|
||||||
|
{local.filtering}
|
||||||
|
</div>
|
||||||
|
)}
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
),
|
),
|
||||||
|
|
@ -929,7 +965,21 @@ export const TableList: FC<TableListProp> = ({
|
||||||
) : (
|
) : (
|
||||||
<div className="c-flex c-items-center c-justify-center c-flex-1 w-full h-full c-flex-col ">
|
<div className="c-flex c-items-center c-justify-center c-flex-1 w-full h-full c-flex-col ">
|
||||||
<Sticker size={35} strokeWidth={1} />
|
<Sticker size={35} strokeWidth={1} />
|
||||||
<div className="c-pt-1">No Data</div>
|
<div className="c-pt-1">
|
||||||
|
No Data
|
||||||
|
<br />
|
||||||
|
{local.filtering && (
|
||||||
|
<div
|
||||||
|
className={css`
|
||||||
|
color: gray;
|
||||||
|
font-style: italic;
|
||||||
|
font-size: 90%;
|
||||||
|
`}
|
||||||
|
>
|
||||||
|
{local.filtering}
|
||||||
|
</div>
|
||||||
|
)}
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
)}
|
)}
|
||||||
</>
|
</>
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue