< 162022-06-17⋎18 >

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
04:13*farmBOT has joined
08:31*margeo[m] has joined
11:58mstenta[m]paul121 symbioquine Huh... the MariaDB scheduled test run failed again last night: github.com/farmOS/farmOS/runs/6932792179
11:59mstenta[m]Same error as we were seeing earlier...
12:00mstenta[m]On a related note, I found this documentation about running tests against SQLite3 (reminded me of the old issue we had with that during parallel runs): www.drupal.org/docs/automated-testing/ph
12:00mstenta[m]Not sure if there's any new information there... need to grok.
13:37mstenta[m]symbioquine: I'm trying to write a farmOS-map behavior that *modifies* the geometry of an existing layer. Looking for an example to work from (been a while since I've touched the JS side of stuff, I forget what's possible). Do you have any prior work on this? Or an example that comes to mind?
13:38mstenta[m]Specifically: a behavior that watches two lat / lon text fields, and auto-updates a layer in a map.
13:38symbioquine[m]mstenta[m]: Should be easy...
13:39mstenta[m]Trying to remember how to get the relevant layer... `getLayerByName()`?
13:39symbioquine[m]You just do the normal HTML/JS input watching part, then query the layer -> source
13:39symbioquine[m]and update the geometry of the relevant feature
13:40symbioquine[m]I bet I can find an example...
13:40mstenta[m]Yea that part makes sense I think... stuck on getting the layer in the first place 😅
13:41symbioquine[m]github.com/symbioquine/farmOS_land_drawi
13:41symbioquine[m]openlayers.org/en/latest/apidoc/module-o
13:41mstenta[m]ah ok so get all layers and iterate through them to find the one i want
13:42symbioquine[m]github.com/symbioquine/farmOS_land_drawi
13:43symbioquine[m]symbioquine[m]: Obviously, there might be better ways to identify the layer you want - if you've "tagged" it somehow in a more machine readable way.
13:43mstenta[m]ah looks like we have a helper!
13:43symbioquine[m]That code I just linked would probably break if "All Locations" were translated to another language
13:43mstenta[m]github.com/farmOS/farmOS-map/blob/777758
13:44mstenta[m]But yea agreed - going by name is a bit sketchy
13:44mstenta[m]But IIRC there wasn't really a better way to do this
13:46symbioquine[m]Layer objects can have arbitrary properties so we could add a way to set a "farm_layer_id" key or something like that to facilitate machine identification.
13:46symbioquine[m]openlayers.org/en/latest/apidoc/module-o
13:46mstenta[m]Ooh that would be nice
13:49mstenta[m]Thanks for the pointers! I think I'm on my way now :-)
13:50symbioquine[m]github.com/symbioquine/farmOS_land_drawi
13:53symbioquine[m]I think it would be something like; `myFeature.setGeometry(new Point([123, 456], 'XY'));`
13:54symbioquine[m]or maybe more efficient to modify the existing `Point` objects geometry - but it probably doesn't matter.
13:54mstenta[m]cool!
13:55symbioquine[m]s/objects/object's/
13:55mstenta[m]might write this up as a blog post ;-) (cc jgaehring )
13:55mstenta[m]as an example of `farm_map_input` + custom behavior in form api
13:55mstenta[m]with a "How To" tag ludwa6
14:24mstenta[m]> I think it would be something like; `myFeature.setGeometry(new Point([123, 456], 'XY'));`
14:24mstenta[m]hmmmm I may end up running into the limitation we've discussed in the past... inside my behavior I don't have access to all the OL objects
14:24mstenta[m]i'm trying to do:... (full message at libera.ems.host/_matrix/media/r0/downloa)
14:25symbioquine[m]A work-around would be to initially add the layer with a single point using WKT/GeoJSON, then get/modify the point
14:25mstenta[m]:-(
14:26paul121[m]since it is just a point, could you manually build the WKT for the point and update the layer's WKT on change?
14:26mstenta[m]i'm starting without any existing geometry
14:27symbioquine[m]paul121[m]: You shouldn't need to do that
14:27symbioquine[m]You'd just use the WKT/GeoJSON loading as a work-around to get `Feature`/`Point` instances created
14:28symbioquine[m]Then you can set the coordinates of that `Point` just fine without any further imports
14:29symbioquine[m]I think it can just be `"POINT (0 0)"`
14:29mstenta[m]but then the map in my form starts with that point
14:29symbioquine[m]ah
14:30paul121[m]could it be an empty WKT string?
14:30paul121[m]to start
14:30symbioquine[m]doubtful
14:30mstenta[m]yes, but then i can't add any features, because I don't have access to the OL `Point` object in my behavior context
14:31mstenta[m]this is a bigger issue we need to figure out
14:31symbioquine[m]`map.getView().getCenter()`
14:31mstenta[m]oh clever :-)
14:31symbioquine[m]mstenta[m]: Might need to happen after the view extent updates though
14:32symbioquine[m]mstenta[m]: One answer is to build the behavior against OpenLayers, then it can bundle any classes it needs.
14:32symbioquine[m]That's what my Land Drawing tool does
14:33paul121[m]This is a throwback to v1, what we did was re-build the WKT layer when updating the geometry. github.com/farmOS/farmOS/blob/509cfb2e92
14:33paul121[m]its not "perfect" but works fine
14:34mstenta[m]ok yea that could work paul121
14:35mstenta[m]trying symbioquine's suggestion first...
14:38mstenta[m]> `map.getView().getCenter()`
14:38mstenta[m]hmm seems like this actually returns an array not a `Point` object :-/
14:41symbioquine[m]> <@mstenta:matrix.org> > `map.getView().getCenter()`
14:41symbioquine[m]>
14:41symbioquine[m]> hmm seems like this actually returns an array not a `Point` object :-/
14:41symbioquine[m]Oh, I meant using that to populate the initial WKT/GeoJSON
14:41mstenta[m]oh oh gotcha
14:43mstenta[m]well anyway - this was a bit of a tangent... i need to focus on getting the form element branch done first
14:44mstenta[m]symbioquine paul121 would you have any interest in taking a quick look in 15 minutes to provide thoughts on what i've done?
14:44mstenta[m]i'm hoping to merge this asap, but want to make sure you have a chance
14:44symbioquine[m]I'm up for it
14:44paul121[m]I won't be available for a few hours :-/
14:44paul121[m]but can look after!
14:45mstenta[m]ok - maybe i'll do a quick pass with Morgan and then push the branch for your review paul121
14:45mstenta[m]i have to take over with kids at at noon eastern
14:45mstenta[m]but might be able to jump in again, just hard to predict
14:56symbioquine[m]meet.jit.si/farmos-dev when you're ready :)
14:57mstenta[m]cool - on a call at the moment - will join as soon as it's done
14:57symbioquine[m]no rush
15:01mstenta[m]paul121: the only bit I didn't get to was the array/string return
15:01mstenta[m]but i think if you and i looked at that together we might be able to knock it out quick
15:02paul121[m]ah yea. we should decide one way or the other, pretty important. But using that validate trick should work! Just need to make sure it doesn't break the GeofieldWidget
15:02mstenta[m]that's what i ran into... `GeofieldWidget` broke
15:03mstenta[m]but might be easy to fix
15:03mstenta[m]with your eyes :-)
15:03paul121[m]oh dang. well, I believe it has some kind of method we could implement to pull out the correct value
15:03mstenta[m]ah ok
15:03mstenta[m]maybe Morgan and I can take a look
15:04mstenta[m](still waiting for this call to end symbioquine ) :-)
15:04symbioquine[m]mstenta[m]: np
15:05symbioquine[m]mstenta[m]: I'll try... some of the Drupal form/render API stuff is still a second language to me
16:38*elpronto[m] has joined
17:32mstenta[m]twitter.com/vordude/status/1537458665044
18:37FarmerEd[m]I'd say it's a very niche market for those T-shirts
19:26mstenta[m]symbioquine: paul121 made the (obvious in hindsight) point that #edit is redundant/unnecessary. Just use farm_map instead of farm_map_input
20:07symbioquine[m]hmmm, interesting
20:08symbioquine[m]What about something like a "confirm submission" page where you want to show the same UX as the input field, but just not editable?
20:08symbioquine[m]How is that handled for other input elements? Is there some `#disabled` argument it should be honoring?
20:09mstenta[m]Hmm I guess it would depend on the situation, but `farm_map` elements take the same properties as `farm_map_input` - they just don't enable editing. So I think you could still just use `farm_map` in that case?
20:10mstenta[m]And have the same UX (if I understand what you mean)
20:10mstenta[m](same `#behaviors` and `#map_settings`)
20:11symbioquine[m]They don't have the same UX though right? I thought `farm_map_input` has the option of showing the raw geometry but `farm_map` doesn't...
20:11mstenta[m]That's true
20:12mstenta[m]> Is there some #disabled argument it should be honoring?
20:12mstenta[m]Maybe this is the correct approach
20:12symbioquine[m]api.drupal.org/api/drupal/core%21lib%21D
20:13symbioquine[m]There is `#disabled`
20:13mstenta[m]If `#disabled` is set to `TRUE` then also disable the textfield/hidden input, and don't allow submitting changes in validation
20:13paul121[m]Ah yea, if you wanted to render a map and show the raw geometry, that could be nice
20:13paul121[m]but then it isn't an "input" right?
20:13symbioquine[m]It still is
20:13symbioquine[m]This is the same pattern as how HTML `<input>` can be disable
20:13symbioquine[m]s/disable/disabled/
20:13mstenta[m]Well stepping back from all of this, I think you're just generally right symbioquine that we need to respect `#disabled`
20:13mstenta[m]Yea
20:13symbioquine[m]You don't just tell folks to use a `<span>` or a `<p>` just because they don't want the user to edit it.
20:14paul121[m]huh, there is `#disabled` too, maybe?
20:14mstenta[m]And if we don't, then `#disabled` won't actually disable our element
20:14symbioquine[m]mstenta[m]: And if we respect disabled, I'm all for not having `#edit` :)
20:15mstenta[m]Makes sense. I'll remove the `#edit` commit and add one that adds support for `#disabled`
20:16mstenta[m]This WILL also disable the edit controls - I think it would have to
20:16mstenta[m]So basically the same as `#edit`, functionally... but only using the core `#disabled` property
20:16symbioquine[m]yep
20:16mstenta[m]That's all around cleaner
20:16symbioquine[m]kind of the reverse of `#edit`, but yeah
20:17mstenta[m]yea :-)
20:18symbioquine[m]I don't understand why `FormElement` also has `#input` though...
20:18symbioquine[m]> `#input`: (**bool**, internal) Whether or not the element accepts input.
20:19mstenta[m]Maybe that means "this accepts input" generally, but `#disabled` is used more case-by-case
20:19mstenta[m]eg: a disabled textfield might not always be disabled but textfields always accept input
20:19symbioquine[m]ah
20:19paul121[m]I can't find the equivalent of this page for D8+, but it is quite nice... api.drupal.org/api/drupal/developer%21to
20:19mstenta[m]can't think of an opposite example
20:19mstenta[m]Yea I miss that reference in D8+ :-)
20:19paul121[m]doesn't exist??
20:20mstenta[m]Haven't seen it anywhere
20:26mstenta[m]> If `#disabled` is set to `TRUE` then also disable the textfield/hidden input, and don't allow submitting changes in validation
20:26mstenta[m]oh actually looks like Drupal handles this itself - we don't need extra validation
20:26symbioquine[m]ah, cool
20:27mstenta[m]it doesn't throw an error - it just doesn't use the overridden value
20:27mstenta[m]which is perfect
20:27symbioquine[m]cool
20:27mstenta[m]nice simple commit :-)
20:27mstenta[m]will share a link shortly...
20:31mstenta[m]github.com/mstenta/farmOS/commit/bf49a1d
20:32mstenta[m]Alright... last bit is the string/array thing... paul121 and I looked at it together but the fix wasn't obvious. I think we came to the conclusion that the `password_confirm` element is not a great example to work from, because it's ONLY a form element... not used in a Field API widget. So the approach it takes may not translate to our case.
20:35symbioquine[m]<mstenta[m]> "Maybe that means "this accepts..." <- I think it is used [here in `FormBuilder.php`](github.com/drupal/drupal/blob/515d10367b)
20:40paul121[m]<mstenta[m]> "Alright... last bit is the..." <- just thinking....... our current `GeofieldWidget` uses `value` in those places because *it was creating a `value` element in the form before*.... we've now pulled this piece out into `farm_map_input`....
20:40paul121[m]doesn't solve this issue but might help understand why that is there
20:42mstenta[m]ah hmm
20:42mstenta[m]could we... move `value` to the root `$element`?
20:42mstenta[m]and somehow stick `farm_map` in too?
20:44mstenta[m](thinking outside the box - pun intended)
20:45mstenta[m]i gotta sign off for the evening...
20:50paul121[m]yea that is the crux of this issue, we're so close :-/
22:14paul121[m]really weird, if you remove both `#tree` and `#input` from the form element it works. even in GeofieldWidget
22:14paul121[m]but then it returns an empty array `[]` when no data is submitted
22:15paul121[m]don't fully understand

< 162022-06-17⋏18 >