< 042023-05-05⋎06 >

Topic for #farmOS is: farmOS (farmos.org) is a free and open source, web-based farm management system. User guide: farmos.org/guide/ - Forum: farmOS.discourse.groupSet by mstenta on 2021-06-15 at 12:52
19:33mstenta[m]symbioquine paul121 I think I found a small bug, curious your thoughts...
19:33mstenta[m]github.com/farmOS/farmOS/blob/a13a0de10a
19:33mstenta[m]Should that be passing element.id instead of element to farmOS.map.create()?
19:34mstenta[m]I discovered this because I was trying to use farmOS.map.targetIndex(id) to look up an instance by ID, but it didn't work... because instance.target was being set to the whole element instead of just the ID
19:35mstenta[m]Changing element to element.id fixed it... and everything seems to be working. I can open a PR, I just wanted to check to see if you think that's correct, or if there are any other considerations...
19:42paul121[m]huh, yeah that makes sense. i didn't realize we had that farmOS.map.targetIndex() helper
19:43paul121[m]I guess OL must accept an ID or the actual element?
19:49mstenta[m]Yea I guess so
20:09symbioquine[m]No, it's better for that function (createMapInstance) to accept the element not the id. That means it can be used in scenarios where the target element doesn't have an id - e.g. a map instance creating by Vue/React/etc.
20:10symbioquine[m]Otherwise, you'd be forced to generate some kind of id just to use the function where you wouldn't otherwise need one - e.g. multiple instances of maps on the same page or maps within dialogs that are created/dismissed in an ad hoc manner.
20:12symbioquine[m]Passing the HTMLElement is one of the standard ways of instantiating a OL Map object: openlayers.org/en/latest/apidoc/module-o
20:13mstenta[m]Ah hmm OK so maybe we need to rethink farmOS.map.targetIndex()
20:14mstenta[m](Or remove it entirely)
20:14symbioquine[m]Do we?
20:14symbioquine[m]It looks like the only thing that needs updating is the doc string for the fn...
20:14symbioquine[m]github.com/farmOS/farmOS-map/blob/4e3800
20:14symbioquine[m]Should also work if passed an element right?
20:15mstenta[m]Yea maybe
20:15symbioquine[m]I'd need to test, but I think comparing element instances with === should work.
20:17symbioquine[m]github.com/symbioquine/farmOS_land_drawi
20:18mstenta[m]Just to clarify, I wasn't suggesting we change what's passed to Drupal.behaviors.farm_map.createMapInstance() - that would still be an element
20:19mstenta[m]Here's the PR I opened (just before I saw your chats): github.com/farmOS/farmOS/pull/672
20:19symbioquine[m]^ Assumes the passed element has an id though.
20:19mstenta[m]That's true - that was the original assumption in farmOS-map, but no longer necessary I guess
20:19mstenta[m](Back when targetIndex() was added)
20:20mstenta[m](Closed that PR)
20:20symbioquine[m]mstenta[m]: Agreed. Seems like there's actually a few places in the farmOS-map docs that should be updated to reflect that we just pass the input through to OL - thus can accept the same argument types.
20:23mstenta[m]> I'd need to test, but I think comparing element instances with `===` should work.
20:23mstenta[m]Confirmed that this works 👍️
20:27toino[m]Wtf
20:27symbioquine[m]> <@mstenta:matrix.org> > I'd need to test, but I think comparing element instances with `===` should work.... (full message at <libera.ems.host/_matrix/media/v3/downloa>)
20:28symbioquine[m]^ Tested the scenario that === doesn't somehow depend on having an id set for HTMLElement.
23:28*farmBOT has joined

< 042023-05-05⋏06 >