Skip to content

Commit

Permalink
feat: Make event importable by configuration
Browse files Browse the repository at this point in the history
  • Loading branch information
mguihal committed Oct 15, 2023
1 parent 8cd4a3a commit ff5c335
Show file tree
Hide file tree
Showing 4 changed files with 37 additions and 8 deletions.
4 changes: 4 additions & 0 deletions frontend/src/config/theme.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@ import { createTheme } from '@mui/material/styles';
const defaultTheme = createTheme();

const theme = createTheme({
archipelago: {
// Displays import tab when creating resource is it is listed here
importableResources: ['Event', 'Project', 'Task', 'Group', 'Organization', 'Idea', 'Document', 'Skill'],
},
palette: {
primary: { main: '#28ccfb', contrastText: '#ffffff' },
secondary: { main: '#bcef5b' },
Expand Down
25 changes: 24 additions & 1 deletion frontend/src/resources/Agent/Activity/Event/EventCreate.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,34 @@
import React from "react";
import { CreateOrImportForm } from "@semapps/interop-components";
import { useResourceContext, SimpleForm } from "react-admin";
import { useTheme } from "@mui/material/styles";
import Create from "../../../../layout/create/Create";
import EventForm from "./EventForm";

const EventCreate = () => {
const theme = useTheme();
const resource = useResourceContext();
const isImportable = theme.archipelago?.importableResources?.includes(resource);

return (
<Create title={"Créer un nouvel évènement"} redirect="show">
<EventForm />
{isImportable ? (
<CreateOrImportForm
stripProperties={[
"pair:topicOf",
"pair:producedBy",
"pair:offeredBy",
]}
spacing={2}
useFlexGap
>
<EventForm />
</CreateOrImportForm>
) : (
<SimpleForm spacing={2} useFlexGap>
<EventForm />
</SimpleForm>
)}
</Create>
);
};
Expand Down
11 changes: 7 additions & 4 deletions frontend/src/resources/Agent/Activity/Event/EventEdit.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,14 @@
import React from 'react';
import React from "react";
import Edit from "../../../../layout/edit/Edit";
import Title from "../../../../layout/Title";
import EventForm from './EventForm';
import EventForm from "./EventForm";
import { SimpleForm } from "react-admin";

const EventEdit = props => (
const EventEdit = (props) => (
<Edit title={<Title />} redirect="show" {...props}>
<EventForm />
<SimpleForm spacing={2} useFlexGap>
<EventForm />
</SimpleForm>
</Edit>
);

Expand Down
5 changes: 2 additions & 3 deletions frontend/src/resources/Agent/Activity/Event/EventForm.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import {
required,
ImageField,
minValue,
SimpleForm,
} from "react-admin";
import { MarkdownInput } from '@semapps/markdown-components';
import { ImageInput } from "@semapps/input-components";
Expand Down Expand Up @@ -35,7 +34,7 @@ const EndDateInput = () => {

const EventForm = () => {
return (
<SimpleForm spacing={2} useFlexGap >
<>
<LargeLabel>Informations de base</LargeLabel>
<TextInput source="pair:label" fullWidth validate={[required()]} />
<Stack direction="row" useFlexGap spacing={2}>
Expand Down Expand Up @@ -87,7 +86,7 @@ const EventForm = () => {
<ImageInput source="image" accept="image/*">
<ImageField source="src" />
</ImageInput>
</SimpleForm>
</>
);
};

Expand Down

0 comments on commit ff5c335

Please sign in to comment.