Skip to content

Commit

Permalink
Client - Display number of active filters (#239)
Browse files Browse the repository at this point in the history
  • Loading branch information
luorlandini authored Jun 11, 2021
1 parent 24323fb commit 1145130
Show file tree
Hide file tree
Showing 7 changed files with 12 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ const FiltersMenu = forwardRef(({
defaultLabelId,
onClear,
totalResources,
totalFilters,
filtersActive
}, ref) => {

Expand All @@ -46,7 +47,7 @@ const FiltersMenu = forwardRef(({
size="sm"
onClick={onClick}
>
<Message msgId="gnhome.filters" />
<Message msgId="gnhome.filtersCount" msgParams={{ count: totalFilters }} />
</Button>
{filtersActive && <Button
variant="default"
Expand Down
12 changes: 5 additions & 7 deletions geonode_mapstore_client/client/js/routes/Home.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -309,11 +309,9 @@ function Home({


const { query } = url.parse(location.search, true);

const queryFilters = Object.keys(query).reduce((acc, key) => key.indexOf('filter') === 0
? [...acc, ...castArray(query[key]).map((value) => ({ key, value }))]
: acc, []);

const queryFilters = Object.keys(query).reduce((acc, key) => key.indexOf('sort') === 0
? acc
: [...acc, ...castArray(query[key]).map((value) => ({ key, value }))], []);

const pk = match.params.pk;
const ctype = match.params.ctype;
Expand Down Expand Up @@ -479,7 +477,6 @@ function Home({
column={ hideHero &&
<ConnectedDetailsPanel
resource={resource}
filters={queryFilters}
linkHref={hrefDetailPanel}
formatHref={handleFormatHref}
sectionStyle={{
Expand Down Expand Up @@ -521,7 +518,8 @@ function Home({
orderOptions={filters?.order?.options}
defaultLabelId={filters?.order?.defaultLabelId}
totalResources={totalResources}
filtersActive={!!(queryFilters.length > 0 || query.f || query.extent)}
totalFilters={queryFilters.length}
filtersActive={!!(queryFilters.length > 0)}
/>

</ConnectedCardGrid>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@
"register": "Registrieren",
"signIn": "Anmelden",
"filters": "Filter",
"filtersCount": "{count, plural, =0 { Filter } other {Filter (#)}}",
"admin": "Admin",
"logOut": "Ausloggen",
"terms": "Terms",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@
"register": "Register",
"signIn": "Sign in",
"filters": "Filters",
"filtersCount": "{count, plural, =0 { Filters } other {Filters (#)}}",
"admin": "Admin",
"logOut": "Log out",
"terms": "Terms",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@
"register": "Registrarse",
"signIn": "Ingresar",
"filters": "Filtros",
"filtersCount": "{count, plural, =0 { Filtros } other {Filtros (#)}}",
"admin": "Administración",
"logOut": "Salir",
"terms": "Terms",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@
"register": "S'inscrire",
"signIn": "Connexion",
"filters": "Filtres",
"filtersCount": "{count, plural, =0 { Filtres } other {Filtres (#)}}",
"admin": "Administration",
"logOut": "Se déconnecter",
"terms": "Terms",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@
"register": "Registrati",
"signIn": "Accedi",
"filters": "Filtri",
"filtersCount": "{count, plural, =0 { Filtri } other {Filtri (#)}}",
"myresources": "Risorse",
"mylink": "I miei Link",
"admin": "Amministrazione",
Expand Down

0 comments on commit 1145130

Please sign in to comment.