@@ -48,11 +48,16 @@ export default {
48
48
data ( ) {
49
49
return {
50
50
screen : null ,
51
+ // We make style a data attribute so as we recurse through nested
52
+ // widgets we can check to see if style attributes have been applied
53
+ // at any level of the widget, i.e. if LABELVALUE applies a style
54
+ // to the VALUE component then we don't want the VALUE widget to think
55
+ // it doesn't have a style when it renders.
56
+ style : { } ,
51
57
}
52
58
} ,
53
59
computed : {
54
60
computedStyle ( ) {
55
- let style = { }
56
61
this . settings . forEach ( ( setting ) => {
57
62
const index = parseInt ( setting [ 0 ] )
58
63
if ( this . widgetIndex !== null ) {
@@ -62,19 +67,25 @@ export default {
62
67
return
63
68
}
64
69
}
65
- this . applySetting ( style , setting )
70
+ this . applySetting ( this . style , setting )
66
71
} )
67
- // If they haven't defined a width then we add flex to the style
68
- if ( style [ 'width' ] === undefined ) {
72
+ // If nothing has yet defined a width then we add flex to the style
73
+ if ( this . style [ 'width' ] === undefined ) {
69
74
// This flex allows for alignment in our widgets
70
75
// The value of '0 10 100%' was achieved through trial and error
71
76
// The larger flex-shrink value was critical for success
72
- style [ 'flex' ] = '0 10 100%' // flex-grow, flex-shrink, flex-basis
77
+ this . style [ 'flex' ] = '0 10 100%' // flex-grow, flex-shrink, flex-basis
73
78
}
74
- return style
79
+ return this . style
75
80
} ,
76
81
} ,
77
82
created ( ) {
83
+ // Look through the settings and get a reference to the screen
84
+ this . settings . forEach ( ( setting ) => {
85
+ if ( setting [ 0 ] === '__SCREEN__' ) {
86
+ this . screen = setting [ 1 ]
87
+ }
88
+ } )
78
89
// Figure out any subsettings that apply
79
90
this . settings = this . settings
80
91
. map ( ( setting ) => {
@@ -89,19 +100,10 @@ export default {
89
100
// on the current widget
90
101
if ( this . widgetIndex === index ) {
91
102
return setting . slice ( 1 )
92
- } else {
93
- return null
94
103
}
95
104
} )
96
105
// Remove any settings that we filtered out with null
97
- . filter ( ( setting ) => setting !== null )
98
-
99
- // Look through the settings and get a reference to the screen
100
- this . settings . forEach ( ( setting ) => {
101
- if ( setting [ 0 ] === '__SCREEN__' ) {
102
- this . screen = setting [ 1 ]
103
- }
104
- } )
106
+ . filter ( ( setting ) => setting !== undefined )
105
107
} ,
106
108
methods : {
107
109
applySetting ( style , setting ) {
0 commit comments