Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Minor bugfixes #180

Merged
merged 1 commit into from
Sep 9, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,7 @@ class ExportSearchResultsWithState extends Component {

// append the `format` param
const params = Qs.parse(queryString);
params['page'] = 1; // Start from the first page
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

how will it behave with other pages?

Copy link
Member Author

@FlorianCassayre FlorianCassayre Sep 9, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

New behavior: the button has the same effect, regardless the currently selected page. Namely it exports the results of the search without taking pagination into account. I assumed this was the intended semantic of that button since it's said to return the "first 10,000 records".
Did I miss something?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I need to investigate this further to make sure, I will merge this and start a ticket

params['format'] = format;
const args = Qs.stringify(params);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { Menu } from 'semantic-ui-react';
export default class ScrollingMenuItem extends Component {
constructor(props) {
super(props);
this.state = { activeItem: props.children[0].elementId };
this.state = { activeItem: props.children[0].props.elementId };
}

setActiveLink = elementId => {
Expand Down
7 changes: 4 additions & 3 deletions src/lib/modules/Document/DocumentAuthors.js
Original file line number Diff line number Diff line change
Expand Up @@ -171,12 +171,13 @@ class DocumentAuthors extends Component {
} = this.props;
const { isExpanded } = this.state;

let displayedAuthors = authors;
const allAuthors = authors ? authors : [];
let displayedAuthors = allAuthors;
if (!isExpanded) {
displayedAuthors = authors.slice(0, limit);
displayedAuthors = allAuthors.slice(0, limit);
}

const isShowingAllAuthors = displayedAuthors.length === authors.length;
const isShowingAllAuthors = displayedAuthors.length === allAuthors.length;
const showAllAuthorsCmp =
!isShowingAllAuthors && expandable ? (
<>
Expand Down
4 changes: 4 additions & 0 deletions src/lib/modules/ESSelector/ESSelector.js
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,7 @@ class ESSelector extends Component {
delay,
alwaysWildcard,
minCharacters,
focus,
serializer,
onSearchChange,
onResults,
Expand All @@ -148,6 +149,7 @@ class ESSelector extends Component {
alwaysWildcard={alwaysWildcard}
minCharacters={minCharacters}
placeholder={placeholder}
focus={focus}
serializer={serializer}
onResults={onResults}
onSelect={this.onSelectResult}
Expand Down Expand Up @@ -186,6 +188,7 @@ ESSelector.propTypes = {
name: PropTypes.string,
selectionInfoText: PropTypes.string,
emptySelectionInfoText: PropTypes.string,
focus: PropTypes.bool,
};

ESSelector.defaultProps = {
Expand All @@ -196,6 +199,7 @@ ESSelector.defaultProps = {
emptySelectionInfoText: null,
selectionInfoText: null,
onResults: null,
focus: false,
};

export default Overridable.component('ESSelector', ESSelector);
6 changes: 4 additions & 2 deletions src/lib/modules/ESSelector/ESSelectorLoanRequest.js
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ export default class ESSelectorLoanRequest extends Component {

render() {
const { title, content, selectorComponent, size, trigger } = this.props;
const { visible, missingPatron } = this.state;
const { visible, missingPatron, selections } = this.state;
const modalTrigger = React.cloneElement(trigger, {
onClick: this.toggle,
});
Expand Down Expand Up @@ -157,7 +157,9 @@ export default class ESSelectorLoanRequest extends Component {
<Button color="black" onClick={this.toggle}>
Close
</Button>
<Button onClick={this.save}>Request</Button>
<Button onClick={this.save} disabled={_isEmpty(selections)}>
Request
</Button>
</Modal.Actions>
</Segment>
</Segment.Group>
Expand Down
8 changes: 5 additions & 3 deletions src/lib/modules/ESSelector/HitsSearch.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,11 +38,12 @@ export class HitsSearch extends Component {
}
}

componentDidMount() {
if (this.searchInputRef) {
componentDidMount = () => {
const { focus } = this.props;
if (focus && this.searchInputRef) {
this.searchInputRef.focus();
}
}
};

clear = () => this.setState(initialState);

Expand Down Expand Up @@ -201,6 +202,7 @@ HitsSearch.propTypes = {
onSelect: PropTypes.func,
open: PropTypes.bool,
query: PropTypes.func.isRequired,
focus: PropTypes.bool,
};

HitsSearch.defaultProps = {
Expand Down
34 changes: 23 additions & 11 deletions src/lib/modules/Literature/LiteratureCover.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,21 +17,31 @@ class LiteratureCover extends Component {
};

render() {
const { asItem, isRestricted, linkTo, size, url, ...uiProps } = this.props;
const {
asItem,
isRestricted,
linkTo,
size,
url,
isLoading,
...uiProps
} = this.props;
const Cmp = asItem ? Item.Image : Image;
const link = linkTo ? { as: Link, to: linkTo } : {};
return url ? (
<Overridable id="LiteratureCover.layout" {...this.props}>
<Cmp
centered
disabled={isRestricted}
label={this.getLabel(isRestricted)}
{...link}
onError={e => (e.target.style.display = 'none')}
src={url}
size={size}
{...uiProps}
/>
{!isLoading && (
<Cmp
centered
disabled={isRestricted}
label={this.getLabel(isRestricted)}
{...link}
onError={e => (e.target.style.display = 'none')}
src={url}
size={size}
{...uiProps}
/>
)}
</Overridable>
) : (
<Overridable id="LiteratureCover.placeholder" {...this.props}>
Expand All @@ -49,6 +59,7 @@ LiteratureCover.propTypes = {
linkTo: PropTypes.string,
size: PropTypes.string,
url: PropTypes.string,
isLoading: PropTypes.bool,
};

LiteratureCover.defaultProps = {
Expand All @@ -57,6 +68,7 @@ LiteratureCover.defaultProps = {
linkTo: null,
size: 'large',
url: null,
isLoading: false,
};

export default Overridable.component('LiteratureCover', LiteratureCover);
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@ export class SearchSortOrderElementMobile extends Component {
constructor(props) {
super(props);
const { currentSortOrder, options, onValueChange } = this.props;
options.map((element, index) => {
this.buttons = {};
options.forEach((element, index) => {
this.buttons[element.value] = (
<Button
icon
Expand All @@ -27,7 +28,6 @@ export class SearchSortOrderElementMobile extends Component {
/>
</Button>
);
return this.buttons;
});
}

Expand Down
4 changes: 4 additions & 0 deletions src/lib/modules/Series/__snapshots__/SeriesCard.test.js.snap
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ exports[`SeriesCard tests should go to book details when clicking on a book 1`]
>
<LiteratureCover
asItem={false}
isLoading={false}
isRestricted={false}
linkTo={null}
size="small"
Expand All @@ -54,6 +55,7 @@ exports[`SeriesCard tests should go to book details when clicking on a book 1`]
<Overridable
asItem={false}
id="LiteratureCover.placeholder"
isLoading={false}
isRestricted={false}
linkTo={null}
size="small"
Expand Down Expand Up @@ -211,6 +213,7 @@ exports[`SeriesCard tests should render the SeriesCard 1`] = `
>
<LiteratureCover
asItem={false}
isLoading={false}
isRestricted={false}
linkTo={null}
size="small"
Expand All @@ -219,6 +222,7 @@ exports[`SeriesCard tests should render the SeriesCard 1`] = `
<Overridable
asItem={false}
id="LiteratureCover.placeholder"
isLoading={false}
isRestricted={false}
linkTo={null}
size="small"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -86,12 +86,16 @@ class CreateLoan extends React.Component {
constructor(props) {
super(props);
this.today = toShortDate(DateTime.local());
this.state = {
this.state = this.initialState();
}

initialState = () => {
return {
modalOpen: false,
startDate: this.today,
endDate: '',
};
}
};

handleStartDateChange = value => {
this.setState({ startDate: value });
Expand All @@ -106,7 +110,7 @@ class CreateLoan extends React.Component {
};

handleCloseModal = () => {
this.setState({ modalOpen: false });
this.setState(this.initialState());
};

isSelectionValid = () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,8 @@ export default class ItemPendingLoans extends Component {
) ||
!invenioConfig.ITEMS.canCirculateStatuses.includes(
itemDetails.metadata.status
)
) ||
isPendingLoansLoading
}
onClick={() =>
performCheckoutAction(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,7 @@ export class LoanMetadata extends Component {

prepareRightData(data) {
const { cancel_reason: reason, state } = data.metadata;
const toShortDateOpt = date => (isFinite(date) ? toShortDate(date) : '-');
const rows = [
{
name: 'Transaction date',
Expand All @@ -132,13 +133,13 @@ export class LoanMetadata extends Component {
rows.push(
{
name: 'Start date',
value: toShortDate(data.metadata.start_date),
value: toShortDateOpt(data.metadata.start_date),
},
{
name: 'End date',
value: (
<>
{toShortDate(data.metadata.end_date)}
{toShortDateOpt(data.metadata.end_date)}
{data.metadata.is_overdue && <Icon name="warning" />}
</>
),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ class DocumentPanel extends Component {
<Grid.Column>
<LiteratureCover
url={_get(doc, 'metadata.cover_metadata.urls.large')}
isLoading={isLoading}
/>
</Grid.Column>
<Grid.Column>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -279,15 +279,17 @@ class PatronCurrentDocumentRequests extends Component {
currentPage={activePage}
renderEmptyResultsElement={this.renderNoResults}
/>
<Container textAlign="center">
<Pagination
currentPage={activePage}
currentSize={rowsPerPage}
loading={isLoading}
onPageChange={this.onPageChange}
totalResults={documentRequests.total}
/>
</Container>
{documentRequests.total > 0 && (
<Container textAlign="center">
<Pagination
currentPage={activePage}
currentSize={rowsPerPage}
loading={isLoading}
onPageChange={this.onPageChange}
totalResults={documentRequests.total}
/>
</Container>
)}
</Error>
</ILSItemPlaceholder>
</>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -115,15 +115,17 @@ class PatronPastDocumentRequests extends Component {
currentPage={activePage}
renderEmptyResultsElement={this.renderNoResults}
/>
<Container textAlign="center">
<Pagination
currentPage={activePage}
currentSize={rowsPerPage}
loading={isLoading}
onPageChange={this.onPageChange}
totalResults={documentRequests.total}
/>
</Container>
{documentRequests.total > 0 && (
<Container textAlign="center">
<Pagination
currentPage={activePage}
currentSize={rowsPerPage}
loading={isLoading}
onPageChange={this.onPageChange}
totalResults={documentRequests.total}
/>
</Container>
)}
</Error>
</ILSItemPlaceholder>
</>
Expand Down