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

InfoClickWin: Fire event on click #286

Open
JakobMiksch opened this issue Apr 7, 2022 · 6 comments
Open

InfoClickWin: Fire event on click #286

JakobMiksch opened this issue Apr 7, 2022 · 6 comments

Comments

@JakobMiksch
Copy link
Collaborator

JakobMiksch commented Apr 7, 2022

Often it is needed to listen to the feature click event from other components in Wegue. Therefore, it would be desirable to fire an event once a feature is selected.

@ntma
Copy link
Contributor

ntma commented Apr 27, 2022

Hi @JakobMiksch ,

Is this issue already solved? I was about to take this issue but found out that there is a util/MapInteraction.js that probably does the intended:

selectClick.on('select', function (evt) {
WguEventBus.$emit(
'map-selectionchange',
layer.get('lid'),
evt.selected,
evt.deselected
);
});

@chrismayer
Copy link
Collaborator

Yes, IMHO this is exactly what is needed by this issue. But maybe @JakobMiksch could also confirm this.

One learning could be that an overview of the fired Wegue events should be listed somewhere. Maybe a markdown file as a simple start for this would work out as a first step.

@fschmenger
Copy link
Collaborator

Agreed, documenting on all the WguEventBus events sounds reasonable, if they are part of the public API we are going to rely on.
One of the things on my list to change is standardising the event signatures (could be done for the next Wgue major version). E.g. as an ad-hoc decision I sometimes coded the "event target" into the event name which is not a good design choice:

WguEventBus.$emit(this.moduleName + '-visibility-change', !this.show)
should rather become something like
WguEventBus.$emit('module-visibility-change', this.moduleName, !this.show)

@ntma
Copy link
Contributor

ntma commented Apr 28, 2022

I see, that seems fairly easy. To kick start this I did a quick search using WguEventBus.$.* and found the following events:

Event Parameters
app-mounted -
sidebar-scroll component
map-selectionchange lid, selected, deselected
ol-map-mounted olMap
ol-map-unmounted olMap
this.overlayId + 'update-overlay' visible, position, data
this.moduleName + 'visibility-change' visible

To complement the standardization @fschmenger, I was also wondering if the events:

  1. should use the same tense? (i.e.: app-mounted vs app-mount);
  2. anatomy should take the form of ${subject}-${verb} or any other fixed form? (i.e.: update-overlay would be overlay-update).

@fschmenger
Copy link
Collaborator

Yes, good catch. Another point would be to consistently relay event-targets either as an object or by it's id (only where applicable). So an argument can be made to change the event from above to

WguEventBus.$emit('map-selectionchange', layer, evt.selected, evt.deselected );
to be consistent with e.g. ol-map-mounted.

I propose we close the issue over here - if @JakobMiksch confirms - and move some of the content to a dedicated issue, e.g. "standardise event signatures"

@JakobMiksch
Copy link
Collaborator Author

JakobMiksch commented Apr 28, 2022

Yes, the original reason for my issue was in a custom application that added the layer later on. Therefore the SelectInteraction was not added automatically.
I agree with @fschmenger 's proposal to close this issue and create a new one with the overview of the events

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants