aboutsummaryrefslogtreecommitdiff
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
parent6a905a729cbb59add629a305f99e1e225f958ea3 (diff)
Hide Until Presented Is Done
-rw-r--r--src/client/views/presentationview/PresentationElement.tsx9
-rw-r--r--src/client/views/presentationview/PresentationView.tsx37
2 files changed, 39 insertions, 7 deletions
diff --git a/src/client/views/presentationview/PresentationElement.tsx b/src/client/views/presentationview/PresentationElement.tsx
index 33c0289d7..2621b92a3 100644
--- a/src/client/views/presentationview/PresentationElement.tsx
+++ b/src/client/views/presentationview/PresentationElement.tsx
@@ -20,7 +20,7 @@ interface PresentationElementProps {
}
-enum buttonIndex {
+export enum buttonIndex {
Show = 0,
Navigate = 1,
HideTillPressed = 2,
@@ -120,14 +120,15 @@ export default class PresentationElement extends React.Component<PresentationEle
@action
onHideDocumentUntilPressClick = (e: React.MouseEvent) => {
e.stopPropagation();
+ const current = NumCast(this.props.mainDocument.selectedDoc);
if (this.selectedButtons[buttonIndex.HideTillPressed]) {
this.selectedButtons[buttonIndex.HideTillPressed] = false;
this.props.document.opacity = 1;
-
} else {
this.selectedButtons[buttonIndex.HideTillPressed] = true;
- this.props.document.opacity = 0;
-
+ if (this.props.index > current) {
+ this.props.document.opacity = 0;
+ }
}
}
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>
);
}