From 1980d7009606bef0fb52104db0856b691c12bb9e Mon Sep 17 00:00:00 2001 From: Monika Date: Wed, 19 Jun 2019 13:48:31 -0400 Subject: checkboxes working and clearing --- src/client/views/search/CheckBox.tsx | 63 +++++++++++++++++++++++--------- src/client/views/search/FieldFilters.tsx | 23 ++++++++++-- src/client/views/search/SearchBox.tsx | 2 +- 3 files changed, 66 insertions(+), 22 deletions(-) (limited to 'src') diff --git a/src/client/views/search/CheckBox.tsx b/src/client/views/search/CheckBox.tsx index fc1d4005e..163507ec3 100644 --- a/src/client/views/search/CheckBox.tsx +++ b/src/client/views/search/CheckBox.tsx @@ -1,6 +1,6 @@ import * as React from 'react'; import { observer } from 'mobx-react'; -import { observable, action, runInAction } from 'mobx'; +import { observable, action, runInAction, IReactionDisposer, reaction } from 'mobx'; import "./CheckBox.scss"; import * as anime from 'animejs'; @@ -8,6 +8,8 @@ interface CheckBoxProps { originalStatus: boolean; updateStatus(newStatus: boolean): void; title: string; + parent: any; + numCount: number; } @observer @@ -17,6 +19,7 @@ export class CheckBox extends React.Component{ @observable uncheckTimeline: anime.AnimeTimelineInstance; @observable checkTimeline: anime.AnimeTimelineInstance; @observable checkRef: any; + @observable _resetReaction?: IReactionDisposer; constructor(props: CheckBoxProps) { @@ -28,21 +31,19 @@ export class CheckBox extends React.Component{ loop: false, autoplay: false, direction: "normal", - });this.uncheckTimeline = anime.timeline({ + }); this.uncheckTimeline = anime.timeline({ loop: false, autoplay: false, direction: "normal", }); } - //testiing - componentDidMount = () => { this.uncheckTimeline.add({ targets: this.checkRef.current, easing: "easeInOutQuad", duration: 500, - opacity: 0 , + opacity: 0, }); this.checkTimeline.add({ targets: this.checkRef.current, @@ -52,37 +53,63 @@ export class CheckBox extends React.Component{ opacity: 1 }); - if(this.props.originalStatus){ + if (this.props.originalStatus) { this.checkTimeline.play(); } + + this._resetReaction = reaction( + () => this.props.parent.resetBoolean, + () => { + if (this.props.parent.resetBoolean) { + runInAction(() => { + this.reset(); + this.props.parent.resetCounter++; + if (this.props.parent.resetCounter === this.props.numCount) { + this.props.parent.resetCounter = 0; + this.props.parent.resetCounter = false; + } + }) + } + }, + ) } @action.bound - onClick = () => { - this.props.updateStatus(!this._status); + reset() { + if (!this._status) { + this._status = true; + this.checkTimeline.play(); + this.checkTimeline.restart(); + } - if(this._status){ + } + + @action.bound + onClick = () => { + if (this._status) { this.uncheckTimeline.play(); this.uncheckTimeline.restart(); } - else{ + else { this.checkTimeline.play(); this.checkTimeline.restart(); } this._status = !this._status; + this.props.updateStatus(this._status); + } render() { return ( -
-
-
- - - -
-
+
+
+
+ + + +
+
{this.props.title}
diff --git a/src/client/views/search/FieldFilters.tsx b/src/client/views/search/FieldFilters.tsx index e84137d69..81391e73b 100644 --- a/src/client/views/search/FieldFilters.tsx +++ b/src/client/views/search/FieldFilters.tsx @@ -16,13 +16,30 @@ export interface FieldFilterProps { } export class FieldFilters extends React.Component { + + static Instance: FieldFilters; + @observable public resetBoolean = false; + @observable public resetCounter: number = 0; + + constructor(props: FieldFilterProps){ + super(props); + FieldFilters.Instance = this; + } + +resetFieldFilters() { + this.props.updateAuthorStatus(true); + this.props.updateDataStatus(true); + this.props.updateTitleStatus(true); + this.resetBoolean = true; +} + render() { return (
Filter by Basic Keys
- - - + + +
) } diff --git a/src/client/views/search/SearchBox.tsx b/src/client/views/search/SearchBox.tsx index a25fff32d..4a0fe452a 100644 --- a/src/client/views/search/SearchBox.tsx +++ b/src/client/views/search/SearchBox.tsx @@ -72,9 +72,9 @@ export class SearchBox extends React.Component { resetFilters = () => { ToggleBar.Instance.resetToggle(); IconBar.Instance.selectAll(); + FieldFilters.Instance.resetFieldFilters(); } - @action.bound onChange(e: React.ChangeEvent) { this._searchString = e.target.value; -- cgit v1.2.3-70-g09d2