diff --git a/src/Components/Core/Presentation/React/LearningSpaceDisplay/StoryElement/StoryElement.tsx b/src/Components/Core/Presentation/React/LearningSpaceDisplay/StoryElement/StoryElement.tsx index 661ce9f9f..e9df897af 100644 --- a/src/Components/Core/Presentation/React/LearningSpaceDisplay/StoryElement/StoryElement.tsx +++ b/src/Components/Core/Presentation/React/LearningSpaceDisplay/StoryElement/StoryElement.tsx @@ -71,12 +71,12 @@ export default function StoryElement({ className }: AdLerUIComponent<{}>) { let complexStory = false; // We only use the first element of the array. If we have 2 stories, we decide based on the picked story. ~FK let type = viewModel.type.Value[0]; + let isSplitStory = viewModel.isSplitStory.Value; // 1 if ( - type === StoryElementType.Intro || - (viewModel.numberOfStories.Value === 2 && - pickedStory === StoryElementType.Intro) || + (type === StoryElementType.Intro && !isSplitStory) || + (isSplitStory && pickedStory === StoryElementType.Intro) || (type === StoryElementType.IntroOutro && !viewModel.outroUnlocked.Value) ) { titleText = translate("introStoryTitle").toString(); @@ -84,8 +84,10 @@ export default function StoryElement({ className }: AdLerUIComponent<{}>) { } // 2 else if ( - (type === StoryElementType.Outro && viewModel.outroUnlocked.Value) || - (viewModel.numberOfStories.Value === 2 && + (type === StoryElementType.Outro && + viewModel.outroUnlocked.Value && + !isSplitStory) || + (isSplitStory && pickedStory === StoryElementType.Outro && viewModel.outroUnlocked.Value) || (type === StoryElementType.IntroOutro && @@ -96,8 +98,10 @@ export default function StoryElement({ className }: AdLerUIComponent<{}>) { } // 3 else if ( - (type === StoryElementType.Outro && !viewModel.outroUnlocked.Value) || - (viewModel.numberOfStories.Value === 2 && + (type === StoryElementType.Outro && + !viewModel.outroUnlocked.Value && + !isSplitStory) || + (viewModel.isSplitStory && pickedStory === StoryElementType.Outro && !viewModel.outroUnlocked.Value) ) { @@ -119,7 +123,7 @@ export default function StoryElement({ className }: AdLerUIComponent<{}>) { // 4.2 else if (viewModel.showOnlyOutro.Value) { titleText = translate("outroStoryTitle").toString(); - contentTexts = viewModel.outroTexts.Value!; + contentTexts = viewModel.outroTexts.Value; } } else { return null; diff --git a/src/Components/Core/Presentation/React/LearningSpaceDisplay/StoryElement/StoryElementPresenter.ts b/src/Components/Core/Presentation/React/LearningSpaceDisplay/StoryElement/StoryElementPresenter.ts index 34bccfba2..58ce973eb 100644 --- a/src/Components/Core/Presentation/React/LearningSpaceDisplay/StoryElement/StoryElementPresenter.ts +++ b/src/Components/Core/Presentation/React/LearningSpaceDisplay/StoryElement/StoryElementPresenter.ts @@ -1,3 +1,4 @@ +import { ValueLineComponent } from "@babylonjs/inspector/lines/valueLineComponent"; import IStoryElementPresenter from "./IStoryElementPresenter"; import StoryElementViewModel from "./StoryElementViewModel"; import LearningSpaceTO from "src/Components/Core/Application/DataTransferObjects/LearningSpaceTO"; @@ -12,7 +13,7 @@ export default class StoryElementPresenter implements IStoryElementPresenter { this.viewModel.showOnlyIntro.Value = false; this.viewModel.showOnlyOutro.Value = false; - if (this.viewModel.numberOfStories.Value === 2) { + if (this.viewModel.isSplitStory.Value) { this.viewModel.pickedStory.Value = type; } } @@ -24,13 +25,30 @@ export default class StoryElementPresenter implements IStoryElementPresenter { } onLearningSpaceLoaded(learningSpaceTO: LearningSpaceTO): void { - this.viewModel.numberOfStories.Value = learningSpaceTO.storyElements.length; + this.viewModel.isSplitStory.Value = + learningSpaceTO.storyElements.length === 2; for (let i = 0; i < learningSpaceTO.storyElements.length; i++) { this.viewModel.type.Value[i] = learningSpaceTO.storyElements[i].storyType; - this.viewModel.introTexts.Value = - learningSpaceTO.storyElements[i].introStoryTexts; - this.viewModel.outroTexts.Value = - learningSpaceTO.storyElements[i].outroStoryTexts; + if ( + learningSpaceTO.storyElements[i].introStoryTexts === undefined || + learningSpaceTO.storyElements[i].introStoryTexts === null || + learningSpaceTO.storyElements[i].introStoryTexts!.length === 0 + ) { + this.viewModel.introTexts.Value = ["Kein Text vorhanden."]; + } else { + this.viewModel.introTexts.Value = + learningSpaceTO.storyElements[i].introStoryTexts!; + } + if ( + learningSpaceTO.storyElements[i].outroStoryTexts === undefined || + learningSpaceTO.storyElements[i].outroStoryTexts === null || + learningSpaceTO.storyElements[i].outroStoryTexts!.length === 0 + ) { + this.viewModel.outroTexts.Value = ["Kein Text vorhanden."]; + } else { + this.viewModel.outroTexts.Value = + learningSpaceTO.storyElements[i].outroStoryTexts!; + } if (learningSpaceTO.storyElements[i].modelType !== null) this.viewModel.modelType.Value[i] = learningSpaceTO.storyElements[i].modelType!; diff --git a/src/Components/Core/Presentation/React/LearningSpaceDisplay/StoryElement/StoryElementViewModel.ts b/src/Components/Core/Presentation/React/LearningSpaceDisplay/StoryElement/StoryElementViewModel.ts index 8797c2593..2c1e9af96 100644 --- a/src/Components/Core/Presentation/React/LearningSpaceDisplay/StoryElement/StoryElementViewModel.ts +++ b/src/Components/Core/Presentation/React/LearningSpaceDisplay/StoryElement/StoryElementViewModel.ts @@ -3,12 +3,8 @@ import Observable from "../../../../../../Lib/Observable"; import { LearningElementModel } from "src/Components/Core/Domain/LearningElementModels/LearningElementModelTypes"; export default class StoryElementViewModel { - introTexts: Observable = new Observable( - null - ); - outroTexts: Observable = new Observable( - null - ); + introTexts: Observable = new Observable(); + outroTexts: Observable = new Observable(); isOpen: Observable = new Observable(false); pageId: Observable = new Observable(0); outroUnlocked: Observable = new Observable(false); @@ -23,7 +19,8 @@ export default class StoryElementViewModel { modelType: Observable = new Observable< LearningElementModel[] >([]); - numberOfStories: Observable = new Observable(); + + isSplitStory: Observable = new Observable(false); pickedStory: Observable = new Observable(); }