@luomus/laji-form 15.1.67 → 15.1.68
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.
package/lib/ApiClient.d.ts
CHANGED
|
@@ -68,7 +68,9 @@ export default class ApiClient {
|
|
|
68
68
|
private flush;
|
|
69
69
|
private getCacheNode;
|
|
70
70
|
/** The response is cached until the resource receives a POST/PUT/DELETE request. */
|
|
71
|
-
get<P extends PathWithMethod<"get">, R extends Responses<P, "get" extends Method<P> ? "get" : never>>(path: P, params?: RelaxQuery<Parameters<paths[P]["get"]>, MiddlewareInjectedKeys>,
|
|
71
|
+
get<P extends PathWithMethod<"get">, R extends Responses<P, "get" extends Method<P> ? "get" : never>>(path: P, params?: RelaxQuery<Parameters<paths[P]["get"]>, MiddlewareInjectedKeys>,
|
|
72
|
+
/** Defaults to true */
|
|
73
|
+
useCache?: boolean): Promise<ExtractContentIfExists<R[IntersectUnionTypes<keyof R, HttpSuccessCodes>]>>;
|
|
72
74
|
/** Subscribe to a GET request. It re-emits when the resource receives a POST/PUT/DELETE request. */
|
|
73
75
|
subscribe<P extends PathWithMethod<"get">, R extends Responses<P, "get" extends Method<P> ? "get" : never>>(path: P, params: RelaxQuery<Parameters<paths[P]["get"]>, MiddlewareInjectedKeys> | undefined, onFulfilled: (response: ExtractContentIfExists<R[IntersectUnionTypes<keyof R, HttpSuccessCodes>]>) => void, onError?: () => void,
|
|
74
76
|
/**
|
package/lib/ApiClient.js
CHANGED
|
@@ -93,7 +93,9 @@ class ApiClient {
|
|
|
93
93
|
;
|
|
94
94
|
/** The response is cached until the resource receives a POST/PUT/DELETE request. */
|
|
95
95
|
get(path_1, params_1) {
|
|
96
|
-
return __awaiter(this, arguments, void 0, function* (path, params,
|
|
96
|
+
return __awaiter(this, arguments, void 0, function* (path, params,
|
|
97
|
+
/** Defaults to true */
|
|
98
|
+
useCache = true) {
|
|
97
99
|
let cacheNode;
|
|
98
100
|
let serializedQuery;
|
|
99
101
|
if (useCache) {
|
|
@@ -48,7 +48,6 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
48
48
|
const React = __importStar(require("react"));
|
|
49
49
|
const ReactContext_1 = __importDefault(require("../../../ReactContext"));
|
|
50
50
|
const utils_1 = require("../../../utils");
|
|
51
|
-
// import { NamedPlace } from "@luomus/laji-schema";
|
|
52
51
|
const Context_1 = __importDefault(require("../../../Context"));
|
|
53
52
|
const NamedPlaceChooser_1 = require("./NamedPlaceChooser");
|
|
54
53
|
const PLACE_WHITELIST = [
|
|
@@ -51,7 +51,6 @@ const ReactContext_1 = __importDefault(require("../../ReactContext"));
|
|
|
51
51
|
const components_1 = require("../components");
|
|
52
52
|
const AutosuggestWidget_1 = require("../widgets/AutosuggestWidget");
|
|
53
53
|
const ArrayFieldTemplate_1 = require("../templates/ArrayFieldTemplate");
|
|
54
|
-
const LINE_TRANSECT_IDS = ["MHL.1", "MHL.27", "MHL.28"];
|
|
55
54
|
let UnitShorthandField = class UnitShorthandField extends React.Component {
|
|
56
55
|
constructor(props) {
|
|
57
56
|
super(props);
|
|
@@ -125,13 +124,13 @@ let UnitShorthandField = class UnitShorthandField extends React.Component {
|
|
|
125
124
|
render() {
|
|
126
125
|
const { uiSchema, formContext, disabled, readonly } = this.props;
|
|
127
126
|
const { SchemaField } = this.props.registry.fields;
|
|
128
|
-
const
|
|
127
|
+
const { shorthandField, lineTransect } = (0, utils_1.getUiOptions)(this.props.uiSchema);
|
|
129
128
|
const toggleButton = this.getToggleButton();
|
|
130
129
|
const tailUiSchema = (0, utils_1.getNestedTailUiSchema)(uiSchema);
|
|
131
|
-
let help = tailUiSchema && tailUiSchema[
|
|
132
|
-
const uiSchemaWithoutHelp = (0, utils_1.isEmptyString)(help) ? uiSchema : (0, utils_1.updateTailUiSchema)(uiSchema, { [
|
|
133
|
-
const id = (
|
|
134
|
-
this.props.idSchema[
|
|
130
|
+
let help = tailUiSchema && tailUiSchema[shorthandField] && tailUiSchema[shorthandField]["ui:belowHelp"];
|
|
131
|
+
const uiSchemaWithoutHelp = (0, utils_1.isEmptyString)(help) ? uiSchema : (0, utils_1.updateTailUiSchema)(uiSchema, { [shorthandField]: { "ui:belowHelp": { $set: undefined } } });
|
|
132
|
+
const id = (shorthandField && this.props.idSchema[shorthandField]) ?
|
|
133
|
+
this.props.idSchema[shorthandField].$id :
|
|
135
134
|
`${this.props.idSchema.$id}_shortHandField`;
|
|
136
135
|
let innerUiSchema = undefined;
|
|
137
136
|
if (this.state.showSchema) {
|
|
@@ -140,7 +139,7 @@ let UnitShorthandField = class UnitShorthandField extends React.Component {
|
|
|
140
139
|
innerUiSchema = Object.assign(Object.assign({}, innerUiSchema), { "ui:options": Object.assign(Object.assign({}, innerOptions), { buttons: [...(innerOptions.buttons || []), toggleButton] }) });
|
|
141
140
|
}
|
|
142
141
|
return !this.state.showSchema ? (React.createElement("div", { className: "laji-form-field-template-item", id: `_laji-form_${id}` },
|
|
143
|
-
React.createElement(CodeReader, { translations: this.props.formContext.translations, onChange: this.onCodeChange, value: this.props.formData[
|
|
142
|
+
React.createElement(CodeReader, { translations: this.props.formContext.translations, onChange: this.onCodeChange, value: this.props.formData[shorthandField], formID: (0, utils_1.getUiOptions)(this.props.uiSchema).formID || formContext.formID || formContext.uiSchemaContext.formID, help: help, id: id, formContext: formContext, disabled: disabled, readonly: readonly, lineTransect: lineTransect, className: "laji-form-field-template-schema" }),
|
|
144
143
|
React.createElement("div", { className: "laji-form-field-template-buttons" }, (0, ArrayFieldTemplate_1.getButton)(toggleButton)))) : (React.createElement(SchemaField, Object.assign({}, this.props, { uiSchema: innerUiSchema })));
|
|
145
144
|
}
|
|
146
145
|
};
|
|
@@ -230,18 +229,15 @@ let CodeReader = class CodeReader extends React.Component {
|
|
|
230
229
|
this.mounted = false;
|
|
231
230
|
}
|
|
232
231
|
render() {
|
|
233
|
-
const { translations, readonly, disabled } = this.props;
|
|
232
|
+
const { translations, readonly, disabled, lineTransect } = this.props;
|
|
234
233
|
let validationState = null;
|
|
235
234
|
if (this.state.failed === true)
|
|
236
235
|
validationState = "warning";
|
|
237
236
|
else if (!(0, utils_1.isEmptyString)(this.props.value) && this.props.value === this.state.value)
|
|
238
237
|
validationState = "success";
|
|
239
|
-
const {
|
|
240
|
-
const inputElem =
|
|
241
|
-
React.createElement(AutosuggestWidget_1.Autosuggest, { autosuggestField: "unit",
|
|
242
|
-
formID,
|
|
243
|
-
includeNonMatching: true
|
|
244
|
-
}, onSuggestionSelected: this.onSuggestionSelected, renderSuggestion: this.renderSuggestion, onChange: this.onAutosuggestChange, formContext: formContext, allowNonsuggestedValue: false })));
|
|
238
|
+
const { formContext } = this.props;
|
|
239
|
+
const inputElem = lineTransect ? (React.createElement(components_1.FetcherInput, { id: this.props.id, loading: this.state.loading, value: this.state.value, validationState: validationState, onChange: this.onFetcherInputChange, onBlur: this.getCode, onKeyDown: this.onKeyDown, readonly: readonly, disabled: disabled })) : (React.createElement("div", { className: "unit-shorthand" },
|
|
240
|
+
React.createElement(AutosuggestWidget_1.Autosuggest, { autosuggestField: "unit", onSuggestionSelected: this.onSuggestionSelected, renderSuggestion: this.renderSuggestion, onChange: this.onAutosuggestChange, formContext: formContext, allowNonsuggestedValue: false })));
|
|
245
241
|
const { FormGroup, HelpBlock } = this.context.theme;
|
|
246
242
|
return (React.createElement(FormGroup, { validationState: this.state.failed ? "error" : undefined },
|
|
247
243
|
inputElem,
|