mirror of
https://github.com/DeNNiiInc/dbgate.git
synced 2026-04-26 00:45:58 +00:00
filter type refactor WIP
This commit is contained in:
18
packages/types/filter-type.d.ts
vendored
Normal file
18
packages/types/filter-type.d.ts
vendored
Normal file
@@ -0,0 +1,18 @@
|
|||||||
|
export type FilterParserCompilerType = 'sqlTree' | 'mongoCondition';
|
||||||
|
|
||||||
|
export interface StructuredFilterType {
|
||||||
|
compilerType: FilterParserCompilerType;
|
||||||
|
|
||||||
|
supportEquals?: boolean;
|
||||||
|
supportStringInclusion?: boolean;
|
||||||
|
supportEmpty?: boolean;
|
||||||
|
supportNumberLikeComparison?: boolean;
|
||||||
|
supportDatetimeComparison?: boolean;
|
||||||
|
supportDatetimeSymbols?: boolean;
|
||||||
|
supportNullTesting?: boolean;
|
||||||
|
supportExistsTesting?: boolean;
|
||||||
|
supportBooleanValues?: boolean;
|
||||||
|
supportSqlCondition?: boolean;
|
||||||
|
|
||||||
|
// allowedOperators: Array<{ value: string; label: string }>;
|
||||||
|
}
|
||||||
1
packages/types/index.d.ts
vendored
1
packages/types/index.d.ts
vendored
@@ -47,3 +47,4 @@ export * from './dbtypes';
|
|||||||
export * from './extensions';
|
export * from './extensions';
|
||||||
export * from './alter-processor';
|
export * from './alter-processor';
|
||||||
export * from './appdefs';
|
export * from './appdefs';
|
||||||
|
export * from './filter-type';
|
||||||
|
|||||||
@@ -20,6 +20,7 @@
|
|||||||
|
|
||||||
export let isReadOnly = false;
|
export let isReadOnly = false;
|
||||||
export let filterType;
|
export let filterType;
|
||||||
|
export let structuredFilterType;
|
||||||
export let filter;
|
export let filter;
|
||||||
export let setFilter;
|
export let setFilter;
|
||||||
export let showResizeSplitter = false;
|
export let showResizeSplitter = false;
|
||||||
@@ -60,6 +61,55 @@
|
|||||||
};
|
};
|
||||||
|
|
||||||
function createMenu() {
|
function createMenu() {
|
||||||
|
const res = [
|
||||||
|
{ onClick: () => setFilter(''), text: 'Clear Filter' },
|
||||||
|
{ onClick: () => filterMultipleValues(), text: 'Filter multiple values' },
|
||||||
|
];
|
||||||
|
|
||||||
|
if (structuredFilterType.supportEquals) {
|
||||||
|
res.push(
|
||||||
|
{ onClick: () => openFilterWindow('='), text: 'Equals...' },
|
||||||
|
{ onClick: () => openFilterWindow('<>'), text: 'Does Not Equal...' }
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (structuredFilterType.supportNullTesting) {
|
||||||
|
res.push(
|
||||||
|
{ onClick: () => setFilter('NULL'), text: 'Is Null' },
|
||||||
|
{ onClick: () => setFilter('NOT NULL'), text: 'Is Not Null' }
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (structuredFilterType.supportNumberLikeComparison) {
|
||||||
|
res.push(
|
||||||
|
{ onClick: () => openFilterWindow('>'), text: 'Greater Than...' },
|
||||||
|
{ onClick: () => openFilterWindow('>='), text: 'Greater Than Or Equal To...' },
|
||||||
|
{ onClick: () => openFilterWindow('<'), text: 'Less Than...' },
|
||||||
|
{ onClick: () => openFilterWindow('<='), text: 'Less Than Or Equal To...' }
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (structuredFilterType.supportBooleanValues) {
|
||||||
|
res.push(
|
||||||
|
{ onClick: () => setFilter('TRUE'), text: 'Is True' },
|
||||||
|
{ onClick: () => setFilter('FALSE'), text: 'Is False' }
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (structuredFilterType.supportBooleanValues && structuredFilterType.supportNullTesting) {
|
||||||
|
res.push(
|
||||||
|
{ onClick: () => setFilter('TRUE, NULL'), text: 'Is True or NULL' },
|
||||||
|
{ onClick: () => setFilter('FALSE, NULL'), text: 'Is False or NULL' }
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (structuredFilterType.supportSqlCondition) {
|
||||||
|
res.push(
|
||||||
|
{ onClick: () => openFilterWindow('sql'), text: 'SQL condition ...' },
|
||||||
|
{ onClick: () => openFilterWindow('sqlRight'), text: 'SQL condition - right side ...' }
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
switch (filterType) {
|
switch (filterType) {
|
||||||
case 'number':
|
case 'number':
|
||||||
return [
|
return [
|
||||||
|
|||||||
Reference in New Issue
Block a user