-
Notifications
You must be signed in to change notification settings - Fork 66
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
Group shields in legend by highway system #773
Conversation
After fetching labels from Wikidata, delete and regenerate any pending rows in the shield section of the legend.
9eedd40
to
2c3d446
Compare
At this location, console errors: |
This PR is specifically about grouping shields that belong to the same highway system but not the same This was implemented as part of #632. (Compare with The King’s Highway in Ontario.) This is an unrelated regression in the shield drawing code: #781.
Fixed. As of #632, whenever the legend encounters instances of a network with and without a We could suppress the duplicate shield whenever the shield definition’s Also #781. |
I concur with leaving #781 issues as a separate work item, and this will help highlight the bug when testing a fix for it. |
Co-authored-by: Josh Lee <[email protected]>
@@ -107,6 +115,9 @@ export default class LegendControl { | |||
for (let data of this.sections) { | |||
let section = this.getSection(data); | |||
if (!section) continue; | |||
if (data.id) { | |||
section.id = `legend-section-${data.id}`; |
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.
This whole flow is a little hard to read: The sections
property is assigned by the caller, one of its items has an id
of "shields"
, and then 569 lines later we query the document for this computed value.
Anyway, LGTM. Something to think about for a future refactor.
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 shield section is different from the rest of the legend in numerous ways, to the point that it requires a completely separate code path to generate it in the first place. I suppose it would be worth trying to consolidate the code paths somehow.
One of the differences is that the descriptions get replaced by Wikidata labels asynchronously. Originally, I intended to implement Wikidata labeling functionality for the whole legend, but I reconsidered in favor of eventually maintaining localizations of the static legend entries in this repository: #744. That work will most likely require us to assign an ID to each of the sections and each of their entries anyways.
Previously, all the description rows’ DOM elements, in every section, were obtained from a querySelectorAll()
call in open()
then plumbed through to prettifyNetworkLabels()
. But there’s nothing particularly special about this selector query. Making the element unique in the DOM allows us to query for it at any time. Instead of consolidating the shield section’s code path with the other section generation code, we could split it out into a separate class in a separate file, making it clearer that the shield section is more involved and independent from the rest of the legend.
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.
#782 tracks refactoring LegendControl
to be more digestible.
The legend now incorporates Wikidata labels into its “Route markers” section while generating the section, instead of patching in the labels afterwards. If the Wikidata Query Service response hasn’t come back by the time the section is generated, the legend blows away the section and regenerates it once it receives the response.
When generating the section, entries are now combined with other entries that correspond to the same highway system item in Wikidata. This improves the display of highway systems that haven’t been modeled in as much detail in Wikidata. More detailed highway systems continue to get separate rows with separate labels.
Fixes #771.