@selfcommunity/react-ui 0.10.2-courses.173 → 0.10.2-courses.174
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/lib/cjs/components/EditCourse/Lessons/LessonRow.js +1 -1
- package/lib/cjs/components/EditCourse/Lessons/SectionRow.js +7 -6
- package/lib/cjs/components/EditCourse/Lessons.js +4 -2
- package/lib/cjs/components/LessonCommentObject/LessonCommentObject.js +1 -6
- package/lib/cjs/components/LessonCommentObjects/LessonCommentObjects.js +1 -2
- package/lib/esm/components/EditCourse/Lessons/LessonRow.js +1 -1
- package/lib/esm/components/EditCourse/Lessons/SectionRow.js +7 -6
- package/lib/esm/components/EditCourse/Lessons.js +4 -2
- package/lib/esm/components/LessonCommentObject/LessonCommentObject.js +1 -6
- package/lib/esm/components/LessonCommentObjects/LessonCommentObjects.js +1 -2
- package/lib/umd/react-ui.js +1 -1
- package/package.json +8 -8
|
@@ -45,7 +45,7 @@ function LessonRow(props) {
|
|
|
45
45
|
const { isDisabled } = (0, hooks_1.useDisabled)();
|
|
46
46
|
const { enqueueSnackbar } = (0, notistack_1.useSnackbar)();
|
|
47
47
|
// HANDLERS
|
|
48
|
-
const handleAbleEditMode = (0, react_1.useCallback)(() => setTimeout(() => setEditMode(true)
|
|
48
|
+
const handleAbleEditMode = (0, react_1.useCallback)(() => setTimeout(() => setEditMode(true)), [setEditMode]);
|
|
49
49
|
const handleDisableEditMode = (0, react_1.useCallback)(() => setEditMode(false), [setEditMode]);
|
|
50
50
|
const handleDeleteLesson = (0, react_1.useCallback)(() => {
|
|
51
51
|
api_services_1.CourseService.deleteCourseLesson(course.id, section.id, lesson.id)
|
|
@@ -60,6 +60,9 @@ function SectionRow(props) {
|
|
|
60
60
|
};
|
|
61
61
|
}, []);
|
|
62
62
|
// HANDLERS
|
|
63
|
+
const handleOpenDialog = (0, react_1.useCallback)(() => {
|
|
64
|
+
setOpen((prev) => !prev);
|
|
65
|
+
}, [setOpen]);
|
|
63
66
|
const handleExpandAccordion = (0, react_1.useCallback)(() => setExpand((prev) => !prev), [setExpand]);
|
|
64
67
|
const handleDragEnd = (0, react_1.useCallback)((e) => {
|
|
65
68
|
if (!e.destination || e.destination.index === e.source.index) {
|
|
@@ -90,7 +93,7 @@ function SectionRow(props) {
|
|
|
90
93
|
}, [course, section, handleManageSection]);
|
|
91
94
|
const handleAddTempLesson = (0, react_1.useCallback)(() => {
|
|
92
95
|
setLessons((prevLessons) => ((prevLessons === null || prevLessons === void 0 ? void 0 : prevLessons.length) > 0 ? [...prevLessons, getLesson(prevLessons.length + 1)] : [getLesson(1)]));
|
|
93
|
-
}, [setLessons]);
|
|
96
|
+
}, [setLessons, getLesson]);
|
|
94
97
|
const handleAbleEditMode = (0, react_1.useCallback)(() => setTimeout(() => setEditMode(true)), [setEditMode]);
|
|
95
98
|
const handleDisableEditMode = (0, react_1.useCallback)(() => setEditMode(false), [setEditMode]);
|
|
96
99
|
const handleDeleteSection = (0, react_1.useCallback)(() => {
|
|
@@ -99,6 +102,7 @@ function SectionRow(props) {
|
|
|
99
102
|
var _a;
|
|
100
103
|
const tempSection = Object.assign(Object.assign({}, section), { num_lessons: ((_a = section.lessons) === null || _a === void 0 ? void 0 : _a.length) || 0 });
|
|
101
104
|
handleManageSection(tempSection, types_2.ActionLessonType.DELETE);
|
|
105
|
+
handleOpenDialog();
|
|
102
106
|
enqueueSnackbar((0, jsx_runtime_1.jsx)(react_intl_1.FormattedMessage, { id: "ui.editCourse.tab.lessons.table.snackbar.delete", defaultMessage: "ui.editCourse.tab.lessons.table.snackbar.delete" }), {
|
|
103
107
|
variant: 'success',
|
|
104
108
|
autoHideDuration: 3000
|
|
@@ -111,7 +115,7 @@ function SectionRow(props) {
|
|
|
111
115
|
autoHideDuration: 3000
|
|
112
116
|
});
|
|
113
117
|
});
|
|
114
|
-
}, [course, section, handleManageSection]);
|
|
118
|
+
}, [course, section, handleManageSection, handleOpenDialog]);
|
|
115
119
|
const handleManageLesson = (0, react_1.useCallback)((lesson, type, newRow) => {
|
|
116
120
|
switch (type) {
|
|
117
121
|
case types_2.ActionLessonType.ADD: {
|
|
@@ -135,14 +139,11 @@ function SectionRow(props) {
|
|
|
135
139
|
}
|
|
136
140
|
}
|
|
137
141
|
}, [section, handleManageSection]);
|
|
138
|
-
const handleOpenDialog = (0, react_1.useCallback)(() => {
|
|
139
|
-
setOpen((prev) => !prev);
|
|
140
|
-
}, [setOpen]);
|
|
141
142
|
return ((0, jsx_runtime_1.jsxs)(react_1.Fragment, { children: [(0, jsx_runtime_1.jsxs)(material_1.TableRow, Object.assign({}, provider.draggableProps, { ref: provider.innerRef, className: classes.tableBodyAccordion }, { children: [(0, jsx_runtime_1.jsx)(material_1.TableCell, Object.assign({ component: "th", scope: "row" }, provider.dragHandleProps, { className: (0, classnames_1.default)(classes.cellWidth, classes.cellPadding) }, { children: (0, jsx_runtime_1.jsxs)(material_1.Stack, Object.assign({ className: classes.tableBodyIconWrapper }, { children: [(0, jsx_runtime_1.jsx)(material_1.IconButton, Object.assign({ "aria-label": "expand row", size: "small", onClick: handleExpandAccordion }, { children: expand ? (0, jsx_runtime_1.jsx)(material_1.Icon, { children: "expand_less" }) : (0, jsx_runtime_1.jsx)(material_1.Icon, { children: "expand_more" }) })), (0, jsx_runtime_1.jsx)(material_1.Icon, Object.assign({ color: "disabled" }, { children: "drag" }))] })) })), (0, jsx_runtime_1.jsx)(material_1.TableCell, { children: (0, jsx_runtime_1.jsx)(FieldName_1.default, { endpoint: {
|
|
142
143
|
url: () => isNewRow
|
|
143
144
|
? api_services_1.Endpoints.CreateCourseSection.url({ id: course.id })
|
|
144
145
|
: api_services_1.Endpoints.PatchCourseSection.url({ id: course.id, section_id: section.id }),
|
|
145
146
|
method: isNewRow ? api_services_1.Endpoints.CreateCourseSection.method : api_services_1.Endpoints.PatchCourseSection.method
|
|
146
|
-
}, row: section, isNewRow: isNewRow, handleManageRow: handleManageSection, editMode: editMode, handleDisableEditMode: handleDisableEditMode }) }), (0, jsx_runtime_1.jsx)(material_1.TableCell, Object.assign({ className: classes.cellAlignCenter }, { children: isDisabled ? ((0, jsx_runtime_1.jsx)(material_1.Skeleton, { animation: false, variant: "rectangular", width: "250px", height: "
|
|
147
|
+
}, row: section, isNewRow: isNewRow, handleManageRow: handleManageSection, editMode: editMode, handleDisableEditMode: handleDisableEditMode }) }), (0, jsx_runtime_1.jsx)(material_1.TableCell, Object.assign({ className: classes.cellAlignCenter }, { children: isDisabled ? ((0, jsx_runtime_1.jsx)(material_1.Skeleton, { animation: false, variant: "rectangular", width: "250px", height: "38px", sx: { margin: 'auto', borderRadius: '5px' } })) : ((0, jsx_runtime_1.jsx)(LessonReleaseMenu_1.default, { course: course, section: section })) })), (0, jsx_runtime_1.jsx)(material_1.TableCell, Object.assign({ className: classes.cellAlignRight }, { children: (0, jsx_runtime_1.jsxs)(material_1.Stack, Object.assign({ className: classes.actionsWrapper }, { children: [(0, jsx_runtime_1.jsx)(AddButton_1.default, { label: "ui.editCourse.tab.lessons.table.lesson", handleAddRow: handleAddTempLesson, color: "primary", variant: "outlined", disabled: isDisabled }), (0, jsx_runtime_1.jsxs)(MenuRow_1.default, Object.assign({ disabled: isDisabled }, { children: [(0, jsx_runtime_1.jsx)(material_1.MenuItem, Object.assign({ onClick: handleAbleEditMode }, { children: (0, jsx_runtime_1.jsx)(material_1.Typography, Object.assign({ variant: "body1" }, { children: (0, jsx_runtime_1.jsx)(react_intl_1.FormattedMessage, { id: "ui.editCourse.tab.lessons.table.menu.rename", defaultMessage: "ui.editCourse.tab.lessons.table.menu.rename" }) })) })), (0, jsx_runtime_1.jsx)(material_1.MenuItem, Object.assign({ onClick: handleOpenDialog }, { children: (0, jsx_runtime_1.jsx)(material_1.Typography, Object.assign({ variant: "body1" }, { children: (0, jsx_runtime_1.jsx)(react_intl_1.FormattedMessage, { id: "ui.editCourse.tab.lessons.table.menu.delete", defaultMessage: "ui.editCourse.tab.lessons.table.menu.delete" }) })) }))] }))] })) }))] })), (0, jsx_runtime_1.jsx)(material_1.TableRow, { children: (0, jsx_runtime_1.jsxs)(material_1.TableCell, Object.assign({ className: classes.tableBodyCollapseWrapper, colSpan: 4 }, { children: [(0, jsx_runtime_1.jsx)(material_1.Collapse, Object.assign({ in: expand, timeout: "auto", unmountOnExit: true }, { children: (0, jsx_runtime_1.jsx)(dnd_1.DragDropContext, Object.assign({ onDragEnd: handleDragEnd }, { children: (0, jsx_runtime_1.jsx)(material_1.Table, { children: (0, jsx_runtime_1.jsx)(dnd_1.Droppable, Object.assign({ droppableId: "droppable-2" }, { children: (outerProvider) => ((0, jsx_runtime_1.jsxs)(material_1.TableBody, Object.assign({ ref: outerProvider.innerRef }, outerProvider.droppableProps, { children: [lessons.map((lesson, i, array) => ((0, jsx_runtime_1.jsx)(dnd_1.Draggable, Object.assign({ draggableId: i.toString(), index: i, isDragDisabled: isDisabled }, { children: (innerProvider) => ((0, jsx_runtime_1.jsx)(LessonRow_1.default, { provider: innerProvider, course: course, section: section, lesson: lesson, isNewRow: isNewLocalRow && i + 1 === array.length, handleManageLesson: handleManageLesson }, i)) }), i))), outerProvider.placeholder] }))) })) }) })) })), open && (0, jsx_runtime_1.jsx)(ConfirmDialog_1.default, { open: true, onClose: handleOpenDialog, onConfirm: handleDeleteSection })] })) })] }));
|
|
147
148
|
}
|
|
148
149
|
exports.default = (0, react_1.memo)(SectionRow);
|
|
@@ -108,9 +108,11 @@ function Lessons(props) {
|
|
|
108
108
|
}, [setSections]);
|
|
109
109
|
const handleManageSection = (0, react_1.useCallback)((section, type, newRow = false) => {
|
|
110
110
|
switch (type) {
|
|
111
|
-
case types_1.ActionLessonType.ADD:
|
|
112
|
-
|
|
111
|
+
case types_1.ActionLessonType.ADD: {
|
|
112
|
+
const newSection = Object.assign(Object.assign({}, section), { lessons: [] });
|
|
113
|
+
setCourse(Object.assign(Object.assign({}, course), { num_sections: course.num_sections + 1, sections: [...course.sections, newSection] }));
|
|
113
114
|
break;
|
|
115
|
+
}
|
|
114
116
|
case types_1.ActionLessonType.RENAME:
|
|
115
117
|
setCourse(Object.assign(Object.assign({}, course), { sections: course.sections.map((prevSection) => {
|
|
116
118
|
if (prevSection.id === section.id) {
|
|
@@ -179,15 +179,10 @@ function LessonCommentObject(inProps) {
|
|
|
179
179
|
* @param comment
|
|
180
180
|
*/
|
|
181
181
|
function renderComment(comment) {
|
|
182
|
-
if (!scUserContext.user || (scUserContext.user && !react_core_1.UserUtils.isStaff(scUserContext.user) && scUserContext.user.id !== comment.created_by.id)) {
|
|
183
|
-
// render the comment if user is logged and is staff (admin, moderator)
|
|
184
|
-
// or the comment author is the logged user
|
|
185
|
-
return null;
|
|
186
|
-
}
|
|
187
182
|
const summaryHtml = (0, contribution_1.getCommentContributionHtml)(comment.html, scRoutingContext.url);
|
|
188
183
|
return ((0, jsx_runtime_1.jsx)(react_1.default.Fragment, { children: editComment && editComment.id === comment.id ? ((0, jsx_runtime_1.jsx)(material_1.Box, Object.assign({ className: classes.comment }, { children: (0, jsx_runtime_1.jsx)(CommentObjectReply_1.default, Object.assign({ text: comment.html, medias: comment.medias, autoFocus: true, id: `edit-${comment.id}`, onSave: handleUpdate, onCancel: handleCancel, editable: !isSavingComment, EditorProps: { uploadFile: true, uploadImage: false } }, CommentObjectReplyProps)) }))) : ((0, jsx_runtime_1.jsx)(BaseItem_1.default, { elevation: 0, className: classes.comment, image: (0, jsx_runtime_1.jsx)(react_core_1.Link, Object.assign({}, (!comment.created_by.deleted && { to: scRoutingContext.url(react_core_1.SCRoutes.USER_PROFILE_ROUTE_NAME, comment.created_by) }), { onClick: comment.created_by.deleted ? () => setOpenAlert(true) : null }, { children: (0, jsx_runtime_1.jsx)(UserAvatar_1.default, Object.assign({ hide: !obj.created_by.community_badge }, { children: (0, jsx_runtime_1.jsx)(material_1.Avatar, { alt: obj.created_by.username, variant: "circular", src: comment.created_by.avatar, className: classes.avatar }) })) })), disableTypography: true, primary: (0, jsx_runtime_1.jsx)(jsx_runtime_1.Fragment, { children: (0, jsx_runtime_1.jsxs)(Widget_1.default, Object.assign({ className: classes.content, elevation: elevation }, rest, { children: [(0, jsx_runtime_1.jsxs)(material_1.CardContent, { children: [(0, jsx_runtime_1.jsx)(react_core_1.Link, Object.assign({ className: classes.author }, (!comment.created_by.deleted && { to: scRoutingContext.url(react_core_1.SCRoutes.USER_PROFILE_ROUTE_NAME, comment.created_by) }), { onClick: comment.created_by.deleted ? () => setOpenAlert(true) : null }, { children: (0, jsx_runtime_1.jsx)(material_1.Typography, Object.assign({ component: "span" }, { children: comment.created_by.username })) })), (0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsx)(Bullet_1.default, {}), (0, jsx_runtime_1.jsx)(DateTimeAgo_1.default, { date: comment.created_at, showStartIcon: false })] }), (0, jsx_runtime_1.jsx)(material_1.Typography, { className: classes.textContent, variant: "body2", gutterBottom: true, dangerouslySetInnerHTML: { __html: summaryHtml } }), obj.medias && obj.medias.length > 0 && ((0, jsx_runtime_1.jsx)(jsx_runtime_1.Fragment, { children: obj.medias.map((media) => {
|
|
189
184
|
return (0, jsx_runtime_1.jsx)(LessonFilePreview_1.default, { className: classes.mediaContent, media: media }, media.id);
|
|
190
|
-
}) }))] }), scUserContext.user && ((0, jsx_runtime_1.jsx)(material_1.Box, Object.assign({ className: classes.commentActionsMenu }, { children: (0, jsx_runtime_1.jsx)(LessonCommentActionsMenu_1.default, { lesson: lessonObject, commentObject: comment, onDelete: handleDelete, onEdit: handleEdit }) })))] })) }) })) }, comment.id));
|
|
185
|
+
}) }))] }), scUserContext.user && scUserContext.user.id === comment.created_by.id && ((0, jsx_runtime_1.jsx)(material_1.Box, Object.assign({ className: classes.commentActionsMenu }, { children: (0, jsx_runtime_1.jsx)(LessonCommentActionsMenu_1.default, { lesson: lessonObject, commentObject: comment, onDelete: handleDelete, onEdit: handleEdit }) })))] })) }) })) }, comment.id));
|
|
191
186
|
}
|
|
192
187
|
/**
|
|
193
188
|
* Render comments
|
|
@@ -88,7 +88,7 @@ function LessonCommentObjects(inProps) {
|
|
|
88
88
|
id: lessonObject.id,
|
|
89
89
|
lessonObject: lessonObject,
|
|
90
90
|
pageSize: 8,
|
|
91
|
-
orderBy: types_1.SCCommentsOrderBy.
|
|
91
|
+
orderBy: types_1.SCCommentsOrderBy.ADDED_AT_ASC,
|
|
92
92
|
cacheStrategy
|
|
93
93
|
});
|
|
94
94
|
// EFFECTS
|
|
@@ -165,7 +165,6 @@ function LessonCommentObjects(inProps) {
|
|
|
165
165
|
}
|
|
166
166
|
commentsObject.updateLessonComments([...updated]);
|
|
167
167
|
};
|
|
168
|
-
console.log(commentsObject.isLoadingNext);
|
|
169
168
|
/**
|
|
170
169
|
* Renders root object(if obj)
|
|
171
170
|
*/
|
|
@@ -42,7 +42,7 @@ function LessonRow(props) {
|
|
|
42
42
|
const { isDisabled } = useDisabled();
|
|
43
43
|
const { enqueueSnackbar } = useSnackbar();
|
|
44
44
|
// HANDLERS
|
|
45
|
-
const handleAbleEditMode = useCallback(() => setTimeout(() => setEditMode(true)
|
|
45
|
+
const handleAbleEditMode = useCallback(() => setTimeout(() => setEditMode(true)), [setEditMode]);
|
|
46
46
|
const handleDisableEditMode = useCallback(() => setEditMode(false), [setEditMode]);
|
|
47
47
|
const handleDeleteLesson = useCallback(() => {
|
|
48
48
|
CourseService.deleteCourseLesson(course.id, section.id, lesson.id)
|
|
@@ -57,6 +57,9 @@ function SectionRow(props) {
|
|
|
57
57
|
};
|
|
58
58
|
}, []);
|
|
59
59
|
// HANDLERS
|
|
60
|
+
const handleOpenDialog = useCallback(() => {
|
|
61
|
+
setOpen((prev) => !prev);
|
|
62
|
+
}, [setOpen]);
|
|
60
63
|
const handleExpandAccordion = useCallback(() => setExpand((prev) => !prev), [setExpand]);
|
|
61
64
|
const handleDragEnd = useCallback((e) => {
|
|
62
65
|
if (!e.destination || e.destination.index === e.source.index) {
|
|
@@ -87,7 +90,7 @@ function SectionRow(props) {
|
|
|
87
90
|
}, [course, section, handleManageSection]);
|
|
88
91
|
const handleAddTempLesson = useCallback(() => {
|
|
89
92
|
setLessons((prevLessons) => ((prevLessons === null || prevLessons === void 0 ? void 0 : prevLessons.length) > 0 ? [...prevLessons, getLesson(prevLessons.length + 1)] : [getLesson(1)]));
|
|
90
|
-
}, [setLessons]);
|
|
93
|
+
}, [setLessons, getLesson]);
|
|
91
94
|
const handleAbleEditMode = useCallback(() => setTimeout(() => setEditMode(true)), [setEditMode]);
|
|
92
95
|
const handleDisableEditMode = useCallback(() => setEditMode(false), [setEditMode]);
|
|
93
96
|
const handleDeleteSection = useCallback(() => {
|
|
@@ -96,6 +99,7 @@ function SectionRow(props) {
|
|
|
96
99
|
var _a;
|
|
97
100
|
const tempSection = Object.assign(Object.assign({}, section), { num_lessons: ((_a = section.lessons) === null || _a === void 0 ? void 0 : _a.length) || 0 });
|
|
98
101
|
handleManageSection(tempSection, ActionLessonType.DELETE);
|
|
102
|
+
handleOpenDialog();
|
|
99
103
|
enqueueSnackbar(_jsx(FormattedMessage, { id: "ui.editCourse.tab.lessons.table.snackbar.delete", defaultMessage: "ui.editCourse.tab.lessons.table.snackbar.delete" }), {
|
|
100
104
|
variant: 'success',
|
|
101
105
|
autoHideDuration: 3000
|
|
@@ -108,7 +112,7 @@ function SectionRow(props) {
|
|
|
108
112
|
autoHideDuration: 3000
|
|
109
113
|
});
|
|
110
114
|
});
|
|
111
|
-
}, [course, section, handleManageSection]);
|
|
115
|
+
}, [course, section, handleManageSection, handleOpenDialog]);
|
|
112
116
|
const handleManageLesson = useCallback((lesson, type, newRow) => {
|
|
113
117
|
switch (type) {
|
|
114
118
|
case ActionLessonType.ADD: {
|
|
@@ -132,14 +136,11 @@ function SectionRow(props) {
|
|
|
132
136
|
}
|
|
133
137
|
}
|
|
134
138
|
}, [section, handleManageSection]);
|
|
135
|
-
const handleOpenDialog = useCallback(() => {
|
|
136
|
-
setOpen((prev) => !prev);
|
|
137
|
-
}, [setOpen]);
|
|
138
139
|
return (_jsxs(Fragment, { children: [_jsxs(TableRow, Object.assign({}, provider.draggableProps, { ref: provider.innerRef, className: classes.tableBodyAccordion }, { children: [_jsx(TableCell, Object.assign({ component: "th", scope: "row" }, provider.dragHandleProps, { className: classNames(classes.cellWidth, classes.cellPadding) }, { children: _jsxs(Stack, Object.assign({ className: classes.tableBodyIconWrapper }, { children: [_jsx(IconButton, Object.assign({ "aria-label": "expand row", size: "small", onClick: handleExpandAccordion }, { children: expand ? _jsx(Icon, { children: "expand_less" }) : _jsx(Icon, { children: "expand_more" }) })), _jsx(Icon, Object.assign({ color: "disabled" }, { children: "drag" }))] })) })), _jsx(TableCell, { children: _jsx(FieldName, { endpoint: {
|
|
139
140
|
url: () => isNewRow
|
|
140
141
|
? Endpoints.CreateCourseSection.url({ id: course.id })
|
|
141
142
|
: Endpoints.PatchCourseSection.url({ id: course.id, section_id: section.id }),
|
|
142
143
|
method: isNewRow ? Endpoints.CreateCourseSection.method : Endpoints.PatchCourseSection.method
|
|
143
|
-
}, row: section, isNewRow: isNewRow, handleManageRow: handleManageSection, editMode: editMode, handleDisableEditMode: handleDisableEditMode }) }), _jsx(TableCell, Object.assign({ className: classes.cellAlignCenter }, { children: isDisabled ? (_jsx(Skeleton, { animation: false, variant: "rectangular", width: "250px", height: "
|
|
144
|
+
}, row: section, isNewRow: isNewRow, handleManageRow: handleManageSection, editMode: editMode, handleDisableEditMode: handleDisableEditMode }) }), _jsx(TableCell, Object.assign({ className: classes.cellAlignCenter }, { children: isDisabled ? (_jsx(Skeleton, { animation: false, variant: "rectangular", width: "250px", height: "38px", sx: { margin: 'auto', borderRadius: '5px' } })) : (_jsx(LessonReleaseMenu, { course: course, section: section })) })), _jsx(TableCell, Object.assign({ className: classes.cellAlignRight }, { children: _jsxs(Stack, Object.assign({ className: classes.actionsWrapper }, { children: [_jsx(AddButton, { label: "ui.editCourse.tab.lessons.table.lesson", handleAddRow: handleAddTempLesson, color: "primary", variant: "outlined", disabled: isDisabled }), _jsxs(MenuRow, Object.assign({ disabled: isDisabled }, { children: [_jsx(MenuItem, Object.assign({ onClick: handleAbleEditMode }, { children: _jsx(Typography, Object.assign({ variant: "body1" }, { children: _jsx(FormattedMessage, { id: "ui.editCourse.tab.lessons.table.menu.rename", defaultMessage: "ui.editCourse.tab.lessons.table.menu.rename" }) })) })), _jsx(MenuItem, Object.assign({ onClick: handleOpenDialog }, { children: _jsx(Typography, Object.assign({ variant: "body1" }, { children: _jsx(FormattedMessage, { id: "ui.editCourse.tab.lessons.table.menu.delete", defaultMessage: "ui.editCourse.tab.lessons.table.menu.delete" }) })) }))] }))] })) }))] })), _jsx(TableRow, { children: _jsxs(TableCell, Object.assign({ className: classes.tableBodyCollapseWrapper, colSpan: 4 }, { children: [_jsx(Collapse, Object.assign({ in: expand, timeout: "auto", unmountOnExit: true }, { children: _jsx(DragDropContext, Object.assign({ onDragEnd: handleDragEnd }, { children: _jsx(Table, { children: _jsx(Droppable, Object.assign({ droppableId: "droppable-2" }, { children: (outerProvider) => (_jsxs(TableBody, Object.assign({ ref: outerProvider.innerRef }, outerProvider.droppableProps, { children: [lessons.map((lesson, i, array) => (_jsx(Draggable, Object.assign({ draggableId: i.toString(), index: i, isDragDisabled: isDisabled }, { children: (innerProvider) => (_jsx(LessonRow, { provider: innerProvider, course: course, section: section, lesson: lesson, isNewRow: isNewLocalRow && i + 1 === array.length, handleManageLesson: handleManageLesson }, i)) }), i))), outerProvider.placeholder] }))) })) }) })) })), open && _jsx(ConfirmDialog, { open: true, onClose: handleOpenDialog, onConfirm: handleDeleteSection })] })) })] }));
|
|
144
145
|
}
|
|
145
146
|
export default memo(SectionRow);
|
|
@@ -105,9 +105,11 @@ function Lessons(props) {
|
|
|
105
105
|
}, [setSections]);
|
|
106
106
|
const handleManageSection = useCallback((section, type, newRow = false) => {
|
|
107
107
|
switch (type) {
|
|
108
|
-
case ActionLessonType.ADD:
|
|
109
|
-
|
|
108
|
+
case ActionLessonType.ADD: {
|
|
109
|
+
const newSection = Object.assign(Object.assign({}, section), { lessons: [] });
|
|
110
|
+
setCourse(Object.assign(Object.assign({}, course), { num_sections: course.num_sections + 1, sections: [...course.sections, newSection] }));
|
|
110
111
|
break;
|
|
112
|
+
}
|
|
111
113
|
case ActionLessonType.RENAME:
|
|
112
114
|
setCourse(Object.assign(Object.assign({}, course), { sections: course.sections.map((prevSection) => {
|
|
113
115
|
if (prevSection.id === section.id) {
|
|
@@ -177,15 +177,10 @@ export default function LessonCommentObject(inProps) {
|
|
|
177
177
|
* @param comment
|
|
178
178
|
*/
|
|
179
179
|
function renderComment(comment) {
|
|
180
|
-
if (!scUserContext.user || (scUserContext.user && !UserUtils.isStaff(scUserContext.user) && scUserContext.user.id !== comment.created_by.id)) {
|
|
181
|
-
// render the comment if user is logged and is staff (admin, moderator)
|
|
182
|
-
// or the comment author is the logged user
|
|
183
|
-
return null;
|
|
184
|
-
}
|
|
185
180
|
const summaryHtml = getCommentContributionHtml(comment.html, scRoutingContext.url);
|
|
186
181
|
return (_jsx(React.Fragment, { children: editComment && editComment.id === comment.id ? (_jsx(Box, Object.assign({ className: classes.comment }, { children: _jsx(CommentObjectReply, Object.assign({ text: comment.html, medias: comment.medias, autoFocus: true, id: `edit-${comment.id}`, onSave: handleUpdate, onCancel: handleCancel, editable: !isSavingComment, EditorProps: { uploadFile: true, uploadImage: false } }, CommentObjectReplyProps)) }))) : (_jsx(BaseItem, { elevation: 0, className: classes.comment, image: _jsx(Link, Object.assign({}, (!comment.created_by.deleted && { to: scRoutingContext.url(SCRoutes.USER_PROFILE_ROUTE_NAME, comment.created_by) }), { onClick: comment.created_by.deleted ? () => setOpenAlert(true) : null }, { children: _jsx(UserAvatar, Object.assign({ hide: !obj.created_by.community_badge }, { children: _jsx(Avatar, { alt: obj.created_by.username, variant: "circular", src: comment.created_by.avatar, className: classes.avatar }) })) })), disableTypography: true, primary: _jsx(_Fragment, { children: _jsxs(Widget, Object.assign({ className: classes.content, elevation: elevation }, rest, { children: [_jsxs(CardContent, { children: [_jsx(Link, Object.assign({ className: classes.author }, (!comment.created_by.deleted && { to: scRoutingContext.url(SCRoutes.USER_PROFILE_ROUTE_NAME, comment.created_by) }), { onClick: comment.created_by.deleted ? () => setOpenAlert(true) : null }, { children: _jsx(Typography, Object.assign({ component: "span" }, { children: comment.created_by.username })) })), _jsxs(_Fragment, { children: [_jsx(Bullet, {}), _jsx(DateTimeAgo, { date: comment.created_at, showStartIcon: false })] }), _jsx(Typography, { className: classes.textContent, variant: "body2", gutterBottom: true, dangerouslySetInnerHTML: { __html: summaryHtml } }), obj.medias && obj.medias.length > 0 && (_jsx(_Fragment, { children: obj.medias.map((media) => {
|
|
187
182
|
return _jsx(LessonFilePreview, { className: classes.mediaContent, media: media }, media.id);
|
|
188
|
-
}) }))] }), scUserContext.user && (_jsx(Box, Object.assign({ className: classes.commentActionsMenu }, { children: _jsx(LessonCommentActionsMenu, { lesson: lessonObject, commentObject: comment, onDelete: handleDelete, onEdit: handleEdit }) })))] })) }) })) }, comment.id));
|
|
183
|
+
}) }))] }), scUserContext.user && scUserContext.user.id === comment.created_by.id && (_jsx(Box, Object.assign({ className: classes.commentActionsMenu }, { children: _jsx(LessonCommentActionsMenu, { lesson: lessonObject, commentObject: comment, onDelete: handleDelete, onEdit: handleEdit }) })))] })) }) })) }, comment.id));
|
|
189
184
|
}
|
|
190
185
|
/**
|
|
191
186
|
* Render comments
|
|
@@ -86,7 +86,7 @@ export default function LessonCommentObjects(inProps) {
|
|
|
86
86
|
id: lessonObject.id,
|
|
87
87
|
lessonObject: lessonObject,
|
|
88
88
|
pageSize: 8,
|
|
89
|
-
orderBy: SCCommentsOrderBy.
|
|
89
|
+
orderBy: SCCommentsOrderBy.ADDED_AT_ASC,
|
|
90
90
|
cacheStrategy
|
|
91
91
|
});
|
|
92
92
|
// EFFECTS
|
|
@@ -163,7 +163,6 @@ export default function LessonCommentObjects(inProps) {
|
|
|
163
163
|
}
|
|
164
164
|
commentsObject.updateLessonComments([...updated]);
|
|
165
165
|
};
|
|
166
|
-
console.log(commentsObject.isLoadingNext);
|
|
167
166
|
/**
|
|
168
167
|
* Renders root object(if obj)
|
|
169
168
|
*/
|