Skip to content
Snippets Groups Projects
Commit d5f2e992 authored by esikkala's avatar esikkala
Browse files

Sketching generalized perspective component

parent b4d6fc74
No related branches found
No related tags found
No related merge requests found
import React, { lazy } from 'react' import React, { lazy } from 'react'
import PropTypes from 'prop-types' import PropTypes from 'prop-types'
import intl from 'react-intl-universal' // import intl from 'react-intl-universal'
import { Route, Redirect } from 'react-router-dom' import { Route, Redirect } from 'react-router-dom'
import PerspectiveTabs from '../../main_layout/PerspectiveTabs' import PerspectiveTabs from '../../main_layout/PerspectiveTabs'
const ResultTable = lazy(() => import('../../facet_results/ResultTable')) const ResultTable = lazy(() => import('../../facet_results/ResultTable'))
const LeafletMap = lazy(() => import('../../facet_results/LeafletMap')) // const LeafletMap = lazy(() => import('../../facet_results/LeafletMap'))
const Deck = lazy(() => import('../../facet_results/Deck')) // const Deck = lazy(() => import('../../facet_results/Deck'))
const ApexChart = lazy(() => import('../../facet_results/ApexChart')) // const ApexChart = lazy(() => import('../../facet_results/ApexChart'))
const BarChartRace = lazy(() => import('../../facet_results/BarChartRace')) // const BarChartRace = lazy(() => import('../../facet_results/BarChartRace'))
const Network = lazy(() => import('../../facet_results/Network')) // const Network = lazy(() => import('../../facet_results/Network'))
const Export = lazy(() => import('../../facet_results/Export')) // const Export = lazy(() => import('../../facet_results/Export'))
const Perspective1 = props => { const Perspective1 = props => {
const { rootUrl, perspective, screenSize, portalConfig } = props const { rootUrl, perspective, /* screenSize, */ portalConfig } = props
const layerControlExpanded = screenSize === 'md' || const { searchMode } = perspective
screenSize === 'lg' || const perspectiveID = perspective.id
screenSize === 'xl' console.log(perspective)
let popupMaxHeight = 320 // const layerControlExpanded = screenSize === 'md' ||
let popupMinWidth = 280 // screenSize === 'lg' ||
let popupMaxWidth = 280 // screenSize === 'xl'
if (screenSize === 'xs' || screenSize === 'sm') { // let popupMaxHeight = 320
popupMaxHeight = 200 // let popupMinWidth = 280
popupMinWidth = 150 // let popupMaxWidth = 280
popupMaxWidth = 150 // if (screenSize === 'xs' || screenSize === 'sm') {
} // popupMaxHeight = 200
return ( // popupMinWidth = 150
<> // popupMaxWidth = 150
<PerspectiveTabs // }
routeProps={props.routeProps} const defaultResultClassConfig = perspective.resultClasses[perspectiveID].paginatedResultsConfig
tabs={props.perspective.tabs}
screenSize={props.screenSize} const createRouteForTab = (resultClass, resultClassConfig) => {
layoutConfig={props.layoutConfig} const { tabPath } = resultClassConfig
/> const facetClass = resultClassConfig.facetClass ? resultClassConfig.facetClass : resultClass
<Route const Component = ResultTable
exact path={`${rootUrl}/${perspective.id}/faceted-search`} return (
render={() => <Redirect to={`${rootUrl}/${perspective.id}/faceted-search/table`} />}
/>
<Route <Route
path={[`${props.rootUrl}/${perspective.id}/faceted-search/table`, '/iframe.html']} path={[`${rootUrl}/${perspectiveID}/${searchMode}/${tabPath}`, '/iframe.html']}
key={resultClass}
render={routeProps => render={routeProps =>
<ResultTable <Component
portalConfig={portalConfig} portalConfig={portalConfig}
data={props.perspectiveState} data={props.perspectiveState}
facetUpdateID={props.facetState.facetUpdateID} facetUpdateID={props.facetState.facetUpdateID}
resultClass='perspective1' resultClass={resultClass}
facetClass='perspective1' facetClass={facetClass}
fetchPaginatedResults={props.fetchPaginatedResults} fetchPaginatedResults={props.fetchPaginatedResults}
updatePage={props.updatePage} updatePage={props.updatePage}
updateRowsPerPage={props.updateRowsPerPage} updateRowsPerPage={props.updateRowsPerPage}
...@@ -54,7 +53,23 @@ const Perspective1 = props => { ...@@ -54,7 +53,23 @@ const Perspective1 = props => {
layoutConfig={props.layoutConfig} layoutConfig={props.layoutConfig}
/>} />}
/> />
)
}
return (
<>
<PerspectiveTabs
routeProps={props.routeProps}
tabs={props.perspective.tabs}
screenSize={props.screenSize}
layoutConfig={props.layoutConfig}
/>
<Route <Route
exact path={`${rootUrl}/${perspective.id}/faceted-search`}
render={() => <Redirect to={`${rootUrl}/${perspective.id}/faceted-search/table`} />}
/>
{createRouteForTab(perspectiveID, defaultResultClassConfig)}
{/* <Route
path={`${rootUrl}/${perspective.id}/faceted-search/production_places`} path={`${rootUrl}/${perspective.id}/faceted-search/production_places`}
render={() => render={() =>
<LeafletMap <LeafletMap
...@@ -333,7 +348,7 @@ const Perspective1 = props => { ...@@ -333,7 +348,7 @@ const Perspective1 = props => {
updatePage={props.updatePage} updatePage={props.updatePage}
layoutConfig={props.layoutConfig} layoutConfig={props.layoutConfig}
/>} />}
/> /> */}
</> </>
) )
} }
......
...@@ -18,6 +18,10 @@ ...@@ -18,6 +18,10 @@
"resultClasses": { "resultClasses": {
"perspective1": { "perspective1": {
"paginatedResultsConfig": { "paginatedResultsConfig": {
"component": "ResultTable",
"tabID": 0,
"tabPath": "table",
"tabIcon": "CalendarViewDay",
"propertiesQueryBlock": "manuscriptPropertiesFacetResults", "propertiesQueryBlock": "manuscriptPropertiesFacetResults",
"paginatedResultsAlwaysExpandRows": true, "paginatedResultsAlwaysExpandRows": true,
"paginatedResultsRowContentMaxHeight": 190, "paginatedResultsRowContentMaxHeight": 190,
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment