diff --git a/Projects/Superalgos/UI/Spaces/Tutorial-Space/TutorialSpace.js b/Projects/Superalgos/UI/Spaces/Tutorial-Space/TutorialSpace.js index 76926be02..61bbbd296 100644 --- a/Projects/Superalgos/UI/Spaces/Tutorial-Space/TutorialSpace.js +++ b/Projects/Superalgos/UI/Spaces/Tutorial-Space/TutorialSpace.js @@ -1162,7 +1162,7 @@ function newSuperalgosTutorialSpace() { /* TITLE and SUBTITLE HANDLING */ - if (nodeConfig.title !== undefined && nodeConfig.title !== "") { + if (nodeConfig.title !== undefined && nodeConfig.title !== "") { template.type = currentNode.type + ' - ' + nodeConfig.title if (nodeConfig.subTitle !== undefined && nodeConfig.subTitle !== '') { @@ -1211,7 +1211,7 @@ function newSuperalgosTutorialSpace() { template.paragraphs.push(paragraph) } - if (nodeConfig.externalLink !== undefined && nodeConfig.externalLink[0] !== "" && nodeConfig.externalLink[1] !== "") { + if (nodeConfig.externalLink !== undefined && nodeConfig.externalLink[0] !== "" && nodeConfig.externalLink[1] !== "") { let paragraph = { style: 'Link', text: nodeConfig.externalLink[0] + '->' + nodeConfig.externalLink[1] @@ -1273,7 +1273,7 @@ function newSuperalgosTutorialSpace() { } SCHEMAS_BY_PROJECT.get(project).array.docsTutorialSchema.push(template) - SCHEMAS_BY_PROJECT.get(project).map.docsTutorialSchema.set(template.type, template) + UI.projects.superalgos.spaces.docsSpace.navigateTo(project, 'Tutorial', template.type) /* Here we will store the keys to access the Content from the Docs */ @@ -1326,83 +1326,150 @@ function newSuperalgosTutorialSpace() { let nodeConfig = JSON.parse(currentNode.config) - if (nodeConfig.docs !== undefined) { return } // TODO Added this + if (nodeConfig.docs === undefined) { return } + + let schemaDocument = SCHEMAS_BY_PROJECT.get(project).map.docsTutorialSchema.get(nodeConfig.docs.type) + let infoToRender = {} + + transformDocsInfoIntoTutorialInfo() + + function transformDocsInfoIntoTutorialInfo() { + if (schemaDocument === undefined) { + infoToRender.subTitle = "Configuration Error" + infoToRender.warning = "The configured Docs reference does not point to any page. Correct that to see here the page contents." + return + } + + let splittedType = nodeConfig.docs.type.split(' - ') + infoToRender.subTitle = getTextFromParagraphStyle('Title') + if (infoToRender.subTitle === undefined) { + infoToRender.subTitle = splittedType[1] + } else { + infoToRender.title = splittedType[1] + } + + infoToRender.summary = getTextFromParagraphStyle('Summary') + infoToRender.gif = getTextFromParagraphStyle('Gif') + infoToRender.summary = getTextFromParagraphStyle('Summary') + infoToRender.callOut = getTextFromParagraphStyle('Callout') + infoToRender.note = getTextFromParagraphStyle('Note') + infoToRender.tip = getTextFromParagraphStyle('Tip') + infoToRender.warning = getTextFromParagraphStyle('Warning') + infoToRender.important = getTextFromParagraphStyle('Important') + + let textsFounds = 0 + let listFound = false + for (let i = 0; i < schemaDocument.paragraphs.length; i++) { + let paragraph = schemaDocument.paragraphs[i] + if (paragraph.style === 'Text') { + listFound = true + } + if (paragraph.style === 'Text') { + textsFounds++ + switch (textsFounds) { + case 1: { + if (listFound === false) { + infoToRender.bulletListIntro = paragraph.text + } else { + infoToRender.paragraph1 = paragraph.text + } + break + } + case 2: { + if (listFound === false) { + infoToRender.bulletListIntro = paragraph.text + } else { + infoToRender.paragraph1 = paragraph.text + } + break + } + } + } + } + + function getTextFromParagraphStyle(style) { + for (let i = 0; i < schemaDocument.paragraphs.length; i++) { + let paragraph = schemaDocument.paragraphs[i] + if (paragraph.style === style) { + return paragraph.text + } + } + } + } let html = '' - if (nodeConfig.title !== undefined && nodeConfig.title !== '') { - html = html + '
| ' - if (nodeConfig.image !== undefined && nodeConfig.image !== '') { + if (infoToRender.image !== undefined && infoToRender.image !== '') { html = html + '' - newImageName = nodeConfig.image + newImageName = infoToRender.image } html = html + ' | ' html = html + '' - html = html + '' + addToolTips(nodeConfig.definition) + '' + html = html + '' + addToolTips(infoToRender.definition) + '' html = html + ' | ' html = html + '