fix(ui): advance search style updates (#8877)

This commit is contained in:
Chirag Madlani 2022-11-18 18:30:57 +05:30 committed by GitHub
parent e966bb343b
commit 3da72ddd63
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 227 additions and 32 deletions

View File

@ -24,6 +24,7 @@ import AntdConfig from 'react-awesome-query-builder/lib/config/antd';
import { suggestQuery } from '../../axiosAPIs/searchAPI'; import { suggestQuery } from '../../axiosAPIs/searchAPI';
import { SuggestionField } from '../../enums/AdvancedSearch.enum'; import { SuggestionField } from '../../enums/AdvancedSearch.enum';
import { SearchIndex } from '../../enums/search.enum'; import { SearchIndex } from '../../enums/search.enum';
import { renderAdvanceSearchButtons } from '../../utils/AdvancedSearchUtils';
const BaseConfig = AntdConfig as BasicConfig; const BaseConfig = AntdConfig as BasicConfig;
@ -33,6 +34,17 @@ const BaseConfig = AntdConfig as BasicConfig;
export const emptyJsonTree: JsonTree = { export const emptyJsonTree: JsonTree = {
id: QbUtils.uuid(), id: QbUtils.uuid(),
type: 'group', type: 'group',
properties: {
conjunction: 'AND',
not: false,
},
children1: {
[QbUtils.uuid()]: {
type: 'group',
properties: {
conjunction: 'AND',
not: false,
},
children1: { children1: {
[QbUtils.uuid()]: { [QbUtils.uuid()]: {
type: 'rule', type: 'rule',
@ -44,6 +56,8 @@ export const emptyJsonTree: JsonTree = {
}, },
}, },
}, },
},
},
}; };
/** /**
@ -66,6 +80,11 @@ export const autocomplete: (
hasMore: false, hasMore: false,
})); }));
const mainWidgetProps = {
fullWidth: true,
valueLabel: i18next.t('label.criteria') + ':',
};
/** /**
* Common fields that exit for all searchable entities * Common fields that exit for all searchable entities
*/ */
@ -83,6 +102,7 @@ const commonQueryBuilderFields: Fields = {
name: { name: {
label: 'username', label: 'username',
type: 'select', type: 'select',
mainWidgetProps,
fieldSettings: { fieldSettings: {
asyncFetch: autocomplete([SearchIndex.USER, SearchIndex.TEAM]), asyncFetch: autocomplete([SearchIndex.USER, SearchIndex.TEAM]),
}, },
@ -90,10 +110,12 @@ const commonQueryBuilderFields: Fields = {
displayName: { displayName: {
label: 'name', label: 'name',
type: 'text', type: 'text',
mainWidgetProps,
}, },
type: { type: {
label: 'type', label: 'type',
type: 'select', type: 'select',
mainWidgetProps,
fieldSettings: { fieldSettings: {
listValues: [ listValues: [
{ value: 'user', title: 'User' }, { value: 'user', title: 'User' },
@ -107,6 +129,7 @@ const commonQueryBuilderFields: Fields = {
'tags.tagFQN': { 'tags.tagFQN': {
label: 'Tags', label: 'Tags',
type: 'select', type: 'select',
mainWidgetProps,
fieldSettings: { fieldSettings: {
asyncFetch: autocomplete([SearchIndex.TAG, SearchIndex.GLOSSARY]), asyncFetch: autocomplete([SearchIndex.TAG, SearchIndex.GLOSSARY]),
}, },
@ -115,6 +138,7 @@ const commonQueryBuilderFields: Fields = {
'tier.tagFQN': { 'tier.tagFQN': {
label: 'Tier', label: 'Tier',
type: 'select', type: 'select',
mainWidgetProps,
fieldSettings: { fieldSettings: {
asyncFetch: autocomplete([SearchIndex.TAG, SearchIndex.GLOSSARY]), asyncFetch: autocomplete([SearchIndex.TAG, SearchIndex.GLOSSARY]),
}, },
@ -132,6 +156,7 @@ const serviceQueryBuilderFields: Fields = {
name: { name: {
label: 'name', label: 'name',
type: 'select', type: 'select',
mainWidgetProps,
fieldSettings: { fieldSettings: {
asyncFetch: autocomplete(SearchIndex.TABLE, SuggestionField.SERVICE), asyncFetch: autocomplete(SearchIndex.TABLE, SuggestionField.SERVICE),
}, },
@ -156,6 +181,7 @@ const tableQueryBuilderFields: Fields = {
name: { name: {
label: 'name', label: 'name',
type: 'select', type: 'select',
mainWidgetProps,
fieldSettings: { fieldSettings: {
asyncFetch: autocomplete(SearchIndex.TABLE, SuggestionField.DATABASE), asyncFetch: autocomplete(SearchIndex.TABLE, SuggestionField.DATABASE),
}, },
@ -175,6 +201,7 @@ const tableQueryBuilderFields: Fields = {
name: { name: {
label: 'name', label: 'name',
type: 'select', type: 'select',
mainWidgetProps,
fieldSettings: { fieldSettings: {
asyncFetch: autocomplete(SearchIndex.TABLE, SuggestionField.SCHEMA), asyncFetch: autocomplete(SearchIndex.TABLE, SuggestionField.SCHEMA),
}, },
@ -190,6 +217,7 @@ const tableQueryBuilderFields: Fields = {
name: { name: {
label: 'Table', label: 'Table',
type: 'select', type: 'select',
mainWidgetProps,
fieldSettings: { fieldSettings: {
asyncFetch: autocomplete(SearchIndex.TABLE, SuggestionField.ROOT), asyncFetch: autocomplete(SearchIndex.TABLE, SuggestionField.ROOT),
}, },
@ -202,6 +230,7 @@ const tableQueryBuilderFields: Fields = {
name: { name: {
label: 'name', label: 'name',
type: 'select', type: 'select',
mainWidgetProps,
fieldSettings: { fieldSettings: {
asyncFetch: autocomplete(SearchIndex.TABLE, SuggestionField.COLUMN), asyncFetch: autocomplete(SearchIndex.TABLE, SuggestionField.COLUMN),
}, },
@ -209,10 +238,12 @@ const tableQueryBuilderFields: Fields = {
dataType: { dataType: {
label: 'data type', label: 'data type',
type: 'text', type: 'text',
mainWidgetProps,
}, },
constraint: { constraint: {
label: 'constraint', label: 'constraint',
type: 'text', type: 'text',
mainWidgetProps,
}, },
}, },
}, },
@ -287,9 +318,12 @@ const initialConfigWithoutFields: BasicConfig = {
...BaseConfig.settings, ...BaseConfig.settings,
showLabels: true, showLabels: true,
canReorder: false, canReorder: false,
renderSize: 'medium',
fieldLabel: i18next.t('label.description') + ':', fieldLabel: i18next.t('label.description') + ':',
operatorLabel: i18next.t('label.condition') + ':', operatorLabel: i18next.t('label.condition') + ':',
showNot: false,
valueLabel: i18next.t('label.criteria') + ':', valueLabel: i18next.t('label.criteria') + ':',
renderButton: renderAdvanceSearchButtons,
}, },
}; };

View File

@ -15,22 +15,74 @@
&.query-builder { &.query-builder {
margin: 0; margin: 0;
font: inherit; font: inherit;
} overflow: visible;
.group--children {
padding-left: 0;
}
.group-or-rule-container {
padding-right: 10px;
padding-left: 10px;
// border: 1px solid #dde3ea;
} }
.group-or-rule-container.group-container { .group-or-rule-container.group-container {
padding: 0px 12px; padding-right: 0px;
} }
& > .group-or-rule-container.group-container {
& > .group.group-or-rule {
& > .group--header + .group--children {
padding-left: 0;
}
}
}
.group-or-rule-container.group-container {
& > .group.group-or-rule {
background-color: transparent;
border: none;
& > .group--header {
margin: 0;
padding: 0;
.group--conjunctions {
position: absolute;
left: 0px;
top: 0px;
.ant-btn-group button span {
text-transform: uppercase;
}
}
.action.action--ADD-RULE {
display: none;
}
.action.action--DELETE {
position: absolute;
top: 10px;
right: 10px;
}
.action.action--ADD-GROUP {
position: absolute;
bottom: 8px;
z-index: 1;
max-width: 128px;
border-color: #7147e8;
border-radius: 4px;
left: 0;
right: 0;
margin: auto;
}
}
}
}
.ant-btn-group {
position: initial;
}
.rule--body {
margin-right: 96px;
}
.group--children {
padding-top: 22px;
padding-bottom: 22px;
.group-or-rule-container.group-container, .group-or-rule-container.group-container,
.group-or-rule-container.rule-container { .group-or-rule-container.rule-container {
.group.group-or-rule, .group.group-or-rule,
@ -47,9 +99,56 @@
} }
} }
.group.group-or-rule {
.group--header {
.group--conjunctions {
position: absolute;
right: 36px;
top: 62px;
left: auto;
z-index: 1;
.ant-btn-group button span {
text-transform: uppercase;
}
}
.action.action--ADD-RULE {
position: absolute;
right: 36px;
bottom: 32px;
z-index: 1;
display: block;
border-color: #7147e8;
border-radius: 4px;
}
.action.action--ADD-GROUP {
display: none;
}
.action.action--DELETE {
position: absolute;
right: 10px;
bottom: 10px;
z-index: 1;
font-size: 16px;
}
}
}
.rule.group-or-rule { .rule.group-or-rule {
padding: 0; padding: 0;
border: none; border: none;
.rule--header {
.ant-btn-group {
align-self: end;
margin-bottom: 8px;
}
}
}
} }
} }
} }

View File

@ -11,7 +11,16 @@
* limitations under the License. * limitations under the License.
*/ */
import Icon, {
CloseCircleOutlined,
DeleteOutlined,
PlusOutlined,
} from '@ant-design/icons';
import { Button } from 'antd';
import i18next from 'i18next';
import { isUndefined } from 'lodash'; import { isUndefined } from 'lodash';
import React from 'react';
import { RenderSettings } from 'react-awesome-query-builder';
import { import {
ALL_DROPDOWN_ITEMS, ALL_DROPDOWN_ITEMS,
COMMON_DROPDOWN_ITEMS, COMMON_DROPDOWN_ITEMS,
@ -77,3 +86,56 @@ export const getAdvancedField = (field: string) => {
return; return;
} }
}; };
export const renderAdvanceSearchButtons: RenderSettings['renderButton'] = (
props
) => {
const type = props?.type;
if (type === 'delRule') {
return (
<Icon
className="action action--DELETE"
component={
// eslint-disable-next-line @typescript-eslint/no-explicit-any
CloseCircleOutlined as React.ForwardRefExoticComponent<any>
}
onClick={props?.onClick}
/>
);
} else if (type === 'addRule') {
return (
<Button
ghost
className="action action--ADD-RULE"
icon={<PlusOutlined />}
type="primary"
onClick={props?.onClick}>
{i18next.t('label.add')}
</Button>
);
} else if (type === 'addGroup') {
return (
<Button
className="action action--ADD-GROUP"
icon={<PlusOutlined />}
type="primary"
onClick={props?.onClick}>
{i18next.t('label.add')}
</Button>
);
} else if (type === 'delGroup') {
return (
<Icon
className="action action--DELETE"
component={
// eslint-disable-next-line @typescript-eslint/no-explicit-any
DeleteOutlined as React.ForwardRefExoticComponent<any>
}
onClick={props?.onClick}
/>
);
}
return <></>;
};