← All changes
|
classes/Visualizer/Gutenberg/src/Components/Sidebar/SeriesSettings.js
+31
-12
3.1.3
→
3.11.10
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,27 @@ | ||
| 59 | 59 | > |
| 60 | 60 | |
| 61 | 61 | { Object.keys( settings.series ) |
| 62 | 62 | .map( ( i, index ) => { |
| 63 | + i = parseInt( i ) + 1; | |
| 64 | + let indexToFormat = parseInt( i ); | |
| 65 | + let label = 'object' === typeof series[i] ? series[i].label : ''; | |
| 66 | + let type = 'object' == typeof series[i] ? series[i].type : ''; | |
| 67 | + let timer = 0; | |
| 68 | + if ( 'tabular' !== type ) { | |
| 69 | + indexToFormat = index; | |
| 70 | + } | |
| 71 | + | |
| 63 | 72 | i++; |
| 73 | + | |
| 64 | 74 | return ( |
| 65 | 75 | <PanelBody |
| 66 | - title={ series[i].label } | |
| 76 | + title={ label } | |
| 67 | 77 | className="visualizer-inner-sections" |
| 68 | 78 | initialOpen={ false } |
| 69 | 79 | > |
| 70 | 80 | |
| 71 | - { ( -1 >= [ 'table', 'pie' ].indexOf( type ) ) && ( | |
| 81 | + { ( -1 >= [ 'tabular', 'pie' ].indexOf( type ) ) && ( | |
| 72 | 82 | <SelectControl |
| 73 | 83 | label={ __( 'Visible In Legend' ) } |
| 74 | 84 | help={ __( 'Determines whether the series has to be presented in the legend or not.' ) } |
| 75 | 85 | value={ settings.series[index].visibleInLegend ? settings.series[index].visibleInLegend : '1' } |
| @@ -83,9 +93,9 @@ | ||
| 83 | 93 | } } |
| 84 | 94 | /> |
| 85 | 95 | ) } |
| 86 | 96 | |
| 87 | - { ( -1 >= [ 'table', 'candlestick', 'combo', 'column', 'bar' ].indexOf( type ) ) && ( | |
| 97 | + { ( -1 >= [ 'tabular', 'candlestick', 'combo', 'column', 'bar' ].indexOf( type ) ) && ( | |
| 88 | 98 | |
| 89 | 99 | <Fragment> |
| 90 | 100 | |
| 91 | 101 | <TextControl |
| @@ -95,8 +105,17 @@ | ||
| 95 | 105 | onChange={ e => { |
| 96 | 106 | settings.series[index].lineWidth = e; |
| 97 | 107 | this.props.edit( settings ); |
| 98 | 108 | } } |
| 109 | + onKeyUp={ e => { | |
| 110 | + clearTimeout( timer ); | |
| 111 | + timer = setTimeout( () => { | |
| 112 | + if ( '' != settings.series[index].lineWidth && 0 >= settings.series[index].lineWidth ) { | |
| 113 | + settings.series[index].lineWidth = '0.1'; | |
| 114 | + this.props.edit( settings ); | |
| 115 | + } | |
| 116 | + }, 700 ); | |
| 117 | + } } | |
| 99 | 118 | /> |
| 100 | 119 | |
| 101 | 120 | <TextControl |
| 102 | 121 | label={ __( 'Point Size' ) } |
| @@ -113,9 +132,9 @@ | ||
| 113 | 132 | ) } |
| 114 | 133 | |
| 115 | 134 | { ( -1 >= [ 'candlestick' ].indexOf( type ) ) && |
| 116 | 135 | |
| 117 | - ( 'number' === series[i].type ) ? ( | |
| 136 | + ( type && 'number' === type ) ? ( | |
| 118 | 137 | |
| 119 | 138 | <Fragment> |
| 120 | 139 | |
| 121 | 140 | <TextControl |
| @@ -120,11 +139,11 @@ | ||
| 120 | 139 | |
| 121 | 140 | <TextControl |
| 122 | 141 | label={ __( 'Format' ) } |
| 123 | 142 | help={ __( 'Enter custom format pattern to apply to this series value.' ) } |
| 124 | - value={ settings.series[index].format } | |
| 143 | + value={ settings.series[indexToFormat].format } | |
| 125 | 144 | onChange={ e => { |
| 126 | - settings.series[index].format = e; | |
| 145 | + settings.series[indexToFormat].format = e; | |
| 127 | 146 | this.props.edit( settings ); |
| 128 | 147 | } } |
| 129 | 148 | /> |
| 130 | 149 | |
| @@ -139,9 +158,9 @@ | ||
| 139 | 158 | </Fragment> |
| 140 | 159 | |
| 141 | 160 | ) : |
| 142 | 161 | |
| 143 | - ( 'date' === series[i].type ) && ( | |
| 162 | + ( 0 <= [ 'date', 'datetime', 'timeofday' ].indexOf( type ) ) && ( | |
| 144 | 163 | |
| 145 | 164 | <Fragment> |
| 146 | 165 | |
| 147 | 166 | <TextControl |
| @@ -147,11 +166,11 @@ | ||
| 147 | 166 | <TextControl |
| 148 | 167 | label={ __( 'Date Format' ) } |
| 149 | 168 | help={ __( 'Enter custom format pattern to apply to this series value.' ) } |
| 150 | 169 | placeholder="dd LLLL yyyy" |
| 151 | - value={ settings.series[index].format } | |
| 170 | + value={ settings.series[indexToFormat].format } | |
| 152 | 171 | onChange={ e => { |
| 153 | - settings.series[index].format = e; | |
| 172 | + settings.series[indexToFormat].format = e; | |
| 154 | 173 | this.props.edit( settings ); |
| 155 | 174 | } } |
| 156 | 175 | /> |
| 157 | 176 | |
| @@ -156,9 +175,9 @@ | ||
| 156 | 175 | /> |
| 157 | 176 | |
| 158 | 177 | <p> |
| 159 | 178 | { __( 'This is a subset of the date formatting ' ) } |
| 160 | - <ExternalLink href="http://userguide.icu-project.org/formatparse/datetime#TOC-Date-Time-Format-Syntax"> | |
| 179 | + <ExternalLink href="https://unicode-org.github.io/icu/userguide/format_parse/datetime/#datetime-format-syntax"> | |
| 161 | 180 | { __( 'ICU date and time format.' ) } |
| 162 | 181 | </ExternalLink> |
| 163 | 182 | </p> |
| 164 | 183 | |
| @@ -220,9 +239,9 @@ | ||
| 220 | 239 | /> |
| 221 | 240 | |
| 222 | 241 | ) } |
| 223 | 242 | |
| 224 | - { ( -1 >= [ 'table' ].indexOf( type ) ) && ( | |
| 243 | + { ( -1 >= [ 'tabular' ].indexOf( type ) ) && ( | |
| 225 | 244 | |
| 226 | 245 | <BaseControl |
| 227 | 246 | label={ __( 'Color' ) } |
| 228 | 247 | > |