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
Add mazemap embed to events and meetings #2383
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Very good work.
A couple of comments. (I guess some of them apply to the previous work done by Tiril, but yeah, you'll get the credits and the blame) 😆
- (Major) When we select a
MazeMapRoom
, it's kinda wired that we also have to fill in the normalLocation
. I get that sometimes one wants to write something in both, but if the event is in R1, then themazemapPoi
field will be translated to R1, Realfagbygget so writing anything in the Location is wired. This is kind of a business-logic problem, but something that should be addressed. I think the solution is to make the fields co-required, meaning at least one has to be filled in. - (Minor) When selecting a room in a create or edit view the map is not visible. I can see arguments in favor of hiding a map in this view. But, when trying to select kinky rooms it could be nice to see that the correct room is selected. We could add the Åpne kart i ny fane label under, so the creator can open the map to check that the correct room was selected.
I think the red looks great 👍🏻 Maybe @ivarnakken has some nit-picking 😆
yeah, I agree that showing the embedded map can be a bit much. I was thinking a link, or a "Open in new window icon" like this: |
That is an elegant solution. |
I've just added a toggle that switches between mazemap/location fields. Someone more familiar with redux forms might be able to simplify this code, but it seems to work correctly. |
{ | ||
// TODO: Bug; meeting is not updated when the field above is changed, so the link | ||
// will go to whatever room mazemapPoi was set to when the editor was opened | ||
/*meeting.mazemapPoi > 0 && ( | ||
<MazemapLink mazemapPoi={meeting.mazemapPoi} linkText="↗️" /> | ||
)*/ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In the editor for events, I've also added a small icon to link externally to mazemap for the given poi, but I couldn't make this work for meetings due to meeting
not updating on every change to the field, like event
does in the event edtior. I've left this as a comment for now.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The reason for this is that the state of the form (both the event and the meeting, is stored in the form
state in redux. This is extracted for each of the editors, so that we can use the current form values in the components again.
If you look in the EventEditRoute
, in the mapStateToProps
, you can see that the event
prop consists of the current event
and all the values from the event form overriding any properties. This is the valueSelector
that is used.
You can also see in the MeetingEditRoute
that the valueSelector is used to get the invitingUsers
. So if you want to use the current mazeMapPoi
form value, just override that prop on the meeting
object with the one from the valueSelector just as you have done with events. Then this should work great 😄
You can now toggle between location textfield and mazemap
and moved hooks to more appropriate location
Maybe drone can find mazemap now (?)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM 👍🏻
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good to me! 😍
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice work! This is a really great feature 👍. Just fixup the comment/TODO in the meeting editor and make sure SSR is good then we can merge this.
{ | ||
// TODO: Bug; meeting is not updated when the field above is changed, so the link | ||
// will go to whatever room mazemapPoi was set to when the editor was opened | ||
/*meeting.mazemapPoi > 0 && ( | ||
<MazemapLink mazemapPoi={meeting.mazemapPoi} linkText="↗️" /> | ||
)*/ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The reason for this is that the state of the form (both the event and the meeting, is stored in the form
state in redux. This is extracted for each of the editors, so that we can use the current form values in the components again.
If you look in the EventEditRoute
, in the mapStateToProps
, you can see that the event
prop consists of the current event
and all the values from the event form overriding any properties. This is the valueSelector
that is used.
You can also see in the MeetingEditRoute
that the valueSelector is used to get the invitingUsers
. So if you want to use the current mazeMapPoi
form value, just override that prop on the meeting
object with the one from the valueSelector just as you have done with events. Then this should work great 😄
Oh, if that's the case I guess you can merge it.😁
________________________________
From: Ludvig Hozman ***@***.***>
Sent: Tuesday, February 8, 2022 10:18:59 PM
To: webkom/lego-webapp ***@***.***>
Cc: Olav Kihle ***@***.***>; Mention ***@***.***>
Subject: Re: [webkom/lego-webapp] Add mazemap embed to events and meetings (PR #2383)
@LudvigHz commented on this pull request.
________________________________
In app/components/MazemapEmbed/index.js<#2383 (comment)>:
+ embeddedMazemap.zLevel = poi.properties.zLevel;
+ };
+
+ const height = embeddedMazemap.getCanvas().clientHeight;
+ const maxHeight = height - 50; // 50 pixels account for margins and spacing
+ embeddedMazemap.zLevelControl.setMaxHeight(maxHeight);
+ });
+ }, [mazemapPoi]);
+
+ return (
+ <>
+ <div style={{ height: props.height || 400 }} id="mazemap-embed" />
+ <MazemapLink mazemapPoi={mazemapPoi} linkText={props.linkText} />
+ </>
+ );
+};
Soo, I just tested this with the latest from your branch, and both events and meetings seem to work just fine? 🥲
Note that sometimes just after you start up the server, you might need to hard refresh a couple times before it's completely stable (due to caching and some weird states and all that). But anyways, this looks really good now. And afaikt this is good to go!
—
Reply to this email directly, view it on GitHub<#2383 (comment)>, or unsubscribe<https://github.com/notifications/unsubscribe-auth/APKFRHL4MBP77PJSDA6O7KLU2GCEHANCNFSM5K6GAVNA>.
Triage notifications on the go with GitHub Mobile for iOS<https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675> or Android<https://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub>.
You are receiving this because you were mentioned.Message ID: ***@***.***>
|
Actually, hold that thought. It seems that for me, joblistings is broken with the |
Could it be in or related to |
See my latest reply in the thread here: #2383 (comment) |
const { Mazemap } = this.state; | ||
const handleSearch = (query: string): void => { | ||
if (!query || !Mazemap) { | ||
return; | ||
} | ||
const mazemapSearchController = new Mazemap.Search.SearchController({ | ||
campusid: 1, | ||
rows: 10, | ||
withpois: true, | ||
withbuilding: false, | ||
withtype: false, | ||
withcampus: false, | ||
resultsFormat: 'geojson', | ||
}); | ||
this.setState({ | ||
searching: true, | ||
}); | ||
mazemapSearchController | ||
.search(query) | ||
.then((results) => { | ||
if (this._isMounted) { | ||
this.setState({ | ||
result: results.results.features.map((result) => | ||
mapRoomAndBuildingToResult( | ||
result.properties.dispPoiNames[0], | ||
result.properties.dispBldNames[0], | ||
result.properties.poiId | ||
) | ||
), | ||
}); | ||
} | ||
}) | ||
.finally(() => { | ||
if (this._isMounted) { | ||
this.setState({ searching: false }); | ||
} | ||
}); | ||
}; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hmm, why did you move these methods into render()
? This will make every render heavier as it sets up new functions for every render and not when creating the component as before.
Also, it's probably alot better to initialize the Mazemap.Search.SearchController
only once in the mount when you do the import, and rather store that in state instead of the entire Mazemap lib, since it seems that that's the only thing used here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good questions all around, I've done some cleanup and moved the methods back out of render(), in what is hopefully the final™ commit on this pr.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice! 🚀 🚀 🚀
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LTGM! 💯 But it seems like there are some small flow problems
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great!
Adds a map to the sidebar of events and meetings if the event or meeting has mazemapPoi set,
and adds fields to the edit pages to be able to search for rooms and set the mazemapPoi.
Solved the jest/test issues by bundling mazemap as a node module instead of in pageRenderer, based on this.
Minor issue:
The saved room is not shown in the field, but is shown in the dropdown, because I have not figured out how to fetch the name of the room when EventEditRoute is rendering.^ Fixed by using location saved on server
Oh, and this is also based on Tirils prior work in pr #1680
Screenshot for anyone curious