@capytale/meta-player 0.9.2 → 0.9.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json
CHANGED
|
@@ -3,7 +3,7 @@ import { createAppSlice } from "../../app/createAppSlice";
|
|
|
3
3
|
|
|
4
4
|
export type Orientation = "horizontal" | "vertical";
|
|
5
5
|
|
|
6
|
-
export type PedagoTab = "instructions" | "sharedNotes" | "pdf";
|
|
6
|
+
export type PedagoTab = "instructions" | "sharedNotes" | "pdf" | null;
|
|
7
7
|
|
|
8
8
|
export interface LayoutState {
|
|
9
9
|
orientation: Orientation;
|
|
@@ -19,7 +19,7 @@ export const initialState: LayoutState = {
|
|
|
19
19
|
orientation: "horizontal",
|
|
20
20
|
isPedagoVisible: null,
|
|
21
21
|
isGradingVisible: true,
|
|
22
|
-
pedagoTab:
|
|
22
|
+
pedagoTab: null,
|
|
23
23
|
showWorkflow: true,
|
|
24
24
|
showSaveForStudents: true,
|
|
25
25
|
};
|
|
@@ -21,9 +21,10 @@ import styles from "./style.module.scss";
|
|
|
21
21
|
import { Button } from "primereact/button";
|
|
22
22
|
import settings from "../../settings";
|
|
23
23
|
import { SelectButton } from "primereact/selectbutton";
|
|
24
|
-
import { FC, useCallback, useMemo } from "react";
|
|
24
|
+
import { FC, useCallback, useEffect, useMemo } from "react";
|
|
25
25
|
import { TabMenu } from "primereact/tabmenu";
|
|
26
26
|
import { classNames } from "primereact/utils";
|
|
27
|
+
import { usePedagoOptions } from "./hooks";
|
|
27
28
|
|
|
28
29
|
export const PedagoCommands = () => {
|
|
29
30
|
const isHorizontal = useAppSelector(selectOrientation) === "horizontal";
|
|
@@ -176,15 +177,14 @@ const DocumentSelectorItemActions: FC<{
|
|
|
176
177
|
|
|
177
178
|
const HorizontalDocumentSelector = () => {
|
|
178
179
|
const pedagoTab = useAppSelector(selectPedagoTab);
|
|
179
|
-
const instructionsType = useAppSelector(selectInstructionsType);
|
|
180
180
|
const mode = useAppSelector(selectMode);
|
|
181
181
|
// const pdfInstructions = useAppSelector(selectPdfInstructions);
|
|
182
|
-
const sharedNotesType = useAppSelector(selectSharedNotesType);
|
|
183
182
|
const dispatch = useAppDispatch();
|
|
183
|
+
const { hasNonEmptyInstructions, hasSharedNotes } = usePedagoOptions();
|
|
184
184
|
|
|
185
185
|
const items: DocumentSelectorHzItem[] = useMemo(() => {
|
|
186
186
|
const allItems: DocumentSelectorHzItem[] = [];
|
|
187
|
-
if (mode === "create" ||
|
|
187
|
+
if (mode === "create" || hasNonEmptyInstructions) {
|
|
188
188
|
allItems.push({
|
|
189
189
|
name: "Consignes",
|
|
190
190
|
value: "instructions",
|
|
@@ -200,7 +200,7 @@ const HorizontalDocumentSelector = () => {
|
|
|
200
200
|
});
|
|
201
201
|
}
|
|
202
202
|
*/
|
|
203
|
-
if (mode === "create" ||
|
|
203
|
+
if (mode === "create" || hasSharedNotes) {
|
|
204
204
|
allItems.push({
|
|
205
205
|
name: "Notes partagées",
|
|
206
206
|
value: "sharedNotes",
|
|
@@ -208,7 +208,13 @@ const HorizontalDocumentSelector = () => {
|
|
|
208
208
|
});
|
|
209
209
|
}
|
|
210
210
|
return allItems;
|
|
211
|
-
}, []);
|
|
211
|
+
}, [mode, hasNonEmptyInstructions, hasSharedNotes]);
|
|
212
|
+
|
|
213
|
+
useEffect(() => {
|
|
214
|
+
if (pedagoTab === null && items.length > 0) {
|
|
215
|
+
dispatch(setPedagoTab(items[0].value));
|
|
216
|
+
}
|
|
217
|
+
}, [pedagoTab, items, dispatch]);
|
|
212
218
|
|
|
213
219
|
return (
|
|
214
220
|
<div className={styles.pedagoHorizontalTabMenu}>
|
|
@@ -259,10 +265,9 @@ const VerticalPedagoCommands = () => {
|
|
|
259
265
|
|
|
260
266
|
const VerticalDocumentSelector = () => {
|
|
261
267
|
const pedagoTab = useAppSelector(selectPedagoTab);
|
|
262
|
-
const instructionsType = useAppSelector(selectInstructionsType);
|
|
263
268
|
const mode = useAppSelector(selectMode);
|
|
264
269
|
// const pdfInstructions = useAppSelector(selectPdfInstructions);
|
|
265
|
-
const
|
|
270
|
+
const { hasNonEmptyInstructions, hasSharedNotes } = usePedagoOptions();
|
|
266
271
|
const dispatch = useAppDispatch();
|
|
267
272
|
|
|
268
273
|
const itemRenderer = useCallback(
|
|
@@ -280,7 +285,7 @@ const VerticalDocumentSelector = () => {
|
|
|
280
285
|
|
|
281
286
|
const items: DocumentSelectorItem[] = useMemo(() => {
|
|
282
287
|
const allItems: DocumentSelectorItem[] = [];
|
|
283
|
-
if (mode === "create" ||
|
|
288
|
+
if (mode === "create" || hasNonEmptyInstructions) {
|
|
284
289
|
allItems.push({
|
|
285
290
|
name: "Consignes",
|
|
286
291
|
value: "instructions",
|
|
@@ -298,7 +303,7 @@ const VerticalDocumentSelector = () => {
|
|
|
298
303
|
});
|
|
299
304
|
}
|
|
300
305
|
*/
|
|
301
|
-
if (mode === "create" ||
|
|
306
|
+
if (mode === "create" || hasSharedNotes) {
|
|
302
307
|
allItems.push({
|
|
303
308
|
name: "Notes partagées",
|
|
304
309
|
value: "sharedNotes",
|
|
@@ -307,9 +312,19 @@ const VerticalDocumentSelector = () => {
|
|
|
307
312
|
});
|
|
308
313
|
}
|
|
309
314
|
return allItems;
|
|
310
|
-
}, []);
|
|
315
|
+
}, [mode, hasNonEmptyInstructions, hasSharedNotes]);
|
|
316
|
+
|
|
317
|
+
useEffect(() => {
|
|
318
|
+
if (pedagoTab === null && items.length > 0) {
|
|
319
|
+
dispatch(setPedagoTab(items[0].value));
|
|
320
|
+
}
|
|
321
|
+
}, [pedagoTab, items, dispatch]);
|
|
322
|
+
|
|
311
323
|
const activeIndex = useMemo(() => {
|
|
312
324
|
const index = items.findIndex((item) => item.value === pedagoTab);
|
|
325
|
+
if (index === -1) {
|
|
326
|
+
return undefined;
|
|
327
|
+
}
|
|
313
328
|
return index;
|
|
314
329
|
}, [items, pedagoTab]);
|
|
315
330
|
|
|
@@ -84,7 +84,10 @@ export const usePedagoOptions = () => {
|
|
|
84
84
|
: hasNonEmptyInstructions || hasSharedNotes || hasGradingOrComments;
|
|
85
85
|
|
|
86
86
|
const showPedago =
|
|
87
|
-
isPedagoVisible ??
|
|
87
|
+
isPedagoVisible ??
|
|
88
|
+
(mode === "create"
|
|
89
|
+
? hasNonEmptyInstructions || hasSharedNotes || showPedagoByDefault
|
|
90
|
+
: hasPedago);
|
|
88
91
|
|
|
89
92
|
const showInstructions =
|
|
90
93
|
mode === "create" ? true : hasNonEmptyInstructions || hasSharedNotes;
|
|
@@ -59,7 +59,9 @@ const Pedago: React.FC<DivProps> = ({ className, ...props }) => {
|
|
|
59
59
|
? "Consignes"
|
|
60
60
|
: pedagoTab === "pdf"
|
|
61
61
|
? "PDF"
|
|
62
|
-
:
|
|
62
|
+
: pedagoTab === "sharedNotes"
|
|
63
|
+
? "Notes partagées"
|
|
64
|
+
: ""
|
|
63
65
|
}
|
|
64
66
|
data-grading-visible={showGrading}
|
|
65
67
|
>
|
|
@@ -68,6 +70,7 @@ const Pedago: React.FC<DivProps> = ({ className, ...props }) => {
|
|
|
68
70
|
{pedagoTab === "instructions" && <InstructionsEditor />}
|
|
69
71
|
{pedagoTab === "sharedNotes" && <SharedNotesEditor />}
|
|
70
72
|
{pedagoTab === "pdf" && <PdfEditor />}
|
|
73
|
+
{pedagoTab === null && <div />}
|
|
71
74
|
</>
|
|
72
75
|
)}
|
|
73
76
|
{showGrading && (
|
|
@@ -99,19 +102,24 @@ const Pedago: React.FC<DivProps> = ({ className, ...props }) => {
|
|
|
99
102
|
? "Consignes"
|
|
100
103
|
: pedagoTab === "pdf"
|
|
101
104
|
? "PDF"
|
|
102
|
-
:
|
|
105
|
+
: pedagoTab === "sharedNotes"
|
|
106
|
+
? "Notes partagées"
|
|
107
|
+
: ""
|
|
103
108
|
}
|
|
104
109
|
header={
|
|
105
110
|
pedagoTab === "instructions"
|
|
106
111
|
? "Consignes"
|
|
107
112
|
: pedagoTab === "pdf"
|
|
108
113
|
? "PDF"
|
|
109
|
-
:
|
|
114
|
+
: pedagoTab === "sharedNotes"
|
|
115
|
+
? "Notes partagées"
|
|
116
|
+
: ""
|
|
110
117
|
}
|
|
111
118
|
>
|
|
112
119
|
{pedagoTab === "instructions" && <InstructionsEditor />}
|
|
113
120
|
{pedagoTab === "sharedNotes" && <SharedNotesEditor />}
|
|
114
121
|
{pedagoTab === "pdf" && <PdfEditor />}
|
|
122
|
+
{pedagoTab === null && <div />}
|
|
115
123
|
</Panel>
|
|
116
124
|
</SplitterPanel>,
|
|
117
125
|
])}
|