diff options
Diffstat (limited to 'src/client/views/collections')
| -rw-r--r-- | src/client/views/collections/CollectionCardDeckView.tsx | 42 |
1 files changed, 32 insertions, 10 deletions
diff --git a/src/client/views/collections/CollectionCardDeckView.tsx b/src/client/views/collections/CollectionCardDeckView.tsx index d0a796218..ab7aac267 100644 --- a/src/client/views/collections/CollectionCardDeckView.tsx +++ b/src/client/views/collections/CollectionCardDeckView.tsx @@ -159,14 +159,18 @@ export class CollectionCardView extends CollectionSubView() { }; @computed get sortedDocsType() { - // This field is set to 'type' to sort documents by their type - // const typeField = 'type'; - - // Whether to sort in descending order + const desc = BoolCast(this.layoutDoc.sortDesc); + let sorted = [] + + for (let i=0; i< this.childLayoutPairs.length; i++){ //copying everything in childlayout pairs to sorted so that i can use the sort function without altering the original list + sorted[i] = this.childLayoutPairs[i] + } + + // Copy and sort documents by type - const docs = this.childLayoutPairs.sort((docA, docB) => { + const docs = sorted.sort((docA, docB) => { const typeA = docA.layout.type ?? ''; // If docA.type is undefined, use an empty string const typeB = docB.layout.type ?? ''; // If docB.type is undefined, use an empty string @@ -177,10 +181,15 @@ export class CollectionCardView extends CollectionSubView() { if (desc) out *= -1; // Reverse the sort order if descending is true return out; }); + return { docs }; } + + + + @observable docRefs = new ObservableMap<Doc, DocumentView>(); @computed get contentSorted() { @@ -213,9 +222,10 @@ export class CollectionCardView extends CollectionSubView() { // Map sorted documents to their rendered components return sortedDocs.map((childPair, index) => { // const childPair = { layout: doc, data: doc }; - const isSelected = this.isSelected(index); const isHovered = this.hoveredNodeIndex === index; - const inactiveIndex = this.sortedDocsType.docs.indexOf(childPair); + const inactiveIndex = this.sortedDocsType.docs.filter(d => !SelectionManager.IsSelected(d.layout)).indexOf(childPair); + const isSelected = SelectionManager.IsSelected(childPair.layout); + @@ -234,7 +244,7 @@ export class CollectionCardView extends CollectionSubView() { height: this.panelHeight(childPair.layout)(), transform: ` rotate(${!isSelected ? this.rotate(amCards, inactiveIndex) : 0}deg) - translateY(${isHovered ? this.translateHover(index) : isSelected ? 50 * this.fitContentScale : this.translateY(amCards, inactiveIndex)}px) + translateY(${isHovered ? this.translateHover(inactiveIndex) : isSelected ? 50 * this.fitContentScale : this.translateY(amCards, inactiveIndex)}px) translateX(${isSelected ? (this._props.PanelWidth() / 2) * this.fitContentScale - this.childDocumentWidth : 0}px) scale(${isSelected ? 1.25 : 1}) `, @@ -250,7 +260,7 @@ export class CollectionCardView extends CollectionSubView() { // const currentIndex = NumCast(this.layoutDoc._carousel_index); const amCards = this.inactiveDocs().length; console.log(amCards + "lol") - const sortedDocs = this.sortedDocsType.docs; // Retrieve sorted documents + // const sortedDocs = this.sortedDocsType.docs; // Retrieve sorted documents // const myInactives = const displayDoc = (childPair: { layout: Doc; data: Doc }, screenToLocalTransform: () => Transform) => { @@ -328,6 +338,18 @@ export class CollectionCardView extends CollectionSubView() { return 0; } + @computed get renderCardsSort(){ + if (BoolCast(this._props.Document.card_sort_type) == true){ + return this.contentSorted + } + + else{ + return this.content + } + } + + + render() { return ( <div @@ -345,7 +367,7 @@ export class CollectionCardView extends CollectionSubView() { height: `${100 * this.fitContentScale}%`, }} onMouseLeave={() => this.setHoveredNodeIndex(-1)}> - {this.contentSorted} + {this.renderCardsSort} </div> {/* <Card className={`custom-modal-position step-${step}`}> |
