← All changes
|
classes/Visualizer/Gutenberg/src/Components/Sidebar/SeriesSettings.js
+29
-11
3.1.0
→
3.7.1
View file →
| @@ -7,9 +7,9 @@ | ||
| 7 | 7 | Component, |
| 8 | 8 | Fragment |
| 9 | 9 | } = wp.element; |
| 10 | 10 | |
| 11 | -const { ColorPalette } = wp.editor; | |
| 11 | +const { ColorPalette } = wp.blockEditor || wp.editor; | |
| 12 | 12 | |
| 13 | 13 | const { |
| 14 | 14 | BaseControl, |
| 15 | 15 | ExternalLink, |
| @@ -59,17 +59,26 @@ | ||
| 59 | 59 | > |
| 60 | 60 | |
| 61 | 61 | { Object.keys( settings.series ) |
| 62 | 62 | .map( ( i, index ) => { |
| 63 | + let indexToFormat = parseInt( i ); | |
| 64 | + let label = series[i].label || ''; | |
| 65 | + let type = series[i].type || ''; | |
| 66 | + let timer = 0; | |
| 67 | + if ( 'tabular' !== type ) { | |
| 68 | + indexToFormat = index; | |
| 69 | + } | |
| 70 | + | |
| 63 | 71 | i++; |
| 72 | + | |
| 64 | 73 | return ( |
| 65 | 74 | <PanelBody |
| 66 | - title={ series[i].label } | |
| 75 | + title={ label } | |
| 67 | 76 | className="visualizer-inner-sections" |
| 68 | 77 | initialOpen={ false } |
| 69 | 78 | > |
| 70 | 79 | |
| 71 | - { ( -1 >= [ 'table', 'pie' ].indexOf( type ) ) && ( | |
| 80 | + { ( -1 >= [ 'tabular', 'pie' ].indexOf( type ) ) && ( | |
| 72 | 81 | <SelectControl |
| 73 | 82 | label={ __( 'Visible In Legend' ) } |
| 74 | 83 | help={ __( 'Determines whether the series has to be presented in the legend or not.' ) } |
| 75 | 84 | value={ settings.series[index].visibleInLegend ? settings.series[index].visibleInLegend : '1' } |
| @@ -83,9 +92,9 @@ | ||
| 83 | 92 | } } |
| 84 | 93 | /> |
| 85 | 94 | ) } |
| 86 | 95 | |
| 87 | - { ( -1 >= [ 'table', 'candlestick', 'combo', 'column', 'bar' ].indexOf( type ) ) && ( | |
| 96 | + { ( -1 >= [ 'tabular', 'candlestick', 'combo', 'column', 'bar' ].indexOf( type ) ) && ( | |
| 88 | 97 | |
| 89 | 98 | <Fragment> |
| 90 | 99 | |
| 91 | 100 | <TextControl |
| @@ -95,8 +104,17 @@ | ||
| 95 | 104 | onChange={ e => { |
| 96 | 105 | settings.series[index].lineWidth = e; |
| 97 | 106 | this.props.edit( settings ); |
| 98 | 107 | } } |
| 108 | + onKeyUp={ e => { | |
| 109 | + clearTimeout( timer ); | |
| 110 | + timer = setTimeout( () => { | |
| 111 | + if ( '' != settings.series[index].lineWidth && 0 >= settings.series[index].lineWidth ) { | |
| 112 | + settings.series[index].lineWidth = '0.1'; | |
| 113 | + this.props.edit( settings ); | |
| 114 | + } | |
| 115 | + }, 700 ); | |
| 116 | + } } | |
| 99 | 117 | /> |
| 100 | 118 | |
| 101 | 119 | <TextControl |
| 102 | 120 | label={ __( 'Point Size' ) } |
| @@ -113,9 +131,9 @@ | ||
| 113 | 131 | ) } |
| 114 | 132 | |
| 115 | 133 | { ( -1 >= [ 'candlestick' ].indexOf( type ) ) && |
| 116 | 134 | |
| 117 | - ( 'number' === series[i].type ) ? ( | |
| 135 | + ( type && 'number' === type ) ? ( | |
| 118 | 136 | |
| 119 | 137 | <Fragment> |
| 120 | 138 | |
| 121 | 139 | <TextControl |
| @@ -120,11 +138,11 @@ | ||
| 120 | 138 | |
| 121 | 139 | <TextControl |
| 122 | 140 | label={ __( 'Format' ) } |
| 123 | 141 | help={ __( 'Enter custom format pattern to apply to this series value.' ) } |
| 124 | - value={ settings.series[index].format } | |
| 142 | + value={ settings.series[indexToFormat].format } | |
| 125 | 143 | onChange={ e => { |
| 126 | - settings.series[index].format = e; | |
| 144 | + settings.series[indexToFormat].format = e; | |
| 127 | 145 | this.props.edit( settings ); |
| 128 | 146 | } } |
| 129 | 147 | /> |
| 130 | 148 | |
| @@ -139,9 +157,9 @@ | ||
| 139 | 157 | </Fragment> |
| 140 | 158 | |
| 141 | 159 | ) : |
| 142 | 160 | |
| 143 | - ( 'date' === series[i].type ) && ( | |
| 161 | + ( 0 <= [ 'date', 'datetime', 'timeofday' ].indexOf( type ) ) && ( | |
| 144 | 162 | |
| 145 | 163 | <Fragment> |
| 146 | 164 | |
| 147 | 165 | <TextControl |
| @@ -147,11 +165,11 @@ | ||
| 147 | 165 | <TextControl |
| 148 | 166 | label={ __( 'Date Format' ) } |
| 149 | 167 | help={ __( 'Enter custom format pattern to apply to this series value.' ) } |
| 150 | 168 | placeholder="dd LLLL yyyy" |
| 151 | - value={ settings.series[index].format } | |
| 169 | + value={ settings.series[indexToFormat].format } | |
| 152 | 170 | onChange={ e => { |
| 153 | - settings.series[index].format = e; | |
| 171 | + settings.series[indexToFormat].format = e; | |
| 154 | 172 | this.props.edit( settings ); |
| 155 | 173 | } } |
| 156 | 174 | /> |
| 157 | 175 | |
| @@ -220,9 +238,9 @@ | ||
| 220 | 238 | /> |
| 221 | 239 | |
| 222 | 240 | ) } |
| 223 | 241 | |
| 224 | - { ( -1 >= [ 'table' ].indexOf( type ) ) && ( | |
| 242 | + { ( -1 >= [ 'tabular' ].indexOf( type ) ) && ( | |
| 225 | 243 | |
| 226 | 244 | <BaseControl |
| 227 | 245 | label={ __( 'Color' ) } |
| 228 | 246 | > |