diff --git a/.gitignore b/.gitignore index 8c0960f5d..3e66c5a41 100644 --- a/.gitignore +++ b/.gitignore @@ -4,6 +4,7 @@ __pycache__/ # Idea software family .idea/ +.vscode/ # C extensions *.so diff --git a/.vscode/settings.json b/.vscode/settings.json deleted file mode 100644 index cfdb08c7b..000000000 --- a/.vscode/settings.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "python.pythonPath": "/usr/bin/python3.6" -} \ No newline at end of file diff --git a/invenio_app_ils/config.py b/invenio_app_ils/config.py index 2e1fbd51b..a3dc03a62 100644 --- a/invenio_app_ils/config.py +++ b/invenio_app_ils/config.py @@ -1141,10 +1141,10 @@ def _(x): ), ), filters=dict( - circulation=default_value_when_missing_filter("circulation.state", - "NOT_ON_LOAN"), ), post_filters=dict( + circulation=default_value_when_missing_filter( + "circulation.state", "NOT_ON_LOAN"), status=terms_filter("status"), medium=terms_filter("medium"), restrictions=terms_filter("circulation_restriction"), @@ -1187,19 +1187,17 @@ def _(x): ) ), ), - filters={ + post_filters={ + "state": terms_filter("state"), + "delivery": terms_filter("delivery.method"), + "availability": keyed_range_filter( + "document.circulation.has_items_for_loan", + {"Available for loan": {"gt": 0}}, + ), "returns.end_date": overdue_loans_filter("end_date"), "loans_from_date": date_range_filter("start_date", "gte"), "loans_to_date": date_range_filter("start_date", "lte"), }, - post_filters=dict( - state=terms_filter("state"), - delivery=terms_filter("delivery.method"), - availability=keyed_range_filter( - "document.circulation.has_items_for_loan", - {"Available for loan": {"gt": 0}}, - ), - ), ), acq_orders=dict( # OrderSearch.Meta.index aggs=dict( diff --git a/ui/package-lock.json b/ui/package-lock.json index c6e5154ae..8ebe9d7cb 100644 --- a/ui/package-lock.json +++ b/ui/package-lock.json @@ -3205,12 +3205,11 @@ "integrity": "sha512-ReZxvNHIOv88FlT7rxcXIIC0fPt4KZqZbOlivyWtXLt8ESx84zd3kMC6iK5jVeS2qt+g7ftS7ye4fi06X5rtRQ==" }, "axios": { - "version": "0.19.0", - "resolved": "https://registry.npmjs.org/axios/-/axios-0.19.0.tgz", - "integrity": "sha512-1uvKqKQta3KBxIz14F2v06AEHZ/dIoeKfbTRkK1E5oqjDnuEerLmYTgJB5AiQZHJcljpg1TuRzdjDR06qNk0DQ==", + "version": "0.19.2", + "resolved": "https://registry.npmjs.org/axios/-/axios-0.19.2.tgz", + "integrity": "sha512-fjgm5MvRHLhx+osE2xoekY70AhARk3a6hkN+3Io1jc00jtquGvxYlKlsFUhmUET0V5te6CcZI7lcv2Ym61mjHA==", "requires": { - "follow-redirects": "1.5.10", - "is-buffer": "^2.0.2" + "follow-redirects": "1.5.10" } }, "axios-mock-adapter": { @@ -8098,11 +8097,6 @@ "integrity": "sha1-mPiygDBoQhmpXzdc+9iM40Bd/5M=", "dev": true }, - "is-buffer": { - "version": "2.0.3", - "resolved": "https://registry.npmjs.org/is-buffer/-/is-buffer-2.0.3.tgz", - "integrity": "sha512-U15Q7MXTuZlrbymiz95PJpZxu8IlipAp4dtS3wOdgPXx3mqBnslrWU14kxfHB+Py/+2PVKSr37dMAgM2A4uArw==" - }, "is-callable": { "version": "1.1.4", "resolved": "https://registry.npmjs.org/is-callable/-/is-callable-1.1.4.tgz", diff --git a/ui/package.json b/ui/package.json index fe75c1e19..af42b91b7 100644 --- a/ui/package.json +++ b/ui/package.json @@ -11,7 +11,7 @@ "format": "prettier --config ./.prettierrc --ignore-path ./.prettierignore --write \"**/*.js\"" }, "dependencies": { - "axios": "^0.19.0", + "axios": "^0.19.2", "extract-text-webpack-plugin": "^3.0.2", "formik": "^2.0.6", "less": "^3.10.3", diff --git a/ui/src/components/SearchControls/__tests__/SearchControls.test.js b/ui/src/components/SearchControls/__tests__/SearchControls.test.js index bd7e208ca..0d8e8734a 100644 --- a/ui/src/components/SearchControls/__tests__/SearchControls.test.js +++ b/ui/src/components/SearchControls/__tests__/SearchControls.test.js @@ -30,8 +30,10 @@ beforeEach(() => { }); const searchApi = new InvenioSearchApi({ - url: documentApi.searchBaseURL, - withCredentials: true, + axios: { + url: documentApi.searchBaseURL, + withCredentials: true, + }, }); describe('SearchControls tests', () => { diff --git a/ui/src/components/SearchControls/__tests__/__snapshots__/SearchControls.test.js.snap b/ui/src/components/SearchControls/__tests__/__snapshots__/SearchControls.test.js.snap index b5c9eb485..66ce4764e 100644 --- a/ui/src/components/SearchControls/__tests__/__snapshots__/SearchControls.test.js.snap +++ b/ui/src/components/SearchControls/__tests__/__snapshots__/SearchControls.test.js.snap @@ -101,16 +101,23 @@ exports[`SearchControls tests should mount SearchControls component 1`] = ` } > { diff --git a/ui/src/pages/backoffice/Acquisition/Vendor/VendorSearch/VendorSearch.js b/ui/src/pages/backoffice/Acquisition/Vendor/VendorSearch/VendorSearch.js index 41a323a95..467d5a451 100644 --- a/ui/src/pages/backoffice/Acquisition/Vendor/VendorSearch/VendorSearch.js +++ b/ui/src/pages/backoffice/Acquisition/Vendor/VendorSearch/VendorSearch.js @@ -29,8 +29,10 @@ import history from '@history'; export class VendorSearch extends Component { searchApi = new InvenioSearchApi({ - url: vendorApi.searchBaseURL, - withCredentials: true, + axios: { + url: vendorApi.searchBaseURL, + withCredentials: true, + }, }); searchConfig = getSearchConfig('vendors'); diff --git a/ui/src/pages/backoffice/Document/DocumentSearch/DocumentSearch.js b/ui/src/pages/backoffice/Document/DocumentSearch/DocumentSearch.js index 38fcbd5ad..e596810bf 100644 --- a/ui/src/pages/backoffice/Document/DocumentSearch/DocumentSearch.js +++ b/ui/src/pages/backoffice/Document/DocumentSearch/DocumentSearch.js @@ -30,8 +30,10 @@ import history from '@history'; export class DocumentSearch extends Component { searchApi = new InvenioSearchApi({ - url: documentApi.searchBaseURL, - withCredentials: true, + axios: { + url: documentApi.searchBaseURL, + withCredentials: true, + }, }); searchConfig = getSearchConfig('documents'); diff --git a/ui/src/pages/backoffice/DocumentRequest/DocumentRequestSearch/DocumentRequestSearch.js b/ui/src/pages/backoffice/DocumentRequest/DocumentRequestSearch/DocumentRequestSearch.js index 24d81d843..5723fc77f 100644 --- a/ui/src/pages/backoffice/DocumentRequest/DocumentRequestSearch/DocumentRequestSearch.js +++ b/ui/src/pages/backoffice/DocumentRequest/DocumentRequestSearch/DocumentRequestSearch.js @@ -29,8 +29,10 @@ import { responseRejectInterceptor } from '@api/base'; export class DocumentRequestSearch extends Component { searchApi = new InvenioSearchApi({ - url: documentRequestApi.searchBaseURL, - withCredentials: true, + axios: { + url: documentRequestApi.searchBaseURL, + withCredentials: true, + }, interceptors: { response: { reject: responseRejectInterceptor }, }, diff --git a/ui/src/pages/backoffice/EItem/EItemSearch/EItemSearch.js b/ui/src/pages/backoffice/EItem/EItemSearch/EItemSearch.js index 26eeed52c..479412636 100644 --- a/ui/src/pages/backoffice/EItem/EItemSearch/EItemSearch.js +++ b/ui/src/pages/backoffice/EItem/EItemSearch/EItemSearch.js @@ -28,8 +28,10 @@ import history from '@history'; export class EItemSearch extends Component { searchApi = new InvenioSearchApi({ - url: eitemApi.searchBaseURL, - withCredentials: true, + axios: { + url: eitemApi.searchBaseURL, + withCredentials: true, + }, interceptors: { response: { reject: responseRejectInterceptor }, }, diff --git a/ui/src/pages/backoffice/ILL/BorrowingRequestSearch/BorrowingRequestSearch.js b/ui/src/pages/backoffice/ILL/BorrowingRequestSearch/BorrowingRequestSearch.js index 35ace6fab..c5c295a55 100644 --- a/ui/src/pages/backoffice/ILL/BorrowingRequestSearch/BorrowingRequestSearch.js +++ b/ui/src/pages/backoffice/ILL/BorrowingRequestSearch/BorrowingRequestSearch.js @@ -29,8 +29,10 @@ import { BorrowingRequestListEntry } from './components'; export class BorrowingRequestSearch extends Component { searchApi = new InvenioSearchApi({ - url: borrowingRequestApi.searchBaseURL, - withCredentials: true, + axios: { + url: borrowingRequestApi.searchBaseURL, + withCredentials: true, + }, }); renderSearchBar = (_, queryString, onInputChange, executeSearch) => { diff --git a/ui/src/pages/backoffice/ILL/LibrarySearch/LibrarySearch.js b/ui/src/pages/backoffice/ILL/LibrarySearch/LibrarySearch.js index d3acb0bd4..e5db5887d 100644 --- a/ui/src/pages/backoffice/ILL/LibrarySearch/LibrarySearch.js +++ b/ui/src/pages/backoffice/ILL/LibrarySearch/LibrarySearch.js @@ -27,8 +27,10 @@ import { LibraryListEntry } from './components/LibraryListEntry'; export class LibrarySearch extends Component { searchApi = new InvenioSearchApi({ - url: libraryApi.searchBaseURL, - withCredentials: true, + axios: { + url: libraryApi.searchBaseURL, + withCredentials: true, + }, }); searchConfig = getSearchConfig('libraries'); diff --git a/ui/src/pages/backoffice/Item/ItemSearch/ItemSearch.js b/ui/src/pages/backoffice/Item/ItemSearch/ItemSearch.js index 688b8f9f5..18200b3a2 100644 --- a/ui/src/pages/backoffice/Item/ItemSearch/ItemSearch.js +++ b/ui/src/pages/backoffice/Item/ItemSearch/ItemSearch.js @@ -25,8 +25,10 @@ import { export class ItemSearch extends Component { searchApi = new InvenioSearchApi({ - url: itemApi.searchBaseURL, - withCredentials: true, + axios: { + url: itemApi.searchBaseURL, + withCredentials: true, + }, interceptors: { response: { reject: responseRejectInterceptor }, }, diff --git a/ui/src/pages/backoffice/Loan/LoanSearch/SearchDateRange.js b/ui/src/pages/backoffice/Loan/LoanSearch/SearchDateRange.js index 7ba7b5ead..cc0e79ce3 100644 --- a/ui/src/pages/backoffice/Loan/LoanSearch/SearchDateRange.js +++ b/ui/src/pages/backoffice/Loan/LoanSearch/SearchDateRange.js @@ -3,6 +3,7 @@ import { Card } from 'semantic-ui-react'; import { DatePicker } from '@components'; import { withState } from 'react-searchkit'; import _isEmpty from 'lodash/isEmpty'; +import _flatten from 'lodash/flatten'; class _SearchDateRange extends Component { getCurrentDates() { @@ -17,16 +18,21 @@ class _SearchDateRange extends Component { return [fromDate, toDate]; } - /** react-searchkit allows having the same filter multiple times. - * For the range dates filters we want each filter one time only so we have - * to remove any pre-existing filters with the same name + /** react-searchkit allows having the same filter multiple times with different values. + * For this range dates filters, we want each filter to appear only one time with one value + * (e.g. loan_start_date = ``) */ onDateChange = newFilter => { const [name, value] = newFilter; - let filters = newFilter; - // If value is empty we simply remove the filter otherwise if we have - // value we remove the filter and add the new one. - if (!_isEmpty(value)) filters = [[name, ''], newFilter]; + if (_isEmpty(value)) + return this.props.updateQueryState({ filters: newFilter }); + + const oldFilters = this.props.currentQueryState.filters.filter( + filter => filter[0] === name + ); + + let filters = [newFilter]; + if (!_isEmpty(oldFilters)) filters.unshift(_flatten(oldFilters)); return this.props.updateQueryState({ filters: filters }); }; diff --git a/ui/src/pages/backoffice/Patron/PatronSearch/PatronSearch.js b/ui/src/pages/backoffice/Patron/PatronSearch/PatronSearch.js index cd58b5789..1f49281cf 100644 --- a/ui/src/pages/backoffice/Patron/PatronSearch/PatronSearch.js +++ b/ui/src/pages/backoffice/Patron/PatronSearch/PatronSearch.js @@ -29,8 +29,10 @@ import { ExportReactSearchKitResults } from '../../components'; export class PatronSearch extends Component { searchApi = new InvenioSearchApi({ - url: patronApi.searchBaseURL, - withCredentials: true, + axios: { + url: patronApi.searchBaseURL, + withCredentials: true, + }, interceptors: { response: { reject: responseRejectInterceptor }, }, diff --git a/ui/src/pages/backoffice/Series/SeriesSearch/SeriesSearch.js b/ui/src/pages/backoffice/Series/SeriesSearch/SeriesSearch.js index 8a4c48f5b..b79e926c1 100644 --- a/ui/src/pages/backoffice/Series/SeriesSearch/SeriesSearch.js +++ b/ui/src/pages/backoffice/Series/SeriesSearch/SeriesSearch.js @@ -31,8 +31,10 @@ import history from '@history'; export class SeriesSearch extends Component { searchApi = new InvenioSearchApi({ - url: seriesApi.searchBaseURL, - withCredentials: true, + axios: { + url: seriesApi.searchBaseURL, + withCredentials: true, + }, interceptors: { response: { reject: responseRejectInterceptor }, }, diff --git a/ui/src/pages/frontsite/Documents/DocumentsSearch/DocumentsSearch.js b/ui/src/pages/frontsite/Documents/DocumentsSearch/DocumentsSearch.js index b21b6d5e1..29060ac94 100644 --- a/ui/src/pages/frontsite/Documents/DocumentsSearch/DocumentsSearch.js +++ b/ui/src/pages/frontsite/Documents/DocumentsSearch/DocumentsSearch.js @@ -35,8 +35,10 @@ import history from '@history'; export class DocumentsSearch extends Component { searchApi = new InvenioSearchApi({ - url: literatureApi.searchBaseURL, - withCredentials: true, + axios: { + url: literatureApi.searchBaseURL, + withCredentials: true, + }, interceptors: { response: { reject: responseRejectInterceptor }, }, diff --git a/ui/src/pages/frontsite/Documents/DocumentsSearch/DocumentsSearchMobile.js b/ui/src/pages/frontsite/Documents/DocumentsSearch/DocumentsSearchMobile.js index 59fcae909..e7acc1b86 100644 --- a/ui/src/pages/frontsite/Documents/DocumentsSearch/DocumentsSearchMobile.js +++ b/ui/src/pages/frontsite/Documents/DocumentsSearch/DocumentsSearchMobile.js @@ -14,8 +14,10 @@ import { DocumentSearchResultsGrid } from './DocumentSearchResultsGrid'; export class DocumentsSearchMobile extends Component { searchApi = new InvenioSearchApi({ - url: documentApi.searchBaseURL, - withCredentials: true, + axios: { + url: documentApi.searchBaseURL, + withCredentials: true, + }, interceptors: { response: { reject: responseRejectInterceptor }, }, diff --git a/ui/src/pages/frontsite/Documents/DocumentsSearch/__tests__/__snapshots__/DocumentsSearch.test.js.snap b/ui/src/pages/frontsite/Documents/DocumentsSearch/__tests__/__snapshots__/DocumentsSearch.test.js.snap index 9ca0d9a16..a41c3c430 100644 --- a/ui/src/pages/frontsite/Documents/DocumentsSearch/__tests__/__snapshots__/DocumentsSearch.test.js.snap +++ b/ui/src/pages/frontsite/Documents/DocumentsSearch/__tests__/__snapshots__/DocumentsSearch.test.js.snap @@ -3,7 +3,9 @@ exports[`DocumentsSearch tests should load the DocumentsSearch component 1`] = ` diff --git a/ui/src/pages/frontsite/components/Series/SeriesLiteratureSearch/__tests__/__snapshots__/SeriesLiteratureSearch.test.js.snap b/ui/src/pages/frontsite/components/Series/SeriesLiteratureSearch/__tests__/__snapshots__/SeriesLiteratureSearch.test.js.snap index 6432e3d00..6f7766485 100644 --- a/ui/src/pages/frontsite/components/Series/SeriesLiteratureSearch/__tests__/__snapshots__/SeriesLiteratureSearch.test.js.snap +++ b/ui/src/pages/frontsite/components/Series/SeriesLiteratureSearch/__tests__/__snapshots__/SeriesLiteratureSearch.test.js.snap @@ -10,7 +10,9 @@ exports[`SeriesLiteratureSearch tests should load the SeriesLiteratureSearch com )