Skip to content

Commit

Permalink
feat(admin): adjust chapter edit mode
Browse files Browse the repository at this point in the history
  • Loading branch information
Gerd Müller committed Jul 1, 2020
1 parent 7397ff4 commit 7983a2b
Show file tree
Hide file tree
Showing 17 changed files with 544 additions and 347 deletions.
1 change: 1 addition & 0 deletions apps/admin/src/app/app.scss
Original file line number Diff line number Diff line change
Expand Up @@ -10,5 +10,6 @@

div {
margin-right: 5px;
width: 100%;
}
}
6 changes: 0 additions & 6 deletions apps/admin/src/app/app.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,7 @@ import { Admin as ReactAdmin, Resource } from 'react-admin';
import polyglotI18nProvider from 'ra-i18n-polyglot';
import germanMessages from 'ra-language-german';

import Dashboard from './Dashboard';
import chapters from './chapters';
import images from './images';
import videos from './videos';
import games from './games';
import tags from './tags';

import jsonServerProvider from 'ra-data-json-server';
import { API_URL } from '@gerdesque/data';
Expand All @@ -23,7 +18,6 @@ export const Admin = () => {
return (
<ReactAdmin
title="Demokratie erLeben Admin"
dashboard={Dashboard}
i18nProvider={i18nProvider}
dataProvider={dataProvider}>
<Resource name="chapters" {...chapters} />
Expand Down
62 changes: 41 additions & 21 deletions apps/admin/src/app/chapters/ChapterEdit.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,38 +5,58 @@ import {
TextInput,
ArrayInput,
SimpleFormIterator,
TextField,
FormDataConsumer,
required
} from 'react-admin';
import ImageIcon from '@material-ui/icons/Collections';
import {Collections, Games, Apartment, VideoLibrary, TextFields, Link, Details} from '@material-ui/icons';

const renderTypeIcon = (type) => {
switch (type) {
case 'video':
return <VideoLibrary />;
case 'image':
return <Collections />;
case 'memory':
case 'daily':
case 'puzzle':
case 'suitcase':
case 'tictactoe':
return <Games />;
case 'smokingpit':
return <Apartment />;
case 'summary':
return <Details />;
case 'redirect':
return <Link />;
case 'text':
return <TextFields />;
default:
return null;
}
}

export const ChapterEdit = props => (
<Edit {...props}>
<SimpleForm>
<TextInput disabled source="id" />
<TextInput source="name" />
<TextInput label="Pfad" source="link" validate={required()}/>
<ArrayInput label="Inhaltsgruppen" source="groups">
<TextInput label="Überschrift des Kapitels" source="name" />
<TextInput disabled label="Link des Kapitels" source="link"/>
<ArrayInput label="Gruppen von Inhaltselementen" source="groups">
<SimpleFormIterator>
<TextInput label="Info" source="info" />
<ArrayInput label="Inhalt" source="content" className="contentarray">
<TextInput label="Text für das Info-Icon" source="info" />
<ArrayInput label="Inhaltselemente" source="content" className="contentarray">
<SimpleFormIterator>
{/* <TextInput label="Typ" source="type" />
<TextInput label="Ebene" source="layer" /> */}
<FormDataConsumer>
{({ getSource, scopedFormData }) => {
return (
<TextField
source={getSource('layer')}
record={scopedFormData}
/>
);
}}
{({scopedFormData, getSource}) =>
scopedFormData?.type
? <>
<TextInput label="Inhaltstyp" source={getSource('type')}/>
{renderTypeIcon(scopedFormData.type)}
</>
: <TextInput label="Inhaltstyp" source="type"/>
}
</FormDataConsumer>
{/* {type === 'image' && <ImageIcon />} */}
<TextInput label="Titel" source="title" />
<TextInput multiline label="Wert" source="value" />
<TextInput multiline label="Text/Wert des Inhaltselements" source="value" />
<TextInput label="Titel" source="title"/>
</SimpleFormIterator>
</ArrayInput>
</SimpleFormIterator>
Expand Down
2 changes: 0 additions & 2 deletions apps/admin/src/app/chapters/index.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,9 @@
import ChapterIcon from '@material-ui/icons/LibraryBooks';
import ChapterList from './ChapterList';
import ChapterEdit from './ChapterEdit';
import ChapterCreate from './ChapterCreate';

export default {
list: ChapterList,
create: ChapterCreate,
edit: ChapterEdit,
icon: ChapterIcon,
options: { label: 'Kapitel' }
Expand Down
7 changes: 7 additions & 0 deletions apps/demol/@types/image.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import 'react'

declare module 'react' {
interface ImgHTMLAttributes<T> extends HTMLAttributes<T> {
loading?: 'lazy' | 'eager' | 'auto';
}
}
Binary file added apps/demol/src/assets/sounds/ankunft.mp3
Binary file not shown.
Binary file removed apps/demol/src/assets/sounds/birds.mp3
Binary file not shown.
Binary file removed apps/demol/src/assets/sounds/family.mp3
Binary file not shown.
Binary file removed apps/demol/src/assets/sounds/huehner.mp3
Binary file not shown.
Binary file removed apps/demol/src/assets/sounds/imprint.mp3
Binary file not shown.
Binary file removed apps/demol/src/assets/sounds/localgroup.mp3
Binary file not shown.
Binary file added apps/demol/src/assets/sounds/ortsgruppe.mp3
Binary file not shown.
Binary file added apps/demol/src/assets/sounds/personen.mp3
Binary file not shown.
Binary file added apps/demol/src/assets/sounds/reise.mp3
Binary file not shown.
2 changes: 1 addition & 1 deletion apps/demol/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
"allowJs": true,
"esModuleInterop": true,
"allowSyntheticDefaultImports": true,
"types": ["node", "jest"]
"types": ["node", "jest", "@types/**"]
},
"files": [
"../../node_modules/@nrwl/react/typings/cssmodule.d.ts",
Expand Down
Loading

0 comments on commit 7983a2b

Please sign in to comment.