From 50cb7d0981a71c2eb45fbecfc2befad94d431eaa Mon Sep 17 00:00:00 2001
From: eperelm2 <emily_perelman@brown.edu>
Date: Fri, 21 Jul 2023 15:07:04 -0400
Subject: filter - stuck on cancelling out

need to remove filters and stop them from showing up.
---
 src/client/views/FilterPanel.tsx | 43 ++++++++++++++++++++++++++++++++--------
 1 file changed, 35 insertions(+), 8 deletions(-)

(limited to 'src/client/views/FilterPanel.tsx')

diff --git a/src/client/views/FilterPanel.tsx b/src/client/views/FilterPanel.tsx
index da00ae255..4f4e39218 100644
--- a/src/client/views/FilterPanel.tsx
+++ b/src/client/views/FilterPanel.tsx
@@ -110,6 +110,7 @@ export class FilterPanel extends React.Component<filterProps> {
 
     @observable _chosenFacets = new ObservableMap<string, 'text' | 'checkbox' | 'slider' | 'range'>();
     @observable _chosenFacetsCollapse = new ObservableMap<string, boolean>();
+    @observable _removeBoolean = false;
     // @observable _currentFilters: string[] ; -- instatitae array to store the currently selected filters (Ex: #food ). remove these filters when removing 
 
     @computed get activeFacets() {
@@ -213,12 +214,21 @@ export class FilterPanel extends React.Component<filterProps> {
                                     <div onClick = {action((e) => { 
                                      
                                         // delete this.activeFacets[facetHeader];
+                                        // StrListCast(this.targetDoc._childFilters).find(filter => filter.split(Doc.FilterSep)[2] = 'remove')
+                                        // .find(filter => filter.split(Doc.FilterSep)[0] === facetHeader && filter.split(Doc.FilterSep)[1] == facetValue)
+                                        // ?.split(Doc.FilterSep)[2] === 'check'
+                                        // console.log("why cant i get this "+ console.log( StrListCast(this.targetDoc._childFilters)
+                                        // .find(filter => filter.split(Doc.FilterSep)[0] === facetHeader)))
                                          this.activeFacets.delete(facetHeader)
                                          this._chosenFacets.delete(facetHeader)
+                                         this._chosenFacetsCollapse.delete(facetHeader)
+                                        //  this._removeBoolean  = true
+                                        //  setTimeout(() => {this._removeBoolean = false}, 1000 )
                                         //  console.log("TRYING SOMETHING NEW " + e.target.checked)
                                         
                                         // check if the current values are apart of the this.facetValues(facetHeader).map(fval ... 
                                          
+                                        // SET UP BOOLEAN AND IF IT IS TRUE MEANS ITS CLICKED AND THEN ALL BOXES SHOULD BE UNCHECKED 
                                         }
                                         )
                                     }  
@@ -261,16 +271,33 @@ export class FilterPanel extends React.Component<filterProps> {
                         <div>
                             <input
                                 style={{ width: 20, marginLeft: 20 }}
-                                checked={
-                                    StrListCast(this.targetDoc._childFilters)
-                                        .find(filter => filter.split(Doc.FilterSep)[0] === facetHeader && filter.split(Doc.FilterSep)[1] == facetValue)
-                                        ?.split(Doc.FilterSep)[2] === 'check'
+                                checked={ this._removeBoolean ? false : 
+                                        StrListCast(this.targetDoc._childFilters)
+                                            .find(filter => filter.split(Doc.FilterSep)[0] === facetHeader && filter.split(Doc.FilterSep)[1] == facetValue)
+                                            ?.split(Doc.FilterSep)[2] === 'check'
+                                     
                                 }
                                 type={type}
-                                onChange={undoable(e => Doc.setDocFilter(this.targetDoc, facetHeader, fval, e.target.checked ? 'check' : 'remove'), 'set filter')}
-                                onClick={undoable (e => 
-                                    e.target.checked ? this._currentFilters.push(fval) :  , 'set filter'
-                                ) }
+                                onChange={undoable(e => Doc.setDocFilter(this.targetDoc, facetHeader, fval,  e.target.checked ? 'check' : 'remove'), 'set filter')}
+                                // onClick={undoable (e => 
+                                //     e.target.checked ? this._currentFilters.push(fval) :  , 'set filter'
+                                // ) }
+                                onClick = {action((e) => {
+                                      console.log("im here")
+                                    console.log( StrListCast(this.targetDoc._childFilters)
+                                    .find(filter => filter.split(Doc.FilterSep)[0] === facetHeader && filter.split(Doc.FilterSep)[1] == facetValue)
+                                    // ?.split(Doc.FilterSep)[2] === 'check'
+                                    )
+                                    StrListCast(this.targetDoc._childFilters).find(filter => console.log(" rahhhhhh1 " + filter.split(Doc.FilterSep)[1] === facetValue))
+                                    StrListCast(this.targetDoc._childFilters).find(filter => console.log(" rahhhhhh2 " + filter.split(Doc.FilterSep)[2]) )
+                                }
+                                  
+                                    //  console.log("this is an experiment " + StrListCast(this.targetDoc._childFilters)
+                                   
+                                     )
+                                    // undoable (e => console.log(" this is an experiment " + e.target.checked), 'set filter')
+                                   
+                                }
                             />
                             {facetValue}
                         </div>
-- 
cgit v1.2.3-70-g09d2

