Skip to content
Snippets Groups Projects
Commit eb788902 authored by borzechof99's avatar borzechof99 :whale2:
Browse files

Cleaned Up Question Order

parent a80629d9
No related branches found
No related tags found
No related merge requests found
import * as React from 'react';
import { Admin, EditGuesser, ListGuesser, Resource } from 'react-admin';
import { Admin, Resource } from 'react-admin';
import dataProviderMapper from './dataProviderMapper';
import { SportList, SportEdit, SportCreate } from './sportList';
import { IncompleteList, IncompleteEdit } from './incompleteList';
import { QuestionList, QuestionEdit, QuestionCreate } from './questionList';
import { ScraperList } from './scraperList';
import { orderList, orderEdit } from './questionOrderList';
import { orderList } from './questionOrderList';
import QuestionAnswerIcon from '@material-ui/icons/QuestionAnswer';
import SportsFootballIcon from '@material-ui/icons/SportsFootball';
import ListAltIcon from '@material-ui/icons/ListAlt';
import YoutubeSearchedForIcon from '@material-ui/icons/YoutubeSearchedFor';
import FormatListNumberedIcon from '@material-ui/icons/FormatListNumbered';
const App = () => (
......@@ -56,6 +57,8 @@ const App = () => (
<Resource
name='question-order'
icon={FormatListNumberedIcon}
options={{ label: 'Fragenreihenfolge' }}
list={orderList}
/>
</Admin>
......
import * as React from 'react';
import { useDataProvider, useNotify, useRedirect, Button, useUnselectAll } from 'react-admin';
import { useDataProvider, useNotify, useRedirect, Button } from 'react-admin';
export const PostScraperButton = ({ selectedIds }) => {
const notify = useNotify();
......
......@@ -2,48 +2,32 @@ import {
List,
Datagrid,
TextField,
NumberField,
DateField,
TopToolbar,
EditButton,
Button,
useNotify,
Edit,
SimpleForm,
ArrayInput,
SimpleFormIterator,
TextInput,
Show,
ReferenceInput,
SelectInput,
AutocompleteInput,
Toolbar,
SaveButton,
DeleteButton,
ReferenceField,
useDataProvider,
RadioButtonGroupInput,
useRefresh,
useRedirect,
useListContext,
useListParams,
Pagination
} from 'react-admin';
import Typography from '@material-ui/core/Typography';
import Card from '@material-ui/core/Card';
import CardContent from '@material-ui/core/CardContent';
import { useReducer } from 'react';
const PostShowActions = ({ basePath, data, resource }) => {
const notify = useNotify();
const refresh = useRefresh();
const dataProvider = useDataProvider();
const action = () => {
notify("Trööt");
};
const addOrderEntry = () => {
dataProvider.add_entry("question-order", {}).then(
response => {
......@@ -58,7 +42,7 @@ const PostShowActions = ({ basePath, data, resource }) => {
const save_order = () => {
dataProvider.save_order("question-order", {}).then(
response => {
notify("Veräenderungen gespeichert!");
notify("Veränderungen gespeichert!");
refresh();
}).catch(error => {
notify("Etwas ist schief gelaufen!", "warning");
......@@ -111,6 +95,34 @@ const AsideQuestionOrder = () => (
>
Tipps&Tricks
</Typography>
<br />
<ul>
<li>
Jeder Eintrag in dieser Liste ist eine Seite im Quiz, die entweder Fragen, Aktivitäten, oder Wissenssnacks anzeigt.
Wenn die Zeilen aufgeklappt werden, dann kann sowohl die Art des Eintrags, als auch die Frage selbst ausgewählt werden.
</li>
<br />
<li>
Um die einzelnen Änderungen an einem Eintrag zu speichern, muss "Save" in dem aufgeklappten Feld gedrückt werden.
Dort kann man ebenso den Eintrag löschen, wenn man möchte.
</li>
<br />
<li>
<p><b>Um die Reihenfolge zu speichern, muss der Knopf "Veränderungen Speichern" oben rechts gedrückt werden.</b></p>
<p>Mit dem Knopf "Veränderungen Verwerfen" werden die lokalen Änderungen auf den letzten Stand zurückgesetzt.</p>
<p>Mit dem Knopf "Eintrag Hinzufügen" kann ein neuer Eintrag am Ende der Liste angehangen werden.</p>
</li>
<br />
<li>
Mit den Knöpfen "Hoch" und "Runter" können die Einträge um jeweils eine Zeile verschoben werden.
</li>
<br />
<li>
In jedem Eintrag vom Typ Frage muss ein Fragentext ausgewählt sein, bevor die Liste gespeichert werden kann.
</li>
</ul>
</CardContent>
</Card>
......@@ -150,32 +162,40 @@ const DirEditButton = props => {
return <Button label={props.custom_label} onClick={action} />
}
export const orderList = props => {
const QuestionOrderPagination = props => <Pagination rowsPerPageOptions={[]} {...props} />;
export const orderList = props => (
return (
<List
{...props}
actions={<PostShowActions />}
aside={<AsideQuestionOrder />}
pagination={<QuestionOrderPagination />}
perPage={1000}
bulkActionButtons={false}
>
<Datagrid
rowClick="expand"
expand={orderShow}
expand={orderEdit}
>
<TextField
label="Reihenfolge"
source="id"
sortable={false}
/>
<TextField
label="Eintragstyp"
source="type"
sortable={false}
/>
<TextField
label="Fragen-ID"
source="question_id"
sortable={false}
/>
<ReferenceField
label="Fragentext"
reference="question"
source="question_id"
sortable={false}
......@@ -189,28 +209,8 @@ export const orderList = props => {
</Datagrid>
</List>
);
};
const QuestionSensitiveField = (props) => {
console.log(props);
if (props.record.type === "question") {
return (
<Typography >
props.record.type
</Typography>
)
} else {
return (
<Typography>
"None Here!"
</Typography>
)
}
}
);
const OrderEditToolbar = props => {
const notify = useNotify();
......@@ -239,7 +239,7 @@ const OrderEditToolbar = props => {
)
};
const CategoryQuestionField = (props) => {
const CategorySensitiveQuestionField = (props) => {
if (props.record.type === "question") {
return (
<ReferenceInput
......@@ -260,7 +260,7 @@ const CategoryQuestionField = (props) => {
}
export const orderShow = props => (
export const orderEdit = props => (
<Edit {...props} mutationMode={"optimistic"}>
<SimpleForm toolbar={<OrderEditToolbar />}>
......@@ -272,7 +272,7 @@ export const orderShow = props => (
{ id: "activity", name: "Aktivität" },
{ id: "question", name: "Frage" }]}
/>
<CategoryQuestionField />
<CategorySensitiveQuestionField />
</SimpleForm>
</Edit>
......
......@@ -2,7 +2,6 @@ import { stringify } from 'query-string';
import {
fetchUtils,
} from 'ra-core';
import { useNotify } from 'react-admin';
/*
......@@ -239,7 +238,7 @@ export default (
body: JSON.stringify(cached_order.data),
});
return { data: {} }
return { data: json }
},
};
......
......@@ -48,7 +48,7 @@ const AsideSportScrape = () => (
const ScraperPagination = props => <Pagination rowsPerPageOptions={[]} {...props} />;
{/* bulkActionButtons should theoretically be able to take a whole Fragment worth of buttons, but React hates us and we return the feeling*/ }
/* bulkActionButtons should theoretically be able to take a whole Fragment worth of buttons, but React hates us and we return the feeling*/
// perPage is set to 1000
// It is important that the page shows all entries, so that there are no issues while scrolling through the pages and sending the data afterwards
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment