Skip to content

Commit

Permalink
Refactor and simplify webcomponent props
Browse files Browse the repository at this point in the history
  • Loading branch information
jimbiscuit committed Jan 20, 2023
1 parent 89c32f2 commit c15e8bd
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 16 deletions.
3 changes: 3 additions & 0 deletions CHANGES.rst
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@ Changelog
1.1.2 (unreleased)
------------------

- Refactor and simplify webcomponent props
[Julien]

- Fix search webcomponent in offcanvas
[Julien]

Expand Down
6 changes: 5 additions & 1 deletion src/imio/smartweb/core/browser/search/search.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
from Products.CMFPlone.browser.search import Search
from Products.CMFPlone.utils import normalizeString

import json


class Search(Search):
valid_keys = ("sort_on", "sort_order", "sort_limit", "fq", "fl", "facet", "core")
Expand Down Expand Up @@ -58,8 +60,10 @@ def get_search_result_option(self):
events_entity_uid = api.portal.get_registry_record("smartweb.events_entity_uid")
news_entity_uid = api.portal.get_registry_record("smartweb.news_entity_uid")

return {
response = {
"directory": bool(directory_entity_uid),
"events": bool(events_entity_uid),
"news": bool(news_entity_uid),
}

return json.dumps(response)
Original file line number Diff line number Diff line change
Expand Up @@ -8,28 +8,15 @@ import WebResult from "./WebResult/WebResult";
import useFilterQuery from "../../hooks/useFilterQuery";
import "./Search.scss";

const jsonParse = (string) => {
return JSON.parse(
string.replaceAll("'", '"').replaceAll("False", '"False"').replaceAll("True", '"True"'),
(key, value) => {
if (value === "True") {
return true;
}
if (value === "False") {
return false;
}
return value;
}
);
};

export default function Search(props) {

return (
<Router>
<SearchView
queryFilterUrl={props.queryFilterUrl}
queryUrl={props.queryUrl}
resultOption={jsonParse(props.resultOption)}
resultOption={JSON.parse(props.resultOption)}
/>
</Router>
);
Expand Down

0 comments on commit c15e8bd

Please sign in to comment.