@@ -24,6 +24,46 @@ class DefaultAttachment extends BaseComponent {
24
24
return defaultAttachmentBuilder ( ) ;
25
25
}
26
26
27
+ /**
28
+ * If the component has values, we need to convert them to attachmentValues
29
+ *
30
+ * When we no longer need to support the old attachments with type radiopanel
31
+ * and have none with type attachment and values, we can remove this.
32
+ */
33
+ init ( ) {
34
+ super . init ( ) ;
35
+
36
+ if ( this . builderMode && ! this . component ?. attachmentValues && this . component ?. values ) {
37
+ if ( ! this . component ?. attachmentType ) {
38
+ this . component . attachmentType = this . component ?. otherDocumentation ? 'other' : 'default' ;
39
+ }
40
+
41
+ if ( this . component . attachmentType === 'other' ) {
42
+ this . component . attachmentValues = {
43
+ leggerVedNaa : { enabled : true } ,
44
+ nei : { enabled : true } ,
45
+ } ;
46
+ } else {
47
+ this . component . attachmentValues = { } ;
48
+ for ( const objectValue of this . component . values ) {
49
+ if (
50
+ objectValue . value === 'leggerVedNaa' ||
51
+ objectValue . value === 'ettersender' ||
52
+ objectValue . value === 'levertTidligere' ||
53
+ objectValue . value === 'nei'
54
+ ) {
55
+ this . component . attachmentValues [ objectValue . value ] = {
56
+ enabled : ! ! objectValue . value ,
57
+ } ;
58
+ }
59
+ }
60
+ }
61
+
62
+ this . component . otherDocumentation = undefined ;
63
+ this . component . values = undefined ;
64
+ }
65
+ }
66
+
27
67
getAttachmentValues ( ) {
28
68
return this . component ?. attachmentValues ? this . component ?. attachmentValues : this . component ?. values ;
29
69
}
0 commit comments