aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authoraidahosa1 <aisosa_idahosa@brown.edu>2024-06-27 14:06:22 -0400
committeraidahosa1 <aisosa_idahosa@brown.edu>2024-06-27 14:06:22 -0400
commit9b0fa4d5581942c54375c10e3887c8010d3eb5e4 (patch)
treedebbbfe19c8702322c3743923069aa7543f3c325
parent3a3d4433e0b4bfc134370ba4938f22cbed61428b (diff)
time
-rw-r--r--src/client/documents/Documents.ts6
-rw-r--r--src/client/util/CurrentUserUtils.ts2
-rw-r--r--src/client/views/collections/CollectionCardDeckView.tsx8
-rw-r--r--src/client/views/collections/CollectionCarouselView.tsx2
-rw-r--r--src/client/views/global/globalScripts.ts80
-rw-r--r--src/client/views/pdf/AnchorMenu.tsx2
6 files changed, 75 insertions, 25 deletions
diff --git a/src/client/documents/Documents.ts b/src/client/documents/Documents.ts
index 53422b0c8..324d80581 100644
--- a/src/client/documents/Documents.ts
+++ b/src/client/documents/Documents.ts
@@ -480,13 +480,13 @@ export class DocumentOptions {
cardSort?: STRt = new StrInfo('way cards are sorted in deck view');
// cardSortForDropDown?: STRt = new StrInfo('needed for dropdown and i dont know why')
- cardSort_customField?: STRt = new StrInfo('field key used for sorting cards');
+ // cardSort_customField?: STRt = new StrInfo('field key used for sorting cards');
cardSort_activeIcons?: List<string>; //icons each card is tagges with
- cardSort_visibleSortGroups?: List<string>; // which sorting values are being filtered (shown)
+ // cardSort_visibleSortGroups?: List<string>; // which sorting values are being filtered (shown)
// cardSort_visibleSortGroups?: List<number>; // which sorting values are being filtered (shown)
cardSort_isDesc?: BOOLt = new BoolInfo('whether the cards are sorted ascending or descending');
- test?: STRt = new StrInfo('testing for filtering')
+ // test?: STRt = new StrInfo('testing for filtering')
}
export const DocOptions = new DocumentOptions();
diff --git a/src/client/util/CurrentUserUtils.ts b/src/client/util/CurrentUserUtils.ts
index 48e4441de..f3b5e5b1d 100644
--- a/src/client/util/CurrentUserUtils.ts
+++ b/src/client/util/CurrentUserUtils.ts
@@ -668,12 +668,14 @@ pie title Minerals in my tap water
{ title: "Type", icon:"eye", toolTip:"Sort by document type", btnType: ButtonType.ToggleButton, expertMode: false, toolType:"docType",funcs: {}, scripts: { onClick: '{ return showFreeform(this.toolType, _readOnly_);}'}},
{ title: "Color", icon:"palette", toolTip:"Sort by document color", btnType: ButtonType.ToggleButton, expertMode: false, toolType:"color", funcs: {}, scripts: { onClick: '{ return showFreeform(this.toolType, _readOnly_);}'}},
{ title: "AI Sort", icon:"robot", toolTip:"Have Chat GPT sort your cards for you !", btnType: ButtonType.ToggleButton, expertMode: false, toolType:"chat", funcs: {}, scripts: { onClick: '{ return showFreeform(this.toolType, _readOnly_);}'}},
+ { title: "Pile", icon:"layer-group", toolTip:"View the cards as a pile in the free form view !", btnType: ButtonType.ClickButton, expertMode: false, toolType:"pile", funcs: {}, scripts: { onClick: '{ return showFreeform(this.toolType, _readOnly_);}'}},
{ title: "Sort", toolTip: "Manage sort order / lock status", icon: "sort" , btnType: ButtonType.MultiToggleButton, toolType:"alignment", ignoreClick: true,
subMenu: [
{ title: "Ascending", toolTip: "Sort the cards in ascending order", btnType: ButtonType.ToggleButton, icon: "sort-up", toolType:"up", ignoreClick: true, scripts: {onClick: '{ return showFreeform(this.toolType, _readOnly_);}' }},
{ title: "Descending", toolTip: "Sort the cards in descending order",btnType: ButtonType.ToggleButton, icon: "sort-down",toolType:"down",ignoreClick: true, scripts: {onClick: '{ return showFreeform(this.toolType, _readOnly_);}'} },
]},
+
{ title: "Filter", icon:"Filter", toolTip:"Filter cards by tags", width: 150, subMenu: this.cardGroupTools(), expertMode: false, toolType:CollectionViewType.Card, funcs: {hidden: `!SelectedDocType(this.toolType, this.expertMode)`, linearView_IsOpen: `SelectedDocType(this.toolType, this.expertMode)`} },
diff --git a/src/client/views/collections/CollectionCardDeckView.tsx b/src/client/views/collections/CollectionCardDeckView.tsx
index d8f4362f1..d3e23c962 100644
--- a/src/client/views/collections/CollectionCardDeckView.tsx
+++ b/src/client/views/collections/CollectionCardDeckView.tsx
@@ -53,6 +53,7 @@ export class CollectionCardView extends CollectionSubView() {
@observable _docDraggedIndex: number = -1;
@observable _isACardBeingDragged: boolean = false;
@observable overIndex: number = -1;
+
static getButtonGroup(groupFieldKey: 'chat' | 'star' | 'idea' | 'like', doc: Doc): number | undefined {
return Cast(doc[groupFieldKey], 'number', null);
@@ -97,8 +98,10 @@ export class CollectionCardView extends CollectionSubView() {
this.Document.childFilters_boolean = 'OR'
this._disposers.sort = reaction(
() => ({ cardSort: this.cardSort }),
- ({ cardSort}) => (cardSort === cardSortings.Chat ? this.openChatPopup() : GPTPopup.Instance.setVisible(false))
+ ({ cardSort}) => (cardSort === cardSortings.Chat ? this.openChatPopup() : GPTPopup.Instance.setVisible(false))
);
+
+
}
componentWillUnmount() {
@@ -475,6 +478,9 @@ export class CollectionCardView extends CollectionSubView() {
* @param gptOutput
*/
@action processGptOutput = (gptOutput: string) => {
+
+ console.log("HIIII")
+ console.log(StrCast(this.Document.cardSort) + "cardSort")
// Split the string into individual list items
const listItems = gptOutput.split('======').filter(item => item.trim() !== '');
// console.log(listItems + " LISTT");
diff --git a/src/client/views/collections/CollectionCarouselView.tsx b/src/client/views/collections/CollectionCarouselView.tsx
index 2adad68e0..4884db709 100644
--- a/src/client/views/collections/CollectionCarouselView.tsx
+++ b/src/client/views/collections/CollectionCarouselView.tsx
@@ -33,7 +33,7 @@ enum practiceVal {
export class CollectionCarouselView extends CollectionSubView() {
private _dropDisposer?: DragManager.DragDropDisposer;
get practiceField() { return this.fieldKey + "_practice"; } // prettier-ignore
- get starField() { return this.fieldKey + "_star"; } // prettier-ignore
+ get starField() { return "star"; } // prettier-ignore
constructor(props: any) {
super(props);
diff --git a/src/client/views/global/globalScripts.ts b/src/client/views/global/globalScripts.ts
index 4239329dd..2ecde0eee 100644
--- a/src/client/views/global/globalScripts.ts
+++ b/src/client/views/global/globalScripts.ts
@@ -38,8 +38,10 @@ import { WebBox } from '../nodes/WebBox';
import { RichTextMenu } from '../nodes/formattedText/RichTextMenu';
import { NumListCast, StrListCast } from '../../../fields/Doc';
import { List } from '../../../fields/List';
-
+import { CollectionViewType } from '../../documents/DocumentTypes';
// import { InkTranscription } from '../InkTranscription';
+import { Docs } from '../../documents/Documents';
+import { CollectionSubView } from '../collections/CollectionSubView';
// eslint-disable-next-line prefer-arrow-callback
ScriptingGlobals.add(function IsNoneSelected() {
@@ -139,11 +141,11 @@ ScriptingGlobals.add(function showFreeform(attr: 'center' | 'grid' | 'snaplines'
const selected = DocumentView.SelectedDocs().lastElement();
function isAttrFiltered(attr: string) {
- return StrListCast(selected._childFilters).some(filter => filter.includes(attr))
+ return StrListCast(selected._childFilters).some(filter => filter.includes(attr));
}
// prettier-ignore
- const map: Map<'flashcards' | 'center' | 'grid' | 'snaplines' | 'clusters' | 'arrange' | 'viewAll' | 'fitOnce' | 'time' | 'docType' | 'color' | 'heart' | 'star' | 'cloud' | 'bolt' | 'chat' | '1' | '2' | '3' | '4' | 'up' | 'down',
+ const map: Map<'flashcards' | 'center' | 'grid' | 'snaplines' | 'clusters' | 'arrange' | 'viewAll' | 'fitOnce' | 'time' | 'docType' | 'color' | 'heart' | 'star' | 'cloud' | 'bolt' | 'chat' | '1' | '2' | '3' | '4' | 'up' | 'down' | 'pile',
{
waitForRender?: boolean;
checkResult: (doc: Doc) => any;
@@ -219,7 +221,11 @@ ScriptingGlobals.add(function showFreeform(attr: 'center' | 'grid' | 'snaplines'
}
}],
['chat', {
- checkResult: (doc: Doc) => StrCast(doc?.cardSort) === "chat",
+ checkResult: (doc: Doc) => {
+
+ if (StrCast(doc?.cardSort) === "chat"){
+ return true
+ }} ,
setDoc: (doc: Doc, dv: DocumentView) => {
doc.cardSort === "chat" ? doc.cardSort = '' : doc.cardSort = 'chat';
},
@@ -236,6 +242,46 @@ ScriptingGlobals.add(function showFreeform(attr: 'center' | 'grid' | 'snaplines'
doc.cardSort_isDesc = true;
},
}],
+ ['pile', {
+ checkResult: (doc: Doc) => doc._type_collection == CollectionViewType.Freeform,
+ setDoc: (doc: Doc, dv: DocumentView) => {
+ doc._type_collection = CollectionViewType.Freeform;
+ const newCol = Docs.Create.CarouselDocument(DocListCast(doc[Doc.LayoutFieldKey(doc)]), {
+ _width: 250,
+ _height: 200,
+ _layout_fitWidth: false,
+ _layout_autoHeight: true,
+ });
+
+
+ const iconMap: { [key: number]: any } = {
+ 0: 'star',
+ 1: 'heart',
+ 2: 'cloud',
+ 3: 'bolt'
+ };
+
+ for (let i=0; i<4; i++){
+ if (isAttrFiltered(iconMap[i])){
+ newCol[iconMap[i]] = true
+ }
+ }
+
+ // if (doc.type == DocumentType.COL ) {
+ newCol && dv.ComponentView?.addDocument?.(newCol);
+ dv.ComponentView?._props.focus(newCol, {willPan: true , willZoomCentered: true, zoomScale: 200} )
+
+ // }
+ // doc as CollectionFreeFormView
+ // doc as typeof CollectionSubView
+
+ // doc._props
+
+ // CollectionFreeFormView.addDocumemnt
+
+ // doc?.addDocument; //this._props.addDocument(newCol)
+ },
+ }],
]);
if (checkResult) {
@@ -243,8 +289,6 @@ ScriptingGlobals.add(function showFreeform(attr: 'center' | 'grid' | 'snaplines'
}
const filters = StrListCast(selected._childFilters).concat(StrListCast(selected?._childFiltersByRanges).filter((filter, i) => !(i % 3)));
-
-
// console.log(filters.some(filter => filter.includes('star'))+ "SUOOOOPPP")
const batch = map.get(attr)?.waitForRender ? UndoManager.StartBatch('set freeform attribute') : { end: () => {} };
@@ -253,7 +297,6 @@ ScriptingGlobals.add(function showFreeform(attr: 'center' | 'grid' | 'snaplines'
return undefined;
});
-
ScriptingGlobals.add(function cardHasLabel(label: string) {
const selected = DocumentView.SelectedDocs().lastElement();
const labelNum = Number(label) - 1;
@@ -355,37 +398,36 @@ ScriptingGlobals.add(function setCardSort(value?: any, checkResult?: boolean) {
if (checkResult) {
// console.log(attr + "attricute")
// console.log(map.get(attr)?.checkResult(selected) + "check result")
- console.log(StrCast(selected?.cardSort) + "check")
- const hi = StrCast(selected?.cardSort)
- return StrCast(selected?.cardSortForDropDown) ?? "Time";
+ console.log(StrCast(selected?.cardSort) + 'check');
+ const hi = StrCast(selected?.cardSort);
+ return StrCast(selected?.cardSortForDropDown) ?? 'Time';
}
-
+
function docFields(doc: Doc): void {
- switch(value){
+ switch (value) {
case 'Custom 1':
- doc.cardSort_customField = "like";
+ doc.cardSort_customField = 'like';
break;
case 'Custom 2':
- doc.cardSort_customField = "star";
+ doc.cardSort_customField = 'star';
break;
case 'Custom 3':
- doc.cardSort_customField = "idea";
+ doc.cardSort_customField = 'idea';
break;
case 'Chat GPT':
- doc.cardSort = "custom";
- doc.cardSort_customField = "chat";
+ doc.cardSort = 'custom';
+ doc.cardSort_customField = 'chat';
break;
default:
break;
}
doc.cardSort_visibleSortGroups = new List<number>();
-
}
// const batch = map.get(attr)?.waitForRender ? UndoManager.StartBatch('set freeform attribute') : { end: () => {} };
DocumentView.Selected().map(dv => {
- dv.Document.cardSortForDropDown = value
+ dv.Document.cardSortForDropDown = value;
if (value != 'Chat GPT') {
dv.Document.cardSort = value.trim().split(/\s+/)[0].toLowerCase();
diff --git a/src/client/views/pdf/AnchorMenu.tsx b/src/client/views/pdf/AnchorMenu.tsx
index 2f6824466..96f025ca0 100644
--- a/src/client/views/pdf/AnchorMenu.tsx
+++ b/src/client/views/pdf/AnchorMenu.tsx
@@ -133,7 +133,7 @@ export class AnchorMenu extends AntimodeMenu<AntimodeMenuProps> {
_layout_autoHeight: true,
});
- this.addToCollection?.(newCol);
+ this.addToCollection?.(newCol); //this._props.addDocument(newCol)
};
pointerDown = (e: React.PointerEvent) => {