mirror of
https://gitee.com/nocobase/nocobase.git
synced 2025-05-07 14:39:25 +08:00
fix: scopeKeyOptions should be obtained in real-time (#4029)
* fix: formula field caluation error * fix: scopeKeyOptions * fix: bug * fix: bug
This commit is contained in:
parent
f36bc41a11
commit
3fd5b05940
@ -175,12 +175,13 @@ export const EditFieldAction = (props) => {
|
||||
const compile = useCompile();
|
||||
const [data, setData] = useState<any>({});
|
||||
const { isDialect } = useDialect();
|
||||
|
||||
const scopeKeyOptions = useMemo(() => {
|
||||
return (
|
||||
record?.fields ||
|
||||
getCollection(record.collectionName)
|
||||
.options.fields.filter((v) => {
|
||||
return v.interface === 'select';
|
||||
return ['string', 'bigInt', 'integer'].includes(v.type);
|
||||
})
|
||||
.map((k) => {
|
||||
return {
|
||||
|
@ -22,7 +22,7 @@ export class SortFieldInterface extends CollectionFieldInterface {
|
||||
'x-validator': 'integer',
|
||||
},
|
||||
};
|
||||
availableTypes = ['bigInt', 'integer', 'sort'];
|
||||
availableTypes = ['sort'];
|
||||
hasDefaultValue = false;
|
||||
properties = {
|
||||
...defaultProps,
|
||||
|
@ -191,6 +191,7 @@ const EditFieldAction = (props) => {
|
||||
const compile = useCompile();
|
||||
const { name } = useParams();
|
||||
const isDialect = (dialect: string) => currentDatabase?.dialect === dialect;
|
||||
const fields = record?.fields || getCollection(record.collectionName, name)?.options?.fields;
|
||||
const currentCollections = useMemo(() => {
|
||||
return collections.map((v) => {
|
||||
return {
|
||||
@ -204,7 +205,7 @@ const EditFieldAction = (props) => {
|
||||
record?.fields ||
|
||||
getCollection(record.collectionName, name)
|
||||
?.options?.fields.filter((v) => {
|
||||
return v.interface === 'select';
|
||||
return ['string', 'bigInt', 'integer'].includes(v.type);
|
||||
})
|
||||
.map((k) => {
|
||||
return {
|
||||
@ -213,7 +214,7 @@ const EditFieldAction = (props) => {
|
||||
};
|
||||
})
|
||||
);
|
||||
}, [record.name]);
|
||||
}, [record.name, fields]);
|
||||
return (
|
||||
<RecordProvider record={record} parent={parentRecord}>
|
||||
<ActionContextProvider value={{ visible, setVisible }}>
|
||||
|
@ -20,7 +20,9 @@ const getInterfaceOptions = (data, type) => {
|
||||
return v.children.length > 0;
|
||||
});
|
||||
};
|
||||
|
||||
const isValueInOptions = (value, options) => {
|
||||
return options?.some((option) => option.children?.some?.((child) => child.name === value));
|
||||
};
|
||||
export const CollectionFieldInterfaceSelect = observer(
|
||||
(props: any) => {
|
||||
const { value, handleFieldChange } = props;
|
||||
@ -51,6 +53,19 @@ export const CollectionFieldInterfaceSelect = observer(
|
||||
);
|
||||
setSelectValue(targetValue);
|
||||
}
|
||||
//选中的值不在选项中切换为第一个
|
||||
} else if (selectValue && !isValueInOptions(selectValue, options)) {
|
||||
const targetValue = options[0]?.children?.[0]?.name;
|
||||
const interfaceConfig = getInterface(targetValue);
|
||||
handleFieldChange(
|
||||
{
|
||||
interface: targetValue,
|
||||
uiSchema: { title: record?.uiSchema?.title, ...interfaceConfig?.default?.uiSchema },
|
||||
},
|
||||
record.name,
|
||||
false,
|
||||
);
|
||||
setSelectValue(targetValue);
|
||||
}
|
||||
}, [options]);
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user