aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/client/views/presentationview/PresentationElement.tsx25
-rw-r--r--src/client/views/presentationview/PresentationView.tsx36
2 files changed, 50 insertions, 11 deletions
diff --git a/src/client/views/presentationview/PresentationElement.tsx b/src/client/views/presentationview/PresentationElement.tsx
index 9fe69c2e3..53e6f903b 100644
--- a/src/client/views/presentationview/PresentationElement.tsx
+++ b/src/client/views/presentationview/PresentationElement.tsx
@@ -71,22 +71,14 @@ export default class PresentationElement extends React.Component<PresentationEle
if (!castedList) {
this.props.presButtonBackUp.selectedButtonDocs = castedList = new List<Doc>();
}
- // let castedList = DocListCast(this.props.presButtonBackUp.selectedButtonDocs);
-
- console.log("Mounted!!");
- console.log("CastedList Len: ", castedList.length);
- console.log("Index of doc: ", this.props.index);
if (castedList.length <= this.props.index) {
- console.log("Entered here by index : ", this.props.index);
castedList.push(new Doc());
} else {
let curDoc: Doc = await castedList[this.props.index];
let selectedButtonOfDoc = Cast(curDoc.selectedButtons, listSpec("boolean"), null);
- console.log("Entered First Place");
if (selectedButtonOfDoc !== undefined) {
runInAction(() => this.selectedButtons = selectedButtonOfDoc);
- console.log("Entered Second Place");
}
}
@@ -167,6 +159,21 @@ export default class PresentationElement extends React.Component<PresentationEle
}
}
+ this.autoSaveGroupChanges();
+
+ }
+
+
+ @action
+ autoSaveGroupChanges = () => {
+ let castedList: List<Doc> = new List<Doc>();
+ this.props.presGroupBackUp.groupDocs = castedList;
+ this.props.groupMappings.forEach((docArray: Doc[], id: String) => {
+ let newGroupDoc = new Doc();
+ castedList.push(newGroupDoc);
+ newGroupDoc.presentIdStore = id.toString();
+ newGroupDoc.grouping = new List(docArray);
+ });
}
@@ -180,6 +187,8 @@ export default class PresentationElement extends React.Component<PresentationEle
} else {
this.selectedButtons[buttonIndex.Group] = true;
}
+ this.autoSaveButtonChange(buttonIndex.Group);
+
}
/**
diff --git a/src/client/views/presentationview/PresentationView.tsx b/src/client/views/presentationview/PresentationView.tsx
index b872181ae..0ba14e8ab 100644
--- a/src/client/views/presentationview/PresentationView.tsx
+++ b/src/client/views/presentationview/PresentationView.tsx
@@ -49,11 +49,22 @@ class PresentationViewList extends React.Component<PresListProps> {
* docs that are in the group, so that mapping won't be disrupted.
*/
@action
- initializeGroupIds = (docList: Doc[]) => {
- docList.forEach((doc: Doc, index: number) => {
+ initializeGroupIds = async (docList: Doc[]) => {
+ docList.forEach(async (doc: Doc, index: number) => {
let docGuid = StrCast(doc.presentId, null);
//checking if part of group
- if (!this.props.groupMappings.has(docGuid)) {
+ let storedGuids: string[] = [];
+ let castedGroupDocs = await DocListCastAsync(this.props.presGroupBackUp.groupDocs);
+ if (castedGroupDocs !== undefined) {
+ castedGroupDocs.forEach((doc: Doc) => {
+ let storedGuid = StrCast(doc.presentIdStore, null);
+ if (storedGuid) {
+ storedGuids.push(storedGuid);
+ }
+
+ });
+ }
+ if (!this.props.groupMappings.has(docGuid) && !storedGuids.includes(docGuid)) {
doc.presentId = Utils.GenerateGuid();
}
});
@@ -117,6 +128,11 @@ export class PresentationView extends React.Component<PresViewProps> {
let toAssign = doc ? doc : new Doc();
this.props.Document.presGroupBackUp = toAssign;
runInAction(() => this.presGroupBackUp = toAssign);
+ if (doc) {
+ if (toAssign[Id] === doc[Id]) {
+ this.retrieveGroupMappings();
+ }
+ }
});
} else {
runInAction(() => {
@@ -148,6 +164,20 @@ export class PresentationView extends React.Component<PresViewProps> {
runInAction(() => this.presStatus = presStatusBackUp);
}
+ retrieveGroupMappings = async () => {
+ //runInAction(() => this.groupMappings = new Map());
+ let castedGroupDocs = await DocListCastAsync(this.presGroupBackUp.groupDocs);
+ if (castedGroupDocs !== undefined) {
+ castedGroupDocs.forEach(async (groupDoc: Doc, index: number) => {
+ let castedGrouping = await DocListCastAsync(groupDoc.grouping);
+ let castedKey = StrCast(groupDoc.presentIdStore, null);
+ if (castedGrouping !== undefined && castedKey !== undefined) {
+ this.groupMappings.set(castedKey, castedGrouping);
+ }
+ });
+ }
+ }
+
//observable means render is re-called every time variable is changed
@observable
collapsed: boolean = false;