diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/client/views/collections/CollectionCarouselView.tsx | 48 |
1 files changed, 24 insertions, 24 deletions
diff --git a/src/client/views/collections/CollectionCarouselView.tsx b/src/client/views/collections/CollectionCarouselView.tsx index 95425a217..c3ba04aa8 100644 --- a/src/client/views/collections/CollectionCarouselView.tsx +++ b/src/client/views/collections/CollectionCarouselView.tsx @@ -48,18 +48,18 @@ export class CollectionCarouselView extends CollectionSubView() { */ advance = (e: React.MouseEvent) => { e.stopPropagation(); - this.layoutDoc._carousel_index = (NumCast(this.layoutDoc._carousel_index) + 1) % this.childLayoutPairs.length; + this.layoutDoc._carousel_index = (NumCast(this.layoutDoc._carousel_index) + 1) % this.carouselItems.length; let startInd = this.layoutDoc._carousel_index; // if the star filter is selected if (this.layoutDoc.filterOp === 'star') { // go to a flashcard that is starred, skip the ones that aren't - while (!this.childLayoutPairs?.[NumCast(startInd)].layout[`${this.fieldKey}_star`] && (startInd + 1) % this.childLayoutPairs.length !== this.layoutDoc._carousel_index) { - startInd = (startInd + 1) % this.childLayoutPairs.length; + while (!this.carouselItems?.[NumCast(startInd)].layout[`${this.fieldKey}_star`] && (startInd + 1) % this.carouselItems.length !== this.layoutDoc._carousel_index) { + startInd = (startInd + 1) % this.carouselItems.length; } this.layoutDoc._carousel_index = startInd; // if there aren't any starred, show all cards - if (!this.childLayoutPairs?.[NumCast(startInd)].layout[`${this.fieldKey}_star`]) { + if (!this.carouselItems?.[NumCast(startInd)].layout[`${this.fieldKey}_star`]) { this.layoutDoc.filterOp = 'all'; } } @@ -67,18 +67,18 @@ export class CollectionCarouselView extends CollectionSubView() { // if the practice filter is selected if (this.layoutDoc.filterOp === 'practice') { // go to a new index that is missed, skip the ones that are correct - while (this.childLayoutPairs?.[NumCast(startInd)].layout[`${this.fieldKey}_missed`] === 'correct' && (startInd + 1) % this.childLayoutPairs.length !== this.layoutDoc._carousel_index) { - startInd = (startInd + 1) % this.childLayoutPairs.length; + while (this.carouselItems?.[NumCast(startInd)].layout[`${this.fieldKey}_missed`] === 'correct' && (startInd + 1) % this.carouselItems.length !== this.layoutDoc._carousel_index) { + startInd = (startInd + 1) % this.carouselItems.length; } this.layoutDoc._carousel_index = startInd; // if the user has gone through all of the cards and gotten them all correct, show all cards and exit practice mode - if (this.childLayoutPairs?.[NumCast(startInd)].layout[`${this.fieldKey}_missed`] === 'correct') { + if (this.carouselItems?.[NumCast(startInd)].layout[`${this.fieldKey}_missed`] === 'correct') { this.layoutDoc.filterOp = 'all'; // set all the cards to missed - for (let i = 0; i < this.childLayoutPairs.length; i++) { - const curDoc = this.childLayoutPairs?.[NumCast(i)]; + for (let i = 0; i < this.carouselItems.length; i++) { + const curDoc = this.carouselItems?.[NumCast(i)]; curDoc.layout[`${this.fieldKey}_missed`] = undefined; } } @@ -91,19 +91,19 @@ export class CollectionCarouselView extends CollectionSubView() { */ goback = (e: React.MouseEvent) => { e.stopPropagation(); - this.layoutDoc._carousel_index = (NumCast(this.layoutDoc._carousel_index) - 1 + this.childLayoutPairs.length) % this.childLayoutPairs.length; + this.layoutDoc._carousel_index = (NumCast(this.layoutDoc._carousel_index) - 1 + this.carouselItems.length) % this.carouselItems.length; let startInd = this.layoutDoc._carousel_index; // if the star filter is selected if (this.layoutDoc.filterOp === 'star') { // go to a new index that is starred, skip the ones that aren't - while (!this.childLayoutPairs?.[NumCast(startInd)].layout[`${this.fieldKey}_star`] && (startInd - 1 + this.childLayoutPairs.length) % this.childLayoutPairs.length !== this.layoutDoc._carousel_index) { - startInd = (startInd - 1 + this.childLayoutPairs.length) % this.childLayoutPairs.length; + while (!this.carouselItems?.[NumCast(startInd)].layout[`${this.fieldKey}_star`] && (startInd - 1 + this.carouselItems.length) % this.carouselItems.length !== this.layoutDoc._carousel_index) { + startInd = (startInd - 1 + this.carouselItems.length) % this.carouselItems.length; } this.layoutDoc._carousel_index = startInd; // if there aren't any starred, show all cards - if (!this.childLayoutPairs?.[NumCast(startInd)].layout[`${this.fieldKey}_star`]) { + if (!this.carouselItems?.[NumCast(startInd)].layout[`${this.fieldKey}_star`]) { this.layoutDoc.filterOp = 'all'; } } @@ -111,18 +111,18 @@ export class CollectionCarouselView extends CollectionSubView() { // if the practice filter is selected if (this.layoutDoc.filterOp === 'practice') { // go to a new index that is missed, skip the ones that are correct - while (this.childLayoutPairs?.[NumCast(startInd)].layout[`${this.fieldKey}_missed`] === 'correct' && (startInd - 1 + this.childLayoutPairs.length) % this.childLayoutPairs.length !== this.layoutDoc._carousel_index) { - startInd = (startInd - 1 + this.childLayoutPairs.length) % this.childLayoutPairs.length; + while (this.carouselItems?.[NumCast(startInd)].layout[`${this.fieldKey}_missed`] === 'correct' && (startInd - 1 + this.carouselItems.length) % this.carouselItems.length !== this.layoutDoc._carousel_index) { + startInd = (startInd - 1 + this.carouselItems.length) % this.carouselItems.length; } this.layoutDoc._carousel_index = startInd; // See all flashcards when finish going through practice mode and set all of the flashcards back to - if (this.childLayoutPairs?.[NumCast(startInd)].layout[`${this.fieldKey}_missed`] === 'correct') { + if (this.carouselItems?.[NumCast(startInd)].layout[`${this.fieldKey}_missed`] === 'correct') { this.layoutDoc.filterOp = 'all'; - for (let i = 0; i < this.childLayoutPairs.length; i++) { - const curDoc = this.childLayoutPairs?.[NumCast(i)]; + for (let i = 0; i < this.carouselItems.length; i++) { + const curDoc = this.carouselItems?.[NumCast(i)]; curDoc.layout[`${this.fieldKey}_missed`] = undefined; } } @@ -134,7 +134,7 @@ export class CollectionCarouselView extends CollectionSubView() { */ star = (e: React.MouseEvent) => { e.stopPropagation(); - const curDoc = this.childLayoutPairs?.[NumCast(this.layoutDoc._carousel_index)]; + const curDoc = this.carouselItems?.[NumCast(this.layoutDoc._carousel_index)]; if (!curDoc) return; if (curDoc.layout[`${this.fieldKey}_star`] === undefined) curDoc.layout[`${this.fieldKey}_star`] = true; else curDoc.layout[`${this.fieldKey}_star`] = !curDoc.layout[`${this.fieldKey}_star`]; @@ -145,7 +145,7 @@ export class CollectionCarouselView extends CollectionSubView() { */ missed = (e: React.MouseEvent, val: string) => { e.stopPropagation(); - const curDoc = this.childLayoutPairs?.[NumCast(this.layoutDoc._carousel_index)]; + const curDoc = this.carouselItems?.[NumCast(this.layoutDoc._carousel_index)]; curDoc.layout[`${this.fieldKey}_missed`] = val; this.advance(e); }; @@ -207,7 +207,7 @@ export class CollectionCarouselView extends CollectionSubView() { ); } @computed get buttons() { - if (!this.childLayoutPairs?.[NumCast(this.layoutDoc._carousel_index)]) return null; + if (!this.carouselItems?.[NumCast(this.layoutDoc._carousel_index)]) return null; return ( <> <div key="back" className="carouselView-back" onClick={this.goback}> @@ -217,7 +217,7 @@ export class CollectionCarouselView extends CollectionSubView() { <FontAwesomeIcon icon="chevron-right" size="2x" /> </div> <div key="star" className="carouselView-star" onClick={this.star}> - <FontAwesomeIcon icon="star" color={this.childLayoutPairs?.[NumCast(this.layoutDoc._carousel_index)].layout[`${this.fieldKey}_star`] ? 'yellow' : 'gray'} size="1x" /> + <FontAwesomeIcon icon="star" color={this.carouselItems?.[NumCast(this.layoutDoc._carousel_index)].layout[`${this.fieldKey}_star`] ? 'yellow' : 'gray'} size="1x" /> </div> <div key="remove" className="carouselView-remove" onClick={e => this.missed(e, 'missed')} style={{ visibility: this.layoutDoc.filterOp === 'practice' ? 'visible' : 'hidden' }}> <FontAwesomeIcon icon="xmark" color="red" size="1x" /> @@ -242,7 +242,7 @@ export class CollectionCarouselView extends CollectionSubView() { {/* Displays a message to the user to add more flashcards if they are in practice mode and no flashcards are there. */} <p style={{ - display: !this.childLayoutPairs?.[NumCast(this.layoutDoc._carousel_index)] && this.layoutDoc.filterOp === 'practice' ? 'flex' : 'none', + display: !this.carouselItems?.[NumCast(this.layoutDoc._carousel_index)] && this.layoutDoc.filterOp === 'practice' ? 'flex' : 'none', justifyContent: 'center', alignItems: 'center', height: '100%', @@ -258,7 +258,7 @@ export class CollectionCarouselView extends CollectionSubView() { position: 'relative', left: '10px', top: '10px', - display: this.childLayoutPairs?.[NumCast(this.layoutDoc._carousel_index)] ? (this.childLayoutPairs?.[NumCast(this.layoutDoc._carousel_index)].layout[`${this.fieldKey}_missed`] === 'missed' ? 'block' : 'none') : 'none', + display: this.carouselItems?.[NumCast(this.layoutDoc._carousel_index)] ? (this.carouselItems?.[NumCast(this.layoutDoc._carousel_index)].layout[`${this.fieldKey}_missed`] === 'missed' ? 'block' : 'none') : 'none', }}> Recently missed! </p> |