@luomus/laji-form 15.1.4 → 15.1.6
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 +46 -0
- package/lib/ApiClient.js +93 -0
- package/lib/Context.d.ts +8 -0
- package/lib/Context.js +18 -0
- package/lib/ReactContext.d.ts +7 -0
- package/lib/ReactContext.js +5 -0
- package/lib/components/BaseComponent.d.ts +9 -0
- package/lib/components/BaseComponent.js +29 -0
- package/lib/components/LajiForm.d.ts +221 -0
- package/lib/components/LajiForm.js +616 -0
- package/lib/components/VirtualSchemaField.d.ts +42 -0
- package/lib/components/VirtualSchemaField.js +74 -0
- package/lib/components/components.d.ts +119 -0
- package/lib/components/components.js +606 -0
- package/lib/components/fields/AnnotationField.d.ts +34 -0
- package/lib/components/fields/AnnotationField.js +242 -0
- package/lib/components/fields/AnyToBooleanField.d.ts +18 -0
- package/lib/components/fields/AnyToBooleanField.js +20 -0
- package/lib/components/fields/ArrayBulkField.d.ts +23 -0
- package/lib/components/fields/ArrayBulkField.js +82 -0
- package/lib/components/fields/ArrayCombinerField.d.ts +36 -0
- package/lib/components/fields/ArrayCombinerField.js +138 -0
- package/lib/components/fields/ArrayField.d.ts +39 -0
- package/lib/components/fields/ArrayField.js +148 -0
- package/lib/components/fields/AsArrayField.d.ts +292 -0
- package/lib/components/fields/AsArrayField.js +38 -0
- package/lib/components/fields/AudioArrayField.d.ts +22 -0
- package/lib/components/fields/AudioArrayField.js +100 -0
- package/lib/components/fields/AutoArrayField.d.ts +24 -0
- package/lib/components/fields/AutoArrayField.js +56 -0
- package/lib/components/fields/AutosuggestField.d.ts +69 -0
- package/lib/components/fields/AutosuggestField.js +299 -0
- package/lib/components/fields/CombinedValueDisplayField.d.ts +41 -0
- package/lib/components/fields/CombinedValueDisplayField.js +100 -0
- package/lib/components/fields/ConditionalOnChangeField.d.ts +42 -0
- package/lib/components/fields/ConditionalOnChangeField.js +107 -0
- package/lib/components/fields/ConditionalUiSchemaField.d.ts +123 -0
- package/lib/components/fields/ConditionalUiSchemaField.js +143 -0
- package/lib/components/fields/ContextInjectionField.d.ts +24 -0
- package/lib/components/fields/ContextInjectionField.js +68 -0
- package/lib/components/fields/DataLeakerField.d.ts +40 -0
- package/lib/components/fields/DataLeakerField.js +68 -0
- package/lib/components/fields/DefaultValueArrayField.d.ts +34 -0
- package/lib/components/fields/DefaultValueArrayField.js +59 -0
- package/lib/components/fields/DependentBooleanField.d.ts +38 -0
- package/lib/components/fields/DependentBooleanField.js +87 -0
- package/lib/components/fields/DependentDisableField.d.ts +35 -0
- package/lib/components/fields/DependentDisableField.js +71 -0
- package/lib/components/fields/EnumRangeArrayField.d.ts +27 -0
- package/lib/components/fields/EnumRangeArrayField.js +115 -0
- package/lib/components/fields/ExtraLabelRowField.d.ts +38 -0
- package/lib/components/fields/ExtraLabelRowField.js +100 -0
- package/lib/components/fields/FakePropertyField.d.ts +18 -0
- package/lib/components/fields/FakePropertyField.js +48 -0
- package/lib/components/fields/FilterArrayField.d.ts +73 -0
- package/lib/components/fields/FilterArrayField.js +121 -0
- package/lib/components/fields/FlatField.d.ts +29 -0
- package/lib/components/fields/FlatField.js +171 -0
- package/lib/components/fields/GeocoderField.d.ts +47 -0
- package/lib/components/fields/GeocoderField.js +372 -0
- package/lib/components/fields/GridLayoutField.d.ts +18 -0
- package/lib/components/fields/GridLayoutField.js +32 -0
- package/lib/components/fields/HiddenField.d.ts +10 -0
- package/lib/components/fields/HiddenField.js +11 -0
- package/lib/components/fields/ImageArrayField.d.ts +172 -0
- package/lib/components/fields/ImageArrayField.js +699 -0
- package/lib/components/fields/ImageDisplayField.d.ts +18 -0
- package/lib/components/fields/ImageDisplayField.js +44 -0
- package/lib/components/fields/InitiallyHiddenField.d.ts +21 -0
- package/lib/components/fields/InitiallyHiddenField.js +58 -0
- package/lib/components/fields/InjectDefaultValueField.d.ts +37 -0
- package/lib/components/fields/InjectDefaultValueField.js +68 -0
- package/lib/components/fields/InjectField.d.ts +46 -0
- package/lib/components/fields/InjectField.js +88 -0
- package/lib/components/fields/InputWithDefaultValueButtonField.d.ts +25 -0
- package/lib/components/fields/InputWithDefaultValueButtonField.js +61 -0
- package/lib/components/fields/LocalityField.d.ts +22 -0
- package/lib/components/fields/LocalityField.js +94 -0
- package/lib/components/fields/LocationChooserField.d.ts +27 -0
- package/lib/components/fields/LocationChooserField.js +440 -0
- package/lib/components/fields/MapArrayField.d.ts +78 -0
- package/lib/components/fields/MapArrayField.js +1783 -0
- package/lib/components/fields/MapField.d.ts +48 -0
- package/lib/components/fields/MapField.js +434 -0
- package/lib/components/fields/MultiAnyToBooleanField.d.ts +25 -0
- package/lib/components/fields/MultiAnyToBooleanField.js +100 -0
- package/lib/components/fields/MultiArrayField.d.ts +53 -0
- package/lib/components/fields/MultiArrayField.js +224 -0
- package/lib/components/fields/MultiLanguageField.d.ts +13 -0
- package/lib/components/fields/MultiLanguageField.js +52 -0
- package/lib/components/fields/MultiTagArrayField.d.ts +36 -0
- package/lib/components/fields/MultiTagArrayField.js +142 -0
- package/lib/components/fields/NamedPlaceChooserField.d.ts +29 -0
- package/lib/components/fields/NamedPlaceChooserField.js +380 -0
- package/lib/components/fields/NamedPlaceSaverField.d.ts +29 -0
- package/lib/components/fields/NamedPlaceSaverField.js +237 -0
- package/lib/components/fields/NestField.d.ts +148 -0
- package/lib/components/fields/NestField.js +289 -0
- package/lib/components/fields/ObjectField.d.ts +2 -0
- package/lib/components/fields/ObjectField.js +119 -0
- package/lib/components/fields/PdfArrayField.d.ts +21 -0
- package/lib/components/fields/PdfArrayField.js +40 -0
- package/lib/components/fields/PrefillingArrayField.d.ts +22 -0
- package/lib/components/fields/PrefillingArrayField.js +65 -0
- package/lib/components/fields/SchemaField.d.ts +7 -0
- package/lib/components/fields/SchemaField.js +109 -0
- package/lib/components/fields/ScopeField.d.ts +85 -0
- package/lib/components/fields/ScopeField.js +521 -0
- package/lib/components/fields/SectionArrayField.d.ts +38 -0
- package/lib/components/fields/SectionArrayField.js +618 -0
- package/lib/components/fields/SelectTreeField.d.ts +39 -0
- package/lib/components/fields/SelectTreeField.js +143 -0
- package/lib/components/fields/SingleActiveArrayField.d.ts +49 -0
- package/lib/components/fields/SingleActiveArrayField.js +974 -0
- package/lib/components/fields/SingleItemArrayField.d.ts +15 -0
- package/lib/components/fields/SingleItemArrayField.js +60 -0
- package/lib/components/fields/SortArrayField.d.ts +73 -0
- package/lib/components/fields/SortArrayField.js +351 -0
- package/lib/components/fields/SplitField.d.ts +28 -0
- package/lib/components/fields/SplitField.js +65 -0
- package/lib/components/fields/StringToArrayField.d.ts +24 -0
- package/lib/components/fields/StringToArrayField.js +48 -0
- package/lib/components/fields/SumField.d.ts +35 -0
- package/lib/components/fields/SumField.js +83 -0
- package/lib/components/fields/TableField.d.ts +18 -0
- package/lib/components/fields/TableField.js +136 -0
- package/lib/components/fields/TagArrayField.d.ts +38 -0
- package/lib/components/fields/TagArrayField.js +128 -0
- package/lib/components/fields/ToggleAdditionalArrayFieldsField.d.ts +26 -0
- package/lib/components/fields/ToggleAdditionalArrayFieldsField.js +81 -0
- package/lib/components/fields/UiFieldApplierField.d.ts +30 -0
- package/lib/components/fields/UiFieldApplierField.js +106 -0
- package/lib/components/fields/UiFieldMapperArrayField.d.ts +42 -0
- package/lib/components/fields/UiFieldMapperArrayField.js +121 -0
- package/lib/components/fields/UnitCountShorthandField.d.ts +22 -0
- package/lib/components/fields/UnitCountShorthandField.js +149 -0
- package/lib/components/fields/UnitListShorthandArrayField.d.ts +26 -0
- package/lib/components/fields/UnitListShorthandArrayField.js +108 -0
- package/lib/components/fields/UnitShorthandField.d.ts +32 -0
- package/lib/components/fields/UnitShorthandField.js +220 -0
- package/lib/components/templates/ArrayFieldTemplate.d.ts +85 -0
- package/lib/components/templates/ArrayFieldTemplate.js +416 -0
- package/lib/components/templates/BaseInputTemplate.d.ts +11 -0
- package/lib/components/templates/BaseInputTemplate.js +80 -0
- package/lib/components/templates/DescriptionField.d.ts +1 -0
- package/lib/components/templates/DescriptionField.js +37 -0
- package/lib/components/templates/ErrorListTemplate.d.ts +9 -0
- package/lib/components/templates/ErrorListTemplate.js +95 -0
- package/lib/components/templates/FieldTemplate.d.ts +6 -0
- package/lib/components/templates/FieldTemplate.js +112 -0
- package/lib/components/templates/ObjectFieldTemplate.d.ts +7 -0
- package/lib/components/templates/ObjectFieldTemplate.js +66 -0
- package/lib/components/templates/TitleField.d.ts +9 -0
- package/lib/components/templates/TitleField.js +51 -0
- package/lib/components/widgets/AnyToBooleanWidget.d.ts +20 -0
- package/lib/components/widgets/AnyToBooleanWidget.js +49 -0
- package/lib/components/widgets/AutosuggestWidget.d.ts +66 -0
- package/lib/components/widgets/AutosuggestWidget.js +1127 -0
- package/lib/components/widgets/CheckboxWidget.d.ts +37 -0
- package/lib/components/widgets/CheckboxWidget.js +139 -0
- package/lib/components/widgets/DateTimeWidget.d.ts +62 -0
- package/lib/components/widgets/DateTimeWidget.js +251 -0
- package/lib/components/widgets/DateWidget.d.ts +23 -0
- package/lib/components/widgets/DateWidget.js +41 -0
- package/lib/components/widgets/HiddenWidget.d.ts +15 -0
- package/lib/components/widgets/HiddenWidget.js +19 -0
- package/lib/components/widgets/ImageSelectWidget.d.ts +14 -0
- package/lib/components/widgets/ImageSelectWidget.js +57 -0
- package/lib/components/widgets/InformalTaxonGroupChooserWidget.d.ts +43 -0
- package/lib/components/widgets/InformalTaxonGroupChooserWidget.js +237 -0
- package/lib/components/widgets/InputGroupWidget.d.ts +21 -0
- package/lib/components/widgets/InputGroupWidget.js +36 -0
- package/lib/components/widgets/InputWithDefaultValueButtonWidget.d.ts +21 -0
- package/lib/components/widgets/InputWithDefaultValueButtonWidget.js +47 -0
- package/lib/components/widgets/NumberWidget.d.ts +13 -0
- package/lib/components/widgets/NumberWidget.js +21 -0
- package/lib/components/widgets/PlainTextWidget.d.ts +12 -0
- package/lib/components/widgets/PlainTextWidget.js +24 -0
- package/lib/components/widgets/SelectWidget.d.ts +52 -0
- package/lib/components/widgets/SelectWidget.js +158 -0
- package/lib/components/widgets/SeparatedDateTimeWidget.d.ts +19 -0
- package/lib/components/widgets/SeparatedDateTimeWidget.js +59 -0
- package/lib/components/widgets/TaxonImageWidget.d.ts +13 -0
- package/lib/components/widgets/TaxonImageWidget.js +30 -0
- package/lib/components/widgets/TextSelectWidget.d.ts +25 -0
- package/lib/components/widgets/TextSelectWidget.js +94 -0
- package/lib/components/widgets/TextareaWidget.d.ts +32 -0
- package/lib/components/widgets/TextareaWidget.js +87 -0
- package/lib/components/widgets/TimeWidget.d.ts +11 -0
- package/lib/components/widgets/TimeWidget.js +19 -0
- package/lib/components/widgets/URLWidget.d.ts +14 -0
- package/lib/components/widgets/URLWidget.js +12 -0
- package/lib/components/widgets/UpperCaseWidget.d.ts +13 -0
- package/lib/components/widgets/UpperCaseWidget.js +21 -0
- package/lib/index.d.ts +20 -0
- package/lib/index.js +50 -0
- package/lib/services/blocker-service.d.ts +11 -0
- package/lib/services/blocker-service.js +55 -0
- package/lib/services/custom-event-service.d.ts +17 -0
- package/lib/services/custom-event-service.js +35 -0
- package/lib/services/dom-id-service.d.ts +8 -0
- package/lib/services/dom-id-service.js +30 -0
- package/lib/services/focus-service.d.ts +13 -0
- package/lib/services/focus-service.js +60 -0
- package/lib/services/id-service.d.ts +22 -0
- package/lib/services/id-service.js +130 -0
- package/lib/services/key-handler-service.d.ts +56 -0
- package/lib/services/key-handler-service.js +184 -0
- package/lib/services/root-instance-service.d.ts +25 -0
- package/lib/services/root-instance-service.js +49 -0
- package/lib/services/settings-service.d.ts +34 -0
- package/lib/services/settings-service.js +154 -0
- package/lib/services/singleton-map-service.d.ts +23 -0
- package/lib/services/singleton-map-service.js +44 -0
- package/lib/services/submit-hook-service.d.ts +24 -0
- package/lib/services/submit-hook-service.js +73 -0
- package/lib/styles.d.ts +1 -0
- package/lib/styles.js +4 -0
- package/lib/themes/bs3.d.ts +3 -0
- package/lib/themes/bs3.js +133 -0
- package/lib/themes/bs5.d.ts +3 -0
- package/lib/themes/bs5.js +111 -0
- package/lib/themes/glyphicon-fa-mapping.d.ts +3 -0
- package/lib/themes/glyphicon-fa-mapping.js +271 -0
- package/lib/themes/stub.d.ts +3 -0
- package/lib/themes/stub.js +82 -0
- package/lib/themes/theme.d.ts +233 -0
- package/lib/themes/theme.js +2 -0
- package/lib/translations.json +847 -0
- package/lib/utils.d.ts +167 -0
- package/lib/utils.js +1185 -0
- package/lib/validation.d.ts +7 -0
- package/lib/validation.js +141 -0
- package/package.json +2 -2
- package/patches/protractor++webdriver-manager+12.1.8.patch +0 -20395
|
@@ -0,0 +1,521 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const React = require("react");
|
|
4
|
+
const PropTypes = require("prop-types");
|
|
5
|
+
const merge = require("deepmerge");
|
|
6
|
+
const equals = require("deep-equal");
|
|
7
|
+
const Spinner = require("react-spinner");
|
|
8
|
+
const components_1 = require("../components");
|
|
9
|
+
const utils_1 = require("../../utils");
|
|
10
|
+
const Context_1 = require("../../Context");
|
|
11
|
+
const ReactContext_1 = require("../../ReactContext");
|
|
12
|
+
const ConditionalUiSchemaField_1 = require("./ConditionalUiSchemaField");
|
|
13
|
+
const utils_2 = require("@rjsf/utils");
|
|
14
|
+
const scopeFieldSettings = {
|
|
15
|
+
taxonGroups: {
|
|
16
|
+
translate: (props, taxonGroup) => {
|
|
17
|
+
return props.formContext.apiClient.fetchCached("/informal-taxon-groups/" + taxonGroup).then((response) => {
|
|
18
|
+
return response.name;
|
|
19
|
+
}).catch(() => {
|
|
20
|
+
return "";
|
|
21
|
+
});
|
|
22
|
+
},
|
|
23
|
+
}
|
|
24
|
+
};
|
|
25
|
+
/**
|
|
26
|
+
* Field with fields, which are shown according to recursive scope.
|
|
27
|
+
* uiSchema = {"ui:options": {
|
|
28
|
+
* additionalsGroupingPath: path to the field scope that defines groups
|
|
29
|
+
* additionalsGroupsTranslator: one of scopeFieldsSettings translator
|
|
30
|
+
* additionalsPersistenceKey: instances with same persistence id use the same additional fields
|
|
31
|
+
* additionalsPersistenceField: form data property value for more fine grained persistence behaviour
|
|
32
|
+
* uiSchema: <uiSchema> (ui schema for inner schema)
|
|
33
|
+
* fields: [<string>] (fields that are always shown)
|
|
34
|
+
* fieldScopes: {
|
|
35
|
+
* fieldName: {
|
|
36
|
+
* fieldValue: {
|
|
37
|
+
* fields: [<string>] (fields that are shown if fieldName[fieldValue} == true)
|
|
38
|
+
* additionalFields: [<string>] (if grouping is enabled, additional fields are shown only if selected from the list)
|
|
39
|
+
* excludeFields: [<string>] (exclude fields from showing)
|
|
40
|
+
* excludeFields: [<string>] (fields that are shown by default)
|
|
41
|
+
* refs: [<string>] (root definitions that are merged recursively to this fieldScope)
|
|
42
|
+
* uiSchema: <uiSchema> (merged recursively to inner uiSchema)
|
|
43
|
+
* uiSchemaMergeType: See documentation for ConditionalUiSchemaField
|
|
44
|
+
* fieldScopes: {fieldName: <fieldScope>, fieldName2 ...}
|
|
45
|
+
* },
|
|
46
|
+
* fieldValue2, ...
|
|
47
|
+
* }
|
|
48
|
+
* },
|
|
49
|
+
* definitions: {
|
|
50
|
+
* defName: <fieldScope>,
|
|
51
|
+
* defname2: ...
|
|
52
|
+
* }
|
|
53
|
+
* }
|
|
54
|
+
*
|
|
55
|
+
* Field scope values accept asterisk (*) and plus (+) as field scope selector.
|
|
56
|
+
*/
|
|
57
|
+
class ScopeField extends React.Component {
|
|
58
|
+
constructor(props) {
|
|
59
|
+
super(props);
|
|
60
|
+
this.getAdditionalPersistenceValue = (props, includeUndefined = true) => {
|
|
61
|
+
const { additionalsPersistenceField, additionalPersistenceContextKey } = utils_1.getUiOptions(props.uiSchema);
|
|
62
|
+
let formDataItem = props.formData[additionalsPersistenceField];
|
|
63
|
+
if (additionalPersistenceContextKey && (formDataItem === undefined || Array.isArray(formDataItem) && formDataItem.length === 0)) {
|
|
64
|
+
formDataItem = Context_1.default(this.props.formContext.contextId)[additionalPersistenceContextKey];
|
|
65
|
+
}
|
|
66
|
+
let items = (Array.isArray(formDataItem) ? formDataItem : [formDataItem]);
|
|
67
|
+
if (includeUndefined)
|
|
68
|
+
items = ["undefined", ...items];
|
|
69
|
+
return items;
|
|
70
|
+
};
|
|
71
|
+
this.getSchemasAndAdditionals = (props, state) => {
|
|
72
|
+
let { schema, uiSchema, formData } = props;
|
|
73
|
+
let additionalFields = (state && state.additionalFields) ? Object.assign({}, state.additionalFields) : {};
|
|
74
|
+
Object.keys(additionalFields).forEach(key => {
|
|
75
|
+
if (!props.schema.properties[key]) {
|
|
76
|
+
delete additionalFields[key];
|
|
77
|
+
}
|
|
78
|
+
});
|
|
79
|
+
let defaultFields = (state && state.defaultFields) ? Object.assign({}, state.defaultFields) : {};
|
|
80
|
+
const options = utils_1.getUiOptions(uiSchema);
|
|
81
|
+
let { fields, definitions, glyphFields = [], geometryField = "unitGathering_geometry", taxonField } = options;
|
|
82
|
+
let generatedUiSchema = utils_1.getInnerUiSchema(uiSchema);
|
|
83
|
+
let fieldsToShow = {};
|
|
84
|
+
(fields || []).forEach(field => {
|
|
85
|
+
fieldsToShow[field] = schema.properties[field];
|
|
86
|
+
});
|
|
87
|
+
let hasSetLocation = false;
|
|
88
|
+
glyphFields.reduce((additionalFields, { show, open, fn }) => {
|
|
89
|
+
if (fn === "setLocation") {
|
|
90
|
+
hasSetLocation = true;
|
|
91
|
+
}
|
|
92
|
+
if (!(show in additionalFields) && show && open) {
|
|
93
|
+
additionalFields[show] = open;
|
|
94
|
+
}
|
|
95
|
+
return additionalFields;
|
|
96
|
+
}, additionalFields);
|
|
97
|
+
function addFieldSelectorsValues(scopes, fieldSelector, fieldSelectorValue) {
|
|
98
|
+
let fieldScope = scopes[fieldSelector][fieldSelectorValue];
|
|
99
|
+
if (!fieldScope)
|
|
100
|
+
return;
|
|
101
|
+
while (fieldScope.refs) {
|
|
102
|
+
let refs = fieldScope.refs;
|
|
103
|
+
fieldScope = Object.assign(Object.assign({}, fieldScope), { refs: undefined });
|
|
104
|
+
refs.forEach(ref => {
|
|
105
|
+
fieldScope = merge(fieldScope, definitions[ref]);
|
|
106
|
+
});
|
|
107
|
+
}
|
|
108
|
+
const { excludeFields = [], fields: _fields = [], defaultFields: _defaultFields = [] } = fieldScope;
|
|
109
|
+
excludeFields.forEach(fieldName => {
|
|
110
|
+
delete fieldsToShow[fieldName];
|
|
111
|
+
});
|
|
112
|
+
_defaultFields.forEach(fieldName => {
|
|
113
|
+
if (additionalFields[fieldName] !== false)
|
|
114
|
+
fieldsToShow[fieldName] = schema.properties[fieldName];
|
|
115
|
+
});
|
|
116
|
+
_fields.forEach((fieldName) => {
|
|
117
|
+
fieldsToShow[fieldName] = schema.properties[fieldName];
|
|
118
|
+
if (additionalFields[fieldName]) {
|
|
119
|
+
delete additionalFields[fieldName];
|
|
120
|
+
}
|
|
121
|
+
});
|
|
122
|
+
if (fieldScope.uiSchema) {
|
|
123
|
+
const { uiSchemaMergeType = "merge" } = fieldScope;
|
|
124
|
+
generatedUiSchema = ConditionalUiSchemaField_1.computeUiSchema(generatedUiSchema, { type: uiSchemaMergeType, uiSchema: fieldScope.uiSchema });
|
|
125
|
+
}
|
|
126
|
+
if (fieldScope.fieldScopes) {
|
|
127
|
+
addFieldScopeFieldsToFieldsToShow(fieldScope);
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
const that = this;
|
|
131
|
+
function addFieldScopeFieldsToFieldsToShow(fieldScope) {
|
|
132
|
+
if (!fieldScope)
|
|
133
|
+
return;
|
|
134
|
+
let scopes = fieldScope.fieldScopes;
|
|
135
|
+
if (scopes)
|
|
136
|
+
Object.keys(scopes).forEach(fieldSelector => {
|
|
137
|
+
let fieldSelectorValues = formData[fieldSelector];
|
|
138
|
+
if (!fieldSelectorValues || Array.isArray(fieldSelectorValues) && !fieldSelectorValues.length) {
|
|
139
|
+
fieldSelectorValues = that.getAdditionalPersistenceValue(props);
|
|
140
|
+
}
|
|
141
|
+
if (!Array.isArray(fieldSelectorValues))
|
|
142
|
+
fieldSelectorValues = [fieldSelectorValues];
|
|
143
|
+
if (scopes[fieldSelector]["+"] && fieldSelectorValues.length > 0 && fieldSelectorValues.some(_fieldSelectorValue => _fieldSelectorValue !== "undefined" && utils_1.hasData(_fieldSelectorValue) && !utils_1.isDefaultData(_fieldSelectorValue, schema.properties[fieldSelector]))) {
|
|
144
|
+
addFieldSelectorsValues(scopes, fieldSelector, "+");
|
|
145
|
+
}
|
|
146
|
+
if (scopes[fieldSelector]["*"]) {
|
|
147
|
+
addFieldSelectorsValues(scopes, fieldSelector, "*");
|
|
148
|
+
}
|
|
149
|
+
fieldSelectorValues.forEach(fieldSelectorValue => {
|
|
150
|
+
if (utils_1.hasData(fieldSelectorValue) && !utils_1.isDefaultData(fieldSelectorValue, schema.properties[fieldSelector].type === "array" ? schema.properties[fieldSelector].items : schema.properties[fieldSelector])) {
|
|
151
|
+
addFieldSelectorsValues(scopes, fieldSelector, fieldSelectorValue);
|
|
152
|
+
}
|
|
153
|
+
});
|
|
154
|
+
});
|
|
155
|
+
}
|
|
156
|
+
function findScopedFields(fieldScope = {}, _fields = {}) {
|
|
157
|
+
const { fields = [], additionalFields = [], fieldScopes = {} } = fieldScope;
|
|
158
|
+
[...fields, ...additionalFields].forEach(f => {
|
|
159
|
+
_fields[f] = true;
|
|
160
|
+
});
|
|
161
|
+
Object.keys(fieldScopes).forEach(f => Object.keys(fieldScopes[f]).forEach(_f => findScopedFields(fieldScopes[f][_f], _fields)));
|
|
162
|
+
return _fields;
|
|
163
|
+
}
|
|
164
|
+
// If no root fields defined, show all fields that aren't in any scopes' fields or additional fields.
|
|
165
|
+
if (!fields) {
|
|
166
|
+
const scopedFields = findScopedFields(options);
|
|
167
|
+
glyphFields.forEach(({ show, open }) => {
|
|
168
|
+
if (open === false) {
|
|
169
|
+
scopedFields[show] = true;
|
|
170
|
+
}
|
|
171
|
+
});
|
|
172
|
+
fieldsToShow = Object.keys(props.schema.properties).reduce((_fields, f) => {
|
|
173
|
+
if (!scopedFields[f]) {
|
|
174
|
+
_fields[f] = props.schema.properties[f];
|
|
175
|
+
}
|
|
176
|
+
return _fields;
|
|
177
|
+
}, {});
|
|
178
|
+
}
|
|
179
|
+
addFieldScopeFieldsToFieldsToShow(options);
|
|
180
|
+
if (additionalFields) {
|
|
181
|
+
Object.keys(additionalFields).filter(field => additionalFields[field]).forEach((property) => {
|
|
182
|
+
if (additionalFields[property]) {
|
|
183
|
+
fieldsToShow[property] = props.schema.properties[property];
|
|
184
|
+
}
|
|
185
|
+
});
|
|
186
|
+
}
|
|
187
|
+
if (formData) {
|
|
188
|
+
Object.keys(formData).forEach((property) => {
|
|
189
|
+
if (!schema.properties[property])
|
|
190
|
+
return;
|
|
191
|
+
const isDefault = utils_1.isDefaultData(formData[property], schema.properties[property]);
|
|
192
|
+
if (!isDefault) {
|
|
193
|
+
fieldsToShow[property] = props.schema.properties[property];
|
|
194
|
+
}
|
|
195
|
+
});
|
|
196
|
+
}
|
|
197
|
+
Object.keys(schema.properties).forEach(prop => {
|
|
198
|
+
if (!fieldsToShow[prop]) {
|
|
199
|
+
generatedUiSchema[prop] = { "ui:field": "HiddenField" };
|
|
200
|
+
}
|
|
201
|
+
});
|
|
202
|
+
if (hasSetLocation) {
|
|
203
|
+
console.warn("ScopeField's glyphField fn 'setLocation' is deprecated and will be removed in the future. The functionality is separated to a new component function 'LocationChooserField', use it instead.");
|
|
204
|
+
const locationFn = {
|
|
205
|
+
"ui:field": "LocationChooserField",
|
|
206
|
+
"ui:options": {
|
|
207
|
+
geometryField,
|
|
208
|
+
taxonField
|
|
209
|
+
}
|
|
210
|
+
};
|
|
211
|
+
const uiFunctions = generatedUiSchema["ui:functions"]
|
|
212
|
+
? utils_1.isObject(generatedUiSchema["ui:functions"])
|
|
213
|
+
? [generatedUiSchema["ui:functions"], locationFn]
|
|
214
|
+
: [...generatedUiSchema["ui:functions"], locationFn]
|
|
215
|
+
: [locationFn];
|
|
216
|
+
generatedUiSchema = Object.assign(Object.assign({}, generatedUiSchema), { "ui:functions": uiFunctions });
|
|
217
|
+
}
|
|
218
|
+
return {
|
|
219
|
+
schema: schema,
|
|
220
|
+
uiSchema: generatedUiSchema,
|
|
221
|
+
additionalFields,
|
|
222
|
+
defaultFields,
|
|
223
|
+
fieldsToShow
|
|
224
|
+
};
|
|
225
|
+
};
|
|
226
|
+
this.onToggleAdditionals = () => {
|
|
227
|
+
this.setState({ additionalsOpen: !this.state.additionalsOpen });
|
|
228
|
+
};
|
|
229
|
+
this.renderAdditionalsButtons = () => {
|
|
230
|
+
const glyphButtons = this.renderGlyphFields();
|
|
231
|
+
if (!this.state.includeAdditionalFieldsChooserButton || Object.keys(this.props.formData || {}).length === 0) {
|
|
232
|
+
if (glyphButtons) {
|
|
233
|
+
return glyphButtons;
|
|
234
|
+
}
|
|
235
|
+
return [];
|
|
236
|
+
}
|
|
237
|
+
const { additionalsGroupingPath } = utils_1.getUiOptions(this.props.uiSchema);
|
|
238
|
+
let additionalProperties = {};
|
|
239
|
+
Object.keys(this.props.schema.properties).forEach(property => {
|
|
240
|
+
if (!this.state.fieldsToShow[property] ||
|
|
241
|
+
(this.state.fieldsToShow[property] && this.state.additionalFields[property]))
|
|
242
|
+
additionalProperties[property] = this.props.schema.properties[property];
|
|
243
|
+
});
|
|
244
|
+
return [
|
|
245
|
+
additionalsGroupingPath
|
|
246
|
+
? this.renderFieldsModal(additionalProperties)
|
|
247
|
+
: this.renderFieldsDropdown(additionalProperties),
|
|
248
|
+
...(glyphButtons ? glyphButtons : [])
|
|
249
|
+
];
|
|
250
|
+
};
|
|
251
|
+
this.onSelect = () => {
|
|
252
|
+
this.preventCloseDropdown = true;
|
|
253
|
+
};
|
|
254
|
+
this.onToggle = (isOpen) => {
|
|
255
|
+
if (!this.preventCloseDropdown)
|
|
256
|
+
this.onToggleAdditionals(isOpen);
|
|
257
|
+
this.preventCloseDropdown = false;
|
|
258
|
+
};
|
|
259
|
+
this.renderFieldsModal = (additionalProperties) => {
|
|
260
|
+
const { translations } = this.props.formContext;
|
|
261
|
+
let list = [];
|
|
262
|
+
const options = utils_1.getUiOptions(this.props.uiSchema);
|
|
263
|
+
const { additionalsGroupingPath } = options;
|
|
264
|
+
let groupTranslations = this.state.additionalsGroupsTranslations;
|
|
265
|
+
const groups = additionalsGroupingPath ? utils_1.parseJSONPointer(options, additionalsGroupingPath) : {};
|
|
266
|
+
const additionalsPersistenceValue = this.getAdditionalPersistenceValue(this.props);
|
|
267
|
+
let groupNames = Object.keys(groups);
|
|
268
|
+
if (additionalsPersistenceValue)
|
|
269
|
+
groupNames = groupNames.sort((a, b) => additionalsPersistenceValue.indexOf(b) - additionalsPersistenceValue.indexOf(a));
|
|
270
|
+
groupNames.forEach(groupName => {
|
|
271
|
+
list.push(React.createElement(_ListGroup, { key: groupName, group: groups[groupName], groupName: groupName, groupTranslations: groupTranslations, additionalProperties: additionalProperties, additionalPropertiesToList: this.additionalPropertiesToList, propertyIsIncluded: this.propertyIsIncluded, schema: this.props.schema, toggleAdditionalProperty: this.toggleAdditionalProperty }));
|
|
272
|
+
});
|
|
273
|
+
const { Modal } = this.context.theme;
|
|
274
|
+
if (this.state.additionalsOpen)
|
|
275
|
+
this.modal = (React.createElement(Modal, { key: "fields-modal", show: true, onHide: this.onToggleAdditionals, dialogClassName: "laji-form scope-field-modal" },
|
|
276
|
+
React.createElement(Modal.Header, { closeButton: true },
|
|
277
|
+
React.createElement(Modal.Title, null, translations.SelectMoreFields)),
|
|
278
|
+
React.createElement(Modal.Body, null, list)));
|
|
279
|
+
return this.renderFieldsButton();
|
|
280
|
+
};
|
|
281
|
+
this.renderFieldsButton = (bsRole) => {
|
|
282
|
+
const { OverlayTrigger, Tooltip } = this.context.theme;
|
|
283
|
+
const tooltip = (React.createElement(Tooltip, { id: `${this.props.idSchema.$id}-additionals-tooltip` }, this.props.formContext.translations.SelectMoreFields));
|
|
284
|
+
return (React.createElement(OverlayTrigger, { key: `${this.props.idSchema.$id}-scope`, overlay: tooltip, placement: "left", bsRole: bsRole },
|
|
285
|
+
React.createElement(components_1.GlyphButton, { glyph: "cog", onClick: this.onToggleAdditionals, id: `${this.props.idSchema.$id}-additionals`, variant: "primary" })));
|
|
286
|
+
};
|
|
287
|
+
this.renderGlyphFields = () => {
|
|
288
|
+
const { glyphFields } = utils_1.getUiOptions(this.props.uiSchema);
|
|
289
|
+
return glyphFields ?
|
|
290
|
+
glyphFields.filter(settings => !settings.fn || settings.fn !== "setLocation").map((settings, i) => React.createElement(GlyphField, { key: i, settings: settings, idSchema: this.props.idSchema, formData: this.props.formData, schema: this.props.schema, registry: this.props.registry, isIncluded: this.propertyIsIncluded(settings.show), toggleAdditionalProperty: this.toggleAdditionalProperty })) : null;
|
|
291
|
+
};
|
|
292
|
+
this.propertyIsIncluded = (property) => {
|
|
293
|
+
const { additionalFields } = this.state;
|
|
294
|
+
const isIncluded = additionalFields[property] === true || this.state.fieldsToShow[property];
|
|
295
|
+
return !!isIncluded;
|
|
296
|
+
};
|
|
297
|
+
this.toggleAdditionalProperty = (fields) => {
|
|
298
|
+
const { additionalsPersistenceField, additionalsPersistenceKey } = utils_1.getUiOptions(this.props.uiSchema);
|
|
299
|
+
if (!Array.isArray(fields))
|
|
300
|
+
fields = [fields];
|
|
301
|
+
const additionalFields = fields.reduce((additionalFields, field) => {
|
|
302
|
+
return Object.assign(Object.assign({}, additionalFields), { [field]: !this.propertyIsIncluded(field) });
|
|
303
|
+
}, this.state.additionalFields);
|
|
304
|
+
if (this._globals) {
|
|
305
|
+
const additionalsPersistenceVal = this.getAdditionalPersistenceValue(this.props, !"don't include undefined");
|
|
306
|
+
let globalsEntry = this._globals || {};
|
|
307
|
+
if (additionalsPersistenceField) {
|
|
308
|
+
let additionalsKeys = this.props.schema.properties[additionalsPersistenceField].type === "array"
|
|
309
|
+
? additionalsPersistenceVal
|
|
310
|
+
: [additionalsPersistenceVal];
|
|
311
|
+
if (additionalsKeys.length === 0)
|
|
312
|
+
additionalsKeys = ["undefined"];
|
|
313
|
+
additionalsKeys.forEach(persistenceKey => {
|
|
314
|
+
globalsEntry[persistenceKey] = additionalFields;
|
|
315
|
+
});
|
|
316
|
+
this.props.formContext.globals[`scopeField_${additionalsPersistenceKey}`] = globalsEntry;
|
|
317
|
+
}
|
|
318
|
+
else if (additionalsPersistenceKey) {
|
|
319
|
+
this.props.formContext.globals[`scopeField_${additionalsPersistenceKey}`] = additionalFields;
|
|
320
|
+
}
|
|
321
|
+
}
|
|
322
|
+
this.setState(Object.assign({ additionalFields }, this.getSchemasAndAdditionals(this.props, Object.assign(Object.assign({}, this.state), { additionalFields }))));
|
|
323
|
+
};
|
|
324
|
+
this.additionalPropertiesToList = (properties, ElemType) => {
|
|
325
|
+
const titles = utils_1.getUiOptions(this.props.uiSchema).titles || {};
|
|
326
|
+
return utils_2.orderProperties(Object.keys(properties), this.props.uiSchema["ui:order"])
|
|
327
|
+
.map(property => {
|
|
328
|
+
const isIncluded = this.propertyIsIncluded(property);
|
|
329
|
+
const hasData = utils_1.propertyHasData(property, this.props.formData) && (!this.props.formData || !utils_1.isDefaultData(this.props.formData[property], this.props.schema.properties[property]));
|
|
330
|
+
if (!this.propertyTogglers) {
|
|
331
|
+
this.propertyTogglers = {};
|
|
332
|
+
}
|
|
333
|
+
if (!this.propertyTogglers[property]) {
|
|
334
|
+
this.propertyTogglers[property] = () => this.toggleAdditionalProperty(property);
|
|
335
|
+
}
|
|
336
|
+
return (React.createElement(ElemType, { key: property, disabled: hasData, active: isIncluded, onClick: this.propertyTogglers[property] }, titles[property] || properties[property].title || property));
|
|
337
|
+
});
|
|
338
|
+
};
|
|
339
|
+
this.translateAdditionalsGroups = (props) => {
|
|
340
|
+
let options = utils_1.getUiOptions(props.uiSchema);
|
|
341
|
+
const { additionalsGroupingPath, additionalsGroupsTranslator } = options;
|
|
342
|
+
if (!additionalsGroupingPath)
|
|
343
|
+
return;
|
|
344
|
+
const groups = utils_1.parseJSONPointer(options, additionalsGroupingPath);
|
|
345
|
+
const groupNames = Object.keys(groups).filter(groupName => !utils_1.isNullOrUndefined(groups[groupName]));
|
|
346
|
+
let translations = {};
|
|
347
|
+
let translationsToKeys = {};
|
|
348
|
+
let translationCount = 0;
|
|
349
|
+
groupNames.forEach(groupName => {
|
|
350
|
+
const title = groups[groupName].title;
|
|
351
|
+
const promise = (!utils_1.isNullOrUndefined(title)) ?
|
|
352
|
+
new Promise(resolve => resolve(title)) :
|
|
353
|
+
scopeFieldSettings[additionalsGroupsTranslator].translate(props, groupName);
|
|
354
|
+
promise.then(translation => {
|
|
355
|
+
translations[groupName] = translation;
|
|
356
|
+
translationsToKeys[translation] = groupName;
|
|
357
|
+
translationCount++;
|
|
358
|
+
if (this.mounted && translationCount == groupNames.length) {
|
|
359
|
+
this.setState({
|
|
360
|
+
additionalsGroupsTranslations: translations,
|
|
361
|
+
additionalsGroupsTranslationsToKeys: translationsToKeys
|
|
362
|
+
});
|
|
363
|
+
}
|
|
364
|
+
});
|
|
365
|
+
});
|
|
366
|
+
};
|
|
367
|
+
this.props.formContext.services.settings.bind(this, props);
|
|
368
|
+
this.state = this.getStateFromProps(props);
|
|
369
|
+
}
|
|
370
|
+
UNSAFE_componentWillReceiveProps(props) {
|
|
371
|
+
const state = this.getStateFromProps(props);
|
|
372
|
+
if (state)
|
|
373
|
+
this.setState(state);
|
|
374
|
+
}
|
|
375
|
+
componentDidMount() {
|
|
376
|
+
this.mounted = true;
|
|
377
|
+
}
|
|
378
|
+
componentWillUnmount() {
|
|
379
|
+
this.mounted = false;
|
|
380
|
+
}
|
|
381
|
+
render() {
|
|
382
|
+
const SchemaField = this.props.registry.fields.SchemaField;
|
|
383
|
+
const { additionalsGroupingPath } = utils_1.getUiOptions(this.props.uiSchema);
|
|
384
|
+
let uiSchema = Object.assign(Object.assign({}, this.state.uiSchema), { "ui:buttons": [
|
|
385
|
+
...(this.props.uiSchema["ui:buttons"] || []),
|
|
386
|
+
...this.renderAdditionalsButtons()
|
|
387
|
+
] });
|
|
388
|
+
const addButton = button => {
|
|
389
|
+
uiSchema = Object.assign(Object.assign({}, uiSchema), { "ui:buttons": [
|
|
390
|
+
...uiSchema["ui:buttons"],
|
|
391
|
+
button
|
|
392
|
+
] });
|
|
393
|
+
};
|
|
394
|
+
if (this.state.additionalsOpen && additionalsGroupingPath) {
|
|
395
|
+
addButton(this.modal);
|
|
396
|
+
}
|
|
397
|
+
return React.createElement(SchemaField, Object.assign({}, this.props, this.state, { uiSchema: uiSchema }));
|
|
398
|
+
}
|
|
399
|
+
componentDidUpdate(prevProps, prevState) {
|
|
400
|
+
if (this.state.additionalsOpen
|
|
401
|
+
&& (!this.state.additionalsGroupsTranslations || prevProps.formContext.lang !== this.props.formContext.lang ||
|
|
402
|
+
utils_1.getUiOptions(prevProps.uiSchema).additionalsGroupsTranslator !== utils_1.getUiOptions(this.props.uiSchema).additionalsGroupsTranslator)) {
|
|
403
|
+
this.translateAdditionalsGroups(this.props);
|
|
404
|
+
}
|
|
405
|
+
if (!equals(prevState.fieldsToShow, this.state.fieldsToShow)) {
|
|
406
|
+
this.props.formContext.utils.syncScroll();
|
|
407
|
+
}
|
|
408
|
+
}
|
|
409
|
+
getStateFromProps(props) {
|
|
410
|
+
const options = utils_1.getUiOptions(props.uiSchema);
|
|
411
|
+
const includeAdditionalFieldsChooserButton = !!options.includeAdditionalFieldsChooserButton;
|
|
412
|
+
let state = {
|
|
413
|
+
includeAdditionalFieldsChooserButton
|
|
414
|
+
};
|
|
415
|
+
const { additionalsPersistenceField, additionalsPersistenceKey } = utils_1.getUiOptions(props.uiSchema);
|
|
416
|
+
let additionalFields = additionalsPersistenceField
|
|
417
|
+
? {}
|
|
418
|
+
: (this.state ? this.state.additionalFields : {});
|
|
419
|
+
if (additionalsPersistenceKey) {
|
|
420
|
+
if (!props.formContext.globals[`scopeField_${additionalsPersistenceKey}`]) {
|
|
421
|
+
props.formContext.globals[`scopeField_${additionalsPersistenceKey}`] = {};
|
|
422
|
+
}
|
|
423
|
+
this._globals = props.formContext.globals[`scopeField_${additionalsPersistenceKey}`];
|
|
424
|
+
let additionalsToAdd = {};
|
|
425
|
+
if (additionalsPersistenceField) {
|
|
426
|
+
const additionalPersistenceValue = this.getAdditionalPersistenceValue(props);
|
|
427
|
+
additionalPersistenceValue.forEach(item => {
|
|
428
|
+
if (this._globals && this._globals[item])
|
|
429
|
+
additionalsToAdd = Object.assign(Object.assign({}, additionalsToAdd), this._globals[item]);
|
|
430
|
+
});
|
|
431
|
+
}
|
|
432
|
+
else {
|
|
433
|
+
if (this._globals)
|
|
434
|
+
additionalsToAdd = this._globals;
|
|
435
|
+
}
|
|
436
|
+
additionalFields = Object.assign(Object.assign({}, additionalFields), additionalsToAdd);
|
|
437
|
+
}
|
|
438
|
+
state.additionalFields = additionalFields;
|
|
439
|
+
state = Object.assign(Object.assign({}, state), this.getSchemasAndAdditionals(props, state));
|
|
440
|
+
return state;
|
|
441
|
+
}
|
|
442
|
+
renderFieldsDropdown(additionalProperties) {
|
|
443
|
+
const { MenuItem, Glyphicon, Dropdown } = this.context.theme;
|
|
444
|
+
return (React.createElement("div", { key: "scope-additionals-dropdown" },
|
|
445
|
+
React.createElement(Dropdown, { pullRight: true, id: this.props.idSchema.$id + "-additionals", open: this.state.additionalsOpen, onToggle: this.onToggle },
|
|
446
|
+
React.createElement(Dropdown.Toggle, { noCaret: true, variant: "primary" },
|
|
447
|
+
React.createElement(Glyphicon, { glyph: "cog" })),
|
|
448
|
+
React.createElement(Dropdown.Menu, { onSelect: this.onSelect }, this.additionalPropertiesToList(additionalProperties, MenuItem)))));
|
|
449
|
+
}
|
|
450
|
+
}
|
|
451
|
+
exports.default = ScopeField;
|
|
452
|
+
ScopeField.contextType = ReactContext_1.default;
|
|
453
|
+
ScopeField.propTypes = {
|
|
454
|
+
uiSchema: PropTypes.shape({
|
|
455
|
+
"ui:options": PropTypes.shape({
|
|
456
|
+
includeAdditionalFieldsChooserButton: PropTypes.boolean,
|
|
457
|
+
additionalsGroupingPath: PropTypes.string,
|
|
458
|
+
additionalsGroupsTranslator: PropTypes.oneOf(Object.keys(scopeFieldSettings)),
|
|
459
|
+
additionalsPersistenceKey: PropTypes.string,
|
|
460
|
+
additionalsPersistenceField: PropTypes.string,
|
|
461
|
+
fieldScopes: PropTypes.object,
|
|
462
|
+
fields: PropTypes.arrayOf(PropTypes.string),
|
|
463
|
+
definitions: PropTypes.object,
|
|
464
|
+
uiSchema: PropTypes.object
|
|
465
|
+
}).isRequired
|
|
466
|
+
}).isRequired,
|
|
467
|
+
schema: PropTypes.shape({
|
|
468
|
+
type: PropTypes.oneOf(["object"])
|
|
469
|
+
}).isRequired,
|
|
470
|
+
formData: PropTypes.object.isRequired
|
|
471
|
+
};
|
|
472
|
+
const getGroupFields = (group, additionalProperties, schema) => {
|
|
473
|
+
const { fields = [], additionalFields = [] } = group;
|
|
474
|
+
const additionalFieldsDict = utils_1.dictionarify(additionalFields);
|
|
475
|
+
let combinedFields = Object.keys(Object.assign(Object.assign({}, utils_1.dictionarify(fields)), additionalFieldsDict));
|
|
476
|
+
let groupFields = {};
|
|
477
|
+
combinedFields.forEach(field => {
|
|
478
|
+
if (additionalProperties[field]) {
|
|
479
|
+
groupFields[field] = additionalProperties[field];
|
|
480
|
+
}
|
|
481
|
+
else if (additionalFieldsDict[field]) {
|
|
482
|
+
groupFields[field] = schema.properties[field];
|
|
483
|
+
}
|
|
484
|
+
});
|
|
485
|
+
return groupFields;
|
|
486
|
+
};
|
|
487
|
+
const _ListGroup = React.memo(function _ListGroup({ group = {}, groupTranslations = {}, additionalProperties, groupName, additionalPropertiesToList, propertyIsIncluded, schema, toggleAdditionalProperty }) {
|
|
488
|
+
const groupFields = React.useMemo(() => getGroupFields(group, additionalProperties, schema), [group, additionalProperties, schema]);
|
|
489
|
+
const { ListGroupItem, ListGroup } = React.useContext(ReactContext_1.default).theme;
|
|
490
|
+
let groupsList = additionalPropertiesToList(groupFields, ListGroupItem);
|
|
491
|
+
const someActive = Object.keys(groupFields).some(propertyIsIncluded);
|
|
492
|
+
const onListGroupClick = React.useCallback(() => {
|
|
493
|
+
toggleAdditionalProperty(Object.keys(groupFields)
|
|
494
|
+
.filter(field => { return propertyIsIncluded(field) === someActive; }));
|
|
495
|
+
}, [toggleAdditionalProperty, groupFields, propertyIsIncluded, someActive]);
|
|
496
|
+
if (!groupsList.length) {
|
|
497
|
+
return null;
|
|
498
|
+
}
|
|
499
|
+
const listGroup = [
|
|
500
|
+
React.createElement(ListGroupItem, { key: groupName + "-list", active: someActive, onClick: onListGroupClick }, groupTranslations[groupName] !== undefined
|
|
501
|
+
? React.createElement("strong", null, groupTranslations[groupName])
|
|
502
|
+
: React.createElement(Spinner, { key: groupName + "-list" })),
|
|
503
|
+
...groupsList
|
|
504
|
+
];
|
|
505
|
+
return (React.createElement("div", { key: groupName, className: "scope-field-modal-item" },
|
|
506
|
+
React.createElement(ListGroup, null, listGroup)));
|
|
507
|
+
});
|
|
508
|
+
function GlyphField({ settings, idSchema, formData, schema, isIncluded, toggleAdditionalProperty }) {
|
|
509
|
+
const { glyph, label, show } = settings;
|
|
510
|
+
const property = show;
|
|
511
|
+
const onButtonClick = React.useCallback(() => toggleAdditionalProperty(property), [property, toggleAdditionalProperty]);
|
|
512
|
+
const { Tooltip, OverlayTrigger } = React.useContext(ReactContext_1.default).theme;
|
|
513
|
+
if (!show) {
|
|
514
|
+
return null;
|
|
515
|
+
}
|
|
516
|
+
const hasData = utils_1.propertyHasData(property, formData) && (!formData || !utils_1.isDefaultData(formData[property], schema.properties[property]));
|
|
517
|
+
const tooltip = React.createElement(Tooltip, { id: `${idSchema.$id}-${property}-tooltip-${glyph}` }, label);
|
|
518
|
+
return (React.createElement(OverlayTrigger, { key: property, overlay: tooltip, placement: "left" },
|
|
519
|
+
React.createElement(components_1.GlyphButton, { glyph: glyph, disabled: hasData, active: isIncluded, onClick: onButtonClick })));
|
|
520
|
+
}
|
|
521
|
+
Context_1.default("SCHEMA_FIELD_WRAPPERS").ScopeField = true;
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
export default class SectionArrayField extends React.Component<any, any, any> {
|
|
2
|
+
static propTypes: {
|
|
3
|
+
uiSchema: PropTypes.Requireable<PropTypes.InferProps<{
|
|
4
|
+
"ui:options": PropTypes.Requireable<PropTypes.InferProps<{}>>;
|
|
5
|
+
}>>;
|
|
6
|
+
schema: PropTypes.Validator<PropTypes.InferProps<{
|
|
7
|
+
type: PropTypes.Requireable<string>;
|
|
8
|
+
}>>;
|
|
9
|
+
formData: PropTypes.Requireable<any[]>;
|
|
10
|
+
};
|
|
11
|
+
static getName(): string;
|
|
12
|
+
constructor(props: any);
|
|
13
|
+
arrayKeyFunctions: {
|
|
14
|
+
insert: (e: any, props: any) => void;
|
|
15
|
+
navigateSection: (e: any, { getProps, left, right, up, goOverRow }: {
|
|
16
|
+
getProps: any;
|
|
17
|
+
left: any;
|
|
18
|
+
right: any;
|
|
19
|
+
up: any;
|
|
20
|
+
goOverRow: any;
|
|
21
|
+
}) => boolean | undefined;
|
|
22
|
+
navigateArray: (e: any, { reverse, getProps, navigateCallforward, getCurrentIdx, focusByIdx, getIdToScrollAfterNavigate }: {
|
|
23
|
+
reverse: any;
|
|
24
|
+
getProps: any;
|
|
25
|
+
navigateCallforward: any;
|
|
26
|
+
getCurrentIdx: any;
|
|
27
|
+
focusByIdx: any;
|
|
28
|
+
getIdToScrollAfterNavigate: any;
|
|
29
|
+
}) => boolean;
|
|
30
|
+
};
|
|
31
|
+
getStateFromProps(props: any): {
|
|
32
|
+
uiSchema: any;
|
|
33
|
+
formContext: any;
|
|
34
|
+
registry: any;
|
|
35
|
+
};
|
|
36
|
+
}
|
|
37
|
+
import * as React from "react";
|
|
38
|
+
import * as PropTypes from "prop-types";
|