Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

(solves 736) Checkbox to toggle latitude and longitude in Venue block #877

Merged
merged 29 commits into from
Nov 15, 2024
Merged
Show file tree
Hide file tree
Changes from 6 commits
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
af760e5
initial push
stephenerdelyi Sep 17, 2024
4fa8150
working updates
stephenerdelyi Sep 17, 2024
cb44491
fix lint error
stephenerdelyi Sep 17, 2024
b2b1eec
Fixed build; added NumberControl; pulled in recent changes from develop.
mauteri Oct 12, 2024
59677ec
Var name change.
mauteri Oct 12, 2024
ede98fe
Name change in more places.
mauteri Oct 12, 2024
418e289
Fix conflicts.
mauteri Oct 12, 2024
9ca69d3
Boilerplate for the store
jmarx Oct 18, 2024
ff4c7bd
Set up a basic interaction with the venue store
jmarx Oct 18, 2024
e64fb45
WIP: Grab updated lat/long values from store and console log them out…
jmarx Oct 18, 2024
7d2acd0
Venue lat/long values are now pulling from the store
jmarx Oct 20, 2024
4df2ab3
Merge branch 'develop' into 736-checkbox-lat-lng
jmarx Oct 20, 2024
a4a7c42
Merge branch 'develop' into 736-checkbox-lat-lng-store
jmarx Oct 20, 2024
35c79ad
Use store to toggle custom lat long attr
jmarx Nov 1, 2024
ea1e0e7
Add store functions in venue information for better performance
jmarx Nov 2, 2024
d53070c
Remove console logs
jmarx Nov 2, 2024
d78a7c7
Merge branch 'develop' into 736-checkbox-lat-lng-store
jmarx Nov 2, 2024
74ebd41
Merge branch 'develop' into 736-checkbox-lat-lng
jmarx Nov 2, 2024
e378324
Merge branch '736-checkbox-lat-lng-store' into 736-checkbox-lat-lng
jmarx Nov 2, 2024
ac7ef12
Remove redundant useeffect
jmarx Nov 2, 2024
ff589c1
hide lat/long heading from event post type
jmarx Nov 3, 2024
9ead249
Clean up some stuff
jmarx Nov 3, 2024
f5f87f2
More Cleanup
jmarx Nov 4, 2024
127029d
enable google maps + custom lat / lng functionality + build
stephenerdelyi Nov 9, 2024
55eb3d0
fix spelling typo, update tests, fix JS formatting
stephenerdelyi Nov 9, 2024
daad077
one last formatting update
stephenerdelyi Nov 9, 2024
7f9fc19
Update docblock and build files.
mauteri Nov 15, 2024
c5275f8
Bump tested up to version.
mauteri Nov 15, 2024
e4970c9
Bump wordpress version checker.
mauteri Nov 15, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion build/272.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion build/481.js

Large diffs are not rendered by default.

1 change: 0 additions & 1 deletion build/535.js

This file was deleted.

File renamed without changes.
File renamed without changes.
1 change: 1 addition & 0 deletions build/567.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion build/980.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion build/blocks/add-to-calendar/index.asset.php
Original file line number Diff line number Diff line change
@@ -1 +1 @@
<?php return array('dependencies' => array('react-jsx-runtime', 'wp-block-editor', 'wp-blocks', 'wp-components', 'wp-i18n'), 'version' => '754b4dfa4e592032751e');
<?php return array('dependencies' => array('react-jsx-runtime', 'wp-block-editor', 'wp-blocks', 'wp-components', 'wp-i18n'), 'version' => 'd363e7f0b415ef3e95a3');
2 changes: 1 addition & 1 deletion build/blocks/add-to-calendar/index.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion build/blocks/event-date/index.asset.php
Original file line number Diff line number Diff line change
@@ -1 +1 @@
<?php return array('dependencies' => array('moment', 'react-jsx-runtime', 'wp-block-editor', 'wp-blocks', 'wp-components', 'wp-data', 'wp-date', 'wp-element', 'wp-i18n'), 'version' => '2a87e9e9bf69563aeae1');
<?php return array('dependencies' => array('moment', 'react-jsx-runtime', 'wp-block-editor', 'wp-blocks', 'wp-components', 'wp-data', 'wp-date', 'wp-element', 'wp-i18n'), 'version' => 'fbdfb147c6c684a7d803');
4 changes: 2 additions & 2 deletions build/blocks/event-date/index.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion build/blocks/events-list/events-list.asset.php
Original file line number Diff line number Diff line change
@@ -1 +1 @@
<?php return array('dependencies' => array('react', 'react-dom', 'react-jsx-runtime', 'wp-api-fetch', 'wp-components', 'wp-data', 'wp-dom-ready', 'wp-element', 'wp-i18n'), 'version' => 'c0e0d5fe46659d5a0d72');
<?php return array('dependencies' => array('react', 'react-dom', 'react-jsx-runtime', 'wp-api-fetch', 'wp-components', 'wp-data', 'wp-dom-ready', 'wp-element', 'wp-i18n'), 'version' => '32836f434d415163a581');
10 changes: 5 additions & 5 deletions build/blocks/events-list/events-list.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion build/blocks/events-list/index.asset.php
Original file line number Diff line number Diff line change
@@ -1 +1 @@
<?php return array('dependencies' => array('lodash', 'react', 'react-dom', 'react-jsx-runtime', 'wp-api-fetch', 'wp-block-editor', 'wp-blocks', 'wp-components', 'wp-core-data', 'wp-data', 'wp-element', 'wp-i18n'), 'version' => '97b565c364ee272e7701');
<?php return array('dependencies' => array('lodash', 'react', 'react-dom', 'react-jsx-runtime', 'wp-api-fetch', 'wp-block-editor', 'wp-blocks', 'wp-components', 'wp-core-data', 'wp-data', 'wp-element', 'wp-i18n'), 'version' => '4842db94aa23d20de87e');
10 changes: 5 additions & 5 deletions build/blocks/events-list/index.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion build/blocks/online-event/index.asset.php
Original file line number Diff line number Diff line change
@@ -1 +1 @@
<?php return array('dependencies' => array('react', 'react-jsx-runtime', 'wp-block-editor', 'wp-blocks', 'wp-components', 'wp-data', 'wp-element', 'wp-i18n'), 'version' => '120d638313cd180d9338');
<?php return array('dependencies' => array('react', 'react-jsx-runtime', 'wp-block-editor', 'wp-blocks', 'wp-components', 'wp-data', 'wp-element', 'wp-i18n'), 'version' => '1196756c1c15c226a71e');
2 changes: 1 addition & 1 deletion build/blocks/online-event/index.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion build/blocks/online-event/online-event.asset.php
Original file line number Diff line number Diff line change
@@ -1 +1 @@
<?php return array('dependencies' => array('react', 'react-jsx-runtime', 'wp-components', 'wp-data', 'wp-dom-ready', 'wp-element', 'wp-i18n'), 'version' => 'eefd96d7d3ced019a949');
<?php return array('dependencies' => array('react', 'react-jsx-runtime', 'wp-components', 'wp-data', 'wp-dom-ready', 'wp-element', 'wp-i18n'), 'version' => '2b9111b895d3b05a8ece');
2 changes: 1 addition & 1 deletion build/blocks/online-event/online-event.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion build/blocks/rsvp-response/index.asset.php
Original file line number Diff line number Diff line change
@@ -1 +1 @@
<?php return array('dependencies' => array('react-jsx-runtime', 'wp-api-fetch', 'wp-block-editor', 'wp-blocks', 'wp-components', 'wp-core-data', 'wp-data', 'wp-element', 'wp-i18n'), 'version' => '1dfd2576a31f517fef45');
<?php return array('dependencies' => array('react-jsx-runtime', 'wp-api-fetch', 'wp-block-editor', 'wp-blocks', 'wp-components', 'wp-core-data', 'wp-data', 'wp-element', 'wp-i18n'), 'version' => '94657e92928e2e24a9d3');
2 changes: 1 addition & 1 deletion build/blocks/rsvp-response/index.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion build/blocks/rsvp/index.asset.php
Original file line number Diff line number Diff line change
@@ -1 +1 @@
<?php return array('dependencies' => array('react', 'react-dom', 'react-jsx-runtime', 'wp-api-fetch', 'wp-block-editor', 'wp-blocks', 'wp-components', 'wp-data', 'wp-element', 'wp-i18n'), 'version' => '3b137897829338f9530a');
<?php return array('dependencies' => array('react', 'react-dom', 'react-jsx-runtime', 'wp-api-fetch', 'wp-block-editor', 'wp-blocks', 'wp-components', 'wp-data', 'wp-element', 'wp-i18n'), 'version' => '34e21d75e332e2e50be5');
10 changes: 5 additions & 5 deletions build/blocks/rsvp/index.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion build/blocks/rsvp/rsvp.asset.php
Original file line number Diff line number Diff line change
@@ -1 +1 @@
<?php return array('dependencies' => array('react', 'react-dom', 'react-jsx-runtime', 'wp-api-fetch', 'wp-components', 'wp-data', 'wp-dom-ready', 'wp-element', 'wp-i18n'), 'version' => '680566d16c88772cbf7c');
<?php return array('dependencies' => array('react', 'react-dom', 'react-jsx-runtime', 'wp-api-fetch', 'wp-components', 'wp-data', 'wp-dom-ready', 'wp-element', 'wp-i18n'), 'version' => 'a739b00e9b9ec0d3e2d7');
10 changes: 5 additions & 5 deletions build/blocks/rsvp/rsvp.js

Large diffs are not rendered by default.

4 changes: 4 additions & 0 deletions build/blocks/venue/block.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,10 @@
"mapHeight": {
"type": "number",
"default": 300
},
"mapCustomLatLong": {
"type": "boolean",
"default": false
}
},
"supports": {
Expand Down
2 changes: 1 addition & 1 deletion build/blocks/venue/index.asset.php
Original file line number Diff line number Diff line change
@@ -1 +1 @@
<?php return array('dependencies' => array('moment', 'react', 'react-jsx-runtime', 'wp-block-editor', 'wp-blocks', 'wp-components', 'wp-compose', 'wp-data', 'wp-date', 'wp-element', 'wp-i18n'), 'version' => '48c337124ea797af392b');
<?php return array('dependencies' => array('moment', 'react', 'react-jsx-runtime', 'wp-block-editor', 'wp-blocks', 'wp-components', 'wp-compose', 'wp-data', 'wp-date', 'wp-element', 'wp-i18n'), 'version' => '63c72435605fd4574135');
6 changes: 3 additions & 3 deletions build/blocks/venue/index.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion build/blocks/venue/venue.asset.php
Original file line number Diff line number Diff line change
@@ -1 +1 @@
<?php return array('dependencies' => array('react', 'react-jsx-runtime', 'wp-components', 'wp-data', 'wp-dom-ready', 'wp-element', 'wp-i18n'), 'version' => 'ac43be418ed67d7ea96a');
<?php return array('dependencies' => array('react', 'react-jsx-runtime', 'wp-components', 'wp-data', 'wp-dom-ready', 'wp-element', 'wp-i18n'), 'version' => 'f1a0db9e615d4c2f9bb7');
4 changes: 2 additions & 2 deletions build/blocks/venue/venue.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion build/profile_style.asset.php
Original file line number Diff line number Diff line change
@@ -1 +1 @@
<?php return array('dependencies' => array(), 'version' => '15d01c9dc99209264b1e');
<?php return array('dependencies' => array(), 'version' => 'b22085380615508e848f');
2 changes: 1 addition & 1 deletion build/profile_style.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion build/settings_style.asset.php
Original file line number Diff line number Diff line change
@@ -1 +1 @@
<?php return array('dependencies' => array(), 'version' => '9c37901c158173551201');
<?php return array('dependencies' => array(), 'version' => '84778738e904eca6ddf2');
2 changes: 1 addition & 1 deletion build/settings_style.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 4 additions & 0 deletions src/blocks/venue/block.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,10 @@
"mapHeight": {
"type": "number",
"default": 300
},
"mapCustomLatLong": {
"type": "boolean",
"default": false
}
},
"supports": {
Expand Down
57 changes: 54 additions & 3 deletions src/blocks/venue/edit.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,15 @@
import { __ } from '@wordpress/i18n';
import { InspectorControls, useBlockProps } from '@wordpress/block-editor';
import {
// eslint-disable-next-line @wordpress/no-unsafe-wp-apis
__experimentalNumberControl as NumberControl,
PanelBody,
PanelRow,
RadioControl,
RangeControl,
ToggleControl,
} from '@wordpress/components';
import { useSelect } from '@wordpress/data';
import { useDispatch, useSelect } from '@wordpress/data';
import { useEffect, useState } from '@wordpress/element';

/**
Expand All @@ -23,7 +25,7 @@ import { isVenuePostType } from '../../helpers/venue';
import VenueSelector from '../../components/VenueSelector';
import VenueInformation from '../../panels/venue-settings/venue-information';
import OnlineEventLink from '../../components/OnlineEventLink';
import { Listener } from '../../helpers/broadcasting';
import { Broadcaster, Listener } from '../../helpers/broadcasting';
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If you'd like to look at the store I created for updates to the Event Date block, you can start using that instead of the Listener / Broadcaster. If not, we can update to that later.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If you'd like to look at the store I created for updates to the Event Date block, you can start using that instead of the Listener / Broadcaster. If not, we can update to that later.

@mauteri Done.

import { isEventPostType } from '../../helpers/event';
import { getFromGlobal, isGatherPressPostType } from '../../helpers/globals';

Expand Down Expand Up @@ -60,7 +62,17 @@ const Edit = ({ attributes, setAttributes, isSelected }) => {
?.gatherpress_online_event_link
);

let { mapShow } = attributes;
let { mapShow, mapCustomLatLong } = attributes;
const editPost = useDispatch('core/editor').editPost;
const updateVenueMeta = (metaData) => {
const payload = JSON.stringify({
...venueInformationMetaData,
...metaData,
});
const meta = { gatherpress_venue_information: payload };

editPost({ meta });
};

let venueInformationMetaData = useSelect(
(select) =>
Expand Down Expand Up @@ -212,6 +224,45 @@ const Edit = ({ attributes, setAttributes, isSelected }) => {
min={100}
max={1000}
/>
<PanelRow>
{__('Latitude / Longitude', 'gatherpress')}
</PanelRow>
<PanelRow>
<ToggleControl
label={
mapCustomLatLong
? __('Use custom values', 'gatherpress')
: __(
'Use default values',
'gatherpress'
)
}
checked={mapCustomLatLong}
onChange={(value) => {
setAttributes({ mapCustomLatLong: value });
}}
/>
</PanelRow>
{mapCustomLatLong && (
<>
<NumberControl
label={__('Latitude', 'gatherpress')}
value={latitude}
onChange={(value) => {
Broadcaster({ setLatitude: value });
updateVenueMeta({ latitude: value });
}}
/>
<NumberControl
label={__('Longitude', 'gatherpress')}
value={longitude}
onChange={(value) => {
Broadcaster({ setLongitude: value });
updateVenueMeta({ longitude: value });
}}
/>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should have a button that will "Reset" the coordinates. Just call the button "Reset" and have it take the address and run it through the API again to bring back original values.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seems that the changes in lat/long are not being retained. I did some updates, but I don't think anything that should have effected functionality. It changes, but then when I leave focus, it reverts... It might be good to use the redux stores rather than Broadcaster/Listener as that may be the issue.

Copy link
Collaborator

@jmarx jmarx Nov 4, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should have a button that will "Reset" the coordinates. Just call the button "Reset" and have it take the address and run it through the API again to bring back original values.

toggling default/custom will now reset the map in way you are describing.
@mauteri

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seems that the changes in lat/long are not being retained. I did some updates, but I don't think anything that should have effected functionality. It changes, but then when I leave focus, it reverts... It might be good to use the redux stores rather than Broadcaster/Listener as that may be the issue.

We implemented the store. So all these issues should be resolved. @mauteri

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@jmarx I would like to add the Reset button. I get what you are saying, but that might not be super obvious to people. A reset button would be.

</>
)}
</PanelBody>
)}
</InspectorControls>
Expand Down