@luomus/laji-form 15.1.34 → 15.1.35
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -20,10 +20,12 @@ export class Autosuggest extends React.Component<any, any, any> {
|
|
|
20
20
|
uiSchema: PropTypes.Requireable<object>;
|
|
21
21
|
informalTaxonGroups: PropTypes.Requireable<string>;
|
|
22
22
|
onInformalTaxonGroupSelected: PropTypes.Requireable<(...args: any[]) => any>;
|
|
23
|
+
cache: PropTypes.Requireable<boolean>;
|
|
23
24
|
};
|
|
24
25
|
static defaultProps: {
|
|
25
26
|
allowNonsuggestedValue: boolean;
|
|
26
27
|
suggestionReceive: string;
|
|
28
|
+
cache: boolean;
|
|
27
29
|
};
|
|
28
30
|
constructor(props: any);
|
|
29
31
|
isValueSuggested: (props: any) => any;
|
|
@@ -320,19 +320,19 @@ class FriendsAutosuggestWidget extends React.Component {
|
|
|
320
320
|
FriendsAutosuggestWidget.contextType = ReactContext_1.default;
|
|
321
321
|
class OrganizationAutosuggestWidget extends React.Component {
|
|
322
322
|
render() {
|
|
323
|
-
return (React.createElement(BasicAutosuggestWidget, Object.assign({}, this.props, this.props.options, { nameField: "fullName", validValueRegexp: "MOS.\\d+", Wrapper: OrganizationWrapper })));
|
|
323
|
+
return (React.createElement(BasicAutosuggestWidget, Object.assign({}, this.props, this.props.options, { nameField: "fullName", validValueRegexp: "MOS.\\d+", cache: false, Wrapper: OrganizationWrapper })));
|
|
324
324
|
}
|
|
325
325
|
}
|
|
326
326
|
OrganizationAutosuggestWidget.contextType = ReactContext_1.default;
|
|
327
327
|
class CollectionAutosuggestWidget extends React.Component {
|
|
328
328
|
render() {
|
|
329
|
-
return (React.createElement(BasicAutosuggestWidget, Object.assign({}, this.props, this.props.options, { nameField: "collectionName", validValueRegexp: "HR.\\d+", Wrapper: CollectionWrapper })));
|
|
329
|
+
return (React.createElement(BasicAutosuggestWidget, Object.assign({}, this.props, this.props.options, { nameField: "collectionName", validValueRegexp: "HR.\\d+", cache: false, Wrapper: CollectionWrapper })));
|
|
330
330
|
}
|
|
331
331
|
}
|
|
332
332
|
CollectionAutosuggestWidget.contextType = ReactContext_1.default;
|
|
333
333
|
class DatasetAutosuggestWidget extends React.Component {
|
|
334
334
|
render() {
|
|
335
|
-
return (React.createElement(BasicAutosuggestWidget, Object.assign({}, this.props, this.props.options, { nameField: "datasetName", validValueRegexp: "GX.\\d+", Wrapper: DatasetWrapper })));
|
|
335
|
+
return (React.createElement(BasicAutosuggestWidget, Object.assign({}, this.props, this.props.options, { nameField: "datasetName", validValueRegexp: "GX.\\d+", cache: false, Wrapper: DatasetWrapper })));
|
|
336
336
|
}
|
|
337
337
|
}
|
|
338
338
|
DatasetAutosuggestWidget.contextType = ReactContext_1.default;
|
|
@@ -348,7 +348,9 @@ class BasicAutosuggestWidget extends React.Component {
|
|
|
348
348
|
getSuggestionFromValue(value) {
|
|
349
349
|
const { autosuggestField, nameField } = this.props;
|
|
350
350
|
if (this.isValueSuggested(value)) {
|
|
351
|
-
|
|
351
|
+
const apiClient = this.props.formContext.apiClient;
|
|
352
|
+
const fetch = (this.props.cache ? apiClient.fetchCached : apiClient.fetch).bind(apiClient);
|
|
353
|
+
return fetch(`/${autosuggestField}/by-id/${value}`).then(result => {
|
|
352
354
|
if (result[nameField]) {
|
|
353
355
|
return {
|
|
354
356
|
value: result[nameField],
|
|
@@ -386,11 +388,13 @@ BasicAutosuggestWidget.propTypes = {
|
|
|
386
388
|
uiSchema: PropTypes.object,
|
|
387
389
|
nameField: PropTypes.string,
|
|
388
390
|
validValueRegexp: PropTypes.string,
|
|
391
|
+
cache: PropTypes.bool,
|
|
389
392
|
Wrapper: PropTypes.object
|
|
390
393
|
};
|
|
391
394
|
BasicAutosuggestWidget.defaultProps = {
|
|
392
395
|
nameField: "name",
|
|
393
|
-
validValueRegexp: ""
|
|
396
|
+
validValueRegexp: "",
|
|
397
|
+
cache: true
|
|
394
398
|
};
|
|
395
399
|
class RangeAutosuggestWidget extends React.Component {
|
|
396
400
|
render() {
|
|
@@ -535,7 +539,8 @@ class Autosuggest extends React.Component {
|
|
|
535
539
|
const request = () => {
|
|
536
540
|
let timestamp = Date.now();
|
|
537
541
|
this.promiseTimestamp = timestamp;
|
|
538
|
-
this.
|
|
542
|
+
const fetch = (this.props.cache ? this.apiClient.fetchCached : this.apiClient.fetch).bind(this.apiClient);
|
|
543
|
+
fetch("/autocomplete/" + autosuggestField, Object.assign({ q: value, includePayload: true, matchType: "exact,partial", includeHidden: false }, query)).then(suggestions => {
|
|
539
544
|
if (this.props.prepareSuggestion) {
|
|
540
545
|
suggestions = suggestions.map(s => this.props.prepareSuggestion(s));
|
|
541
546
|
}
|
|
@@ -776,11 +781,13 @@ Autosuggest.propTypes = {
|
|
|
776
781
|
onInputChange: PropTypes.func,
|
|
777
782
|
uiSchema: PropTypes.object,
|
|
778
783
|
informalTaxonGroups: PropTypes.string,
|
|
779
|
-
onInformalTaxonGroupSelected: PropTypes.func
|
|
784
|
+
onInformalTaxonGroupSelected: PropTypes.func,
|
|
785
|
+
cache: PropTypes.bool
|
|
780
786
|
};
|
|
781
787
|
Autosuggest.defaultProps = {
|
|
782
788
|
allowNonsuggestedValue: true,
|
|
783
|
-
suggestionReceive: "key"
|
|
789
|
+
suggestionReceive: "key",
|
|
790
|
+
cache: true
|
|
784
791
|
};
|
|
785
792
|
class _TaxonWrapper extends React.Component {
|
|
786
793
|
constructor(props) {
|