From 4b5b6e3b02ebd3425b0230a1f282e67de93866c6 Mon Sep 17 00:00:00 2001 From: "G.Ambatte" Date: Sun, 28 Aug 2022 23:46:19 +1200 Subject: [PATCH 01/12] Initial pass at visibility functionality --- .../pages/basePages/listPage/listPage.jsx | 61 ++++++++++++++++--- .../pages/basePages/listPage/listPage.less | 23 +++++++ client/homebrew/pages/userPage/userPage.jsx | 14 +++-- 3 files changed, 82 insertions(+), 16 deletions(-) diff --git a/client/homebrew/pages/basePages/listPage/listPage.jsx b/client/homebrew/pages/basePages/listPage/listPage.jsx index 934d147be..a2a063a37 100644 --- a/client/homebrew/pages/basePages/listPage/listPage.jsx +++ b/client/homebrew/pages/basePages/listPage/listPage.jsx @@ -6,28 +6,58 @@ const moment = require('moment'); const BrewItem = require('./brewItem/brewItem.jsx'); +const USERPAGE_KEY_PREFIX = 'HOMEBREWERY-LISTPAGE-VISIBILITY'; + const ListPage = createClass({ displayName : 'ListPage', getDefaultProps : function() { return { brewCollection : [ { - title : '', - class : '', - brews : [] + title : '', + class : '', + brews : [], + visible : true } ], navItems : <> }; }, getInitialState : function() { + let brewCollection = []; + + if(typeof window !== 'undefined') { + brewCollection = this.props.brewCollection.map((brewGroup)=>{ + const localVisibility = localStorage.getItem(`${USERPAGE_KEY_PREFIX}-${brewGroup.class}`) ?? 'true'; + if(brewGroup.visible != (localVisibility=='true')) { + brewGroup.visible = (localVisibility=='true'); + }; + return brewGroup; + }); + } + return { - sortType : 'alpha', - sortDir : 'asc', - filterString : this.props.query?.filter || '', - query : this.props.query + sortType : 'alpha', + sortDir : 'asc', + filterString : this.props.query?.filter || '', + query : this.props.query, + brewCollection : brewCollection }; }, + componentDidMount : function() { + // SAVE TO LOCAL STORAGE WHEN LEAVING PAGE + window.onbeforeunload = this.saveToLocalStorage; + }, + + componentWillUnmount : function() { + window.onbeforeunload = function(){}; + }, + + saveToLocalStorage : function() { + this.state.brewCollection.map((brewGroup)=>{ + localStorage.setItem(`${USERPAGE_KEY_PREFIX}-${brewGroup.class}`, `${brewGroup.visible}`); + }); + }, renderBrews : function(brews){ if(!brews || !brews.length) return
No Brews.
; @@ -150,11 +180,22 @@ const ListPage = createClass({ return _.orderBy(brews, (brew)=>{ return this.sortBrewOrder(brew); }, this.state.sortDir); }, + toggleBrewCollectionState : function(brewGroupClass) { + this.setState((prevState)=>({ + brewCollection : prevState.brewCollection.map( + (brewGroup)=>brewGroup.class === brewGroupClass ? { ...brewGroup, visible: !brewGroup.visible } : brewGroup + ) + })); + }, + renderBrewCollection : function(brewCollection){ + if(brewCollection == []) return
+

No Brews

+
; return _.map(brewCollection, (brewGroup, idx)=>{ return
-

{brewGroup.title || 'No Title'}

- {this.renderBrews(this.getSortedBrews(brewGroup.brews))} +

{this.toggleBrewCollectionState(brewGroup.class);}}>{brewGroup.title || 'No Title'}

+ {brewGroup.visible ? this.renderBrews(this.getSortedBrews(brewGroup.brews)) : <>}
; }); }, @@ -167,7 +208,7 @@ const ListPage = createClass({
{this.renderSortOptions()} - {this.renderBrewCollection(this.props.brewCollection)} + {this.renderBrewCollection(this.state.brewCollection)}
; diff --git a/client/homebrew/pages/basePages/listPage/listPage.less b/client/homebrew/pages/basePages/listPage/listPage.less index 6be946404..5c86040a7 100644 --- a/client/homebrew/pages/basePages/listPage/listPage.less +++ b/client/homebrew/pages/basePages/listPage/listPage.less @@ -74,4 +74,27 @@ } } } + h1 { + cursor: pointer; + &.active { + color: #58180D; + } + &.active::before { + content: '\f107'; + font-family: 'Font Awesome 5 Free'; + font-weight: 900; + font-size: 0.6cm; + padding-right: 0.5em; + } + &.inactive { + color: #707070; + } + &.inactive::before { + content: '\f105'; + font-family: 'Font Awesome 5 Free'; + font-weight: 900; + font-size: 0.6cm; + padding-right: 0.5em; + } + } } diff --git a/client/homebrew/pages/userPage/userPage.jsx b/client/homebrew/pages/userPage/userPage.jsx index 6c3af7907..861351c6f 100644 --- a/client/homebrew/pages/userPage/userPage.jsx +++ b/client/homebrew/pages/userPage/userPage.jsx @@ -31,17 +31,19 @@ const UserPage = createClass({ const brewCollection = [ { - title : `${usernameWithS} published brews`, - class : 'published', - brews : brews.published + title : `${usernameWithS} published brews`, + class : 'published', + brews : brews.published, + visible : true } ]; if(this.props.username == global.account?.username){ brewCollection.push( { - title : `${usernameWithS} unpublished brews`, - class : 'unpublished', - brews : brews.private + title : `${usernameWithS} unpublished brews`, + class : 'unpublished', + brews : brews.private, + visible : true } ); } From 4bb5e96c4224bb4669af7926f4f587a7bee89dcf Mon Sep 17 00:00:00 2001 From: "G.Ambatte" Date: Sun, 28 Aug 2022 23:46:19 +1200 Subject: [PATCH 02/12] Initial pass at visibility functionality --- .../pages/basePages/listPage/listPage.jsx | 61 ++++++++++++++++--- .../pages/basePages/listPage/listPage.less | 23 +++++++ client/homebrew/pages/userPage/userPage.jsx | 14 +++-- 3 files changed, 82 insertions(+), 16 deletions(-) diff --git a/client/homebrew/pages/basePages/listPage/listPage.jsx b/client/homebrew/pages/basePages/listPage/listPage.jsx index 934d147be..a2a063a37 100644 --- a/client/homebrew/pages/basePages/listPage/listPage.jsx +++ b/client/homebrew/pages/basePages/listPage/listPage.jsx @@ -6,28 +6,58 @@ const moment = require('moment'); const BrewItem = require('./brewItem/brewItem.jsx'); +const USERPAGE_KEY_PREFIX = 'HOMEBREWERY-LISTPAGE-VISIBILITY'; + const ListPage = createClass({ displayName : 'ListPage', getDefaultProps : function() { return { brewCollection : [ { - title : '', - class : '', - brews : [] + title : '', + class : '', + brews : [], + visible : true } ], navItems : <> }; }, getInitialState : function() { + let brewCollection = []; + + if(typeof window !== 'undefined') { + brewCollection = this.props.brewCollection.map((brewGroup)=>{ + const localVisibility = localStorage.getItem(`${USERPAGE_KEY_PREFIX}-${brewGroup.class}`) ?? 'true'; + if(brewGroup.visible != (localVisibility=='true')) { + brewGroup.visible = (localVisibility=='true'); + }; + return brewGroup; + }); + } + return { - sortType : 'alpha', - sortDir : 'asc', - filterString : this.props.query?.filter || '', - query : this.props.query + sortType : 'alpha', + sortDir : 'asc', + filterString : this.props.query?.filter || '', + query : this.props.query, + brewCollection : brewCollection }; }, + componentDidMount : function() { + // SAVE TO LOCAL STORAGE WHEN LEAVING PAGE + window.onbeforeunload = this.saveToLocalStorage; + }, + + componentWillUnmount : function() { + window.onbeforeunload = function(){}; + }, + + saveToLocalStorage : function() { + this.state.brewCollection.map((brewGroup)=>{ + localStorage.setItem(`${USERPAGE_KEY_PREFIX}-${brewGroup.class}`, `${brewGroup.visible}`); + }); + }, renderBrews : function(brews){ if(!brews || !brews.length) return
No Brews.
; @@ -150,11 +180,22 @@ const ListPage = createClass({ return _.orderBy(brews, (brew)=>{ return this.sortBrewOrder(brew); }, this.state.sortDir); }, + toggleBrewCollectionState : function(brewGroupClass) { + this.setState((prevState)=>({ + brewCollection : prevState.brewCollection.map( + (brewGroup)=>brewGroup.class === brewGroupClass ? { ...brewGroup, visible: !brewGroup.visible } : brewGroup + ) + })); + }, + renderBrewCollection : function(brewCollection){ + if(brewCollection == []) return
+

No Brews

+
; return _.map(brewCollection, (brewGroup, idx)=>{ return
-

{brewGroup.title || 'No Title'}

- {this.renderBrews(this.getSortedBrews(brewGroup.brews))} +

{this.toggleBrewCollectionState(brewGroup.class);}}>{brewGroup.title || 'No Title'}

+ {brewGroup.visible ? this.renderBrews(this.getSortedBrews(brewGroup.brews)) : <>}
; }); }, @@ -167,7 +208,7 @@ const ListPage = createClass({
{this.renderSortOptions()} - {this.renderBrewCollection(this.props.brewCollection)} + {this.renderBrewCollection(this.state.brewCollection)}
; diff --git a/client/homebrew/pages/basePages/listPage/listPage.less b/client/homebrew/pages/basePages/listPage/listPage.less index 6be946404..5c86040a7 100644 --- a/client/homebrew/pages/basePages/listPage/listPage.less +++ b/client/homebrew/pages/basePages/listPage/listPage.less @@ -74,4 +74,27 @@ } } } + h1 { + cursor: pointer; + &.active { + color: #58180D; + } + &.active::before { + content: '\f107'; + font-family: 'Font Awesome 5 Free'; + font-weight: 900; + font-size: 0.6cm; + padding-right: 0.5em; + } + &.inactive { + color: #707070; + } + &.inactive::before { + content: '\f105'; + font-family: 'Font Awesome 5 Free'; + font-weight: 900; + font-size: 0.6cm; + padding-right: 0.5em; + } + } } diff --git a/client/homebrew/pages/userPage/userPage.jsx b/client/homebrew/pages/userPage/userPage.jsx index 6c3af7907..861351c6f 100644 --- a/client/homebrew/pages/userPage/userPage.jsx +++ b/client/homebrew/pages/userPage/userPage.jsx @@ -31,17 +31,19 @@ const UserPage = createClass({ const brewCollection = [ { - title : `${usernameWithS} published brews`, - class : 'published', - brews : brews.published + title : `${usernameWithS} published brews`, + class : 'published', + brews : brews.published, + visible : true } ]; if(this.props.username == global.account?.username){ brewCollection.push( { - title : `${usernameWithS} unpublished brews`, - class : 'unpublished', - brews : brews.private + title : `${usernameWithS} unpublished brews`, + class : 'unpublished', + brews : brews.private, + visible : true } ); } From a25c7a5ccdb25af32add47ebd7d99d7b29b1d8a6 Mon Sep 17 00:00:00 2001 From: "G.Ambatte" Date: Mon, 29 Aug 2022 20:39:16 +1200 Subject: [PATCH 03/12] Load from local storage working without errors --- .../pages/basePages/listPage/listPage.jsx | 29 ++++++++++++------- 1 file changed, 18 insertions(+), 11 deletions(-) diff --git a/client/homebrew/pages/basePages/listPage/listPage.jsx b/client/homebrew/pages/basePages/listPage/listPage.jsx index a2a063a37..e8042cbd0 100644 --- a/client/homebrew/pages/basePages/listPage/listPage.jsx +++ b/client/homebrew/pages/basePages/listPage/listPage.jsx @@ -24,17 +24,11 @@ const ListPage = createClass({ }; }, getInitialState : function() { - let brewCollection = []; - - if(typeof window !== 'undefined') { - brewCollection = this.props.brewCollection.map((brewGroup)=>{ - const localVisibility = localStorage.getItem(`${USERPAGE_KEY_PREFIX}-${brewGroup.class}`) ?? 'true'; - if(brewGroup.visible != (localVisibility=='true')) { - brewGroup.visible = (localVisibility=='true'); - }; - return brewGroup; - }); - } + // HIDE ALL GROUPS UNTIL LOADED + const brewCollection = this.props.brewCollection.map((brewGroup)=>{ + brewGroup.visible = false; + return brewGroup; + }); return { sortType : 'alpha', @@ -44,9 +38,22 @@ const ListPage = createClass({ brewCollection : brewCollection }; }, + componentDidMount : function() { // SAVE TO LOCAL STORAGE WHEN LEAVING PAGE window.onbeforeunload = this.saveToLocalStorage; + + // LOAD FROM LOCAL STORAGE + if(typeof window !== 'undefined') { + const brewCollection = this.props.brewCollection.map((brewGroup)=>{ + const localVisibility = (localStorage.getItem(`${USERPAGE_KEY_PREFIX}-${brewGroup.class}`) ?? 'true')=='true'; + brewGroup.visible = (brewGroup.visible != localVisibility ? localVisibility : brewGroup.visible); + return brewGroup; + }); + this.setState({ + brewCollection : brewCollection + }); + }; }, componentWillUnmount : function() { From 9571cb0cc4f55832b621586243603b0a12ced8ba Mon Sep 17 00:00:00 2001 From: "G.Ambatte" Date: Sun, 28 Aug 2022 23:46:19 +1200 Subject: [PATCH 04/12] Initial pass at visibility functionality --- .../pages/basePages/listPage/listPage.jsx | 61 ++++++++++++++++--- .../pages/basePages/listPage/listPage.less | 23 +++++++ client/homebrew/pages/userPage/userPage.jsx | 14 +++-- 3 files changed, 82 insertions(+), 16 deletions(-) diff --git a/client/homebrew/pages/basePages/listPage/listPage.jsx b/client/homebrew/pages/basePages/listPage/listPage.jsx index e546e2c7f..25603255c 100644 --- a/client/homebrew/pages/basePages/listPage/listPage.jsx +++ b/client/homebrew/pages/basePages/listPage/listPage.jsx @@ -6,28 +6,58 @@ const moment = require('moment'); const BrewItem = require('./brewItem/brewItem.jsx'); +const USERPAGE_KEY_PREFIX = 'HOMEBREWERY-LISTPAGE-VISIBILITY'; + const ListPage = createClass({ displayName : 'ListPage', getDefaultProps : function() { return { brewCollection : [ { - title : '', - class : '', - brews : [] + title : '', + class : '', + brews : [], + visible : true } ], navItems : <> }; }, getInitialState : function() { + let brewCollection = []; + + if(typeof window !== 'undefined') { + brewCollection = this.props.brewCollection.map((brewGroup)=>{ + const localVisibility = localStorage.getItem(`${USERPAGE_KEY_PREFIX}-${brewGroup.class}`) ?? 'true'; + if(brewGroup.visible != (localVisibility=='true')) { + brewGroup.visible = (localVisibility=='true'); + }; + return brewGroup; + }); + } + return { - sortType : 'alpha', - sortDir : 'asc', - filterString : this.props.query?.filter || '', - query : this.props.query + sortType : 'alpha', + sortDir : 'asc', + filterString : this.props.query?.filter || '', + query : this.props.query, + brewCollection : brewCollection }; }, + componentDidMount : function() { + // SAVE TO LOCAL STORAGE WHEN LEAVING PAGE + window.onbeforeunload = this.saveToLocalStorage; + }, + + componentWillUnmount : function() { + window.onbeforeunload = function(){}; + }, + + saveToLocalStorage : function() { + this.state.brewCollection.map((brewGroup)=>{ + localStorage.setItem(`${USERPAGE_KEY_PREFIX}-${brewGroup.class}`, `${brewGroup.visible}`); + }); + }, renderBrews : function(brews){ if(!brews || !brews.length) return
No Brews.
; @@ -149,11 +179,22 @@ const ListPage = createClass({ return _.orderBy(brews, (brew)=>{ return this.sortBrewOrder(brew); }, this.state.sortDir); }, + toggleBrewCollectionState : function(brewGroupClass) { + this.setState((prevState)=>({ + brewCollection : prevState.brewCollection.map( + (brewGroup)=>brewGroup.class === brewGroupClass ? { ...brewGroup, visible: !brewGroup.visible } : brewGroup + ) + })); + }, + renderBrewCollection : function(brewCollection){ + if(brewCollection == []) return
+

No Brews

+
; return _.map(brewCollection, (brewGroup, idx)=>{ return
-

{brewGroup.title || 'No Title'}

- {this.renderBrews(this.getSortedBrews(brewGroup.brews))} +

{this.toggleBrewCollectionState(brewGroup.class);}}>{brewGroup.title || 'No Title'}

+ {brewGroup.visible ? this.renderBrews(this.getSortedBrews(brewGroup.brews)) : <>}
; }); }, @@ -166,7 +207,7 @@ const ListPage = createClass({
{this.renderSortOptions()} - {this.renderBrewCollection(this.props.brewCollection)} + {this.renderBrewCollection(this.state.brewCollection)}
; diff --git a/client/homebrew/pages/basePages/listPage/listPage.less b/client/homebrew/pages/basePages/listPage/listPage.less index 64131e35b..317dd88ff 100644 --- a/client/homebrew/pages/basePages/listPage/listPage.less +++ b/client/homebrew/pages/basePages/listPage/listPage.less @@ -74,4 +74,27 @@ } } } + h1 { + cursor: pointer; + &.active { + color: #58180D; + } + &.active::before { + content: '\f107'; + font-family: 'Font Awesome 5 Free'; + font-weight: 900; + font-size: 0.6cm; + padding-right: 0.5em; + } + &.inactive { + color: #707070; + } + &.inactive::before { + content: '\f105'; + font-family: 'Font Awesome 5 Free'; + font-weight: 900; + font-size: 0.6cm; + padding-right: 0.5em; + } + } } diff --git a/client/homebrew/pages/userPage/userPage.jsx b/client/homebrew/pages/userPage/userPage.jsx index 6c3af7907..861351c6f 100644 --- a/client/homebrew/pages/userPage/userPage.jsx +++ b/client/homebrew/pages/userPage/userPage.jsx @@ -31,17 +31,19 @@ const UserPage = createClass({ const brewCollection = [ { - title : `${usernameWithS} published brews`, - class : 'published', - brews : brews.published + title : `${usernameWithS} published brews`, + class : 'published', + brews : brews.published, + visible : true } ]; if(this.props.username == global.account?.username){ brewCollection.push( { - title : `${usernameWithS} unpublished brews`, - class : 'unpublished', - brews : brews.private + title : `${usernameWithS} unpublished brews`, + class : 'unpublished', + brews : brews.private, + visible : true } ); } From e355621bbf6110056b4ead37503f5a59c621c90e Mon Sep 17 00:00:00 2001 From: "G.Ambatte" Date: Mon, 29 Aug 2022 20:39:16 +1200 Subject: [PATCH 05/12] Load from local storage working without errors --- .../pages/basePages/listPage/listPage.jsx | 29 ++++++++++++------- 1 file changed, 18 insertions(+), 11 deletions(-) diff --git a/client/homebrew/pages/basePages/listPage/listPage.jsx b/client/homebrew/pages/basePages/listPage/listPage.jsx index 25603255c..776d16ec7 100644 --- a/client/homebrew/pages/basePages/listPage/listPage.jsx +++ b/client/homebrew/pages/basePages/listPage/listPage.jsx @@ -24,17 +24,11 @@ const ListPage = createClass({ }; }, getInitialState : function() { - let brewCollection = []; - - if(typeof window !== 'undefined') { - brewCollection = this.props.brewCollection.map((brewGroup)=>{ - const localVisibility = localStorage.getItem(`${USERPAGE_KEY_PREFIX}-${brewGroup.class}`) ?? 'true'; - if(brewGroup.visible != (localVisibility=='true')) { - brewGroup.visible = (localVisibility=='true'); - }; - return brewGroup; - }); - } + // HIDE ALL GROUPS UNTIL LOADED + const brewCollection = this.props.brewCollection.map((brewGroup)=>{ + brewGroup.visible = false; + return brewGroup; + }); return { sortType : 'alpha', @@ -44,9 +38,22 @@ const ListPage = createClass({ brewCollection : brewCollection }; }, + componentDidMount : function() { // SAVE TO LOCAL STORAGE WHEN LEAVING PAGE window.onbeforeunload = this.saveToLocalStorage; + + // LOAD FROM LOCAL STORAGE + if(typeof window !== 'undefined') { + const brewCollection = this.props.brewCollection.map((brewGroup)=>{ + const localVisibility = (localStorage.getItem(`${USERPAGE_KEY_PREFIX}-${brewGroup.class}`) ?? 'true')=='true'; + brewGroup.visible = (brewGroup.visible != localVisibility ? localVisibility : brewGroup.visible); + return brewGroup; + }); + this.setState({ + brewCollection : brewCollection + }); + }; }, componentWillUnmount : function() { From 66626b3427b431a9be298283e92ca755dd410fa4 Mon Sep 17 00:00:00 2001 From: "G.Ambatte" Date: Thu, 1 Sep 2022 20:06:30 +1200 Subject: [PATCH 06/12] Remove unnecessary `visible` from UserPage props --- client/homebrew/pages/basePages/listPage/listPage.jsx | 10 ++++------ client/homebrew/pages/userPage/userPage.jsx | 7 +++---- 2 files changed, 7 insertions(+), 10 deletions(-) diff --git a/client/homebrew/pages/basePages/listPage/listPage.jsx b/client/homebrew/pages/basePages/listPage/listPage.jsx index 776d16ec7..5fbb3c9de 100644 --- a/client/homebrew/pages/basePages/listPage/listPage.jsx +++ b/client/homebrew/pages/basePages/listPage/listPage.jsx @@ -14,10 +14,9 @@ const ListPage = createClass({ return { brewCollection : [ { - title : '', - class : '', - brews : [], - visible : true + title : '', + class : '', + brews : [] } ], navItems : <> @@ -46,8 +45,7 @@ const ListPage = createClass({ // LOAD FROM LOCAL STORAGE if(typeof window !== 'undefined') { const brewCollection = this.props.brewCollection.map((brewGroup)=>{ - const localVisibility = (localStorage.getItem(`${USERPAGE_KEY_PREFIX}-${brewGroup.class}`) ?? 'true')=='true'; - brewGroup.visible = (brewGroup.visible != localVisibility ? localVisibility : brewGroup.visible); + brewGroup.visible = (localStorage.getItem(`${USERPAGE_KEY_PREFIX}-${brewGroup.class}`) ?? 'true')=='true'; return brewGroup; }); this.setState({ diff --git a/client/homebrew/pages/userPage/userPage.jsx b/client/homebrew/pages/userPage/userPage.jsx index 861351c6f..c9abc5d76 100644 --- a/client/homebrew/pages/userPage/userPage.jsx +++ b/client/homebrew/pages/userPage/userPage.jsx @@ -40,10 +40,9 @@ const UserPage = createClass({ if(this.props.username == global.account?.username){ brewCollection.push( { - title : `${usernameWithS} unpublished brews`, - class : 'unpublished', - brews : brews.private, - visible : true + title : `${usernameWithS} unpublished brews`, + class : 'unpublished', + brews : brews.private } ); } From 80428fc4125b68ad001a54f53c89ff3b44f4b387 Mon Sep 17 00:00:00 2001 From: "G.Ambatte" Date: Thu, 1 Sep 2022 23:03:33 +1200 Subject: [PATCH 07/12] Expand `updateUrl` function --- .../pages/basePages/listPage/listPage.jsx | 21 ++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) diff --git a/client/homebrew/pages/basePages/listPage/listPage.jsx b/client/homebrew/pages/basePages/listPage/listPage.jsx index e546e2c7f..b360adc6e 100644 --- a/client/homebrew/pages/basePages/listPage/listPage.jsx +++ b/client/homebrew/pages/basePages/listPage/listPage.jsx @@ -22,9 +22,9 @@ const ListPage = createClass({ }, getInitialState : function() { return { - sortType : 'alpha', - sortDir : 'asc', filterString : this.props.query?.filter || '', + sortType : this.props.query?.sort || 'alpha', + sortDir : this.props.query?.dir || 'asc', query : this.props.query }; }, @@ -50,14 +50,18 @@ const ListPage = createClass({ }, handleSortOptionChange : function(event){ + this.updateUrl(this.state.filterString, event.target.value, this.state.sortDir); this.setState({ sortType : event.target.value }); }, handleSortDirChange : function(event){ + const newDir = this.state.sortDir == 'asc' ? 'desc' : 'asc'; + + this.updateUrl(this.state.filterString, this.state.sortType, newDir); this.setState({ - sortDir : `${(this.state.sortDir == 'asc' ? 'desc' : 'asc')}` + sortDir : newDir }); }, @@ -77,19 +81,22 @@ const ListPage = createClass({ this.setState({ filterString : e.target.value, }); - this.updateUrl(e.target.value); + this.updateUrl(e.target.value, this.state.sortType, this.state.sortDir); return; }, - updateUrl : function(filterTerm){ + updateUrl : function(filterTerm, sortType, sortDir){ const url = new URL(window.location.href); const urlParams = new URLSearchParams(url.search); - if(urlParams.get('filter') == filterTerm) - return; + + urlParams.set('sort', sortType); + urlParams.set('dir', sortDir); + if(!filterTerm) urlParams.delete('filter'); else urlParams.set('filter', filterTerm); + url.search = urlParams; window.history.replaceState(null, null, url); }, From 3262751fea3024bee233a302d01b409d0d0d2fbb Mon Sep 17 00:00:00 2001 From: "G.Ambatte" Date: Thu, 1 Sep 2022 23:25:52 +1200 Subject: [PATCH 08/12] Add tags to UserPage BrewItem --- .../pages/basePages/listPage/brewItem/brewItem.jsx | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/client/homebrew/pages/basePages/listPage/brewItem/brewItem.jsx b/client/homebrew/pages/basePages/listPage/brewItem/brewItem.jsx index 5756b0df1..7efb2248b 100644 --- a/client/homebrew/pages/basePages/listPage/brewItem/brewItem.jsx +++ b/client/homebrew/pages/basePages/listPage/brewItem/brewItem.jsx @@ -104,6 +104,13 @@ const BrewItem = createClass({
+ {brew.tags ? <> + + {brew.tags.join(', ')} + +
+ : <> + } {brew.authors?.join(', ')} From 407d3565cd7c484619c2eef669688a89ba0a970f Mon Sep 17 00:00:00 2001 From: Trevor Buckner Date: Thu, 1 Sep 2022 11:05:47 -0400 Subject: [PATCH 09/12] Fix /new page "default" values not being read --- client/homebrew/pages/newPage/newPage.jsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/client/homebrew/pages/newPage/newPage.jsx b/client/homebrew/pages/newPage/newPage.jsx index 3986916a5..895438997 100644 --- a/client/homebrew/pages/newPage/newPage.jsx +++ b/client/homebrew/pages/newPage/newPage.jsx @@ -72,7 +72,7 @@ const NewPage = createClass({ componentDidMount : function() { document.addEventListener('keydown', this.handleControlKeys); - const brew = this.props.brew; + const brew = this.state.brew; if(typeof window !== 'undefined') { //Load from localStorage if in client browser const brewStorage = localStorage.getItem(BREWKEY); From 3f1bc028852b03b35855a70410715bb81192e2c0 Mon Sep 17 00:00:00 2001 From: "G.Ambatte" Date: Sat, 3 Sep 2022 09:58:17 +1200 Subject: [PATCH 10/12] Reduce duplicate CSS Co-authored-by: Trevor Buckner --- .../pages/basePages/listPage/listPage.less | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/client/homebrew/pages/basePages/listPage/listPage.less b/client/homebrew/pages/basePages/listPage/listPage.less index 317dd88ff..d4efbe445 100644 --- a/client/homebrew/pages/basePages/listPage/listPage.less +++ b/client/homebrew/pages/basePages/listPage/listPage.less @@ -79,22 +79,21 @@ &.active { color: #58180D; } - &.active::before { - content: '\f107'; + &.inactive { + color: #707070; + + } + &.active::before, &.inactive::before { font-family: 'Font Awesome 5 Free'; font-weight: 900; font-size: 0.6cm; - padding-right: 0.5em; + padding-right: 0.5em; } - &.inactive { - color: #707070; + &.active::before { + content: '\f107'; } &.inactive::before { content: '\f105'; - font-family: 'Font Awesome 5 Free'; - font-weight: 900; - font-size: 0.6cm; - padding-right: 0.5em; } } } From b9f64092b8892b1e48147a5171def9795bb7e0fa Mon Sep 17 00:00:00 2001 From: "G.Ambatte" Date: Sat, 3 Sep 2022 12:48:04 +1200 Subject: [PATCH 11/12] Remove unnecessary `visible` from UserPage --- client/homebrew/pages/userPage/userPage.jsx | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/client/homebrew/pages/userPage/userPage.jsx b/client/homebrew/pages/userPage/userPage.jsx index c9abc5d76..6c3af7907 100644 --- a/client/homebrew/pages/userPage/userPage.jsx +++ b/client/homebrew/pages/userPage/userPage.jsx @@ -31,10 +31,9 @@ const UserPage = createClass({ const brewCollection = [ { - title : `${usernameWithS} published brews`, - class : 'published', - brews : brews.published, - visible : true + title : `${usernameWithS} published brews`, + class : 'published', + brews : brews.published } ]; if(this.props.username == global.account?.username){ From 9807e24e0ab94278a92acf7472f7adfc5cc463c1 Mon Sep 17 00:00:00 2001 From: "G.Ambatte" Date: Sat, 3 Sep 2022 12:58:45 +1200 Subject: [PATCH 12/12] Add `brewTags` class to BrewItem tags --- client/homebrew/pages/basePages/listPage/brewItem/brewItem.jsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/client/homebrew/pages/basePages/listPage/brewItem/brewItem.jsx b/client/homebrew/pages/basePages/listPage/brewItem/brewItem.jsx index 7efb2248b..fc69466f1 100644 --- a/client/homebrew/pages/basePages/listPage/brewItem/brewItem.jsx +++ b/client/homebrew/pages/basePages/listPage/brewItem/brewItem.jsx @@ -105,7 +105,7 @@ const BrewItem = createClass({
{brew.tags ? <> - + {brew.tags.join(', ')}