Skip to content

Commit

Permalink
Carousel and Portfolio Editor Fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
kevincharles committed Mar 30, 2023
1 parent 3b62254 commit 9cfc72a
Show file tree
Hide file tree
Showing 9 changed files with 192 additions and 147 deletions.
3 changes: 1 addition & 2 deletions public/api/getPortfolioActivityData.php
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,6 @@
FROM course_content
WHERE doenetId = '$doenetId'
";
$temp = $sql;
$result = $conn->query($sql);

if ($result->num_rows > 0) {
Expand Down Expand Up @@ -100,6 +99,7 @@
'public' => $row['isPublic'],
'isNew' => false,
'pageDoenetId' => $pageDoenetId,
'courseId' => $courseId,
];
} else {
$success = false;
Expand All @@ -112,7 +112,6 @@
'success' => $success,
'message' => $message,
'activityData' => $activityData,
'temp' => $temp,
];

http_response_code(200);
Expand Down
11 changes: 3 additions & 8 deletions src/Tools/_framework/HeaderControls/PortfolioBreadCrumb.jsx
Original file line number Diff line number Diff line change
@@ -1,17 +1,12 @@
import React, { Suspense } from 'react';
import { useNavigate } from 'react-router';
import { useRecoilValue } from 'recoil';
import { courseIdAtom, itemByDoenetId } from '../../../_reactComponents/Course/CourseActions';
import { useLoaderData, useNavigate } from 'react-router';
import { BreadCrumb } from '../../../_reactComponents/PanelHeaderComponents/BreadCrumb';
import { searchParamAtomFamily } from '../NewToolRoot';


export default function PortfolioBreadCrumb() {
const navigate = useNavigate();
const courseId = useRecoilValue(courseIdAtom);
const doenetId = useRecoilValue(searchParamAtomFamily('doenetId'));
const activityObj = useRecoilValue(itemByDoenetId(doenetId));
let { label } = activityObj;
let data = useLoaderData();
const { label, courseId } = data;

return (
<Suspense fallback={<div>Loading Breadcrumb...</div>}>
Expand Down
14 changes: 2 additions & 12 deletions src/Tools/_framework/MenuPanelCaps/PortfilioEditorInfoCap.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,8 @@ import { Box, Image } from '@chakra-ui/react';
import React from 'react';
import { useLoaderData } from 'react-router';

export async function loader(){
// export async function loader({params}){
// let params = new URL(document.location).searchParams;
// let search = new URL(document.location).search;
// console.log("search",search)
// let doenetId = params.get("doenetId");
let afterDoenetId = document.location.href?.split('&doenetId=')[1];
let doenetId = afterDoenetId?.split('&pageId=')[0];
//Somehow it still has the url which got us here
if (doenetId == undefined){
doenetId = document.location.href?.split('/')[4];
}
export async function loader({params}){
const doenetId = params.doenetId;
const response = await fetch(`/api/getPortfolioActivityData.php?doenetId=${doenetId}`);
const data = await response.json();

Expand Down
3 changes: 2 additions & 1 deletion src/Tools/_framework/NewToolRoot.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -990,7 +990,8 @@ function RootController(props) {
let isURLChange = false;
if (locationStr !== lastLocationStr.current) {
isURLChange = true;
nextPageToolView.page = location.pathname.replaceAll('/', '').toLowerCase();
// nextPageToolView.page = location.pathname.replaceAll('/', '').toLowerCase();
nextPageToolView.page = location.pathname.split('/')[1].toLowerCase(); //Needed this for portfolio editor
if (nextPageToolView.page === '') {
nextPageToolView.page = 'home';
const url = window.location.origin + window.location.pathname + 'home';
Expand Down
2 changes: 1 addition & 1 deletion src/Tools/_framework/Paths/Portfolio.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ function Card({
const { compileActivity, updateAssignItem } = useCourse(courseId);

// const activityLink = `/portfolio/${doenetId}/editor`;
const activityLink = `/portfolioeditor?tool=editor&doenetId=${doenetId}&pageId=${pageDoenetId}`;
const activityLink = `/portfolioeditor/${doenetId}?tool=editor&doenetId=${doenetId}&pageId=${pageDoenetId}`;



Expand Down
7 changes: 6 additions & 1 deletion src/Tools/_framework/ToolPanels/DoenetMLEditor.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,13 @@ import CodeMirror from '../CodeMirror';
import { courseIdAtom } from '../../../_reactComponents/Course/CourseActions';
import { useSaveDraft } from '../../../_utils/hooks/useSaveDraft'
import { editorPageIdInitAtom, textEditorDoenetMLAtom, updateTextEditorDoenetMLAtom, viewerDoenetMLAtom } from '../../../_sharedRecoil/EditorViewerRecoil';
import { useLoaderData } from 'react-router';


export default function DoenetMLEditor() {
// console.log(">>>===DoenetMLEditor")
let data = useLoaderData();
const loaderPageId = data?.pageDoenetId;

// const [editorDoenetML,setEditorDoenetML] = useRecoilState(textEditorDoenetMLAtom);
const setEditorDoenetML = useSetRecoilState(textEditorDoenetMLAtom);
Expand All @@ -26,6 +29,9 @@ export default function DoenetMLEditor() {
readOnly = true;
effectivePageId = paramlinkPageId
}
if (loaderPageId){
effectivePageId = loaderPageId;
}
const courseId = useRecoilValue(courseIdAtom)

const initializedPageId = useRecoilValue(editorPageIdInitAtom);
Expand Down Expand Up @@ -68,7 +74,6 @@ export default function DoenetMLEditor() {
}
}, [viewerDoenetML])


if (effectivePageId !== initializedPageId) {
//DoenetML is changing to another PageId
backupOldDraft.current = true;
Expand Down
10 changes: 8 additions & 2 deletions src/Tools/_framework/ToolPanels/EditorViewer.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import { profileAtom, searchParamAtomFamily, suppressMenusAtom } from '../NewToo
import { itemByDoenetId, courseIdAtom, useInitCourseItems, useSetCourseIdFromDoenetId } from '../../../_reactComponents/Course/CourseActions';
import { editorPageIdInitAtom, editorViewerErrorStateAtom, refreshNumberAtom, textEditorDoenetMLAtom, updateTextEditorDoenetMLAtom, viewerDoenetMLAtom } from '../../../_sharedRecoil/EditorViewerRecoil';
import axios from 'axios';
import { useLocation } from 'react-router';
import { useLoaderData, useLocation } from 'react-router';
import { pageVariantInfoAtom, pageVariantPanelAtom } from '../../../_sharedRecoil/PageViewerRecoil';

export const useUpdateViewer = () => {
Expand All @@ -35,6 +35,9 @@ export default function EditorViewer() {
// let refreshCount = useRef(1);
// console.log(">>>>===EditorViewer",refreshCount.current)
// refreshCount.current++;
let data = useLoaderData();
const loaderDoenetId = data?.doenetId;
const loaderPageId = data?.pageDoenetId;
const viewerDoenetML = useRecoilValue(viewerDoenetMLAtom);
const paramPageId = useRecoilValue(searchParamAtomFamily('pageId'))
const paramlinkPageId = useRecoilValue(searchParamAtomFamily('linkPageId'))
Expand All @@ -45,6 +48,10 @@ export default function EditorViewer() {
effectivePageId = paramlinkPageId;
effectiveDoenetId = paramlinkPageId;
}
if (loaderDoenetId){
effectivePageId = loaderPageId;
effectiveDoenetId = loaderDoenetId;
}
const courseId = useRecoilValue(courseIdAtom)
const initializedPageId = useRecoilValue(editorPageIdInitAtom);
const [variantInfo, setVariantInfo] = useRecoilState(pageVariantInfoAtom);
Expand Down Expand Up @@ -103,7 +110,6 @@ export default function EditorViewer() {
// response = response.data;
// }
// const doenetML = response;
// console.log("initDoenetML doenetML",doenetML)

set(updateTextEditorDoenetMLAtom, doenetML);
set(textEditorDoenetMLAtom, doenetML)
Expand Down
Loading

0 comments on commit 9cfc72a

Please sign in to comment.