@@ -3,6 +3,27 @@ module.exports = function (cardscript) {
3
3
$simpleTitleMaps : { }
4
4
}
5
5
6
+ function buildLabelList ( id , choices ) {
7
+ const map = { }
8
+ lists [ id ] = choices . map ( ( { title, value } ) => {
9
+ map [ value ] = title || value
10
+ return {
11
+ text : title || value ,
12
+ label : title || value ,
13
+ value
14
+ }
15
+ } )
16
+ lists . $simpleTitleMaps [ id ] = map
17
+ }
18
+
19
+ function buildTitleMap ( id , choices ) {
20
+ const map = { }
21
+ choices . forEach ( ( { title, value } ) => {
22
+ map [ value ] = title || value
23
+ } )
24
+ lists . $simpleTitleMaps [ id ] = map
25
+ }
26
+
6
27
function parseElement ( element ) {
7
28
switch ( element . type ) {
8
29
case 'Container' :
@@ -11,10 +32,7 @@ module.exports = function (cardscript) {
11
32
case 'ColumnSet' :
12
33
element . columns . forEach ( parseElement )
13
34
break
14
- case 'FactSet' :
15
- element . facts . forEach ( parseElement )
16
- break
17
- case 'CardList' :
35
+ case 'CardList' :
18
36
element . card . body . forEach ( parseElement )
19
37
break
20
38
case 'Column' :
@@ -25,18 +43,15 @@ module.exports = function (cardscript) {
25
43
break
26
44
case 'Input.ChoiceSet' :
27
45
if ( element . choices ) {
28
- const map = { }
29
- lists [ element . id ] = element . choices . map ( ( { title, value } ) => {
30
- map [ value ] = title || value
31
- return {
32
- text : title || value ,
33
- label : title || value ,
34
- value
35
- }
36
- } )
37
- lists . $simpleTitleMaps [ element . id ] = map
38
- }
46
+ buildLabelList ( element . id , element . choices ) }
39
47
break
48
+ case 'FactSet' :
49
+ for ( const fact of element . facts ) {
50
+ if ( fact . choices ) {
51
+ buildTitleMap ( fact . title , fact . choices , true )
52
+ }
53
+ }
54
+ break ;
40
55
}
41
56
}
42
57
0 commit comments