Skip to content

Commit

Permalink
Resolve
Browse files Browse the repository at this point in the history
  • Loading branch information
MikeTaylor committed Jan 13, 2025
2 parents 22dc2e2 + 94e5f37 commit a90a480
Show file tree
Hide file tree
Showing 5 changed files with 36 additions and 2 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
* Support per-service config item `allowAnyDate` to disable date validation in forms. Update docs, add tests. Fixes PR-2059.
* Support per-service config item `alwaysShowForm` to specify that the full form always should be displayed once for confirmation even when the submitted OpenURL has complete basic metadata. Update docs. Fixes PR-2059.
* Add Service Level field to blank request form. Fixes PR-2056.
* Add maximum cost field-pair (`maximumCostsMonetaryValue` and `maximumCostsCurrencyCode`) to blank request form. Fixes PR-2058.
* TECH DEBT: The `OkapiSession`'s config object is now in its `cfg` member, not `logger`. Fixes PR-2095.

## [1.6.0](https://github.com/openlibraryenvironment/listener-openurl/tree/v1.6.0) (2024-03-04)
Expand Down
18 changes: 18 additions & 0 deletions config/templates/form1.html
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,24 @@ <h2>Request type</h2>
</div>
</div>

<div class="key-value-pair">
<div class="key">Maximum cost (amount)</div>
<div class="value">
<input id="input-costAmount" type="text" name="svc.costAmount" value="{{'svc.costAmount'}}" />
</div>
</div>

<div class="key-value-pair">
<div class="key">Maxium cost (currency)</div>
<div class="value">
<select class="select" id="input-costCurrency" name="svc.costCurrency">
{{#each currencies}}
<option value="{{this.code}}" {{this.selected}}>{{this.name}}</option>
{{/each}}
</select>
</div>
</div>

{{#unless digitalOnly}}
<div id="div-pickupLocation" class="key-value-pair">
<label class="key" for="input-pickupLocation">Pick up location</label>
Expand Down
5 changes: 5 additions & 0 deletions src/OkapiSession.js
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,11 @@ class OkapiSession {
this.serviceLevels = await this._getRefDataValues('ServiceLevels', 'service levels');
}

async getCurrencies() {
// XXX could no-op if this.currencies is already defined
this.currencies = await this._getRefDataValues('CurrencyCodes', 'currencies');
}

async getDefaultCopyrightType() {
const path = '/rs/settings/appSettings?filters=section%3D%3Dother&filters=key%3D%3Ddefault_copyright_type&perPage=1';
const json = await this._getDataFromReShare(path, 'default copyright type');
Expand Down
12 changes: 10 additions & 2 deletions src/OpenURLServer.js
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,10 @@ function makeFormData(ctx, query, service, valuesNotShownInForm, firstTry, npl)
...x,
selected: x.code === query['svc.level'] ? 'selected' : '',
})),
currencies: (service.currencies || []).map(x => ({
...x,
selected: x.code === query['svc.costCurrency'] ? 'selected' : '',
})),
pubDateValidation: ctx.state?.svcCfg?.allowAnyDate ? '' : 'pattern="[0-9]*" ',
});

Expand Down Expand Up @@ -183,7 +187,8 @@ async function maybeRenderForm(ctx, next) {
formName = 'form1';
formFields.push('rft.title', 'rft.au', 'rft.date', 'rft.pub', 'rft.place', 'rft.edition', 'rft.isbn', 'rft.oclc',
'rft.authorOfComponent', 'rft.copyrightType', 'rft.genre', 'rft.issn', 'rft.jtitle', 'rft.pagesRequested',
'rft.sponsoringBody', 'rft.subtitle', 'rft.titleOfComponent', 'rft.issue', 'svc_id', 'svc.level');
'rft.sponsoringBody', 'rft.subtitle', 'rft.titleOfComponent', 'rft.issue', 'svc_id', 'svc.level',
'svc.costAmount', 'svc.costCurrency');
}

ctx.cfg.log('flow', 'Rendering form', formName);
Expand All @@ -196,7 +201,10 @@ async function maybeRenderForm(ctx, next) {
]);
}

await service.getServiceLevels();
await Promise.all([
service.getServiceLevels(),
service.getCurrencies()
]);

const originalQuery = co.getQuery();
const query = {};
Expand Down
2 changes: 2 additions & 0 deletions src/ReshareRequest.js
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,8 @@ function translateCOtoRR(co) {
// These are non-standard fields in OpenURL 1.0
rr.serviceType = _.get(a, 'svc.id'); // No example of this in Z39.88
rr.serviceLevel = _.get(m, 'svc.level');
rr.maximumCostsMonetaryValue = _.get(m, 'svc.costAmount');
rr.maximumCostsCurrencyCode = _.get(m, 'svc.costCurrency');
rr.isRequester = true;
const copyrightType = _.get(m, 'rft.copyrightType');
if (copyrightType) rr.copyrightType = { value: copyrightType };
Expand Down

0 comments on commit a90a480

Please sign in to comment.