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