Skip to content

Commit

Permalink
Merge pull request #277 from mlibrary/parser_test_1
Browse files Browse the repository at this point in the history
Parser test 1
  • Loading branch information
bertrama authored Mar 30, 2021
2 parents db05d85 + 015a37f commit 71af41a
Show file tree
Hide file tree
Showing 12 changed files with 769 additions and 499 deletions.
19 changes: 16 additions & 3 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

93 changes: 42 additions & 51 deletions src/modules/institution/components/InstitutionSelect/index.js
Original file line number Diff line number Diff line change
@@ -1,53 +1,41 @@
import React from 'react';
import { connect } from 'react-redux'
import { bindActionCreators } from 'redux'
import { _ } from 'underscore'
import { withRouter } from 'react-router-dom';
import ReactGA from 'react-ga'
import {
setActiveInstitution
} from '../../../institution'

import {
stringifySearchQueryForURL
} from '../../../pride'
import React from "react";
import { connect } from "react-redux";
import { _ } from "underscore";
import { withRouter } from "react-router-dom";
import ReactGA from "react-ga";

import { stringifySearchQueryForURL } from "../../../pride";

class InstitutionSelect extends React.Component {
handleChange(event) {
const {
searchQuery,
activeFilters,
activeDatastore,
history
} = this.props
const { searchQuery, activeFilters, activeDatastore, history } = this.props;

const queryString = stringifySearchQueryForURL({
query: searchQuery,
filter: activeFilters,
library: event.target.value
})
library: event.target.value,
});

ReactGA.event({
action: 'Select',
category: 'Filter',
label: `Change Scope to ${event.target.value}`
})
action: "Select",
category: "Filter",
label: `Change Scope to ${event.target.value}`,
});

history.push(`/${activeDatastore.slug}?${queryString}`)
history.push(`/${activeDatastore.slug}?${queryString}`);
}

render() {
const { activeDatastore, type } = this.props
const { active, defaultInstitution, options } = this.props.institution
const { activeDatastore, type } = this.props;
const { active, defaultInstitution, options } = this.props.institution;

// This feature is only for Mirlyn.
if (activeDatastore.uid !== 'mirlyn') {
return null
if (activeDatastore.uid !== "mirlyn") {
return null;
}

if (type === 'switch') {
const selectedOption = active ? active : defaultInstitution
if (type === "switch") {
const selectedOption = active ? active : defaultInstitution;

return (
<fieldset className="radio-fieldset">
Expand All @@ -61,47 +49,50 @@ class InstitutionSelect extends React.Component {
value={option}
onChange={(event) => this.handleChange(event)}
/>
<label htmlFor={`library-${index}`} className={`radio-label ${selectedOption === option ? 'radio-selected' : ''}`}><span className="radio-label-text">{option}</span></label>
<label
htmlFor={`library-${index}`}
className={`radio-label ${
selectedOption === option ? "radio-selected" : ""
}`}
>
<span className="radio-label-text">{option}</span>
</label>
</span>
))}
</fieldset>
)
);
} else {
return (
<fieldset className="institution-select-container">
<label className="institution-select-label"><span className="institution-select-label-text">Library Scope</span>
<label className="institution-select-label">
<span className="institution-select-label-text">Library Scope</span>
<select
className="dropdown"
value={active ? active : defaultInstitution}
onChange={(event) => this.handleChange(event)}
>
{options.map((option, index) =>
<option value={option} key={index}>{option}</option>
)}
{options.map((option, index) => (
<option value={option} key={index}>
{option}
</option>
))}
</select>
</label>
</fieldset>
)
);
}
}
}

function mapStateToProps(state) {
return {
activeDatastore: _.findWhere(state.datastores.datastores, { uid: state.datastores.active }),
activeDatastore: _.findWhere(state.datastores.datastores, {
uid: state.datastores.active,
}),
institution: state.institution,
activeFilters: state.filters.active[state.datastores.active],
searchQuery: state.search.query
searchQuery: state.search.query,
};
}

function mapDispatchToProps(dispatch) {
return bindActionCreators({
setActiveInstitution
}, dispatch)
}

export default withRouter(connect(
mapStateToProps,
mapDispatchToProps
)(InstitutionSelect))
export default withRouter(connect(mapStateToProps)(InstitutionSelect));
24 changes: 12 additions & 12 deletions src/modules/pages/components/DatastorePage/container.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ import {
DatastoreInfo,
Landing,
DatastoreAuthenticationAlert,
DatastoreAlerts
DatastoreAlerts,
} from "../../../datastores";

import { Filters } from "../../../filters";
Expand All @@ -28,7 +28,7 @@ import {
RecordList,
Pagination,
BentoboxList,
RecordFull
RecordFull,
} from "../../../records";

import { GetThisPage } from "../../../getthis";
Expand Down Expand Up @@ -71,7 +71,7 @@ class DatastorePageContainer extends React.Component {
location,
isAdvanced,
activeFilterCount,
activeDatastore
activeDatastore,
} = this.props;

if (activeDatastore === undefined) {
Expand Down Expand Up @@ -123,11 +123,11 @@ class DatastorePageContainer extends React.Component {
marginTop: "-0.75rem",
".alert-inner": {
display: "flex",
justifyContent: "center"
justifyContent: "center",
},
":empty": {
display: "none"
}
display: "none",
},
}}
>
<DatastoreAlerts />
Expand All @@ -137,21 +137,21 @@ class DatastorePageContainer extends React.Component {
<ConnectedSwitch>
<Route
path={match.url + `/record/:recordUid/get-this/:barcode`}
render={props => {
render={(props) => {
return <GetThisPage />;
}}
/>
<Route
path={match.url + `/record/:recordUid`}
exact
render={props => {
render={(props) => {
return <RecordFull />;
}}
/>
<Route
path={match.url + `/list`}
exact
render={props => {
render={(props) => {
return <List />;
}}
/>
Expand Down Expand Up @@ -199,7 +199,7 @@ const Results = ({ searching, activeDatastore, activeFilterCount }) => {
{!activeDatastore.isMultisearch ? (
<div className="side-container">
<MediaQuery minWidth={980}>
{matches => {
{(matches) => {
if (matches) {
return (
<React.Fragment>
Expand Down Expand Up @@ -266,11 +266,11 @@ function mapStateToProps(state) {
query: state.search.query,
datastores: state.datastores,
activeDatastore: _.findWhere(state.datastores.datastores, {
uid: state.datastores.active
uid: state.datastores.active,
}),
location: state.router.location,
isAdvanced: state.advanced[state.datastores.active] ? true : false,
activeFilterCount: activeFilters ? Object.keys(activeFilters).length : 0
activeFilterCount: activeFilters ? Object.keys(activeFilters).length : 0,
};
}

Expand Down
Loading

0 comments on commit 71af41a

Please sign in to comment.