From 79a6e8c89e21a8fd31de62dac898b794a8f24e3d Mon Sep 17 00:00:00 2001 From: Luis Fernando Molina Date: Wed, 23 Dec 2020 12:54:58 +0100 Subject: [PATCH] Includes Working --- Client/WebServer/css/docs.css | 11 ++ Client/WebServer/index.html | 1 + .../Schemas/Docs-Concepts/casa.json | 46 +++++++ .../UI/Spaces/Docs-Space/DocsSpace.js | 122 +++++++++++++++++- 4 files changed, 178 insertions(+), 2 deletions(-) create mode 100644 Projects/Superalgos/Schemas/Docs-Concepts/casa.json diff --git a/Client/WebServer/css/docs.css b/Client/WebServer/css/docs.css index 4d2d7e8ce..b9b054498 100644 --- a/Client/WebServer/css/docs.css +++ b/Client/WebServer/css/docs.css @@ -208,6 +208,17 @@ margin: 20px 0; width: 95%; } +.docs-alert-error { +color: #f1e426; +background-color: #ff3131; +border-color: #c23d53; +padding: 15px; +border: 1px solid transparent; +border-radius: 4px; +margin: 20px 0; +width: 95%; +} + .docs-callout { padding: 20px; margin: 20px 0; diff --git a/Client/WebServer/index.html b/Client/WebServer/index.html index f83557e8f..f11f52936 100644 --- a/Client/WebServer/index.html +++ b/Client/WebServer/index.html @@ -116,6 +116,7 @@ + diff --git a/Projects/Superalgos/Schemas/Docs-Concepts/casa.json b/Projects/Superalgos/Schemas/Docs-Concepts/casa.json new file mode 100644 index 000000000..731e77d8e --- /dev/null +++ b/Projects/Superalgos/Schemas/Docs-Concepts/casa.json @@ -0,0 +1,46 @@ +{ + "type": "Casa", + "definition": "Write here the definition of this Concept.", + "paragraphs": [ + { + "style": "Text", + "text": "Left click and Edit to enter edit mode and change this text. ENTER to write new paragraphs. ESC to exit edit mode." + }, + { + "style": "Text", + "text": "Casa 1" + }, + { + "style": "Include", + "text": "Superalgos->Concept->Vaina->Anchor 1" + }, + { + "style": "Text", + "text": "Casa 2" + }, + { + "style": "Text", + "text": "Casa 3" + }, + { + "style": "Text", + "text": "Casa 4" + }, + { + "style": "Text", + "text": "Casa 5" + }, + { + "style": "Text", + "text": "Casa 6" + }, + { + "style": "Text", + "text": "Casa 7" + }, + { + "style": "Text", + "text": "Casa 8" + } + ] +} \ No newline at end of file diff --git a/Projects/Superalgos/UI/Spaces/Docs-Space/DocsSpace.js b/Projects/Superalgos/UI/Spaces/Docs-Space/DocsSpace.js index 4237d934f..d3c6aeafd 100644 --- a/Projects/Superalgos/UI/Spaces/Docs-Space/DocsSpace.js +++ b/Projects/Superalgos/UI/Spaces/Docs-Space/DocsSpace.js @@ -71,6 +71,7 @@ function newSuperalgosDocSpace() { toSubtitle: toSubtitle, toNote: toNote, toWarning: toWarning, + toError: toError, toImportant: toImportant, toSuccess: toSuccess, toCallout: toCallout, @@ -118,6 +119,9 @@ function newSuperalgosDocSpace() { if (selectedParagraph.id.indexOf('warning') >= 0) { extraClassName = ' ' + 'docs-alert-warning' } + if (selectedParagraph.id.indexOf('error') >= 0) { + extraClassName = ' ' + 'docs-alert-error' + } if (selectedParagraph.id.indexOf('javascript') >= 0) { extraClassName = ' ' + 'language-javascript' } @@ -189,6 +193,13 @@ function newSuperalgosDocSpace() { renderDocumentPage() } + function toError() { + let docSchemaParagraph = paragraphMap.get(selectedParagraph.id) + docSchemaParagraph.style = 'Error' + contextMenuForceOutClick() + renderDocumentPage() + } + function toImportant() { let docSchemaParagraph = paragraphMap.get(selectedParagraph.id) docSchemaParagraph.style = 'Important' @@ -562,6 +573,9 @@ function newSuperalgosDocSpace() { if (paragraphNode.id.indexOf('-warning') >= 0) { selectedParagraphData = paragraphNode.innerText.substring(10, paragraphNode.innerText.length) } + if (paragraphNode.id.indexOf('-error') >= 0) { + selectedParagraphData = paragraphNode.innerText.substring(8, paragraphNode.innerText.length) + } if (paragraphNode.id.indexOf('-list') >= 0) { selectedParagraphData = paragraphNode.innerText } @@ -1317,6 +1331,10 @@ function newSuperalgosDocSpace() { documentPoints = documentPoints + thisPhraseCount * 6 break } + case 'error': { + documentPoints = documentPoints + thisPhraseCount * 6 + break + } case 'important': { documentPoints = documentPoints + thisPhraseCount * 7 break @@ -1773,14 +1791,106 @@ function newSuperalgosDocSpace() { for (let i = 0; i < schemaDocument.paragraphs.length; i++) { let key = 'editable-paragraph-' + paragraphIndex let paragraph = schemaDocument.paragraphs[i] - renderParagraph(paragraph, key) - paragraphIndex++ + + if (paragraph.style === "Include") { + renderParagraph(paragraph, key) + paragraphIndex++ + let error = addIncludedParagraphs(paragraph.text) + if (error !== undefined) { + paragraph = { + style: "Error", + text: error + } + renderParagraph(paragraph, key) + paragraphIndex++ + } + } else { + renderParagraph(paragraph, key) + paragraphIndex++ + } } } if (objectBeingRendered.category === 'Node') { autoGeneratedHtml() } HTML = HTML + '' // Content Ends + + function addIncludedParagraphs(includeText) { + let splittedIncludeText = includeText.split('->') + let project = splittedIncludeText[0] + let category = splittedIncludeText[1] + let type = splittedIncludeText[2] + let anchor + let definition = false + if (splittedIncludeText[3] === 'Definition') { + definition = true + } else { + anchor = splittedIncludeText[3] + } + let includedSchemaDocument + + if (SCHEMAS_BY_PROJECT.get(project) === undefined) { + return 'Project ' + project + ' not found.' + } + switch (category) { + case 'Node': { + includedSchemaDocument = SCHEMAS_BY_PROJECT.get(project).map.docsNodeSchema.get(type) + break + } + case 'Concept': { + includedSchemaDocument = SCHEMAS_BY_PROJECT.get(project).map.docsConceptSchema.get(type) + break + } + case 'Topic': { + includedSchemaDocument = SCHEMAS_BY_PROJECT.get(project).map.docsTopicSchema.get(type) + break + } + default: return 'Category provided (' + category + ') not valid. Use Node, Concept or Topic instead.' + } + if (includedSchemaDocument === undefined) { + return category + ' document ' + type + ' not found at project ' + project + } + if (includedSchemaDocument.paragraphs === undefined) { + return 'Schema Document found, but without paragraphs.' + } + + if (definition === true) { + + } else { + let anchorFound = false + for (let i = 0; i < includedSchemaDocument.paragraphs.length; i++) { + + let key = 'included-paragraph-' + paragraphIndex + let paragraph = includedSchemaDocument.paragraphs[i] + + if (anchorFound === false) { + if (paragraph.style === "Anchor" && paragraph.text === anchor) { + anchorFound = true + } + } else { + if (paragraph.style === "Anchor") { + return + } + if (paragraph.style === "Include") { + renderParagraph(paragraph, key) + paragraphIndex++ + let error = addIncludedParagraphs(paragraph.text) + if (error !== undefined) { + paragraph = { + style: "Error", + text: error + } + renderParagraph(paragraph, key) + paragraphIndex++ + } + } else { + renderParagraph(paragraph, key) + paragraphIndex++ + } + } + } + } + } } function addImages() { @@ -2522,6 +2632,14 @@ function newSuperalgosDocSpace() { innerHTML = addToolTips(innerHTML) break } + case 'Error': { + styleClass = 'class="docs-font-small docs-alert-error"' + prefix = ' Error:' + role = 'role="alert"' + key = key + '-error' + innerHTML = paragraph.text + break + } case 'Callout': { styleClass = 'class="docs-font-small docs-callout"' prefix = ''