ballerina-core 1.0.224 → 1.0.226
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/package.json
CHANGED
|
@@ -1877,10 +1877,37 @@ export const dispatchToAPIRawValue =
|
|
|
1877
1877
|
);
|
|
1878
1878
|
}
|
|
1879
1879
|
|
|
1880
|
+
const filteredRawValues = raw.fields.filter((value) => {
|
|
1881
|
+
if (!PredicateValue.Operations.IsRecord(value)) {
|
|
1882
|
+
console.warn(
|
|
1883
|
+
"Received a non-record value in a multi selection, ignoring: ",
|
|
1884
|
+
JSON.stringify(value),
|
|
1885
|
+
);
|
|
1886
|
+
return false;
|
|
1887
|
+
}
|
|
1888
|
+
|
|
1889
|
+
const fieldsObject = value.fields.toJS();
|
|
1890
|
+
|
|
1891
|
+
if (
|
|
1892
|
+
!CollectionReference.Operations.IsCollectionReference(
|
|
1893
|
+
fieldsObject,
|
|
1894
|
+
) &&
|
|
1895
|
+
!EnumReference.Operations.IsEnumReference(fieldsObject)
|
|
1896
|
+
) {
|
|
1897
|
+
console.warn(
|
|
1898
|
+
"Received a non-collection or enum reference value in a multi selection, ignoring: ",
|
|
1899
|
+
JSON.stringify(value),
|
|
1900
|
+
);
|
|
1901
|
+
return false;
|
|
1902
|
+
}
|
|
1903
|
+
return true;
|
|
1904
|
+
});
|
|
1905
|
+
|
|
1880
1906
|
const rawValue: Map<
|
|
1881
1907
|
string,
|
|
1882
1908
|
ValueOrErrors<CollectionReference | EnumReference, string>
|
|
1883
|
-
> =
|
|
1909
|
+
> = filteredRawValues.map((value) => {
|
|
1910
|
+
// should never happen due to the filter above but is a type check
|
|
1884
1911
|
if (!PredicateValue.Operations.IsRecord(value)) {
|
|
1885
1912
|
return ValueOrErrors.Default.throwOne(
|
|
1886
1913
|
`Record expected but got ${JSON.stringify(value)}`,
|
|
@@ -1900,6 +1927,7 @@ export const dispatchToAPIRawValue =
|
|
|
1900
1927
|
)}`,
|
|
1901
1928
|
);
|
|
1902
1929
|
}
|
|
1930
|
+
|
|
1903
1931
|
return ValueOrErrors.Default.return(fieldsObject);
|
|
1904
1932
|
});
|
|
1905
1933
|
|
|
@@ -95,7 +95,9 @@ export type ListAbstractRendererView<
|
|
|
95
95
|
ListAbstractRendererState,
|
|
96
96
|
ListAbstractRendererForeignMutationsExpected<Flags>
|
|
97
97
|
>;
|
|
98
|
-
embeddedPlaceholderElementTemplate: (
|
|
98
|
+
embeddedPlaceholderElementTemplate: (
|
|
99
|
+
elementIndex: number,
|
|
100
|
+
) => (
|
|
99
101
|
flags: Flags | undefined,
|
|
100
102
|
) => Template<
|
|
101
103
|
ListAbstractRendererReadonlyContext<
|
|
@@ -104,7 +106,7 @@ export type ListAbstractRendererView<
|
|
|
104
106
|
> &
|
|
105
107
|
ListAbstractRendererState,
|
|
106
108
|
ListAbstractRendererState,
|
|
107
|
-
|
|
109
|
+
ListAbstractRendererForeignMutationsExpected<Flags>
|
|
108
110
|
>;
|
|
109
111
|
}
|
|
110
112
|
>;
|
package/src/forms/domains/dispatched-forms/runner/domains/abstract-renderers/list/template.tsx
CHANGED
|
@@ -143,37 +143,105 @@ export const ListAbstractRenderer = <
|
|
|
143
143
|
},
|
|
144
144
|
}));
|
|
145
145
|
|
|
146
|
-
const embeddedPlaceholderElementTemplate =
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
(
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
146
|
+
const embeddedPlaceholderElementTemplate =
|
|
147
|
+
(elementIndex: number) => (flags: Flags | undefined) =>
|
|
148
|
+
elementTemplate
|
|
149
|
+
.mapContext(
|
|
150
|
+
(
|
|
151
|
+
_: ListAbstractRendererReadonlyContext<
|
|
152
|
+
CustomPresentationContext,
|
|
153
|
+
ExtraContext
|
|
154
|
+
> &
|
|
155
|
+
ListAbstractRendererState,
|
|
156
|
+
) => ({
|
|
157
|
+
disabled: _.disabled,
|
|
158
|
+
locked: _.locked,
|
|
159
|
+
value: PredicateValue.Operations.IsUnit(_.value)
|
|
160
|
+
? _.value
|
|
161
|
+
: _.value.values.get(elementIndex) || GetDefaultElementValue(),
|
|
162
|
+
...(_.elementFormStates?.get(elementIndex) ||
|
|
163
|
+
GetDefaultElementState()),
|
|
164
|
+
bindings: _.bindings,
|
|
165
|
+
extraContext: _.extraContext,
|
|
166
|
+
type: _.type.args[0],
|
|
167
|
+
customPresentationContext: _.customPresentationContext,
|
|
168
|
+
remoteEntityVersionIdentifier: _.remoteEntityVersionIdentifier,
|
|
169
|
+
domNodeAncestorPath:
|
|
170
|
+
_.domNodeAncestorPath + `[list][${elementIndex}]`,
|
|
171
|
+
typeAncestors: [_.type as DispatchParsedType<T>].concat(
|
|
172
|
+
_.typeAncestors,
|
|
173
|
+
),
|
|
174
|
+
lookupTypeAncestorNames: _.lookupTypeAncestorNames,
|
|
175
|
+
}),
|
|
176
|
+
)
|
|
177
|
+
.mapState((_) =>
|
|
178
|
+
ListAbstractRendererState.Updaters.Core.elementFormStates(id),
|
|
179
|
+
)
|
|
180
|
+
.mapForeignMutationsFromProps<
|
|
181
|
+
ListAbstractRendererForeignMutationsExpected<Flags>
|
|
182
|
+
>((props) => ({
|
|
183
|
+
onChange: (elementUpdater, nestedDelta) => {
|
|
184
|
+
const value =
|
|
185
|
+
props.context.value.kind == "tuple"
|
|
186
|
+
? props.context.value.values.get(elementIndex) ||
|
|
187
|
+
GetDefaultElementValue()
|
|
188
|
+
: GetDefaultElementValue();
|
|
189
|
+
const delta: DispatchDelta<Flags> = {
|
|
190
|
+
kind: "ArrayAdd",
|
|
191
|
+
value:
|
|
192
|
+
elementUpdater.kind == "r"
|
|
193
|
+
? elementUpdater.value(value)
|
|
194
|
+
: GetDefaultElementValue(),
|
|
195
|
+
state: {
|
|
196
|
+
commonFormState: props.context.commonFormState,
|
|
197
|
+
elementFormStates: props.context.elementFormStates,
|
|
198
|
+
},
|
|
199
|
+
type: props.context.type.args[0],
|
|
200
|
+
flags,
|
|
201
|
+
sourceAncestorLookupTypeNames:
|
|
202
|
+
nestedDelta.sourceAncestorLookupTypeNames,
|
|
203
|
+
};
|
|
204
|
+
props.foreignMutations.onChange(
|
|
205
|
+
elementUpdater.kind == "l"
|
|
206
|
+
? Option.Default.none()
|
|
207
|
+
: Option.Default.some(
|
|
208
|
+
Updater((list) =>
|
|
209
|
+
list.values.has(elementIndex)
|
|
210
|
+
? PredicateValue.Default.tuple(
|
|
211
|
+
list.values.update(
|
|
212
|
+
elementIndex,
|
|
213
|
+
PredicateValue.Default.unit(),
|
|
214
|
+
elementUpdater.value,
|
|
215
|
+
),
|
|
216
|
+
)
|
|
217
|
+
: list,
|
|
218
|
+
),
|
|
219
|
+
),
|
|
220
|
+
delta,
|
|
221
|
+
);
|
|
222
|
+
props.setState(
|
|
223
|
+
ListAbstractRendererState.Updaters.Core.commonFormState(
|
|
224
|
+
DispatchCommonFormState.Updaters.modifiedByUser(
|
|
225
|
+
replaceWith(true),
|
|
226
|
+
),
|
|
227
|
+
).then(
|
|
228
|
+
ListAbstractRendererState.Updaters.Core.elementFormStates(
|
|
229
|
+
MapRepo.Updaters.upsert(
|
|
230
|
+
elementIndex,
|
|
231
|
+
() => GetDefaultElementState(),
|
|
232
|
+
(_) => ({
|
|
233
|
+
..._,
|
|
234
|
+
commonFormState:
|
|
235
|
+
DispatchCommonFormState.Updaters.modifiedByUser(
|
|
236
|
+
replaceWith(true),
|
|
237
|
+
)(_.commonFormState),
|
|
238
|
+
}),
|
|
239
|
+
),
|
|
240
|
+
),
|
|
241
|
+
),
|
|
242
|
+
);
|
|
243
|
+
},
|
|
244
|
+
}));
|
|
177
245
|
|
|
178
246
|
return Template.Default<
|
|
179
247
|
ListAbstractRendererReadonlyContext<
|