@luomus/laji-form 15.1.96 → 15.1.98
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/dist/laji-form.js +1 -1
- package/lib/components/LajiForm.d.ts +1 -0
- package/lib/components/fields/ArrayPropertyCountField.d.ts +21 -0
- package/lib/components/fields/ArrayPropertyCountField.js +67 -0
- package/lib/components/fields/TaxonSetPopulatorField.js +13 -16
- package/lib/components/fields/index.d.ts +1 -0
- package/lib/components/fields/index.js +4 -2
- package/package.json +1 -1
|
@@ -199,6 +199,7 @@ export default class LajiForm extends React.Component<LajiFormProps, LajiFormSta
|
|
|
199
199
|
ObjectField: (props: any) => JSX.Element;
|
|
200
200
|
NestField: typeof fields.NestField;
|
|
201
201
|
ArrayPropertySumField: typeof fields.ArrayPropertySumField;
|
|
202
|
+
ArrayPropertyCountField: typeof fields.ArrayPropertyCountField;
|
|
202
203
|
ScopeField: typeof fields.ScopeField;
|
|
203
204
|
SelectTreeField: typeof fields.SelectTreeField;
|
|
204
205
|
GridLayoutField: {
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
import * as PropTypes from "prop-types";
|
|
3
|
+
import { FieldProps, JSONSchemaObject } from "../../types";
|
|
4
|
+
interface State {
|
|
5
|
+
count: number;
|
|
6
|
+
}
|
|
7
|
+
export default class ArrayPropertyCountField extends React.Component<FieldProps<JSONSchemaObject[], JSONSchemaObject>, State> {
|
|
8
|
+
static propTypes: {
|
|
9
|
+
uiSchema: PropTypes.Validator<NonNullable<PropTypes.InferProps<{
|
|
10
|
+
"ui:options": PropTypes.Requireable<PropTypes.InferProps<{
|
|
11
|
+
propertyField: PropTypes.Validator<string>;
|
|
12
|
+
}>>;
|
|
13
|
+
uiSchema: PropTypes.Requireable<object>;
|
|
14
|
+
}>>>;
|
|
15
|
+
schema: PropTypes.Validator<object>;
|
|
16
|
+
formData: PropTypes.Validator<any[]>;
|
|
17
|
+
};
|
|
18
|
+
static getName(): string;
|
|
19
|
+
render(): JSX.Element;
|
|
20
|
+
}
|
|
21
|
+
export {};
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
+
var ownKeys = function(o) {
|
|
20
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
+
var ar = [];
|
|
22
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
+
return ar;
|
|
24
|
+
};
|
|
25
|
+
return ownKeys(o);
|
|
26
|
+
};
|
|
27
|
+
return function (mod) {
|
|
28
|
+
if (mod && mod.__esModule) return mod;
|
|
29
|
+
var result = {};
|
|
30
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
+
__setModuleDefault(result, mod);
|
|
32
|
+
return result;
|
|
33
|
+
};
|
|
34
|
+
})();
|
|
35
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
|
+
const React = __importStar(require("react"));
|
|
37
|
+
const PropTypes = __importStar(require("prop-types"));
|
|
38
|
+
const utils_1 = require("../../utils");
|
|
39
|
+
class ArrayPropertyCountField extends React.Component {
|
|
40
|
+
static getName() { return "ArrayPropertyCountField"; }
|
|
41
|
+
render() {
|
|
42
|
+
const SchemaField = this.props.registry.fields.SchemaField;
|
|
43
|
+
const count = getCount(this.props);
|
|
44
|
+
return (React.createElement(React.Fragment, null,
|
|
45
|
+
React.createElement(SchemaField, Object.assign({}, this.props, { uiSchema: (0, utils_1.getInnerUiSchema)(this.props.uiSchema) })),
|
|
46
|
+
React.createElement("h4", null,
|
|
47
|
+
this.props.uiSchema["ui:title"],
|
|
48
|
+
": ",
|
|
49
|
+
count)));
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
ArrayPropertyCountField.propTypes = {
|
|
53
|
+
uiSchema: PropTypes.shape({
|
|
54
|
+
"ui:options": PropTypes.shape({
|
|
55
|
+
propertyField: PropTypes.string.isRequired
|
|
56
|
+
}),
|
|
57
|
+
uiSchema: PropTypes.object
|
|
58
|
+
}).isRequired,
|
|
59
|
+
schema: PropTypes.object.isRequired,
|
|
60
|
+
formData: PropTypes.array.isRequired
|
|
61
|
+
};
|
|
62
|
+
exports.default = ArrayPropertyCountField;
|
|
63
|
+
const getCount = (props) => {
|
|
64
|
+
const formData = props.formData || [];
|
|
65
|
+
const propertyField = (0, utils_1.getUiOptions)(props.uiSchema).propertyField;
|
|
66
|
+
return formData.filter(item => item === null || item === void 0 ? void 0 : item[propertyField]).length;
|
|
67
|
+
};
|
|
@@ -99,30 +99,27 @@ let TaxonSetPopulatorField = class TaxonSetPopulatorField extends React.Componen
|
|
|
99
99
|
return this.unitTaxonSets[unit.identifications[0].taxonID]
|
|
100
100
|
&& this.unitTaxonSets[unit.identifications[0].taxonID].includes(deletedTaxonSetId);
|
|
101
101
|
});
|
|
102
|
-
deletedTaxonSetUnits.
|
|
102
|
+
observationsExist = deletedTaxonSetUnits.some((unit) => {
|
|
103
103
|
var _a, _b, _c, _d;
|
|
104
|
-
|
|
104
|
+
return unit.maleIndividualCount ||
|
|
105
105
|
unit.femaleIndividualCount ||
|
|
106
106
|
unit.nestCount ||
|
|
107
107
|
((_a = unit.unitFact) === null || _a === void 0 ? void 0 : _a.destroyedNestCount) ||
|
|
108
108
|
((_b = unit.unitFact) === null || _b === void 0 ? void 0 : _b.broodCount) ||
|
|
109
109
|
((_c = unit.unitFact) === null || _c === void 0 ? void 0 : _c.femalesWithBroodsCount) ||
|
|
110
|
-
((_d = unit.unitFact) === null || _d === void 0 ? void 0 : _d.juvenileCount)
|
|
111
|
-
window.alert(translations === null || translations === void 0 ? void 0 : translations.TaxonSetDeletionFailed);
|
|
112
|
-
observationsExist = true;
|
|
113
|
-
const updatedFormData = Object.assign(Object.assign({}, formData), { taxonCensus: [
|
|
114
|
-
...formData.taxonCensus,
|
|
115
|
-
{
|
|
116
|
-
censusTaxonSetID: deletedTaxonSetId,
|
|
117
|
-
taxonCensusType: "MY.taxonCensusTypeCounted"
|
|
118
|
-
}
|
|
119
|
-
] });
|
|
120
|
-
this.selectedTaxonSets = [...this.selectedTaxonSets, deletedTaxonSetId];
|
|
121
|
-
this.props.onChange(updatedFormData);
|
|
122
|
-
return;
|
|
123
|
-
}
|
|
110
|
+
((_d = unit.unitFact) === null || _d === void 0 ? void 0 : _d.juvenileCount);
|
|
124
111
|
});
|
|
125
112
|
if (observationsExist) {
|
|
113
|
+
window.alert(translations === null || translations === void 0 ? void 0 : translations.TaxonSetDeletionFailed);
|
|
114
|
+
const restoredFormData = Object.assign(Object.assign({}, formData), { taxonCensus: [
|
|
115
|
+
...formData.taxonCensus,
|
|
116
|
+
{
|
|
117
|
+
censusTaxonSetID: deletedTaxonSetId,
|
|
118
|
+
taxonCensusType: "MY.taxonCensusTypeCounted"
|
|
119
|
+
}
|
|
120
|
+
] });
|
|
121
|
+
this.selectedTaxonSets = [...this.selectedTaxonSets, deletedTaxonSetId];
|
|
122
|
+
this.props.onChange(restoredFormData);
|
|
126
123
|
return;
|
|
127
124
|
}
|
|
128
125
|
const updatedUnits = currentUnits.filter((unit) => {
|
|
@@ -3,6 +3,7 @@ export { default as ArrayField } from "./ArrayField";
|
|
|
3
3
|
export { default as ObjectField } from "./ObjectField";
|
|
4
4
|
export { default as NestField } from "./NestField";
|
|
5
5
|
export { default as ArrayPropertySumField } from "./ArrayPropertySumField";
|
|
6
|
+
export { default as ArrayPropertyCountField } from "./ArrayPropertyCountField";
|
|
6
7
|
export { default as ScopeField } from "./ScopeField";
|
|
7
8
|
export { default as SelectTreeField } from "./SelectTreeField";
|
|
8
9
|
export { default as GridLayoutField } from "./GridLayoutField";
|
|
@@ -3,8 +3,8 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.
|
|
7
|
-
exports.AccordionArrayField = exports.UnitRapidField = exports.ConditionalField = exports.InputTransformerField = exports.ArraySchemaField = exports.ScientificNameTaxonAutosuggestField = exports.TaxonSetPopulatorField = exports.FillDateRangeField = exports.PrefixArrayField = exports.MultiActiveArrayField = exports.CondensedObjectField = exports.AsArrayField = exports.PdfArrayField = exports.MultiTagArrayField = exports.InputWithDefaultValueButtonField = exports.SortArrayField = exports.MultiLanguageField = exports.UiFieldApplierField = exports.DefaultValueArrayField = exports.ToggleAdditionalArrayFieldsField = exports.UnitCountShorthandField = exports.MultiAnyToBooleanField = exports.FilterArrayField = exports.AudioArrayField = exports.MultiArrayField = void 0;
|
|
6
|
+
exports.FakePropertyField = exports.ImageDisplayField = exports.LocalityField = exports.DataLeakerField = exports.LocationChooserField = exports.UnitListShorthandArrayField = exports.EnumRangeArrayField = exports.AnyToBooleanField = exports.PrefillingArrayField = exports.AnnotationField = exports.ConditionalUiSchemaField = exports.ConditionalOnChangeField = exports.StringToArrayField = exports.TagArrayField = exports.GeocoderField = exports.MapField = exports.NamedPlaceSaverField = exports.NamedPlaceChooserField = exports.SumField = exports.ExtraLabelRowField = exports.UiFieldMapperArrayField = exports.CombinedValueDisplayField = exports.UnitShorthandField = exports.SingleItemArrayField = exports.SingleActiveArrayField = exports.FlatField = exports.SplitField = exports.ImageArrayField = exports.ContextInjectionField = exports.InitiallyHiddenField = exports.HiddenWithTextField = exports.HiddenField = exports.AutosuggestField = exports.AutoArrayField = exports.MapArrayField = exports.DependentDisableField = exports.DependentBooleanField = exports.ArrayCombinerField = exports.InjectDefaultValueField = exports.InjectField = exports.TableField = exports.GridLayoutField = exports.SelectTreeField = exports.ScopeField = exports.ArrayPropertyCountField = exports.ArrayPropertySumField = exports.NestField = exports.ObjectField = exports.ArrayField = exports.SchemaField = void 0;
|
|
7
|
+
exports.AccordionArrayField = exports.UnitRapidField = exports.ConditionalField = exports.InputTransformerField = exports.ArraySchemaField = exports.ScientificNameTaxonAutosuggestField = exports.TaxonSetPopulatorField = exports.FillDateRangeField = exports.PrefixArrayField = exports.MultiActiveArrayField = exports.CondensedObjectField = exports.AsArrayField = exports.PdfArrayField = exports.MultiTagArrayField = exports.InputWithDefaultValueButtonField = exports.SortArrayField = exports.MultiLanguageField = exports.UiFieldApplierField = exports.DefaultValueArrayField = exports.ToggleAdditionalArrayFieldsField = exports.UnitCountShorthandField = exports.MultiAnyToBooleanField = exports.FilterArrayField = exports.AudioArrayField = exports.MultiArrayField = exports.SectionArrayField = void 0;
|
|
8
8
|
var SchemaField_1 = require("./SchemaField");
|
|
9
9
|
Object.defineProperty(exports, "SchemaField", { enumerable: true, get: function () { return __importDefault(SchemaField_1).default; } });
|
|
10
10
|
var ArrayField_1 = require("./ArrayField");
|
|
@@ -15,6 +15,8 @@ var NestField_1 = require("./NestField");
|
|
|
15
15
|
Object.defineProperty(exports, "NestField", { enumerable: true, get: function () { return __importDefault(NestField_1).default; } });
|
|
16
16
|
var ArrayPropertySumField_1 = require("./ArrayPropertySumField");
|
|
17
17
|
Object.defineProperty(exports, "ArrayPropertySumField", { enumerable: true, get: function () { return __importDefault(ArrayPropertySumField_1).default; } });
|
|
18
|
+
var ArrayPropertyCountField_1 = require("./ArrayPropertyCountField");
|
|
19
|
+
Object.defineProperty(exports, "ArrayPropertyCountField", { enumerable: true, get: function () { return __importDefault(ArrayPropertyCountField_1).default; } });
|
|
18
20
|
var ScopeField_1 = require("./ScopeField");
|
|
19
21
|
Object.defineProperty(exports, "ScopeField", { enumerable: true, get: function () { return __importDefault(ScopeField_1).default; } });
|
|
20
22
|
var SelectTreeField_1 = require("./SelectTreeField");
|