Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: configurable layer import #556

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions assets/formconfigs/layer.json
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@
"entityName": "#i18n.entityName",
"navigationTitle": "#i18n.navigationTitle",
"subTitle": "",
"importEnabled": true,
"formConfig": {
"name": "layer",
"fields": [
Expand Down
26 changes: 14 additions & 12 deletions src/Component/GeneralEntity/GeneralEntityRoot/GeneralEntityRoot.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -108,33 +108,35 @@ type FeatureTypeAttributes = {
};

export type GeneralEntityConfigType<T extends BaseEntity> = {
i18n: FormTranslations;
defaultEntity?: T;
endpoint: string;
entityType: string;
entityName?: string;
entityType: string;
formConfig: FormConfig;
i18n: FormTranslations;
importEnabled?: boolean;
navigationTitle?: string;
onEntitiesLoaded?: (entities: T[], entityType: string) => void;
subTitle?: string;
formConfig: FormConfig;
tableConfig: TableConfig<T>;
onEntitiesLoaded?: (entities: T[], entityType: string) => void;
defaultEntity?: T;
};

type OwnProps<T extends BaseEntity> = GeneralEntityConfigType<T>;

export type GeneralEntityRootProps<T extends BaseEntity> = OwnProps<T> & React.HTMLAttributes<HTMLDivElement>;

export function GeneralEntityRoot<T extends BaseEntity>({
i18n,
importEnabled = true,
defaultEntity,
endpoint,
entityType,
entityName = 'Entität',
entityType,
formConfig,
i18n,
navigationTitle = 'Entitäten',
onEntitiesLoaded = () => { },
subTitle = '… mit denen man Dinge tun kann (aus Gründen bspw.)',
formConfig,
tableConfig = {},
defaultEntity,
onEntitiesLoaded = () => { }
tableConfig = {}
}: GeneralEntityRootProps<T>) {

const location = useLocation();
Expand Down Expand Up @@ -757,7 +759,7 @@ export function GeneralEntityRoot<T extends BaseEntity>({
</Button>
</Link>
{/* Upload only available for layer entities */}
{entityType === 'layer' && (
{entityType === 'layer' && importEnabled && (
<Upload
customRequest={onFileUploadAction}
accept='image/tiff,application/zip'
Expand Down