feat: support attachment file fields in public forms (#5749)

* feat: support attachment file fields in public forms

* fix: bug
This commit is contained in:
Katherine 2024-12-02 12:38:23 +08:00 committed by GitHub
parent 9aae0e68fa
commit 2fcd584846
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 14 additions and 3 deletions

View File

@ -20,7 +20,7 @@ import {
SchemaComponentOptions,
Uploader,
useActionContext,
useSchemaOptionsContext,
useDesignable,
} from '../..';
import {
TableSelectorParamsProvider,
@ -157,6 +157,7 @@ const InternalFileManager = (props) => {
const [selectedRows, setSelectedRows] = useState([]);
const insertSelector = useInsertSchema('Selector');
const fieldNames = useFieldNames(props);
const { designable } = useDesignable();
const field: any = useField();
const [options, setOptions] = useState([]);
const { getField } = useCollection_deprecated();
@ -167,7 +168,11 @@ const InternalFileManager = (props) => {
const handleSelect = (ev) => {
ev.stopPropagation();
ev.preventDefault();
if (designable) {
insertSelector(schema.Selector);
} else {
fieldSchema.addProperty('selector', schema.Selector);
}
setVisibleSelector(true);
setSelectedRows([]);
};

View File

@ -162,11 +162,17 @@ export class PluginPublicFormsServer extends Plugin {
return next();
}
const { resourceName, actionName } = ctx.action;
const collection = this.db.getCollection(resourceName);
if (actionName === 'create' && ctx.PublicForm['collectionName'] === resourceName) {
ctx.permission = {
skip: true,
};
} else if (actionName === 'list' && ctx.PublicForm['targetCollections'].includes(resourceName)) {
} else if (
(actionName === 'list' && ctx.PublicForm['targetCollections'].includes(resourceName)) ||
(collection.options.template === 'file' && actionName === 'create') ||
(resourceName === 'storages' && actionName === 'getRules') ||
(resourceName === 'map-configuration' && actionName === 'get')
) {
ctx.permission = {
skip: true,
};