aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/client/documents/Documents.ts14
-rw-r--r--src/client/views/collections/CollectionCardDeckView.tsx188
2 files changed, 112 insertions, 90 deletions
diff --git a/src/client/documents/Documents.ts b/src/client/documents/Documents.ts
index eded2b485..80774f4ad 100644
--- a/src/client/documents/Documents.ts
+++ b/src/client/documents/Documents.ts
@@ -501,8 +501,20 @@ export class DocumentOptions {
cardSort?: STRt = new StrInfo('way cards are sorted in deck view');
customSortNumber?: NUMt = new NumInfo('number of custom sorts the user has created');
- customHashMap?: List<string>
+ // customGroup1?: List<Doc>
+ // customGroup2?: List<Doc>
+ // customGroup3?: List<Doc>
visibleGroupNumbers?: List<number>
+ custom1Group?: NUMt = new NumInfo('Which group a card is in for the 1st custom grouping');
+ custom2Group?: NUMt = new NumInfo('Which group a card is in for the 2nd custom grouping');
+ custom3Group?: NUMt = new NumInfo('Which group a card is in for the 3rd custom grouping');
+ chatGroup?: NUMt = new NumInfo("Which group a card is in for the chat's grouping");
+ chatAmGroups?: NUMt = new NumInfo("Number of cards created by chat sort");
+
+
+
+
+
// card_sort_time?: BOOLt = new BoolInfo('whether sorting cards in deck view by time');
// card_sort_type?: BOOLt = new BoolInfo('whether sorting cards in deck view by type');
diff --git a/src/client/views/collections/CollectionCardDeckView.tsx b/src/client/views/collections/CollectionCardDeckView.tsx
index 42c82ca74..c719c9e19 100644
--- a/src/client/views/collections/CollectionCardDeckView.tsx
+++ b/src/client/views/collections/CollectionCardDeckView.tsx
@@ -33,7 +33,8 @@ export class CollectionCardView extends CollectionSubView() {
// documents themselves
@observable hoveredNodeIndex = -1;
- //index to group
+
+ //key is the index in the child pair list, value is the id# for the group its in
@observable customGroupDictionary: Map<number, number>[] = [new Map<number, number>(), new Map<number, number>(), new Map<number, number>()];
@@ -43,9 +44,9 @@ export class CollectionCardView extends CollectionSubView() {
// console.log("Active Groups:", activeGroups);
- for (let i=0; i< activeGroups.length; i++){
- console.log("Active Groups" + activeGroups[i])
- }
+ // for (let i=0; i< activeGroups.length; i++){
+ // console.log("Active Groups" + activeGroups[i])
+ // }
// console.log("Current Custom Sort Number:", currCustom);
if (activeGroups.length <= 0) {
@@ -121,10 +122,32 @@ export class CollectionCardView extends CollectionSubView() {
super(props);
makeObservable(this);
// this.rotationDegree(7);
+ const pairs = this.childLayoutPairs.filter(d => d.layout.type != DocumentType.LINK);
+
- if (this._props.Document.customHashMap != undefined){
- this.customGroupDictionary = this.getCustoms(StrListCast(this._props.Document.customHashMap))
+ for (let i=0; i< pairs.length; i++){
+ if (pairs[i].layout.custom1Group != undefined){
+ this.customGroupDictionary[0].set(i, NumCast(pairs[i].layout.custom1Group))
+ }
+
+ if (pairs[i].layout.custom2Group != undefined){
+ this.customGroupDictionary[1].set(i, NumCast(pairs[i].layout.custom2Group))
+ }
+
+ if (pairs[i].layout.custom3Group != undefined){
+ this.customGroupDictionary[2].set(i, NumCast(pairs[i].layout.custom3Group))
+ }
+
+ if (pairs[i].layout.chatGroup != undefined){
+ this.gptGroups.set(pairs[i].layout, NumCast(pairs[i].layout.chatGroup))
+ this.amGPTGroups = NumCast(this._props.Document.chatAmGroups)
+
+ }
}
+
+ // if (this._props.Document.customHashMap != undefined){
+ // this.customGroupDictionary = this.convertListsToArrayOfMaps(DocListCast(this._props.Document.customGroup1),DocListCast(this._props.Document.customGroup2), DocListCast(this._props.Document.customGroup3))
+ // }
// this._props.Document.visibleGroupNumbers = new List<number>([1,2,3,4])
@@ -139,32 +162,52 @@ export class CollectionCardView extends CollectionSubView() {
);
}
+ //converts the customGroupDictionary into a Lists of Docs
+ mapToField(groupNumber: number) {
+ const groupList = new List<Doc>();
+
+ const pairs = this.childLayoutPairs.filter(d => d.layout.type != DocumentType.LINK);
+ console.log(groupNumber+ "group#")
+
+ this.customGroupDictionary[groupNumber].forEach((group, index) => {
+ const doc = pairs[index].layout;
+ groupList.push(doc);
+ });
+
+ this._props.Document[`group${groupNumber}`] = groupList;
+ }
- @computed get mapToField(): List<string> {
- const resultList = new List<string>();
-
- this.customGroupDictionary.forEach(map => {
- // Convert each map to a single string with entries formatted as "key:value"
- const mapString = Array.from(map.entries())
- .map(([key, value]) => `${key}:${value}`)
- .join(','); // Join all key-value pairs with commas
- resultList.push(mapString); // Add the formatted string of the current map to the list
+ // This function converts three Lists of Docs back into an array of maps
+ convertListsToArrayOfMaps = (group0: Doc[], group1: Doc[], group2: Doc[]): Map<number, number>[] => {
+ const mapsArray: Map<number, number>[] = [
+ new Map<number, number>(),
+ new Map<number, number>(),
+ new Map<number, number>()
+ ];
+ const layoutPairs = this.childLayoutPairs.filter(d => d.layout.type != DocumentType.LINK)
+
+ group0.forEach((doc, index) => {
+ const docIndex = layoutPairs.findIndex(pair => pair.layout === doc);
+ if (docIndex !== -1) {
+ mapsArray[0].set(docIndex, 0);
+ }
});
- return resultList;
- }
+ group1.forEach((doc, index) => {
+ const docIndex = layoutPairs.findIndex(pair => pair.layout === doc);
+ if (docIndex !== -1) {
+ mapsArray[1].set(docIndex, 1);
+ }
+ });
- getCustoms = (stringFrom: string[]): Map<number, number>[] => {
- return stringFrom.map(s => {
- // Create a new Map object for each string.
- const map = new Map<number, number>();
- // Split the string by commas to get key-value pairs, then process each pair.
- s.split(',').forEach(pair => {
- const [key, value] = pair.split(':');
- map.set(Number(key), Number(value));
- });
- return map;
+ group2.forEach((doc, index) => {
+ const docIndex = layoutPairs.findIndex(pair => pair.layout === doc);
+ if (docIndex !== -1) {
+ mapsArray[2].set(docIndex, 2);
+ }
});
+
+ return mapsArray;
}
@@ -278,17 +321,6 @@ export class CollectionCardView extends CollectionSubView() {
@computed get sortedDocsType() {
- // if (this._props.Document.cardSort === 'chat'){
- // this.openChatPopup()
- // const textDesc = await this.childPairStringList();
- // GPTPopup.Instance.setSortDesc(textDesc)
- // }
-
- // if (this._props.Document.cardSort === 'chat' && this.sortedDocs.length === 0) {
-
- // this.smartSort(); // Trigger the sorting if it hasn't been done yet
- // return { docs: [] }; // Return an empty array or a loading state
- // }
const desc = BoolCast(this.layoutDoc.sortDesc);
@@ -374,9 +406,9 @@ export class CollectionCardView extends CollectionSubView() {
// console.log(this.customGroupDictionary[NumCast(this._props.Document.customSortNumber)])
typeA = this.gptGroups.get(docA.layout) ?? '9999';
- console.log(typeA + "typea")
+ // console.log(typeA + "typea")
typeB = this.gptGroups.get(docB.layout) ?? '9999';
- console.log(typeB + "typeB")
+ // console.log(typeB + "typeB")
// console.log(typeA + "A")
@@ -539,35 +571,45 @@ export class CollectionCardView extends CollectionSubView() {
onMouseEnter={() => this.setHoveredNodeIndex(index)}>
{this.displayDoc(childPair, childScreenToLocal)}
- {this._props.Document.cardSort == 'custom' ? this.renderButtons(childPairIndex) : ''}
+ {this._props.Document.cardSort == 'custom' ? this.renderButtons(childPairIndex, childPair.layout, false) : ''}
{this._props.Document.cardSort == 'chat' ? this.renderButtons(childPairIndex, childPair.layout, true) : ''}
</div>
);
});
}
+
-
-
-
-
-
-
- @action toggleButton(childPairIndex: number, buttonID: number, isChat = false, doc?: Doc) {
+ @action toggleButton(childPairIndex: number, buttonID: number, isChat = false, doc: Doc) {
if (!isChat) {
- this.customGroupDictionary[NumCast(this._props.Document.customSortNumber)].set(childPairIndex, buttonID);
- this._props.Document.customHashMap = this.mapToField;
+ const sortNumber = NumCast(this._props.Document.customSortNumber)
+ this.customGroupDictionary[sortNumber].set(childPairIndex, buttonID)
+ switch (sortNumber){
+ case 0:
+ doc.custom1Group = buttonID
+ break
+ case 1:
+ doc.custom2Group = buttonID
+ break
+ case 2:
+ doc.custom3Group = buttonID
+ break
+ default:
+ break
+ }
+ // this.mapToField(buttonID);
}
if (isChat && doc) {
this.gptGroups.set(doc, buttonID);
+ doc.chatGroup = buttonID
}
// console.log(`Toggled button for childPairIndex: ${childPairIndex}, buttonID: ${buttonID}, isChat: ${isChat}`);
// console.log(`Updated customGroupDictionary:`, this.customGroupDictionary);
- if (isChat && doc) {
- console.log(`Updated gptGroups for doc ${doc}:`, this.gptGroups.get(doc));
- }
+ // if (isChat && doc) {
+ // // console.log(`Updated gptGroups for doc ${doc}:`, this.gptGroups.get(doc));
+ // }
}
@@ -645,39 +687,6 @@ export class CollectionCardView extends CollectionSubView() {
}
}
-
-
- //a set of all the images that have already been given desc
- //a map from the text to the Doc (for everything)
-
-
- // @action async smartSort() {
- // this.isLoading = true;
- // console.log("loading");
-
- // // Store the result of childPairStringList in a variable
- // const childPairStrings = await this.childPairStringList();
-
- // if (childPairStrings === "") {
- // console.log("no child pairs :(");
- // } else {
- // console.log(childPairStrings + " og list");
- // let prompt = childPairStrings;
-
- // let res = await gptAPICall(prompt, GPTCallType.SORT);
- // this.isLoading = false;
- // if (res == 'Error connecting with API.') {
- // // If GPT call failed
- // console.error('GPT call failed');
- // } else if (res != null) {
- // console.log(res);
- // this.processGptOutput(res);
- // // Update the observable with the sorted documents
- // this.sortedDocs = this.sort(this.myChildLayoutPairs, 'gpt', BoolCast(this.layoutDoc.sortDesc)).docs;
- // }
- // this.isLoading = false;
- // }
- // }
gptGroups = new ObservableMap<Doc, number>
@observable amGPTGroups = 0
@@ -688,6 +697,7 @@ export class CollectionCardView extends CollectionSubView() {
// Split the string into individual list items
const listItems = gptOutput.split('======').filter(item => item.trim() !== '');
this.amGPTGroups = listItems.length
+ this._props.Document.chatAmGroups = this.amGPTGroups
listItems.forEach((item, index) => {
// Split the item by '~~~~~~' to get all descriptors
@@ -730,7 +740,7 @@ export class CollectionCardView extends CollectionSubView() {
- renderButtons(childPairIndex: number, doc?: Doc, isChat = false) {
+ renderButtons(childPairIndex: number, doc: Doc, isChat = false) {
const buttons = []; // Array to hold the button elements
const groupNumber = NumCast(this._props.Document.customSortNumber);
@@ -744,11 +754,11 @@ export class CollectionCardView extends CollectionSubView() {
activeButtonIndex = this.gptGroups.get(doc);
}
- console.log("childPairIndex:", childPairIndex, "activeButtonIndex:", activeButtonIndex, "groupNumber:", groupNumber);
+ // console.log("childPairIndex:", childPairIndex, "activeButtonIndex:", activeButtonIndex, "groupNumber:", groupNumber);
for (let i = 0; i < amButtons; i++) {
const isActive = activeButtonIndex === i;
- console.log(`Rendering button ${i} for childPairIndex ${childPairIndex} isActive: ${isActive}`);
+ // console.log(`Rendering button ${i} for childPairIndex ${childPairIndex} isActive: ${isActive}`);
buttons.push(
<button
key={i}