aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/client/views/presentationview/PresentationElement.tsx41
-rw-r--r--src/client/views/presentationview/PresentationView.tsx54
2 files changed, 86 insertions, 9 deletions
diff --git a/src/client/views/presentationview/PresentationElement.tsx b/src/client/views/presentationview/PresentationElement.tsx
index f346940a2..7928722f2 100644
--- a/src/client/views/presentationview/PresentationElement.tsx
+++ b/src/client/views/presentationview/PresentationElement.tsx
@@ -1,7 +1,7 @@
import { observer } from "mobx-react";
import React = require("react");
-import { Doc } from "../../../new_fields/Doc";
-import { NumCast, BoolCast, StrCast } from "../../../new_fields/Types";
+import { Doc, DocListCast } from "../../../new_fields/Doc";
+import { NumCast, BoolCast, StrCast, Cast } from "../../../new_fields/Types";
import { Id } from "../../../new_fields/FieldSymbols";
import { observable, action, computed } from "mobx";
import "./PresentationView.scss";
@@ -10,6 +10,8 @@ import { library } from '@fortawesome/fontawesome-svg-core';
import { FontAwesomeIcon } from "@fortawesome/react-fontawesome";
import { faFile as fileSolid, faLocationArrow, faArrowUp, faSearch } from '@fortawesome/free-solid-svg-icons';
import { faFile as fileRegular } from '@fortawesome/free-regular-svg-icons';
+import { List } from "../../../new_fields/List";
+import { listSpec } from "../../../new_fields/Schema";
@@ -29,6 +31,8 @@ interface PresentationElementProps {
allListElements: Doc[];
groupMappings: Map<String, Doc[]>;
presStatus: boolean;
+ presButtonBackUp: Doc;
+ presGroupBackUp: Doc;
}
@@ -60,6 +64,22 @@ export default class PresentationElement extends React.Component<PresentationEle
get selected() {
return this.selectedButtons;
}
+ @action
+ componentDidMount() {
+ // let castedList = Cast(this.props.presButtonBackUp.selectedButtons, listSpec(Doc), null) as any as List<List<boolean>>;
+ let castedList = DocListCast(this.props.presButtonBackUp.selectedButtonDocs);
+ if (castedList.length !== 0) {
+ // this.selectedButtons = castedList;
+ let selectedButtonOfDoc = Cast(castedList[this.props.index].selectedButtons, listSpec("boolean"), null);
+ if (selectedButtonOfDoc !== undefined) {
+ this.selectedButtons = selectedButtonOfDoc;
+ }
+ console.log("Entered!!");
+
+ }
+ console.log("Mounted!!");
+ //this.props.presButtonBackUp.elIndex = this.props.index;
+ }
/**
* The function that is called to group docs together. It tries to group a doc
@@ -171,6 +191,16 @@ export default class PresentationElement extends React.Component<PresentationEle
}
}
}
+ this.autoSaveButtonChange(buttonIndex.HideTillPressed);
+ }
+
+ @action
+ autoSaveButtonChange = (index: buttonIndex) => {
+ // let castedList = Cast(this.props.presButtonBackUp.selectedButtons, listSpec(Doc), null) as any as List<List<boolean>>;
+ let castedList = DocListCast(this.props.presButtonBackUp.selectedButtonDocs);
+ castedList[this.props.index].selectedButtons = new List(this.selectedButtons);
+
+ //this.props.mainDocument.presButtonBackUp = this.props.presButtonBackUp;
}
/**
@@ -198,6 +228,8 @@ export default class PresentationElement extends React.Component<PresentationEle
}
}
}
+ this.autoSaveButtonChange(buttonIndex.HideAfter);
+
}
/**
@@ -225,6 +257,8 @@ export default class PresentationElement extends React.Component<PresentationEle
}
}
}
+ this.autoSaveButtonChange(buttonIndex.FadeAfter);
+
}
/**
@@ -239,6 +273,9 @@ export default class PresentationElement extends React.Component<PresentationEle
} else {
this.selectedButtons[buttonIndex.Navigate] = true;
}
+
+ this.autoSaveButtonChange(buttonIndex.Navigate);
+
}
diff --git a/src/client/views/presentationview/PresentationView.tsx b/src/client/views/presentationview/PresentationView.tsx
index 40e6885f0..8b0b919fd 100644
--- a/src/client/views/presentationview/PresentationView.tsx
+++ b/src/client/views/presentationview/PresentationView.tsx
@@ -31,6 +31,8 @@ interface PresListProps extends PresViewProps {
presElementsMappings: Map<Doc, PresentationElement>;
setChildrenDocs: (docList: Doc[]) => void;
presStatus: boolean;
+ presButtonBackUp: Doc;
+ presGroupBackUp: Doc;
}
@@ -57,14 +59,30 @@ class PresentationViewList extends React.Component<PresListProps> {
});
}
+ @action
+ initializeSelectedButtonDocs = (docList: Doc[]) => {
+
+ let castedList = DocListCast(this.props.presButtonBackUp.selectedButtonDocs);
+ if (castedList.length === 0) {
+ let newDocArray: List<Doc> = new List();
+ newDocArray.push(new Doc());
+ this.props.presButtonBackUp.selectedButtonDocs = newDocArray;
+ } else {
+ castedList.push(new Doc());
+ }
+
+
+ }
+
render() {
const children = DocListCast(this.props.Document.data);
this.initializeGroupIds(children);
this.props.setChildrenDocs(children);
+ this.initializeSelectedButtonDocs(children);
return (
<div className="presentationView-listCont">
- {children.map((doc: Doc, index: number) => <PresentationElement ref={(e) => { if (e) { this.props.presElementsMappings.set(doc, e); } }} key={index} mainDocument={this.props.Document} document={doc} index={index} deleteDocument={this.props.deleteDocument} gotoDocument={this.props.gotoDocument} groupMappings={this.props.groupMappings} allListElements={children} presStatus={this.props.presStatus} />)}
+ {children.map((doc: Doc, index: number) => <PresentationElement ref={(e) => { if (e) { this.props.presElementsMappings.set(doc, e); } }} key={index} mainDocument={this.props.Document} document={doc} index={index} deleteDocument={this.props.deleteDocument} gotoDocument={this.props.gotoDocument} groupMappings={this.props.groupMappings} allListElements={children} presStatus={this.props.presStatus} presButtonBackUp={this.props.presButtonBackUp} presGroupBackUp={this.props.presGroupBackUp} />)}
</div>
);
}
@@ -83,6 +101,28 @@ export class PresentationView extends React.Component<PresViewProps> {
@observable childrenDocs: Doc[] = [];
//variable to hold if presentation is started
@observable presStatus: boolean = false;
+ //back-up so that presentation stays the way it's when refreshed
+ @observable presGroupBackUp: Doc = new Doc();
+ @observable presButtonBackUp: Doc = new Doc();
+
+ @action
+ componentDidMount() {
+ let castedGroupBackUp: Doc = Cast(this.props.Document.presGroupBackUp, Doc, new Doc());
+ let castedButtonBackUp: Doc = Cast(this.props.Document.presButtonBackUp, Doc, new Doc());
+ // if (castedButtonBackUp === undefined) {
+ // this.props.Document.presButtonBackUp = new Doc();
+ // } else {
+ this.presButtonBackUp = castedButtonBackUp;
+ // }
+ // if (castedGroupBackUp === undefined) {
+ // this.props.Document.presGroupBackUp = new Doc();
+ // } else {
+ this.presGroupBackUp = castedGroupBackUp;
+ //
+
+ // }
+
+ }
//observable means render is re-called every time variable is changed
@observable
@@ -326,12 +366,12 @@ export class PresentationView extends React.Component<PresViewProps> {
@action
resetPresentation = () => {
- this.groupMappings = new Map();
- let selectedButtons: boolean[];
+ //this.groupMappings = new Map();
+ //let selectedButtons: boolean[];
this.presElementsMappings.forEach((component: PresentationElement, doc: Doc) => {
- selectedButtons = component.selected;
- selectedButtons.forEach((val: boolean, index: number) => selectedButtons[index] = false);
- doc.presentId = Utils.GenerateGuid();
+ //selectedButtons = component.selected;
+ //selectedButtons.forEach((val: boolean, index: number) => selectedButtons[index] = false);
+ //doc.presentId = Utils.GenerateGuid();
doc.opacity = 1;
});
this.props.Document.selectedDoc = 0;
@@ -379,7 +419,7 @@ export class PresentationView extends React.Component<PresViewProps> {
{this.renderPlayPauseButton()}
<button title="Next" className="presentation-button" onClick={this.next}><FontAwesomeIcon icon={"arrow-right"} /></button>
</div>
- <PresentationViewList Document={this.props.Document} deleteDocument={this.RemoveDoc} gotoDocument={this.gotoDocument} groupMappings={this.groupMappings} presElementsMappings={this.presElementsMappings} setChildrenDocs={this.setChildrenDocs} presStatus={this.presStatus} />
+ <PresentationViewList Document={this.props.Document} deleteDocument={this.RemoveDoc} gotoDocument={this.gotoDocument} groupMappings={this.groupMappings} presElementsMappings={this.presElementsMappings} setChildrenDocs={this.setChildrenDocs} presStatus={this.presStatus} presButtonBackUp={this.presButtonBackUp} presGroupBackUp={this.presGroupBackUp} />
</div>
);
}