IRC logs for #farmOS, 2022-05-25 (GMT)

2022-05-24
2022-05-26
TimeNickMessage
[21:28:36]<mstenta[m]>paul121: FYI I opened this issue https://www.drupal.org/project/farm/issues/3282186
[21:28:54]<mstenta[m]>if you have any insights on this can you add them there when you have a chance?
[21:31:24]* coralgoat has left #farmos (Leaving)
[05:00:11]* AllanMacGregor[m has quit (Quit: You have been kicked for being idle)
[05:00:16]* kunigunde[m] has quit (Quit: You have been kicked for being idle)
[05:00:17]* oliverp44[m] has quit (Quit: You have been kicked for being idle)
[05:06:30]* farmBOT has quit (Ping timeout: 240 seconds)
[05:06:53]* farmBOT has joined #farmos
[10:32:37]<MarcosCarballal[>Hi all, I am working on re-creating this figma page (https://www.figma.com/proto/Qphf9J98kT8oBovPzRnE8W/UX-Artifacts?node-id=...) using the Forms API. I am struggling to find a reasonable way to accomplish the "Add another Contact" button, which needs to manipulate the form to allow for another contact input.
[10:32:38]<MarcosCarballal[>I am using the $form_state with some custom attributes to store the state of how many contacts are currently on the screen, but I think I am doing it wrong. Happy to share my code or do a brief call if possible.
[10:35:56]<mstenta[m]>Marcos Carballal: you need `#ajax` :-)
[10:36:08]<MarcosCarballal[>Yes I am using ajax
[10:36:12]<MarcosCarballal[>Just incorrectly 😆
[10:36:20]<mstenta[m]>I'm not at my computer right now
[10:36:35]<mstenta[m]>There is an example in farmOS
[10:36:46]<mstenta[m]>In the planting quick form
[10:36:57]<mstenta[m]>Maybe also in the drupal examples module
[10:38:28]<MarcosCarballal[>https://api.drupal.org/api/examples/form_api_example!src!Form!AjaxAddMor... I was basing my solution off of this one.
[10:39:00]<mstenta[m]>If you can share your code somewhere I can take a look
[10:41:31]<MarcosCarballal[>https://pastebin.com/LE10swvr
[10:45:03]<MarcosCarballal[>Interesting bit on line 242. I had (i < $form_state->get('num_lines') but it wasn't rebuilding how I was expecting to
[10:45:15]<mstenta[m]>This is going to be difficult to read on my phone :-)
[10:45:50]<MarcosCarballal[>Haha all good. It is not urgent.
[10:45:56]<mstenta[m]>I might recommend deleting everything (temporarily) but the part you're working on. Get it working simply (like the example) first and build up from there
[10:46:30]<mstenta[m]>Maybe even just copy the example into your code, make sure that works, then iterate on it till it does what you want
[10:49:28]<MarcosCarballal[>I'll give that a shot.
[12:36:49]<MarcosCarballal[>Okay I think that I now have a more specific issue. So I did as you suggested and started with the example form. I was able to get an add/delete setup that makes the fields just fine. However, when I try and bring in some data from the database to populate the drop-down, it breaks the "Add another button" with the... (full message at https://libera.ems.host/_matrix/media/r0/download/libera.chat/a4df7aadb7...)
[12:37:34]<MarcosCarballal[> * Okay I think that I now have a more specific issue. So I did as you suggested and started with the example form. I was able to get an add/delete setup that makes the fields just fine. However, when I try and bring in some data from the database to populate the drop-down, it breaks the "Add another button... (full message at https://libera.ems.host/_matrix/media/r0/download/libera.chat/5ec1513a9a...)
[14:14:20]<mstenta[m]>Hi Marcos Carballal - just sat down at my computer... catching up...
[14:16:23]<mstenta[m]>Is the pastebin still relevant? Or could you share your updated code?
[14:22:39]<MarcosCarballal[>I can make another paste bin
[14:23:05]<MarcosCarballal[>https://pastebin.com/nGQ37CB4
[14:23:26]<mstenta[m]>ahh much better on a big screen :-)
[14:23:41]<MarcosCarballal[>This bit of code doesn't have the same symptoms
[14:24:14]<mstenta[m]>The pastebin doesn't have the same symptoms you described above?
[14:24:30]<MarcosCarballal[>But if for example `getAwardeeContactNameOptions()` is changed to look like `getAwardeeOptions()` (grabbing dynamically form db) then those symptoms will show
[14:25:10]<mstenta[m]>Might be hard to understand via chat. Do you have any time to look at it together?
[14:25:42]<MarcosCarballal[>Yes I do
[14:26:00]<mstenta[m]>Hop into the Jitsi room? https://meet.jit.si/farmos-dev
[14:26:16]<MarcosCarballal[>In
[14:33:23]<MarcosCarballal[>https://meet.google.com/coh-okrp-iyn
[15:00:51]<mstenta[m]>Marcos Carballal: here's the link I was thinking of regarding caching: https://www.drupal.org/node/2598914
[15:01:26]<mstenta[m]>There's a lot of layers in Drupal (good for users, bad for developers), so that outlines a lot of the details and shows how to disable everything
[15:01:50]<mstenta[m]>Tbh I haven't really grokked it all myself in D8/9 and still lean heavily on `drush cr` 😅
[15:02:11]<mstenta[m]>(aka the cache sledgehammer)
[15:02:53]<mstenta[m]>But I also haven't done a ton in the theming layer personally (I did in earlier Drupal versions for other projects, but farmOS + Gin doesn't need much from me)
[15:29:34]<MarcosCarballal[>"When all you have is a sledgehammer, everything looks like cache" or something like that 😄.
[15:29:41]<MarcosCarballal[>Thanks for the resource
[15:39:27]* EvanKelley[m] has joined #farmos
[15:39:27]<EvanKelley[m]>Hey guys sorry to interject with another question, but currently we are working on modifying a view to have the title and the table of fields for a given asset type appear in one white area on the screen. However there are a lot of containers and divs that the view module uses by default to create the title and the table kinda getting in our way. Can anyone think of a better way in the views module that we can do something like this?
[15:39:50]<EvanKelley[m]>ACTION uploaded an image: (33KiB) < https://libera.ems.host/_matrix/media/r0/download/matrix.org/beSoOYmGriW... >
[15:39:57]<EvanKelley[m]>We want it to look something like this
[15:40:48]<mstenta[m]>Are "Projects" assets?
[15:40:53]<EvanKelley[m]>Yes
[15:40:54]<mstenta[m]>(Hi Evan Kelley :-) )
[15:41:06]<mstenta[m]>And what problem are you running into?
[15:41:30]<mstenta[m]>You want less DIVs basically? Or more control over the DIVs?
[15:41:39]<mstenta[m]>And CSS isn't enough?
[15:43:47]<mstenta[m]>It is possible to override the Twig templates that the Views module provides... but I don't know if I would recommend that... it requires some deeper understanding of the lower level structures - so while it's possible you might find it ends up taking more time understanding that than it does to just use CSS.
[15:44:11]<EvanKelley[m]>Hey Mike, when trying to inject our own CSS with hooks on this page we've seen there's actually a lot of div's and classes that have a 0 height but are the width of the page. The major reason I believe those exist is because the views module seprates the title of the page and the contnet of the page into two different sections and adds a lot of divs that just kinda get in the way
[15:44:11]<mstenta[m]>Happy to point you in that direction though if you want
[15:45:35]<mstenta[m]>Here are all the core Views templates that can be overridden: https://git.drupalcode.org/project/drupal/-/tree/9.3.x/core/modules/view...
[15:46:04]<mstenta[m]>Because you mention "page title" vs "content", you *may* actually be talking about the page template more broadly, though... not Views
[15:46:23]<mstenta[m]>In which case you may want the theme template (provided by the Gin theme or Drupal core itself)
[15:46:59]<mstenta[m]>https://www.drupal.org/docs/theming-drupal/twig-in-drupal/working-with-t...
[15:47:44]<EvanKelley[m]>Hmm okay it is labeled as a page in the Views UI when we create it there. I was trying to follow the steps that were posted in here I believe on Tuesday when Marcos was asking about it but I could have done it inccorectly
[15:48:41]<mstenta[m]>Cool - do you want to take a look together? Would that be helpful?
[15:48:53]<EvanKelley[m]>Very much yes
[15:48:59]<mstenta[m]>:-)
[15:49:08]<mstenta[m]>Dev jitsi? https://meet.jit.si/farmos-dev
[16:16:12]* eddieironsmith[m has joined #farmos
[16:16:39]<mstenta[m]>Evan Kelley: here is how to set up "template suggestions" (comments in the HTML that show which template each thing comes from): https://www.drupal.org/node/1922666
[16:17:20]<FarmerEd[m]>ACTION uploaded an image: (2613KiB) < https://libera.ems.host/_matrix/media/r0/download/matrix.org/zPdnSQVsJNH... >
[16:17:23]<mstenta[m]>In your `sites/default` directory is a `default.services.yml` file. copy that to `services.yml` and that's where you'll change `parameters.twig.config.debug` to `true`
[16:18:00]<mstenta[m]>WOW Farmer Ed !
[16:20:00]<FarmerEd[m]>Definitely bailing twine and pallets at the moment, but at least I didn't use Node-Red 😆
[16:21:23]<mstenta[m]>Haha that is awesome!
[16:23:19]<mstenta[m]>ACTION uploaded an image: (10KiB) < https://libera.ems.host/_matrix/media/r0/download/matrix.org/YqmJtPCwREx... >
[16:23:20]<mstenta[m]>Evan Kelley: this is the option for "separate buttons" in Drupal 7 w/ the Views Bulk Operations module that I was thinking of...
[16:24:21]<mstenta[m]>I can't seem to find that in Drupal 9... I'm asking in Drupal Slack #support to see if anyone knows. It's possible that it wasn't actually included when they merged the Views module and VBO into Drupal core (both used to be non-core modules before D8)
[16:24:42]<mstenta[m]>I have to imagine there's a way to do it still... I'll let you know if I find anything
[16:24:58]<EvanKelley[m]>Okay great, thank you so much!
[16:25:06]<mstenta[m]>(One idea that comes to mind: override the template for it and turn it into buttons! 😆)
[16:25:32]<EvanKelley[m]>Yeah we just might
[16:29:13]<mstenta[m]>Evan Kelley: oh you know what? It might be provided by the Views Bulk Operations module: https://www.drupal.org/project/views_bulk_operations
[16:30:01]<mstenta[m]>That module used to be the primary way of adding those actions to Views before D8. With D8 they added the native "bulk update" option when they merged Views into core. So now it sounds like VBO extends the core features to add some "extras", and "separate buttons" might be one of the features it provides
[16:30:35]<mstenta[m]>Sort of a vestigal contrib module that just adds the bells and whistles to core now :-)
[16:30:55]<EvanKelley[m]>Alrighty that portion of it was a stretch goal for now so it should be fine if we figure that out later
[16:30:57]<mstenta[m]>I haven't tried it - but I see mention of the "separate buttons" in that modules' issue queue, so worth a try perhaps
[16:31:01]<mstenta[m]>Ok cool
[17:28:46]<EvanKelley[m]>Hey mstenta one more question I have, it appears that we don't have the "themes" directory in our repo for farmOS should we still be able to override the Twig page without it?
[17:30:46]<mstenta[m]>Yes
[17:31:14]<mstenta[m]>The themes directory is created when you run composer install, and will be populated by the gin module
[17:31:48]<mstenta[m]>But you will be providing your override template in a "templates" directory in your module
[17:32:01]<mstenta[m]>s/module/theme/
[17:32:41]<mstenta[m]>Your module will basically say "hey drupal ignore gin's template and use this one"
[17:33:24]<mstenta[m]>(you'll need to implement a hook in your *.module file to tell drupal to do that)
[17:34:08]<EvanKelley[m]>Okay I think that's our problem then I just need to setup that hook in our module file
[17:34:30]<mstenta[m]>Yea. That's the part I'm not sure about off the top of my head
[17:34:38]<mstenta[m]>I'm off for the evening
[17:34:57]<mstenta[m]>But if you join Drupal slack you can get an answer pretty quick I get
[17:35:00]<EvanKelley[m]>Okay no worries thanks for responding when you're out!
[17:35:00]<mstenta[m]>s/get/bet/
[17:35:15]<mstenta[m]>In the #support channel