Skip to content

Commit 7705faa

Browse files
Fix tag control default values
1 parent 5591498 commit 7705faa

File tree

3 files changed

+245
-31
lines changed

3 files changed

+245
-31
lines changed

demo/data/dialog-data.json

Lines changed: 238 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -317,25 +317,25 @@
317317
{
318318
"href": "http://localhost:3001/api/service_templates/10000000000015/service_dialogs/10000000007063",
319319
"id": 1,
320-
"name": "1",
320+
"name": "string_dropdown_1",
321321
"data_type": "string",
322322
"display": "edit",
323323
"display_method_options": {},
324324
"required": true,
325325
"required_method_options": {},
326-
"default_value": "2",
326+
"default_value": "two",
327327
"values": [
328328
[
329-
"1",
330-
"1"
329+
"one",
330+
"First"
331331
],
332332
[
333-
"2",
334-
"2"
333+
"two",
334+
"Second"
335335
],
336336
[
337-
"4",
338-
"4"
337+
"three",
338+
"Third"
339339
],
340340
[
341341
null,
@@ -365,25 +365,25 @@
365365
{
366366
"href": "http://localhost:3001/api/service_templates/10000000000015/service_dialogs/10000000007063",
367367
"id": 2,
368-
"name": "2",
368+
"name": "string_dropdown_2",
369369
"data_type": "string",
370370
"display": "edit",
371371
"display_method_options": {},
372372
"required": true,
373373
"required_method_options": {},
374-
"default_value": ["1", "2"],
374+
"default_value": ["first", "2"],
375375
"values": [
376376
[
377-
"1",
378-
"1"
377+
"first",
378+
"First"
379379
],
380380
[
381381
"2",
382-
"2"
382+
"Second"
383383
],
384384
[
385-
"4",
386-
"4"
385+
"3",
386+
"Third"
387387
],
388388
[
389389
null,
@@ -413,7 +413,7 @@
413413
{
414414
"href": "http://localhost:3001/api/service_templates/10000000000015/service_dialogs/10000000007063",
415415
"id": 3,
416-
"name": "3",
416+
"name": "integer_dropdown_3",
417417
"data_type": "integer",
418418
"display": "edit",
419419
"display_method_options": {},
@@ -423,15 +423,15 @@
423423
"values": [
424424
[
425425
"1",
426-
1
426+
"First"
427427
],
428428
[
429429
"2",
430-
2
430+
"Second"
431431
],
432432
[
433-
"4",
434-
4
433+
"3",
434+
"Third"
435435
],
436436
[
437437
null,
@@ -461,25 +461,25 @@
461461
{
462462
"href": "http://localhost:3001/api/service_templates/10000000000015/service_dialogs/10000000007063",
463463
"id": 4,
464-
"name": "4",
464+
"name": "integer_dropdown_4",
465465
"data_type": "integer",
466466
"display": "edit",
467467
"display_method_options": {},
468468
"required": true,
469469
"required_method_options": {},
470-
"default_value": ["1", "2"],
470+
"default_value": [1, 2],
471471
"values": [
472472
[
473473
"1",
474-
1
474+
"New York"
475475
],
476476
[
477477
"2",
478-
2
478+
"Chicago"
479479
],
480480
[
481-
"4",
482-
4
481+
"3",
482+
"Seattle"
483483
],
484484
[
485485
null,
@@ -505,6 +505,218 @@
505505
"resource_type": "DialogField",
506506
"ae_attributes": {}
507507
}
508+
},
509+
{
510+
"name": "tag_control_1",
511+
"description": "",
512+
"type": "DialogFieldTagControl",
513+
"display": "edit",
514+
"display_method_options": {},
515+
"read_only": false,
516+
"required": false,
517+
"required_method_options": {},
518+
"default_value": "2",
519+
"values_method_options": {},
520+
"label": "Tag String Single Select",
521+
"position": 0,
522+
"dynamic": false,
523+
"show_refresh_button": false,
524+
"load_values_on_init": true,
525+
"auto_refresh": false,
526+
"trigger_auto_refresh": false,
527+
"reconfigurable": false,
528+
"visible": true,
529+
"options": {
530+
"category_id": "",
531+
"force_single_value": true,
532+
"sort_by": "description",
533+
"sort_order": "ascending"
534+
},
535+
"resource_action": {
536+
"resource_type": "DialogField",
537+
"ae_attributes": {}
538+
},
539+
"data_type": "string",
540+
"values": [
541+
{
542+
"description": "Automotive",
543+
"href": "http://localhost:3000/api/service_dialogs/1",
544+
"id": "1",
545+
"name": "automotive"
546+
},
547+
{
548+
"description": "Engineering",
549+
"href": "http://localhost:3000/api/service_dialogs/2",
550+
"id": "2",
551+
"name": "engineering"
552+
},
553+
{
554+
"description": "Test",
555+
"href": "http://localhost:3000/api/service_dialogs/3",
556+
"id": "3",
557+
"name": "test"
558+
}
559+
],
560+
"automation_type": "embedded_automate"
561+
},
562+
{
563+
"name": "tag_control_2",
564+
"description": "",
565+
"type": "DialogFieldTagControl",
566+
"display": "edit",
567+
"display_method_options": {},
568+
"read_only": false,
569+
"required": false,
570+
"required_method_options": {},
571+
"default_value": ["1", "2"],
572+
"values_method_options": {},
573+
"label": "Tag String Multi Select",
574+
"position": 0,
575+
"dynamic": false,
576+
"show_refresh_button": false,
577+
"load_values_on_init": true,
578+
"auto_refresh": false,
579+
"trigger_auto_refresh": false,
580+
"reconfigurable": false,
581+
"visible": true,
582+
"options": {
583+
"category_id": "",
584+
"force_single_value": false,
585+
"sort_by": "description",
586+
"sort_order": "ascending"
587+
},
588+
"resource_action": {
589+
"resource_type": "DialogField",
590+
"ae_attributes": {}
591+
},
592+
"data_type": "string",
593+
"values": [
594+
{
595+
"description": "Automotive",
596+
"href": "http://localhost:3000/api/service_dialogs/1",
597+
"id": "1",
598+
"name": "automotive"
599+
},
600+
{
601+
"description": "Engineering",
602+
"href": "http://localhost:3000/api/service_dialogs/2",
603+
"id": "2",
604+
"name": "engineering"
605+
},
606+
{
607+
"description": "Test",
608+
"href": "http://localhost:3000/api/service_dialogs/3",
609+
"id": "3",
610+
"name": "test"
611+
}
612+
],
613+
"automation_type": "embedded_automate"
614+
},
615+
{
616+
"name": "tag_control_3",
617+
"description": "",
618+
"type": "DialogFieldTagControl",
619+
"display": "edit",
620+
"display_method_options": {},
621+
"read_only": false,
622+
"required": false,
623+
"required_method_options": {},
624+
"default_value": 2,
625+
"values_method_options": {},
626+
"label": "Tag Integer Single Select",
627+
"position": 0,
628+
"dynamic": false,
629+
"show_refresh_button": false,
630+
"load_values_on_init": true,
631+
"auto_refresh": false,
632+
"trigger_auto_refresh": false,
633+
"reconfigurable": false,
634+
"visible": true,
635+
"options": {
636+
"category_id": "",
637+
"force_single_value": true,
638+
"sort_by": "description",
639+
"sort_order": "ascending"
640+
},
641+
"resource_action": {
642+
"resource_type": "DialogField",
643+
"ae_attributes": {}
644+
},
645+
"data_type": "integer",
646+
"values": [
647+
{
648+
"description": "Automotive",
649+
"href": "http://localhost:3000/api/service_dialogs/1",
650+
"id": "1",
651+
"name": "automotive"
652+
},
653+
{
654+
"description": "Engineering",
655+
"href": "http://localhost:3000/api/service_dialogs/2",
656+
"id": "2",
657+
"name": "engineering"
658+
},
659+
{
660+
"description": "Test",
661+
"href": "http://localhost:3000/api/service_dialogs/3",
662+
"id": "3",
663+
"name": "test"
664+
}
665+
],
666+
"automation_type": "embedded_automate"
667+
},
668+
{
669+
"name": "tag_control_4",
670+
"description": "",
671+
"type": "DialogFieldTagControl",
672+
"display": "edit",
673+
"display_method_options": {},
674+
"read_only": false,
675+
"required": false,
676+
"required_method_options": {},
677+
"default_value": [1, 2],
678+
"values_method_options": {},
679+
"label": "Tag Integer Multi Select",
680+
"position": 0,
681+
"dynamic": false,
682+
"show_refresh_button": false,
683+
"load_values_on_init": true,
684+
"auto_refresh": false,
685+
"trigger_auto_refresh": false,
686+
"reconfigurable": false,
687+
"visible": true,
688+
"options": {
689+
"category_id": "",
690+
"force_single_value": false,
691+
"sort_by": "description",
692+
"sort_order": "ascending"
693+
},
694+
"resource_action": {
695+
"resource_type": "DialogField",
696+
"ae_attributes": {}
697+
},
698+
"data_type": "integer",
699+
"values": [
700+
{
701+
"description": "Automotive",
702+
"href": "http://localhost:3000/api/service_dialogs/1",
703+
"id": "1",
704+
"name": "automotive"
705+
},
706+
{
707+
"description": "Engineering",
708+
"href": "http://localhost:3000/api/service_dialogs/2",
709+
"id": "2",
710+
"name": "engineering"
711+
},
712+
{
713+
"description": "Test",
714+
"href": "http://localhost:3000/api/service_dialogs/3",
715+
"id": "3",
716+
"name": "test"
717+
}
718+
],
719+
"automation_type": "embedded_automate"
508720
}
509721
]
510722
}

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@
7373
"karma-webpack": "1.8.0",
7474
"lodash": "~4.17.20",
7575
"ng-annotate-webpack-plugin": "0.1.3",
76-
"node-sass": "^4.12.0",
76+
"node-sass": "^9.0.0",
7777
"numeral": "^2.0.6",
7878
"patternfly": "^3.15.0",
7979
"patternfly-bootstrap-treeview": "^2.1.5",

src/dialog-user/services/dialogData.ts

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -131,10 +131,12 @@ export default class DialogDataService {
131131
if (data.type === 'DialogFieldTagControl') {
132132
if (data.default_value === null || data.default_value === '') {
133133
defaultValue = null;
134-
} else if (data.options.force_single_value) {
135-
defaultValue = this.convertDropdownValue(data.default_value, data.data_type);
136-
} else {
137-
defaultValue = JSON.parse(data.default_value).map((value) => this.convertDropdownValue(value, data.data_type));
134+
} else if (data.options.force_single_value) { // string/integer default value
135+
// For tag control, always convert to string
136+
defaultValue = this.convertDropdownValue(data.default_value, 'string');
137+
} else { // array default value
138+
// For tag control, always convert to string
139+
defaultValue = data.default_value.map((value) => value.toString());
138140
}
139141
}
140142

0 commit comments

Comments
 (0)