Skip to content

Commit

Permalink
Removed Console.logs
Browse files Browse the repository at this point in the history
  • Loading branch information
Lizardguard committed Feb 7, 2024
1 parent 8079ec8 commit ba893c1
Show file tree
Hide file tree
Showing 3 changed files with 40 additions and 21 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -71,21 +71,23 @@ 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();
contentTexts = viewModel.introTexts.Value!;
}
// 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 &&
Expand All @@ -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)
) {
Expand All @@ -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;
Expand Down
Original file line number Diff line number Diff line change
@@ -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";
Expand All @@ -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;
}
}
Expand All @@ -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!;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,8 @@ import Observable from "../../../../../../Lib/Observable";
import { LearningElementModel } from "src/Components/Core/Domain/LearningElementModels/LearningElementModelTypes";

export default class StoryElementViewModel {
introTexts: Observable<string[] | null> = new Observable<string[] | null>(
null
);
outroTexts: Observable<string[] | null> = new Observable<string[] | null>(
null
);
introTexts: Observable<string[]> = new Observable<string[]>();
outroTexts: Observable<string[]> = new Observable<string[]>();
isOpen: Observable<boolean> = new Observable<boolean>(false);
pageId: Observable<number> = new Observable<number>(0);
outroUnlocked: Observable<boolean> = new Observable<boolean>(false);
Expand All @@ -23,7 +19,8 @@ export default class StoryElementViewModel {
modelType: Observable<LearningElementModel[]> = new Observable<
LearningElementModel[]
>([]);
numberOfStories: Observable<number> = new Observable<number>();

isSplitStory: Observable<boolean> = new Observable<boolean>(false);
pickedStory: Observable<StoryElementType> =
new Observable<StoryElementType>();
}

0 comments on commit ba893c1

Please sign in to comment.