@f1studio/form-spec 5.0.0-alpha.108 → 5.0.0-alpha.110
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/FormSpec.FS/FormSpec.d.ts +3 -1
- package/FormSpec.FS/FormSpec.d.ts.map +1 -1
- package/FormSpec.FS/Helpers.d.ts +7 -0
- package/FormSpec.FS/Helpers.d.ts.map +1 -1
- package/FormSpec.FS/Interop/FormSpec.Api.Helpers.d.ts +29 -3
- package/FormSpec.FS/Interop/FormSpec.Api.Helpers.d.ts.map +1 -1
- package/FormSpec.FS/PathwayExecutor.d.ts +0 -4
- package/FormSpec.FS/PathwayExecutor.d.ts.map +1 -1
- package/FormSpec.TS/FormSpec.FS/FormSpec.js +11 -1
- package/FormSpec.TS/FormSpec.FS/FormSpec.js.map +1 -1
- package/FormSpec.TS/FormSpec.FS/FormSpec.ts.map +1 -1
- package/FormSpec.TS/FormSpec.FS/Helpers.js +52 -24
- package/FormSpec.TS/FormSpec.FS/Helpers.js.map +1 -1
- package/FormSpec.TS/FormSpec.FS/Helpers.ts.map +1 -1
- package/FormSpec.TS/FormSpec.FS/Interop/FormSpec.Api.Helpers.js +161 -26
- package/FormSpec.TS/FormSpec.FS/Interop/FormSpec.Api.Helpers.js.map +1 -1
- package/FormSpec.TS/FormSpec.FS/Interop/FormSpec.Api.Helpers.ts.map +1 -1
- package/FormSpec.TS/FormSpec.FS/Interop/FormSpec.Api.Option.js +1 -1
- package/FormSpec.TS/FormSpec.FS/Interop/FormSpec.Api.Option.js.map +1 -1
- package/FormSpec.TS/FormSpec.FS/Interop/FormSpec.Api.Option.ts.map +1 -1
- package/FormSpec.TS/FormSpec.FS/PathwayExecutor.js +4 -32
- package/FormSpec.TS/FormSpec.FS/PathwayExecutor.js.map +1 -1
- package/FormSpec.TS/FormSpec.FS/PathwayExecutor.ts.map +1 -1
- package/FormSpec.TS/fable_modules/Thoth.Json.10.4.1/Encode.fs.js.map +1 -1
- package/FormSpec.TS/fable_modules/Thoth.Json.10.4.1/Encode.fs.ts.map +1 -1
- package/FormSpec.TS/plugins/bmi/src/BMIField.js +1 -1
- package/FormSpec.TS/plugins/bmi/src/BMIField.js.map +1 -1
- package/FormSpec.TS/plugins/bmi/src/BMIField.ts.map +1 -1
- package/FormSpec.TS/plugins/likert/src/LikertField.js +251 -84
- package/FormSpec.TS/plugins/likert/src/LikertField.js.map +1 -1
- package/FormSpec.TS/plugins/likert/src/LikertField.ts.map +1 -1
- package/FormSpec.TS/plugins/signature/src/SignatureField.js +1 -1
- package/FormSpec.TS/plugins/signature/src/SignatureField.js.map +1 -1
- package/FormSpec.TS/plugins/signature/src/SignatureField.ts.map +1 -1
- package/FormSpec.TS/plugins/vitals/src/VitalsField.js +1 -1
- package/FormSpec.TS/plugins/vitals/src/VitalsField.js.map +1 -1
- package/FormSpec.TS/plugins/vitals/src/VitalsField.ts.map +1 -1
- package/README.md +7 -7
- package/package.json +2 -2
- package/plugins/bmi/src/BMIField.d.ts.map +1 -1
- package/plugins/likert/src/LikertField.d.ts.map +1 -1
- package/plugins/signature/src/SignatureField.d.ts.map +1 -1
- package/plugins/vitals/src/VitalsField.d.ts.map +1 -1
- package/src/FormSpec.FS/FormSpec.ts +6 -2
- package/src/FormSpec.FS/Helpers.ts +55 -27
- package/src/FormSpec.FS/Interop/FormSpec.Api.Helpers.ts +172 -36
- package/src/FormSpec.FS/Interop/FormSpec.Api.Option.ts +1 -1
- package/src/FormSpec.FS/PathwayExecutor.ts +40 -69
- package/src/plugins/bmi/src/BMIField.ts +1 -1
- package/src/plugins/likert/src/LikertField.ts +211 -89
- package/src/plugins/signature/src/SignatureField.ts +1 -1
- package/src/plugins/vitals/src/VitalsField.ts +1 -1
|
@@ -1,25 +1,26 @@
|
|
|
1
1
|
import { value as value_11, map, unwrap, defaultArgWith as defaultArgWith_1, Option, defaultArg as defaultArg_1 } from "@fable-org/fable-library-js/Option.js";
|
|
2
|
-
import { tryPick, isEmpty, singleton, map as map_3, empty, ofArray as ofArray_1, ofSeq, fold, collect, tryFind, FSharpList } from "@fable-org/fable-library-js/List.js";
|
|
2
|
+
import { tryPick, filter, mapIndexed as mapIndexed_1, isEmpty, singleton, map as map_3, empty, ofArray as ofArray_1, ofSeq, fold, collect, tryFind, FSharpList } from "@fable-org/fable-library-js/List.js";
|
|
3
3
|
import { join, printf, toConsole } from "@fable-org/fable-library-js/String.js";
|
|
4
4
|
import { Auto_generateBoxedEncoder_437914C6, toString } from "../../fable_modules/Thoth.Json.10.4.1/Encode.fs.js";
|
|
5
5
|
import { array_type, string_type, union_type, TypeInfo, obj_type } from "@fable-org/fable-library-js/Reflection.js";
|
|
6
6
|
import { Auto_generateBoxedDecoder_Z6670B51, fromString } from "../../fable_modules/Thoth.Json.10.4.1/Decode.fs.js";
|
|
7
|
-
import { equals, createObj, compare, IDisposable, disposeSafe, IEnumerator, getEnumerator, IMap, isArrayLike, uncurry2 } from "@fable-org/fable-library-js/Util.js";
|
|
8
|
-
import { ClinicalPathway_StateType_$union, ClinicalPathway_TaskPriority_$union, ClinicalPathway_AlertSeverity_$union, ClinicalPathway_ReferralUrgency_$union, ClinicalPathway_ActionInfo_$union, ClinicalPathway_NavigateToFormAction, ClinicalPathway_ProblemAction, ClinicalPathway_AlertAction, ClinicalPathway_EducationAction, ClinicalPathway_ProcedureAction, ClinicalPathway_TestAction, ClinicalPathway_DocumentationAction, ClinicalPathway_FieldValueSource_$union, ClinicalPathway_SetFieldValueAction, ClinicalPathway_PrescriptionAction, ClinicalPathway_MedicationAction, ClinicalPathway_ReferralAction, Shared_FieldValue_$union, ClinicalPathway_ClinicalPathwaySpec, ClinicalPathway_PathRequirement, ClinicalPathway_ConstraintDefinition, ClinicalPathway_PathwayExecutionMode_SinglePathway, ClinicalPathway_SinglePathwayConfig, ClinicalPathway_SelectionStrategy_HighestPriority, ClinicalPathway_TransitionDefinition, ClinicalPathway_TransitionCondition_FieldCondition, Shared_ConditionValue_Single, ClinicalPathway_FieldEvaluator_Equals, Shared_TransitionKey, ClinicalPathway_StateType_Terminal, ClinicalPathway_TerminalInfo, ClinicalPathway_StateDefinition, ClinicalPathway_StateType_Action, ClinicalPathway_ActionInfo_Task, ClinicalPathway_TaskAction, ClinicalPathway_DueDate_Today, ClinicalPathway_TaskPriority_Medium, ClinicalPathway_TaskPriority_Low, ClinicalPathway_TaskPriority_High, Shared_StateKey, Spec_FieldType_PluginField, Spec_PluginFieldConfig, Spec_FieldType_Matrix, Spec_MatrixInfo, Spec_FormLifecycle_Blueprint, Spec_FieldType_Text, Spec_TextInfo, Spec_FieldType_CheckboxList, Spec_MultiChoiceInfo, Shared_FieldOptionKey, Spec_FieldType_Checkbox, Spec_BooleanInfo, Shared_FieldKey, Shared_FieldOption, Shared_FieldValue_Single, Shared_FieldValue_PluginData, Shared_PluginDataProperty, Shared_PluginPropertyKey, Shared_FieldValue_Matrix, Shared_MatrixAnswer, Shared_MatrixItemKey, Shared_FieldValue_Multiple, Shared_FieldAnswer, Spec_FormStep$1, Spec_FormField$1, Spec_FieldType_$union, Spec_FormSpec$1, Spec_FormSpec$1_$reflection, Spec_FieldType_$reflection } from "../FormSpec.js";
|
|
7
|
+
import { equals, createObj, stringHash, compare, IDisposable, disposeSafe, IEnumerator, getEnumerator, IMap, isArrayLike, uncurry2 } from "@fable-org/fable-library-js/Util.js";
|
|
8
|
+
import { ClinicalPathway_StateType_$union, ClinicalPathway_TaskPriority_$union, ClinicalPathway_AlertSeverity_$union, ClinicalPathway_ReferralUrgency_$union, ClinicalPathway_ActionInfo_$union, ClinicalPathway_NavigateToFormAction, ClinicalPathway_ProblemAction, ClinicalPathway_AlertAction, ClinicalPathway_EducationAction, ClinicalPathway_ProcedureAction, ClinicalPathway_TestAction, ClinicalPathway_DocumentationAction, ClinicalPathway_FieldValueSource_$union, ClinicalPathway_SetFieldValueAction, ClinicalPathway_PrescriptionAction, ClinicalPathway_MedicationAction, ClinicalPathway_ReferralAction, Shared_FieldValue, Shared_FieldValue_$union, ClinicalPathway_ClinicalPathwaySpec, ClinicalPathway_PathRequirement, ClinicalPathway_ConstraintDefinition, ClinicalPathway_PathwayExecutionMode_SinglePathway, ClinicalPathway_SinglePathwayConfig, ClinicalPathway_SelectionStrategy_HighestPriority, ClinicalPathway_TransitionDefinition, ClinicalPathway_TransitionCondition_FieldCondition, Shared_ConditionValue_Single, ClinicalPathway_FieldEvaluator_Equals, Shared_TransitionKey, ClinicalPathway_StateType_Terminal, ClinicalPathway_TerminalInfo, ClinicalPathway_StateDefinition, ClinicalPathway_StateType_Action, ClinicalPathway_ActionInfo_Task, ClinicalPathway_TaskAction, ClinicalPathway_DueDate_Today, ClinicalPathway_TaskPriority_Medium, ClinicalPathway_TaskPriority_Low, ClinicalPathway_TaskPriority_High, Shared_StateKey, Spec_FieldType_PluginField, Spec_PluginFieldConfig, Spec_FieldType_Matrix, Spec_MatrixInfo, Spec_FormLifecycle_Blueprint, Spec_FieldType_Text, Spec_TextInfo, Spec_FieldType_CheckboxList, Spec_MultiChoiceInfo, Shared_FieldOptionKey, Spec_FieldType_Checkbox, Spec_BooleanInfo, Shared_FieldKey, Shared_FieldOption, Shared_FieldValue_Single, Shared_FieldValue_PluginData, Shared_PluginDataProperty, Shared_PluginPropertyKey, Shared_FieldValue_Matrix, Shared_MatrixAnswer, Shared_MatrixItemKey, Shared_FieldValue_Multiple, Shared_FieldAnswer, Spec_FormStep$1, Spec_FormField$1, Spec_FieldType_$union, Spec_FormSpec$1, Spec_FormSpec$1_$reflection, Spec_FieldType_$reflection } from "../FormSpec.js";
|
|
9
9
|
import { FSharpResult$2_Ok, FSharpResult$2_Error, FSharpResult$2_$union } from "@fable-org/fable-library-js/Result.js";
|
|
10
10
|
import { Union } from "@fable-org/fable-library-js/Types.js";
|
|
11
11
|
import { IOptionalGetter, array as array_4, IGetters, dict as dict_1, string, IRequiredGetter, object, fromString as fromString_1 } from "../../fable_modules/Thoth.Json.10.4.1/Decode.fs.js";
|
|
12
12
|
import { ErrorReason_$union } from "../../fable_modules/Thoth.Json.10.4.1/Types.fs.js";
|
|
13
|
-
import { ofSeq as ofSeq_1, FSharpMap } from "@fable-org/fable-library-js/Map.js";
|
|
13
|
+
import { ofSeq as ofSeq_1, toList, FSharpMap } from "@fable-org/fable-library-js/Map.js";
|
|
14
14
|
import { addToDict } from "@fable-org/fable-library-js/MapUtil.js";
|
|
15
15
|
import { getFieldDetails as getFieldDetails_1, FieldDetails$1, findStepIndexForField, updateField } from "../FormSpecValues.js";
|
|
16
16
|
import { int32 } from "@fable-org/fable-library-js/Int32.js";
|
|
17
|
-
import { singleton as singleton_1, empty as empty_1, collect as collect_1, delay, toList, mapIndexed, map as map_2, choose } from "@fable-org/fable-library-js/Seq.js";
|
|
17
|
+
import { singleton as singleton_1, empty as empty_1, collect as collect_1, delay, toList as toList_1, mapIndexed, map as map_2, choose } from "@fable-org/fable-library-js/Seq.js";
|
|
18
18
|
import { toArray, ofArray } from "@fable-org/fable-library-js/Set.js";
|
|
19
19
|
import { map as map_1 } from "@fable-org/fable-library-js/Array.js";
|
|
20
20
|
import { newGuid, parse } from "@fable-org/fable-library-js/Guid.js";
|
|
21
21
|
import { now } from "@fable-org/fable-library-js/DateOffset.js";
|
|
22
22
|
import { initializeExecution } from "../PathwayExecutor.js";
|
|
23
|
+
import { List_distinct, distinct } from "@fable-org/fable-library-js/Seq2.js";
|
|
23
24
|
|
|
24
25
|
/**
|
|
25
26
|
* Get value from Option or return default (SAFE - recommended)
|
|
@@ -229,7 +230,7 @@ export function decodeAsMatrixValue(fieldKey: string, obj: any): { description:
|
|
|
229
230
|
let str: string;
|
|
230
231
|
const objAsString: string = (typeof obj === "string") ? ((str = (obj as string), str)) : toString(0, Auto_generateBoxedEncoder_437914C6(obj_type, undefined, undefined, undefined)(obj));
|
|
231
232
|
try {
|
|
232
|
-
const matchValue_1: FSharpResult$2_$union<{ description: string, values: IMap<string, string> }, string> = fromString_1<{ description: string, values: IMap<string, string> }>((path_2: string,
|
|
233
|
+
const matchValue_1: FSharpResult$2_$union<{ description: string, values: IMap<string, string> }, string> = fromString_1<{ description: string, values: IMap<string, string> }>((path_2: string, v_1: any): FSharpResult$2_$union<{ description: string, values: IMap<string, string> }, [string, ErrorReason_$union]> => object<{ description: string, values: IMap<string, string> }>((get$: IGetters): { description: string, values: IMap<string, string> } => {
|
|
233
234
|
let description: string;
|
|
234
235
|
const objectArg: IRequiredGetter = get$.Required;
|
|
235
236
|
description = objectArg.Field<string>("description", string);
|
|
@@ -238,11 +239,11 @@ export function decodeAsMatrixValue(fieldKey: string, obj: any): { description:
|
|
|
238
239
|
const objectArg_1: IRequiredGetter = get$.Required;
|
|
239
240
|
valuesMap = objectArg_1.Field<FSharpMap<string, string>>("values", uncurry2(arg_3));
|
|
240
241
|
const valuesDict: IMap<string, string> = new Map<string, string>([]);
|
|
241
|
-
const enumerator: IEnumerator<[string, string]> = getEnumerator(valuesMap);
|
|
242
|
+
const enumerator: IEnumerator<[string, string]> = getEnumerator(toList<string, string>(valuesMap));
|
|
242
243
|
try {
|
|
243
244
|
while (enumerator["System.Collections.IEnumerator.MoveNext"]()) {
|
|
244
|
-
const
|
|
245
|
-
addToDict(valuesDict,
|
|
245
|
+
const forLoopVar: [string, string] = enumerator["System.Collections.Generic.IEnumerator`1.get_Current"]();
|
|
246
|
+
addToDict(valuesDict, forLoopVar[0], forLoopVar[1]);
|
|
246
247
|
}
|
|
247
248
|
}
|
|
248
249
|
finally {
|
|
@@ -252,7 +253,7 @@ export function decodeAsMatrixValue(fieldKey: string, obj: any): { description:
|
|
|
252
253
|
description: description,
|
|
253
254
|
values: valuesDict,
|
|
254
255
|
};
|
|
255
|
-
}, path_2,
|
|
256
|
+
}, path_2, v_1), objAsString);
|
|
256
257
|
if (matchValue_1.tag === /* Error */ 1) {
|
|
257
258
|
let matchValue_2: FSharpResult$2_$union<{ description: string, values: IMap<string, string> }, string>;
|
|
258
259
|
const matchValue: FSharpResult$2_$union<FSharpMap<string, string>, string> = fromString_1<FSharpMap<string, string>>(uncurry2(dict_1<string>(string)), objAsString);
|
|
@@ -262,11 +263,11 @@ export function decodeAsMatrixValue(fieldKey: string, obj: any): { description:
|
|
|
262
263
|
else {
|
|
263
264
|
const valuesMap_1: FSharpMap<string, string> = matchValue.fields[0];
|
|
264
265
|
const valuesDict_1: IMap<string, string> = new Map<string, string>([]);
|
|
265
|
-
const enumerator_1: IEnumerator<[string, string]> = getEnumerator(valuesMap_1);
|
|
266
|
+
const enumerator_1: IEnumerator<[string, string]> = getEnumerator(toList<string, string>(valuesMap_1));
|
|
266
267
|
try {
|
|
267
268
|
while (enumerator_1["System.Collections.IEnumerator.MoveNext"]()) {
|
|
268
|
-
const
|
|
269
|
-
addToDict(valuesDict_1,
|
|
269
|
+
const forLoopVar_1: [string, string] = enumerator_1["System.Collections.Generic.IEnumerator`1.get_Current"]();
|
|
270
|
+
addToDict(valuesDict_1, forLoopVar_1[0], forLoopVar_1[1]);
|
|
270
271
|
}
|
|
271
272
|
}
|
|
272
273
|
finally {
|
|
@@ -440,7 +441,7 @@ export function createMatrixField(fieldKeyString: string, label: string, items:
|
|
|
440
441
|
* TypeScript: createPluginField(fieldKey: string, label: string, config: {pluginId: string})
|
|
441
442
|
*/
|
|
442
443
|
export function createPluginField(fieldKeyString: string, label: string, config: { pluginId: string }): Spec_FormField$1<Spec_FieldType_$union> {
|
|
443
|
-
return new Spec_FormField$1(1, new Shared_FieldKey(parse(fieldKeyString)), label, undefined, undefined, false, false, Spec_FieldType_PluginField(new Spec_PluginFieldConfig(config.pluginId)), undefined);
|
|
444
|
+
return new Spec_FormField$1(1, new Shared_FieldKey(parse(fieldKeyString)), label, undefined, undefined, false, false, Spec_FieldType_PluginField(new Spec_PluginFieldConfig(config.pluginId, undefined, undefined)), undefined);
|
|
444
445
|
}
|
|
445
446
|
|
|
446
447
|
/**
|
|
@@ -550,7 +551,7 @@ export function getFieldDetails(formSpec: Spec_FormSpec$1<Spec_FieldType_$union>
|
|
|
550
551
|
export function createTestFormSpec(): Spec_FormSpec$1<Spec_FieldType_$union> {
|
|
551
552
|
const option1: Shared_FieldOption = new Shared_FieldOption("Option 1", "opt1", new Shared_FieldOptionKey(newGuid()), undefined);
|
|
552
553
|
const option2: Shared_FieldOption = new Shared_FieldOption("Option 2", "opt2", new Shared_FieldOptionKey(newGuid()), undefined);
|
|
553
|
-
const testStep: Spec_FormStep$1<Spec_FieldType_$union> = new Spec_FormStep$1(1, "Test Step", ofArray_1([new Spec_FormField$1(1, new Shared_FieldKey("11111111-1111-1111-1111-111111111111"), "Test Text Field", undefined, undefined, false, false, Spec_FieldType_Text(new Spec_TextInfo(undefined)), undefined), new Spec_FormField$1(2, new Shared_FieldKey("22222222-2222-2222-2222-222222222222"), "Test Checkbox List", undefined, undefined, false, false, Spec_FieldType_CheckboxList(new Spec_MultiChoiceInfo(ofArray_1([option1, option2]))), undefined), new Spec_FormField$1(3, new Shared_FieldKey("33333333-3333-3333-3333-333333333333"), "Test Matrix", undefined, undefined, false, false, Spec_FieldType_Matrix(new Spec_MatrixInfo(ofArray_1([option1, option2]), ofArray_1([new Shared_FieldOption("Scale 1", "1", new Shared_FieldOptionKey(newGuid()), 1), new Shared_FieldOption("Scale 2", "2", new Shared_FieldOptionKey(newGuid()), 2)]))), undefined), new Spec_FormField$1(4, new Shared_FieldKey("44444444-4444-4444-4444-444444444444"), "Test Plugin Field", undefined, undefined, false, false, Spec_FieldType_PluginField(new Spec_PluginFieldConfig("test.plugin")), undefined)]));
|
|
554
|
+
const testStep: Spec_FormStep$1<Spec_FieldType_$union> = new Spec_FormStep$1(1, "Test Step", ofArray_1([new Spec_FormField$1(1, new Shared_FieldKey("11111111-1111-1111-1111-111111111111"), "Test Text Field", undefined, undefined, false, false, Spec_FieldType_Text(new Spec_TextInfo(undefined)), undefined), new Spec_FormField$1(2, new Shared_FieldKey("22222222-2222-2222-2222-222222222222"), "Test Checkbox List", undefined, undefined, false, false, Spec_FieldType_CheckboxList(new Spec_MultiChoiceInfo(ofArray_1([option1, option2]))), undefined), new Spec_FormField$1(3, new Shared_FieldKey("33333333-3333-3333-3333-333333333333"), "Test Matrix", undefined, undefined, false, false, Spec_FieldType_Matrix(new Spec_MatrixInfo(ofArray_1([option1, option2]), ofArray_1([new Shared_FieldOption("Scale 1", "1", new Shared_FieldOptionKey(newGuid()), 1), new Shared_FieldOption("Scale 2", "2", new Shared_FieldOptionKey(newGuid()), 2)]))), undefined), new Spec_FormField$1(4, new Shared_FieldKey("44444444-4444-4444-4444-444444444444"), "Test Plugin Field", undefined, undefined, false, false, Spec_FieldType_PluginField(new Spec_PluginFieldConfig("test.plugin", undefined, undefined)), undefined)]));
|
|
554
555
|
return new Spec_FormSpec$1(newGuid(), "TEST-001", "Test Form", "Test form for buildDynamicFormResultData", "1.0.0", "5.0.0", singleton(testStep), empty<string>(), undefined, empty<string>(), false, false, undefined, Spec_FormLifecycle_Blueprint(), undefined);
|
|
555
556
|
}
|
|
556
557
|
|
|
@@ -584,15 +585,31 @@ export function getFieldTypeInfo(field: Spec_FormField$1<Spec_FieldType_$union>)
|
|
|
584
585
|
}
|
|
585
586
|
|
|
586
587
|
/**
|
|
587
|
-
* Extract plugin field config (PluginId) for PluginField types.
|
|
588
|
-
* TypeScript: getPluginFieldConfig(field: FormField) => {pluginId: string} | null
|
|
588
|
+
* Extract plugin field config (PluginId, optional items/options) for PluginField types.
|
|
589
|
+
* TypeScript: getPluginFieldConfig(field: FormField) => {pluginId: string, items?: ..., options?: ...} | null
|
|
589
590
|
* Returns null for non-PluginField fields.
|
|
590
591
|
*/
|
|
591
|
-
export function getPluginFieldConfig(field: Spec_FormField$1<Spec_FieldType_$union>): Option<{ pluginId: string }> {
|
|
592
|
+
export function getPluginFieldConfig(field: Spec_FormField$1<Spec_FieldType_$union>): Option<{ items?: { key: string, label: string }[], options?: { description: string, key: string, value: string }[], pluginId: string }> {
|
|
592
593
|
const matchValue: Spec_FieldType_$union = field.FieldType;
|
|
593
594
|
if (matchValue.tag === /* PluginField */ 22) {
|
|
595
|
+
const config: Spec_PluginFieldConfig = matchValue.fields[0];
|
|
594
596
|
return {
|
|
595
|
-
|
|
597
|
+
items: unwrap(map<FSharpList<Shared_FieldOption>, { key: string, label: string }[]>((items: FSharpList<Shared_FieldOption>): { key: string, label: string }[] => {
|
|
598
|
+
const collection: FSharpList<{ key: string, label: string }> = map_3<Shared_FieldOption, { key: string, label: string }>((item: Shared_FieldOption): { key: string, label: string } => ({
|
|
599
|
+
key: item.OptionKey.fields[0],
|
|
600
|
+
label: item.Description,
|
|
601
|
+
}), items);
|
|
602
|
+
return Array.from(collection);
|
|
603
|
+
}, config.Items)),
|
|
604
|
+
options: unwrap(map<FSharpList<Shared_FieldOption>, { description: string, key: string, value: string }[]>((opts: FSharpList<Shared_FieldOption>): { description: string, key: string, value: string }[] => {
|
|
605
|
+
const collection_1: FSharpList<{ description: string, key: string, value: string }> = map_3<Shared_FieldOption, { description: string, key: string, value: string }>((opt: Shared_FieldOption): { description: string, key: string, value: string } => ({
|
|
606
|
+
description: opt.Description,
|
|
607
|
+
key: opt.OptionKey.fields[0],
|
|
608
|
+
value: opt.Value,
|
|
609
|
+
}), opts);
|
|
610
|
+
return Array.from(collection_1);
|
|
611
|
+
}, config.Options)),
|
|
612
|
+
pluginId: config.PluginId,
|
|
596
613
|
};
|
|
597
614
|
}
|
|
598
615
|
else {
|
|
@@ -656,28 +673,147 @@ export function getFieldChoiceOptions(field: Spec_FormField$1<Spec_FieldType_$un
|
|
|
656
673
|
}
|
|
657
674
|
|
|
658
675
|
/**
|
|
659
|
-
* Extract matrix field structure (items and options)
|
|
676
|
+
* Extract matrix field structure (items and options).
|
|
677
|
+
* Handles both Matrix fields and PluginField (e.g. Likert) when config has Items and Options.
|
|
660
678
|
* TypeScript: getFieldMatrixInfo(field: FormField) => {items: {key: string, label: string}[], options: {key: string, description: string, value: string}[]} | null
|
|
661
679
|
*/
|
|
662
680
|
export function getFieldMatrixInfo(field: Spec_FormField$1<Spec_FieldType_$union>): Option<{ items: { key: string, label: string }[], options: { description: string, key: string, value: string }[] }> {
|
|
663
|
-
let collection: FSharpList<{ key: string, label: string }>, collection_1: FSharpList<{ description: string, key: string, value: string }
|
|
681
|
+
let collection: FSharpList<{ key: string, label: string }>, collection_1: FSharpList<{ description: string, key: string, value: string }>, collection_2: FSharpList<{ key: string, label: string }>, collection_3: FSharpList<{ description: string, key: string, value: string }>, config: Spec_PluginFieldConfig;
|
|
664
682
|
const matchValue: Spec_FieldType_$union = field.FieldType;
|
|
665
|
-
|
|
666
|
-
|
|
667
|
-
|
|
668
|
-
|
|
669
|
-
|
|
670
|
-
|
|
671
|
-
|
|
672
|
-
|
|
673
|
-
|
|
674
|
-
|
|
675
|
-
|
|
676
|
-
}
|
|
677
|
-
|
|
683
|
+
let matchResult: int32, matrixInfo: Spec_MatrixInfo, config_1: Spec_PluginFieldConfig;
|
|
684
|
+
switch (matchValue.tag) {
|
|
685
|
+
case /* Matrix */ 19: {
|
|
686
|
+
matchResult = 0;
|
|
687
|
+
matrixInfo = matchValue.fields[0];
|
|
688
|
+
break;
|
|
689
|
+
}
|
|
690
|
+
case /* PluginField */ 22: {
|
|
691
|
+
if ((config = matchValue.fields[0], (config.Items != null) && (config.Options != null))) {
|
|
692
|
+
matchResult = 1;
|
|
693
|
+
config_1 = matchValue.fields[0];
|
|
694
|
+
}
|
|
695
|
+
else {
|
|
696
|
+
matchResult = 2;
|
|
697
|
+
}
|
|
698
|
+
break;
|
|
699
|
+
}
|
|
700
|
+
default:
|
|
701
|
+
matchResult = 2;
|
|
702
|
+
}
|
|
703
|
+
switch (matchResult) {
|
|
704
|
+
case 0:
|
|
705
|
+
return {
|
|
706
|
+
items: (collection = map_3<Shared_FieldOption, { key: string, label: string }>((item: Shared_FieldOption): { key: string, label: string } => ({
|
|
707
|
+
key: item.OptionKey.fields[0],
|
|
708
|
+
label: item.Description,
|
|
709
|
+
}), matrixInfo!.Items), Array.from(collection)),
|
|
710
|
+
options: (collection_1 = map_3<Shared_FieldOption, { description: string, key: string, value: string }>((opt: Shared_FieldOption): { description: string, key: string, value: string } => ({
|
|
711
|
+
description: opt.Description,
|
|
712
|
+
key: opt.OptionKey.fields[0],
|
|
713
|
+
value: opt.Value,
|
|
714
|
+
}), matrixInfo!.Options), Array.from(collection_1)),
|
|
715
|
+
};
|
|
716
|
+
case 1:
|
|
717
|
+
return {
|
|
718
|
+
items: (collection_2 = map_3<Shared_FieldOption, { key: string, label: string }>((item_1: Shared_FieldOption): { key: string, label: string } => ({
|
|
719
|
+
key: item_1.OptionKey.fields[0],
|
|
720
|
+
label: item_1.Description,
|
|
721
|
+
}), value_11(config_1!.Items)), Array.from(collection_2)),
|
|
722
|
+
options: (collection_3 = map_3<Shared_FieldOption, { description: string, key: string, value: string }>((opt_1: Shared_FieldOption): { description: string, key: string, value: string } => ({
|
|
723
|
+
description: opt_1.Description,
|
|
724
|
+
key: opt_1.OptionKey.fields[0],
|
|
725
|
+
value: opt_1.Value,
|
|
726
|
+
}), value_11(config_1!.Options)), Array.from(collection_3)),
|
|
727
|
+
};
|
|
728
|
+
default:
|
|
729
|
+
return undefined;
|
|
730
|
+
}
|
|
731
|
+
}
|
|
732
|
+
|
|
733
|
+
/**
|
|
734
|
+
* Extract matrix info from field.Value when it's Matrix or PluginData (FilledForm).
|
|
735
|
+
* Use when getFieldMatrixInfo returns null - e.g. when FieldType doesn't match but Value has Matrix/PluginData.
|
|
736
|
+
* TypeScript: getFieldMatrixInfoFromValue(field: FormField) => {items, options} | null
|
|
737
|
+
*/
|
|
738
|
+
export function getFieldMatrixInfoFromValue(field: Spec_FormField$1<Spec_FieldType_$union>): Option<{ items: { key: string, label: string }[], options: { description: string, key: string, value: string }[] }> {
|
|
739
|
+
let collection: FSharpList<{ key: string, label: string }>, collection_1: FSharpList<{ description: string, key: string, value: string }>, collection_2: FSharpList<{ key: string, label: string }>, collection_3: FSharpList<{ description: string, key: string, value: string }>;
|
|
740
|
+
const matchValue: Option<Shared_FieldValue_$union> = field.Value;
|
|
741
|
+
let matchResult: int32, ma: Shared_MatrixAnswer, props: FSharpList<Shared_PluginDataProperty>;
|
|
742
|
+
if (matchValue != null) {
|
|
743
|
+
switch (value_11(matchValue).tag) {
|
|
744
|
+
case /* Matrix */ 2: {
|
|
745
|
+
matchResult = 0;
|
|
746
|
+
ma = (value_11(matchValue) as Shared_FieldValue<2>).fields[0];
|
|
747
|
+
break;
|
|
748
|
+
}
|
|
749
|
+
case /* PluginData */ 3: {
|
|
750
|
+
matchResult = 1;
|
|
751
|
+
props = (value_11(matchValue) as Shared_FieldValue<3>).fields[0];
|
|
752
|
+
break;
|
|
753
|
+
}
|
|
754
|
+
default:
|
|
755
|
+
matchResult = 2;
|
|
756
|
+
}
|
|
678
757
|
}
|
|
679
758
|
else {
|
|
680
|
-
|
|
759
|
+
matchResult = 2;
|
|
760
|
+
}
|
|
761
|
+
switch (matchResult) {
|
|
762
|
+
case 0: {
|
|
763
|
+
const itemKeys: FSharpList<string> = toList_1<string>(distinct<string>(map_2<[Shared_MatrixItemKey, string], string>((kvp: [Shared_MatrixItemKey, string]): string => kvp[0].fields[0], ma!.Values), {
|
|
764
|
+
Equals: (x: string, y: string): boolean => (x === y),
|
|
765
|
+
GetHashCode: stringHash,
|
|
766
|
+
}));
|
|
767
|
+
const optionValues: FSharpList<string> = toList_1<string>(distinct<string>(map_2<[Shared_MatrixItemKey, string], string>((kvp_1: [Shared_MatrixItemKey, string]): string => kvp_1[1], ma!.Values), {
|
|
768
|
+
Equals: (x_1: string, y_1: string): boolean => (x_1 === y_1),
|
|
769
|
+
GetHashCode: stringHash,
|
|
770
|
+
}));
|
|
771
|
+
if (isEmpty(itemKeys) ? true : isEmpty(optionValues)) {
|
|
772
|
+
return undefined;
|
|
773
|
+
}
|
|
774
|
+
else {
|
|
775
|
+
return {
|
|
776
|
+
items: (collection = mapIndexed_1<string, { key: string, label: string }>((i: int32, k: string): { key: string, label: string } => ({
|
|
777
|
+
key: k,
|
|
778
|
+
label: k,
|
|
779
|
+
}), itemKeys), Array.from(collection)),
|
|
780
|
+
options: (collection_1 = mapIndexed_1<string, { description: string, key: string, value: string }>((i_1: int32, v: string): { description: string, key: string, value: string } => ({
|
|
781
|
+
description: v,
|
|
782
|
+
key: v,
|
|
783
|
+
value: v,
|
|
784
|
+
}), optionValues), Array.from(collection_1)),
|
|
785
|
+
};
|
|
786
|
+
}
|
|
787
|
+
}
|
|
788
|
+
case 1: {
|
|
789
|
+
const likertProps: FSharpList<Shared_PluginDataProperty> = filter<Shared_PluginDataProperty>((p: Shared_PluginDataProperty): boolean => (p.Name !== "TotalScore"), props!);
|
|
790
|
+
const itemKeys_1: FSharpList<string> = List_distinct<string>(map_3<Shared_PluginDataProperty, string>((p_1: Shared_PluginDataProperty): string => p_1.Name, likertProps), {
|
|
791
|
+
Equals: (x_2: string, y_2: string): boolean => (x_2 === y_2),
|
|
792
|
+
GetHashCode: stringHash,
|
|
793
|
+
});
|
|
794
|
+
const optionValues_1: FSharpList<string> = List_distinct<string>(map_3<Shared_PluginDataProperty, string>((p_2: Shared_PluginDataProperty): string => p_2.Value, likertProps), {
|
|
795
|
+
Equals: (x_3: string, y_3: string): boolean => (x_3 === y_3),
|
|
796
|
+
GetHashCode: stringHash,
|
|
797
|
+
});
|
|
798
|
+
if (isEmpty(itemKeys_1) ? true : isEmpty(optionValues_1)) {
|
|
799
|
+
return undefined;
|
|
800
|
+
}
|
|
801
|
+
else {
|
|
802
|
+
return {
|
|
803
|
+
items: (collection_2 = mapIndexed_1<string, { key: string, label: string }>((i_2: int32, k_1: string): { key: string, label: string } => ({
|
|
804
|
+
key: k_1,
|
|
805
|
+
label: k_1,
|
|
806
|
+
}), itemKeys_1), Array.from(collection_2)),
|
|
807
|
+
options: (collection_3 = mapIndexed_1<string, { description: string, key: string, value: string }>((i_3: int32, v_1: string): { description: string, key: string, value: string } => ({
|
|
808
|
+
description: v_1,
|
|
809
|
+
key: v_1,
|
|
810
|
+
value: v_1,
|
|
811
|
+
}), optionValues_1), Array.from(collection_3)),
|
|
812
|
+
};
|
|
813
|
+
}
|
|
814
|
+
}
|
|
815
|
+
default:
|
|
816
|
+
return undefined;
|
|
681
817
|
}
|
|
682
818
|
}
|
|
683
819
|
|
|
@@ -695,7 +831,7 @@ export function getFieldKeyString(fieldKey: Shared_FieldKey): string {
|
|
|
695
831
|
* TypeScript: extractFormValuesFromFormSpec(formSpec: FormSpec) => Record<string, any>
|
|
696
832
|
*/
|
|
697
833
|
export function extractFormValuesFromFormSpec(spec: Spec_FormSpec$1<Spec_FieldType_$union>): any {
|
|
698
|
-
const pairs: FSharpList<[string, any]> =
|
|
834
|
+
const pairs: FSharpList<[string, any]> = toList_1<[string, any]>(delay<[string, any]>((): Iterable<[string, any]> => collect_1<Spec_FormStep$1<Spec_FieldType_$union>, Iterable<[string, any]>, [string, any]>((step: Spec_FormStep$1<Spec_FieldType_$union>): Iterable<[string, any]> => collect_1<Spec_FormField$1<Spec_FieldType_$union>, Iterable<[string, any]>, [string, any]>((field: Spec_FormField$1<Spec_FieldType_$union>): Iterable<[string, any]> => {
|
|
699
835
|
let arr: string[], ma: Shared_MatrixAnswer, dict: IMap<string, string>, enumerator: IEnumerator<[Shared_MatrixItemKey, string]>, arr_1: FSharpList<any>;
|
|
700
836
|
const matchValue: Option<Shared_FieldValue_$union> = field.Value;
|
|
701
837
|
if (matchValue == null) {
|
|
@@ -1168,7 +1168,7 @@ export function Converters_fieldTypeFromTS(fieldType: Types_FieldTypeTS): Option
|
|
|
1168
1168
|
return undefined;
|
|
1169
1169
|
}
|
|
1170
1170
|
else {
|
|
1171
|
-
return Spec_FieldType_PluginField(new Spec_PluginFieldConfig(value_2(matchValue_34).PluginId));
|
|
1171
|
+
return Spec_FieldType_PluginField(new Spec_PluginFieldConfig(value_2(matchValue_34).PluginId, undefined, undefined));
|
|
1172
1172
|
}
|
|
1173
1173
|
}
|
|
1174
1174
|
default:
|