mirror of
https://github.com/nocobase/nocobase
synced 2024-11-15 07:57:20 +00:00
refactor: collection template support presetFieldsDisabled (#4159)
* refactor: collection template support presetFieldsDisabled * refactor: code improve
This commit is contained in:
parent
343b97de14
commit
2d66f4d44b
@ -145,6 +145,7 @@ export const AddCollectionAction = (props) => {
|
||||
const { getTemplate, templates: collectionTemplates } = useCollectionManager_deprecated();
|
||||
const [visible, setVisible] = useState(false);
|
||||
const [schema, setSchema] = useState({});
|
||||
const [currentTemplate, setCurrentTemplate] = useState(null);
|
||||
const compile = useCompile();
|
||||
const { t } = useTranslation();
|
||||
const items = useMemo(() => {
|
||||
@ -173,6 +174,7 @@ export const AddCollectionAction = (props) => {
|
||||
},
|
||||
onClick: (info) => {
|
||||
const schema = getSchema(getTemplate(info.key), category, compile);
|
||||
setCurrentTemplate(getTemplate(info.key));
|
||||
setSchema(schema);
|
||||
setVisible(true);
|
||||
},
|
||||
@ -199,6 +201,7 @@ export const AddCollectionAction = (props) => {
|
||||
useCreateCollection,
|
||||
record,
|
||||
showReverseFieldConfig: true,
|
||||
presetFieldsDisabled: currentTemplate?.presetFieldsDisabled,
|
||||
...scope,
|
||||
}}
|
||||
/>
|
||||
|
@ -194,8 +194,8 @@ export const PresetFields = observer(
|
||||
type: 'checkbox',
|
||||
selectedRowKeys,
|
||||
getCheckboxProps: (record) => ({
|
||||
disabled: form.values.template === 'file', // Column configuration not to be checked
|
||||
name: record.name,
|
||||
disabled: props?.disabled,
|
||||
}),
|
||||
onChange: (_, selectedRows) => {
|
||||
const fields = getDefaultCollectionFields(selectedRows, form.values);
|
||||
|
@ -64,6 +64,9 @@ export const defaultConfigurableProperties = {
|
||||
`,
|
||||
},
|
||||
'x-component': PresetFields,
|
||||
'x-component-props': {
|
||||
disabled: '{{ presetFieldsDisabled }}',
|
||||
},
|
||||
},
|
||||
};
|
||||
|
||||
|
@ -139,6 +139,7 @@ export class FileCollectionTemplate extends CollectionTemplate {
|
||||
},
|
||||
],
|
||||
};
|
||||
presetFieldsDisabled = true;
|
||||
configurableProperties = {
|
||||
...getConfigurableProperties('title', 'name'),
|
||||
inherits: {
|
||||
|
Loading…
Reference in New Issue
Block a user