добавление ноды через меню выбора по клику по ноде
This commit is contained in:
parent
89f2140715
commit
4623dfd2ee
@ -125,15 +125,17 @@ export const CsComponent = ({
|
|||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (modalQuestionTargetContentId.length !== 0 && modalQuestionParentContentId.length !== 0) {
|
if (modalQuestionTargetContentId.length !== 0 && modalQuestionParentContentId.length !== 0) {
|
||||||
console.log("был выбран вопрос " + modalQuestionTargetContentId)
|
console.log("был выбран вопрос " + modalQuestionTargetContentId)
|
||||||
|
addNode({ parentNodeContentId:modalQuestionParentContentId, targetNodeContentId:modalQuestionTargetContentId })
|
||||||
}
|
}
|
||||||
|
|
||||||
}, [modalQuestionTargetContentId])
|
}, [modalQuestionTargetContentId])
|
||||||
|
|
||||||
const addNode = ({ parentNodeContentId }: { parentNodeContentId: string }) => {
|
const addNode = ({ parentNodeContentId, targetNodeContentId }: { parentNodeContentId: string, targetNodeContentId?: string }) => {
|
||||||
console.log("dragQuestionContentId " + dragQuestionContentId)
|
console.log("dragQuestionContentId " + dragQuestionContentId)
|
||||||
const cy = cyRef?.current
|
const cy = cyRef?.current
|
||||||
const parentNodeChildren = cy?.$('edge[source = "' + parentNodeContentId + '"]')?.length
|
const parentNodeChildren = cy?.$('edge[source = "' + parentNodeContentId + '"]')?.length
|
||||||
const targetQuestion = { ...getQuestionByContentId(dragQuestionContentId) } as AnyQuizQuestion
|
//если есть инфо о выбранном вопросе из модалки - берём родителя из инфо модалки. Иначе из значения дропа
|
||||||
|
const targetQuestion = { ...getQuestionByContentId(targetNodeContentId || dragQuestionContentId) } as AnyQuizQuestion
|
||||||
|
|
||||||
if (Object.keys(targetQuestion).length !== 0 && Object.keys(targetQuestion).length !== 0 && parentNodeContentId && parentNodeChildren !== undefined) {
|
if (Object.keys(targetQuestion).length !== 0 && Object.keys(targetQuestion).length !== 0 && parentNodeContentId && parentNodeChildren !== undefined) {
|
||||||
clearDataAfterAddNode({ parentNodeContentId, targetQuestion, parentNodeChildren })
|
clearDataAfterAddNode({ parentNodeContentId, targetQuestion, parentNodeChildren })
|
||||||
@ -274,8 +276,6 @@ export const CsComponent = ({
|
|||||||
}, [startRemove]);
|
}, [startRemove]);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
const readyLO = (e) => {
|
const readyLO = (e) => {
|
||||||
e.cy.data('changed', false)
|
e.cy.data('changed', false)
|
||||||
//удаляем иконки
|
//удаляем иконки
|
||||||
@ -473,10 +473,10 @@ export const CsComponent = ({
|
|||||||
layoutElement.classList.add("popper-layout");
|
layoutElement.classList.add("popper-layout");
|
||||||
layoutElement.setAttribute("data-id", item.id());
|
layoutElement.setAttribute("data-id", item.id());
|
||||||
layoutElement.addEventListener("mouseup", () => {
|
layoutElement.addEventListener("mouseup", () => {
|
||||||
alert("layout")
|
//Узнаём грани, идущие от этой ноды
|
||||||
}
|
setModalQuestionParentContentId(item.id())
|
||||||
// setStartCreate(node.id())
|
setOpenedModalQuestions(true)
|
||||||
);
|
});
|
||||||
layoutsContainer.current?.appendChild(layoutElement);
|
layoutsContainer.current?.appendChild(layoutElement);
|
||||||
|
|
||||||
return layoutElement;
|
return layoutElement;
|
||||||
@ -504,6 +504,7 @@ export const CsComponent = ({
|
|||||||
plusElement.addEventListener("mouseup", () => {
|
plusElement.addEventListener("mouseup", () => {
|
||||||
setStartCreate(node.id());
|
setStartCreate(node.id());
|
||||||
});
|
});
|
||||||
|
|
||||||
plusesContainer.current?.appendChild(plusElement);
|
plusesContainer.current?.appendChild(plusElement);
|
||||||
|
|
||||||
return plusElement;
|
return plusElement;
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user