diff --git a/.github/workflows/build-and-pre-release-wordpress.yml b/.github/workflows/build-and-pre-release-wordpress.yml index 138f2460..43cbaa52 100644 --- a/.github/workflows/build-and-pre-release-wordpress.yml +++ b/.github/workflows/build-and-pre-release-wordpress.yml @@ -43,8 +43,9 @@ jobs: with: github_token: ${{ secrets.GITHUB_TOKEN }} tag_prefix: v - release_branches: production,release/* - pre_release_branches: main,task/*,feature/*,bugfix/*,feat/*,fix/* + default_prerelease_bump: prerelease + release_branches: __no-stable-release-branch__ + pre_release_branches: .* append_to_pre_release_tag: rc dry_run: "true" diff --git a/plugins/wp-react-blocks-plugin/blocks/map/APIConfig.js b/plugins/wp-react-blocks-plugin/blocks/map/APIConfig.js index 3c94c771..34126642 100644 --- a/plugins/wp-react-blocks-plugin/blocks/map/APIConfig.js +++ b/plugins/wp-react-blocks-plugin/blocks/map/APIConfig.js @@ -194,6 +194,7 @@ export class APIConfig extends Component { filters, dimension1, dimension2, + dimension3, type, types } @@ -223,6 +224,16 @@ export class APIConfig extends Component { options={allDimensions} /> + + { + setAttributes({dimension3: value}) + }} + options={allDimensions} + /> + , , <> diff --git a/plugins/wp-react-blocks-plugin/blocks/map/BlockEdit.js b/plugins/wp-react-blocks-plugin/blocks/map/BlockEdit.js index 4486424e..ea0ccadf 100644 --- a/plugins/wp-react-blocks-plugin/blocks/map/BlockEdit.js +++ b/plugins/wp-react-blocks-plugin/blocks/map/BlockEdit.js @@ -427,6 +427,7 @@ class BlockEdit extends BlockEditWithAPIMetadata { app, dimension1, dimension2, + dimension3, legendBreaks, mainLayerId, mappingField, @@ -446,7 +447,7 @@ class BlockEdit extends BlockEditWithAPIMetadata { } = this.props; const {mapFiles} = this.state; - const levels = [dimension1, dimension2] + const levels = [dimension1, dimension2, dimension3] const source = levels.filter(l => l != 'none' && l != null).join('/') const validLegendBreaks = legendBreaks.filter(b => b.min || b.max); let params = {} @@ -489,6 +490,7 @@ class BlockEdit extends BlockEditWithAPIMetadata { app: app, dimension1: 'none', dimension2: 'none', + dimension3: 'none', filters: [] }) }} @@ -558,7 +560,7 @@ class BlockEdit extends BlockEditWithAPIMetadata { onChange={(value) => {this.setValue(file.value, 'index', value)}} max={10} type="number" />} - {app != 'csv' && + {app !== 'csv' &&

@@ -676,7 +678,7 @@ class BlockEdit extends BlockEditWithAPIMetadata { - {app != 'csv' && + {app !== 'csv' && - + {mapType == "POINTS_MAP" && @@ -798,4 +800,4 @@ const Edit = (props) => { } -export default Edit; +export default Edit; \ No newline at end of file diff --git a/plugins/wp-react-blocks-plugin/blocks/map/BlockSave.js b/plugins/wp-react-blocks-plugin/blocks/map/BlockSave.js index 0249f2a4..d85842c7 100644 --- a/plugins/wp-react-blocks-plugin/blocks/map/BlockSave.js +++ b/plugins/wp-react-blocks-plugin/blocks/map/BlockSave.js @@ -10,6 +10,7 @@ const SaveComponent = (props) => { dataSourceLabel, dimension1, dimension2, + dimension3, measures, filters, app, @@ -73,7 +74,7 @@ const SaveComponent = (props) => { zoomOnFilterField, labelsExclusionList, noDataText, - customMeasureLabels, + customMeasureLabels, showShadingLayerLabels, dvzProxyDatasetId } @@ -83,7 +84,7 @@ const SaveComponent = (props) => { className: 'viz component map' }); - const levels = [dimension1, dimension2] + const levels = [dimension1, dimension2, dimension3] const source = levels.filter(l => l != 'none' && l != null).join('/') const validLegendBreaks = legendBreaks.filter(b => b.min || b.max); @@ -152,6 +153,7 @@ const SaveComponent = (props) => { data-file-type={fileType} data-dimension1={dimension1} data-dimension2={dimension2} + data-dimension3={dimension3} data-enabled-layers={encodeURIComponent(JSON.stringify(enabledLayers))} data-point-label-color={pointLabelColor} data-point-label-format={pointLabelFormat} diff --git a/plugins/wp-react-blocks-plugin/blocks/map/README.md b/plugins/wp-react-blocks-plugin/blocks/map/README.md index 5cd62baf..aac0f46e 100644 --- a/plugins/wp-react-blocks-plugin/blocks/map/README.md +++ b/plugins/wp-react-blocks-plugin/blocks/map/README.md @@ -12,7 +12,8 @@ A Gutenberg block that renders an interactive choropleth/symbol map by embedding | `app` | `String` | `"csv"` | Data source identifier (`"csv"` or an API app slug). | | `csv` | `String` | `""` | Inline CSV data used when `app` is `"csv"`. | | `dimension1` | `String` | `"zone"` | Primary geographic dimension field. | -| `dimension2` | `String` | `"gender"` | Secondary dimension field (e.g. for disaggregation). | +| `dimension2` | `String` | `"none"` | Secondary dimension field (e.g. for disaggregation). | +| `dimension3` | `String` | `"none"` | Additional dimension (can be for tooltips) | | `measures` | `Array` | `[]` | Measure fields to visualise on the map. Must be configured; no measure is pre-selected by default. | | `filters` | `Array` | `[]` | Active filter values passed as query params to the data API. | | `mapFile` | `String` | `""` | Path (relative to the UI app) to the TopoJSON map file. | diff --git a/plugins/wp-react-blocks-plugin/blocks/map/Tooltips.js b/plugins/wp-react-blocks-plugin/blocks/map/Tooltips.js index c627b3bb..05109d25 100644 --- a/plugins/wp-react-blocks-plugin/blocks/map/Tooltips.js +++ b/plugins/wp-react-blocks-plugin/blocks/map/Tooltips.js @@ -1,132 +1,327 @@ import { Component } from "@wordpress/element"; -import { __ } from '@wordpress/i18n'; +import { __ } from "@wordpress/i18n"; import { - Button, - PanelBody, - PanelRow, - SelectControl, - TextareaControl, - RangeControl, - ToggleControl -} from '@wordpress/components'; + Button, + PanelBody, + PanelRow, + SelectControl, + TextareaControl, + RangeControl, + ToggleControl, +} from "@wordpress/components"; -export default class Tooltips extends Component { - constructor(props) { - super(props); - this.addCustomTooltip = this.addCustomTooltip.bind(this) - this.removeCustomTooltip = this.removeCustomTooltip.bind(this) - } +function APITooltipGuide({ + allMeasures = [], + allDimensions = [], + dimension1 = "none", + dimension2 = "none", + dimension3 = "none", + filters = [], +}) { + return ( + <> +

DEFAULT VARIABLES

+ + + Location -> {"{locationName}"} + + + + + Field Label -> {"{label}"} + + + + + Measure Label -> {"{measureLabel}"} + + + + + Field Value -> {"{value}"} + + +
+

DYNAMIC VARIABLES

+ {dimension1 && dimension1 !== "none" && ( + +

+ Dimension 1: {"{" + dimension1 + "}"} +

+
+ )} - setFieldData(field, value, idx) { - const { attributes: { customTooltips }, setAttributes } = this.props - const newCustomTooltip = customTooltips.slice() - newCustomTooltip[idx][field] = value; - setAttributes({ customTooltips: newCustomTooltip }); - } + {dimension2 && dimension2 !== "none" && ( + +

+ Dimension 2: {"{" + dimension2 + "}"} +

+
+ )} - addCustomTooltip() { - const { attributes: { customTooltips }, setAttributes } = this.props - let index = customTooltips.length; - const newCustomTooltip = {} - let newCustomTooltips = customTooltips.slice() - newCustomTooltips.push(newCustomTooltip) - setAttributes({ customTooltips: newCustomTooltips }) - } + {dimension3 && dimension3 !== "none" && ( + +

+ Dimension 3: {"{" + dimension3 + "}"} +

+
+ )} - removeCustomTooltip(f) { - const { attributes: { customTooltips }, setAttributes } = this.props - let newCustomTooltips = customTooltips.slice(0, -1) - setAttributes({ customTooltips: newCustomTooltips }) - } +

+ Measures +

+ {allMeasures && + allMeasures.map((m) => ( + +

+ {"{" + m + "}"} +

+
+ ))} + + ); +} - render() { - const { setAttributes, attributes: { customTooltips, app, tooltipFormat, showTooltip, showNoDataTooltip, tooltipTheme, tooltipFontSize}, locations } = this.props; - return [ - - - setAttributes({ showTooltip: !showTooltip })} /> +function CSVTooltipGuide() { + return ( + <> + + + Location -> {"{locationName}"} + + + + + Field Label -> {"{label}"} + + + + + Measure Label -> {"{measureLabel}"} + + + + + Field Value -> {"{value}"} + + + + + All variables/columns that start with an _ in csv + + + + ); +} + +export default class Tooltips extends Component { + constructor(props) { + super(props); + this.addCustomTooltip = this.addCustomTooltip.bind(this); + this.removeCustomTooltip = this.removeCustomTooltip.bind(this); + } - - {showTooltip && - <> - - setAttributes({ showNoDataTooltip: !showNoDataTooltip })} /> + setFieldData(field, value, idx) { + const { + attributes: { customTooltips }, + setAttributes, + } = this.props; + const newCustomTooltip = customTooltips.slice(); + newCustomTooltip[idx][field] = value; + setAttributes({ customTooltips: newCustomTooltip }); + } - - - { - setAttributes({ tooltipTheme }) - }} - options={[{ label: "Dark", value: "map-tooltip-dark" }, { label: "Light", value: "map-tooltip-light" }]}> + addCustomTooltip() { + const { + attributes: { customTooltips }, + setAttributes, + } = this.props; + let index = customTooltips.length; + const newCustomTooltip = {}; + let newCustomTooltips = customTooltips.slice(); + newCustomTooltips.push(newCustomTooltip); + setAttributes({ customTooltips: newCustomTooltips }); + } - - - - setAttributes({ tooltipFontSize })} - min={0} - max={20} /> - - - Location -> { '{locationName}'} - - - Field Label -> { '{label}'} - - - Measure Label -> { '{measureLabel}'} - - - Field Value -> { '{value}'} - - - All variables/columns that start with an _ in csv - - - setAttributes({tooltipFormat})} - /> + removeCustomTooltip(f) { + const { + attributes: { customTooltips }, + setAttributes, + } = this.props; + let newCustomTooltips = customTooltips.slice(0, -1); + setAttributes({ customTooltips: newCustomTooltips }); + } + + render() { + const { + setAttributes, + attributes: { + customTooltips, + app, + tooltipFormat, + showTooltip, + showNoDataTooltip, + tooltipTheme, + tooltipFontSize, + dimension1, + dimension2, + dimension3, + measures, + filters, + }, + locations, + } = this.props; + + return [ + + + setAttributes({ showTooltip: !showTooltip })} + /> + + {showTooltip && ( + <> + + + setAttributes({ showNoDataTooltip: !showNoDataTooltip }) + } + /> - - {customTooltips.map((f, index) => { - return ( - - { { - this.setFieldData('location', value, index) - }} - options={locations ? [{value:'', label: 'Select Location'}, ...locations] : []}> - } + + { + setAttributes({ tooltipTheme }); + }} + options={[ + { label: "Dark", value: "map-tooltip-dark" }, + { label: "Light", value: "map-tooltip-light" }, + ]} + > + + + + setAttributes({ tooltipFontSize }) + } + min={0} + max={20} + /> + + {app === "csv" && } - { this.setFieldData('tooltip', value, index)} />} - ) - })} + {app !== "csv" && ( + + )} - - + setAttributes({ tooltipFormat })} + /> - - - } - - ] - } + + {customTooltips.map((f, index) => { + return ( + + { + { + this.setFieldData("location", value, index); + }} + options={ + locations + ? [ + { value: "", label: "Select Location" }, + ...locations, + ] + : [] + } + > + } + + { + + this.setFieldData("tooltip", value, index) + } + /> + } + + ); + })} + + + + + + + )} + , + ]; + } } diff --git a/plugins/wp-react-blocks-plugin/blocks/map/index.js b/plugins/wp-react-blocks-plugin/blocks/map/index.js index ca1c04dd..7de80470 100644 --- a/plugins/wp-react-blocks-plugin/blocks/map/index.js +++ b/plugins/wp-react-blocks-plugin/blocks/map/index.js @@ -33,7 +33,11 @@ registerBlockType(BLOCKS_NS + '/map', }, dimension2: { type: 'String', - default: 'gender' + default: 'none' + }, + dimension3: { + type: 'String', + default: 'none' }, app: { type: 'String',