aboutsummaryrefslogtreecommitdiff
path: root/src/client/views/presentationview/PresentationView.tsx
diff options
context:
space:
mode:
authormadelinegr <mgriswold99@gmail.com>2019-06-07 15:53:21 -0400
committermadelinegr <mgriswold99@gmail.com>2019-06-07 15:53:21 -0400
commitecac03b032c4d1484408b892024135a814cd3265 (patch)
tree015144a80f66109c9aba7c8ad45737d654714f95 /src/client/views/presentationview/PresentationView.tsx
parent6a905a729cbb59add629a305f99e1e225f958ea3 (diff)
Hide Until Presented Is Done
Diffstat (limited to 'src/client/views/presentationview/PresentationView.tsx')
-rw-r--r--src/client/views/presentationview/PresentationView.tsx37
1 files changed, 34 insertions, 3 deletions
diff --git a/src/client/views/presentationview/PresentationView.tsx b/src/client/views/presentationview/PresentationView.tsx
index 9acdea98e..4fcc0b523 100644
--- a/src/client/views/presentationview/PresentationView.tsx
+++ b/src/client/views/presentationview/PresentationView.tsx
@@ -10,7 +10,7 @@ import { Cast, NumCast, FieldValue, PromiseValue, StrCast, BoolCast } from "../.
import { Id } from "../../../new_fields/FieldSymbols";
import { List } from "../../../new_fields/List";
import { CurrentUserUtils } from "../../../server/authentication/models/current_user_utils";
-import PresentationElement from "./PresentationElement";
+import PresentationElement, { buttonIndex } from "./PresentationElement";
export interface PresViewProps {
Document: Doc;
@@ -21,6 +21,7 @@ interface PresListProps extends PresViewProps {
gotoDocument(index: number): void;
groupMappings: Map<String, Doc[]>;
presElementsMappings: Map<Doc, PresentationElement>;
+ setChildrenDocs: (docList: Doc[]) => void;
}
@@ -57,7 +58,6 @@ class PresentationViewList extends React.Component<PresListProps> {
let docGuid = StrCast(doc.presentId, null);
if (!this.props.groupMappings.has(docGuid)) {
doc.presentId = Utils.GenerateGuid();
-
}
});
}
@@ -109,6 +109,7 @@ class PresentationViewList extends React.Component<PresListProps> {
render() {
const children = DocListCast(this.props.Document.data);
this.initializeGroupIds(children);
+ this.props.setChildrenDocs(children);
return (
<div className="presentationView-listCont">
@@ -126,6 +127,7 @@ export class PresentationView extends React.Component<PresViewProps> {
@observable groupedMembers: Doc[][] = [];
@observable groupMappings: Map<String, Doc[]> = new Map();
@observable presElementsMappings: Map<Doc, PresentationElement> = new Map();
+ @observable childrenDocs: Doc[] = [];
//observable means render is re-called every time variable is changed
@observable
@@ -175,6 +177,26 @@ export class PresentationView extends React.Component<PresViewProps> {
this.gotoDocument(prevSelected);
}
+ showAfterPresented = (index: number) => {
+ this.presElementsMappings.forEach((presElem: PresentationElement, key: Doc) => {
+ if (presElem.selected[buttonIndex.HideTillPressed]) {
+ if (this.childrenDocs.indexOf(key) <= index) {
+ key.opacity = 1;
+ }
+ }
+ });
+ }
+
+ hideIfNotPresented = (index: number) => {
+ this.presElementsMappings.forEach((presElem: PresentationElement, key: Doc) => {
+ if (presElem.selected[buttonIndex.HideTillPressed]) {
+ if (this.childrenDocs.indexOf(key) > index) {
+ key.opacity = 0;
+ }
+ }
+ });
+ }
+
getDocAtIndex = async (index: number) => {
const list = FieldValue(Cast(this.props.Document.data, listSpec(Doc)));
if (!list) {
@@ -209,6 +231,10 @@ export class PresentationView extends React.Component<PresViewProps> {
this.props.Document.selectedDoc = index;
const doc = await list[index];
DocumentManager.Instance.jumpToDocument(doc);
+ this.hideIfNotPresented(index);
+ this.showAfterPresented(index);
+
+
}
//initilize class variables
@@ -233,6 +259,11 @@ export class PresentationView extends React.Component<PresViewProps> {
this.props.Document.width = 300;
}
+ @action
+ setChildrenDocs = (docList: Doc[]) => {
+ this.childrenDocs = docList;
+ }
+
render() {
let titleStr = StrCast(this.props.Document.title);
let width = NumCast(this.props.Document.width);
@@ -248,7 +279,7 @@ export class PresentationView extends React.Component<PresViewProps> {
<button className="presentation-button" onClick={this.back}>back</button>
<button className="presentation-button" onClick={this.next}>next</button>
</div>
- <PresentationViewList Document={this.props.Document} deleteDocument={this.RemoveDoc} gotoDocument={this.gotoDocument} groupMappings={this.groupMappings} presElementsMappings={this.presElementsMappings} />
+ <PresentationViewList Document={this.props.Document} deleteDocument={this.RemoveDoc} gotoDocument={this.gotoDocument} groupMappings={this.groupMappings} presElementsMappings={this.presElementsMappings} setChildrenDocs={this.setChildrenDocs} />
</div>
);
}