mirror of
https://github.com/nocobase/nocobase
synced 2024-11-15 09:47:10 +00:00
fix: reset issue that reverts filter button title to default (#5635)
* fix: reset issue that reverts filter button title to default * fix: bug
This commit is contained in:
parent
b7495a7757
commit
586c515ff7
@ -21,6 +21,7 @@ import { useProps } from '../../hooks/useProps';
|
||||
import { Action, ActionProps } from '../action';
|
||||
import { DatePickerProvider } from '../date-picker/DatePicker';
|
||||
import { StablePopover } from '../popover';
|
||||
import { useCompile } from '../../';
|
||||
|
||||
export const FilterActionContext = createContext<any>(null);
|
||||
FilterActionContext.displayName = 'FilterActionContext';
|
||||
@ -50,6 +51,8 @@ export const FilterAction = withDynamicSchemaProps(
|
||||
const [visible, setVisible] = useState(false);
|
||||
const { designable, dn } = useDesignable();
|
||||
const fieldSchema = useFieldSchema();
|
||||
const compile = useCompile();
|
||||
|
||||
const form = useMemo<Form>(() => props.form || createForm(), []);
|
||||
|
||||
// 新版 UISchema(1.0 之后)中已经废弃了 useProps,这里之所以继续保留是为了兼容旧版的 UISchema
|
||||
@ -58,7 +61,6 @@ export const FilterAction = withDynamicSchemaProps(
|
||||
const onOpenChange = useCallback((visible: boolean): void => {
|
||||
setVisible(visible);
|
||||
}, []);
|
||||
|
||||
return (
|
||||
<FilterActionContext.Provider value={{ field, fieldSchema, designable, dn }}>
|
||||
<Container
|
||||
@ -99,7 +101,7 @@ export const FilterAction = withDynamicSchemaProps(
|
||||
onClick={async () => {
|
||||
await form.reset();
|
||||
onReset?.(form.values);
|
||||
field.title = t('Filter');
|
||||
field.title = compile(fieldSchema.title) || t('Filter');
|
||||
setVisible(false);
|
||||
}}
|
||||
>
|
||||
|
@ -16,7 +16,7 @@ import { useBlockRequestContext } from '../../../block-provider';
|
||||
import { useCollectionManager_deprecated, useCollection_deprecated } from '../../../collection-manager';
|
||||
import { mergeFilter } from '../../../filter-provider/utils';
|
||||
import { useDataLoadingMode } from '../../../modules/blocks/data-blocks/details-multi/setDataLoadingModeSettingsItem';
|
||||
|
||||
import { useCompile } from '../../';
|
||||
export const useGetFilterOptions = () => {
|
||||
const { getCollectionFields } = useCollectionManager_deprecated();
|
||||
const getFilterFieldOptions = useGetFilterFieldOptions();
|
||||
@ -182,6 +182,8 @@ export const useFilterFieldProps = ({ options, service, params }) => {
|
||||
const { t } = useTranslation();
|
||||
const field = useField<Field>();
|
||||
const dataLoadingMode = useDataLoadingMode();
|
||||
const fieldSchema = useFieldSchema();
|
||||
const compile = useCompile();
|
||||
|
||||
return {
|
||||
options,
|
||||
@ -205,7 +207,7 @@ export const useFilterFieldProps = ({ options, service, params }) => {
|
||||
if (items?.length) {
|
||||
field.title = t('{{count}} filter items', { count: items?.length || 0 });
|
||||
} else {
|
||||
field.title = t('Filter');
|
||||
field.title = compile(fieldSchema.title) || t('Filter');
|
||||
}
|
||||
},
|
||||
onReset() {
|
||||
@ -222,8 +224,6 @@ export const useFilterFieldProps = ({ options, service, params }) => {
|
||||
{ filters },
|
||||
];
|
||||
|
||||
field.title = t('Filter');
|
||||
|
||||
if (dataLoadingMode === 'manual') {
|
||||
service.params = newParams;
|
||||
return service.mutate(undefined);
|
||||
|
Loading…
Reference in New Issue
Block a user