< 222022-09-23⋎24 >

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
02:03evered[m]Thanks y'all. Love and blessings to the team. Botanic Gardens was "lovely" today.
06:12skipper_is[m]It was because it had started life as a quickform, and had the farm_quick name, changed it and straight away worked
12:57mstenta[m]Ah great! Glad you figured it out skipper_is
16:13skipper_is[m]Yea, id10t error :)
18:05skipper_is[m]Trying to pull out the tag_ids. trying
18:05skipper_is[m]> $tag_id = $entity_wrapper_field_farm_animal_tag_id->value();
18:05skipper_is[m] Is this the right approach? Or is it an entity metadata wrapper?
18:08skipper_is[m](I've made a typo, it should be $entity_wrapper->field*
18:15skipper_is[m]Or should I use farm_asset_property_get on `field_farm_animal_tag_id_value` ?
18:39mstenta[m]skipper_is: I have deleted the 1.x code from my brain to free up space 😅
18:40mstenta[m]ID tags were a "field collection" iirc
18:40mstenta[m]Which means they were technically a separate entity referenced by the animal asset
18:41mstenta[m](If that helps at all. im on my phone so cant look closer right now)
18:41skipper_is[m]No worries. I'm now trying to figure out how to handle a field collection :)
18:47mstenta[m]field_collection_load($id) should work... just need the id
18:47mstenta[m]Which is referenced from the animal
18:47mstenta[m]Maybe grep for other examples of that
18:48skipper_is[m]The $id of the asset? or the field collection id?
18:49mstenta[m]FC
18:49mstenta[m]Not asset
19:05skipper_is[m]And to get the id of the fc, is that through the entity metadata wrapper of the asset?
19:06mstenta[m]Yea should be able to
19:06mstenta[m]There might be an easier way I forget
19:07mstenta[m]One sec gonna see if I can find an example... on my phone waiting to pick up kid from school :-)
19:12mstenta[m]Something like that
19:12mstenta[m]github.com/farmOS/farmOS/blob/509cfb2e92
19:12mstenta[m]That's for loading a movement field collection, but same idea
19:15skipper_is[m]Gotcha, so field_collection_item_load($entity_metadata_wrapper->field_farm_animal_tag),
19:15skipper_is[m]Just need to find what sub-arrays its under
19:34skipper_is[m]Debug:
19:34skipper_is[m]'UK175206 141'
19:34skipper_is[m]Yes!
20:10skipper_is[m]And now it exports CSV! Good times! Right, leave it on a roll! Goodnight all
20:16*farmBOT has joined
22:38paul121[m]symbioquine mstenta curious if either of you have thoughts on this AJAX map chunk loading issue: www.drupal.org/project/farm/issues/32439
22:39symbioquine[m]I've thought about it some...
22:39paul121[m]it was some time ago when we first discovered and there isn't much in the issue about potential solutions :-)
22:40symbioquine[m]The strategy I'm using for Asset Link may be an option. i.e. using a controller to dynamically set the path from which the chunks should be loaded as part of serving the JS library.
22:41symbioquine[m]The problem is I'm not sure how to do it without forcing all consumers of the library to use a similar strategy
22:43symbioquine[m]github.com/symbioquine/farmOS_asset_link
22:43symbioquine[m]github.com/symbioquine/farmOS_asset_link
22:45paul121[m]so `"/__THIS_GETS_REPLACED_AT_RUNTIME_BY_THE_DRUPAL_CONTROLLER__/"` ends up in the built JS?
22:45symbioquine[m]I also didn't see an easy way to use Drupal's library system out of the box. i.e. how do you say "this library entry-point is served by this controller/route" and have it take into account the current base path of the site
22:45symbioquine[m]paul121[m]: yes
22:46symbioquine[m]and gets replaced by the PHP code as it serves the JS entry-point/chunks
22:47paul121[m]ah yea, it needs to do it in each chunk
22:47symbioquine[m]symbioquine[m]: `.libraries.yml` clearly allows you to specify a URL for the library, but I didn't see a way to make it relative to the site's base path
22:47symbioquine[m]paul121[m]: maybe, I'm not totally sure if the path gets embedded into chunks other than the entry-point
22:47paul121[m]symbioquine[m]: ahhh interesting! the URL property might only be picked up if you set `external: true`
22:48paul121[m]that would be a clever approach
22:49symbioquine[m]Yeah, I thought so. But the documentation is pretty lacking as to if/how the url can point at the current site or a PHP controller therein
22:52symbioquine[m]symbioquine[m]: It looks like it gets embedded in a number of files that I'm pretty sure aren't entry-points
22:52paul121[m]I imagine you have read this, just sharing here... "Dynamically generated css and js" www.drupal.org/docs/creating-modules/add
22:53paul121[m]> In the case of dynamic JS: please consider using configurable JavaScript instead, that is almost always the much better choice.
22:54paul121[m]could we write something that lets `publicPath` be configured in global JS?
22:55paul121[m]and let the `farm_map.js` specify the value?
22:57symbioquine[m]Supposedly, there's a way to set the public path at runtime by setting `__webpack_public_path__` but I haven't succeeded when I've experimented with it in the past...
22:58symbioquine[m]stackoverflow.com/questions/39879680/exa
22:58paul121[m]ohh just came across that
22:58symbioquine[m]webpack.js.org/guides/public-path/#on-th
23:13paul121[m]<symbioquine[m]> "Supposedly, there's a way to set..." <- stackoverflow.com/a/51245153
23:13paul121[m]seems like explicitly setting that in `app.js` is important. do you know if you tried that?
23:13paul121[m]I can give it a spin
23:14paul121[m]`app.js` == `main.js` for farmOS-map I believe
23:16symbioquine[m]I can't recall exactly what approaches I've tried, just that I remember experimenting with it in the past.
23:31paul121[m]okay, here is a start... adding this to line 1 of `main.js` works!
23:31paul121[m]```
23:31paul121[m]__webpack_public_path__ = '/libraries/farmOS-map/';
23:31paul121[m]```
23:33paul121[m]now to try something like:... (full message at <libera.ems.host/_matrix/media/r0/downloa>)
23:35paul121[m]Seems to be working!!
23:37symbioquine[m]Huh, that's cool
23:43paul121[m]and we can populate this with a simple drupal JS library that the real `farmOS-map.js` entrypoint library depends on:... (full message at <libera.ems.host/_matrix/media/r0/downloa>)
23:44symbioquine[m]Two problems with that part...
23:44paul121[m]now to not hard-code the `/libraries-farmOS-map/` ... Drupal must have a way to get that path, know off the top of your head?
23:45symbioquine[m]No :(
23:45symbioquine[m]The Drupal base path could be different and maybe even the library install path.
23:47symbioquine[m]That's why the controller strategy seems pretty elegant - is sidesteps those issues
23:48paul121[m]That's true
23:50paul121[m]I wonder if you could define a route in its place?
23:51paul121[m]Still make the library definition, but then override the path with a route/controller?
23:52paul121[m]<paul121[m]> "I imagine you have read this..." <- they say here:
23:52paul121[m]> If the dynamic CSS/JS is built for each request, then you enter the truly advanced territory. This is hard, and for a good reason: per-request dynamic assets have to be built on every single request and therefore slow Drupal down. We want to make it hard to make Drupal slow down, so this is why we don't offer a nice API for this — since we don't want you to do it.
23:52paul121[m]It is possible though. In the case of dynamic JS: please consider using configurable JavaScript instead, that is almost always the much better choice.
23:56mstenta[m]What if we cache the path to the library file in Drupal state, and use that wherever we load the lib. Then it would point to the static file so Drupal wouldn't be used to fetch it (faster load) but it would still allow for dynamically determining the path to the file.
23:58mstenta[m]I don't know *how* exactly we "use that wherever we load the lib"... :-)

< 222022-09-23⋏24 >