< 192021-10-20⋎21 >

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
06:59*jonasbits_ has joined
07:09*med65[m] has quit (Ping timeout: 260 seconds)
07:09*calbasi[m] has quit (Ping timeout: 260 seconds)
07:09*jonasbits has quit (Ping timeout: 260 seconds)
07:11*med65[m] has joined
07:18*calbasi[m] has joined
19:16symbioquine[m]I think I got the "Assets for Taxonomy" tab mostly working...
19:17symbioquine[m]The main complexity now is that the fields are different for different types of assets/term combinations.
19:18symbioquine[m]I was trying to write a ViewsArgument plugin that would dynamically create the query on the basis of the filtered term/asset type, but that seems kinda hard...
19:18symbioquine[m]Is that the best path forward? Any advice?
19:19mstenta[m]Oh yea that is tricky huh
19:21symbioquine[m]I was able to implement a ViewsAccessCheck to filter out asset types which don't reference the taxonomy vocabulary in question. e.g. only show all/plant/seed asset tabs for a crop taxonomy term.
19:23mstenta[m]This might be hard to fully automate
19:24mstenta[m]> I was trying to write a ViewsArgument plugin that would dynamically create the query on the basis of the filtered term/asset type, but that seems kinda hard...
19:24mstenta[m]This seems like the "right" approach, I agree... but it feels like it would be pretty hard to get right
19:24mstenta[m]Especially when you consider base fields vs bundle fields vs config fields
19:24symbioquine[m]If I go forward with the views argument plugin, I think I'd need to do a left outer join between the asset table and each of the relevant taxonomy term reference fields. e.g. `asset__plant_type` or `asset__animal_type`.
19:25mstenta[m]Thinking backwards... I imagine you will want to render multiple Views in the frontend... one for each term reference field, essentially
19:26symbioquine[m]symbioquine[m]: with an `OR`'d `WHERE` statement, filtering only those assets which have the term in at least one of those joined fields.
19:26mstenta[m]Hmmmmmm
19:27mstenta[m]I'm really questioning if this is worth the effort
19:27symbioquine[m]mstenta[m]: So you're suggesting the approach like the "asset_or_location" plugin?
19:27mstenta[m]Can't you get essentially the same information by using exposed filters on asset lists?
19:27mstenta[m](granted, it would be on a bundle-by-bundle basis... so you couldn't see Seed and Plant assets at the same time...)
19:27symbioquine[m]symbioquine[m]: Where you get the ids of all the assets as a number of separate queries, then add a simpler filter which just filters by those ids?
19:28mstenta[m]Hmm I don't know if that's what I was suggesting 😅
19:28symbioquine[m]:)
19:28mstenta[m]Just trying to visualize what the desired end result would be
19:28symbioquine[m]Yeah
19:28mstenta[m]Are you imagining a single tab that shows all assets (of different types) that reference the term?
19:29symbioquine[m]At least for my use-case, I'm trying to get away from linking my collaborators to searches.
19:29symbioquine[m]I want to be able to link to the term and make it easy to navigate from there to all the assets which reference it.
19:29mstenta[m]> for consistency, it would probably make the most sense to add "Assets" and "Logs" tabs to term pages that show assets/logs that reference them
19:29mstenta[m]Sorry - I think I'm starting to backtrack on this idea hehe
19:30mstenta[m]Maybe it would make sense to just make a custom thing for your purposes
19:30symbioquine[m]e.g. see all the animals of a type or all the plants of a given crop
19:30mstenta[m]If it's primarily for seeds + plants
19:30symbioquine[m]mstenta[m]: It might...
19:31mstenta[m]> At least for my use-case, I'm trying to get away from linking my collaborators to searches.
19:31mstenta[m]Mm yea I can see the reasoning for this
19:32mstenta[m]A general purpose solution would probably require some complicated hacks, no matter how you slice it :-(
19:32mstenta[m]So it might just make sense to create a set of simple Views for each instead
19:33mstenta[m]I don't love the idea of maintaining those in farmOS core, personally, because like I said the same basic thing can be accomplished with existing exposed filters... so maybe it makes sense to just start out as custom... but maybe there will be a lot of demand for this in the future... we'll see
19:34mstenta[m]This makes me think of an old idea I had... to basically merge `animal_type`, `plant_type`, and any others that make sense, into a single unified `species` vocabulary (or something like that)
19:34mstenta[m]For pretty much this exact reason... (There might even be an old issue for this kicking around...)
19:35mstenta[m]That way it would be the same field used on all assets
19:35mstenta[m]But there are bigger problems with that idea I think
19:37mstenta[m]Ah found it haha www.drupal.org/project/farm/issues/29347
19:38mstenta[m]Not exactly the same... but similar
19:38symbioquine[m]mstenta[m]: Using the existing exposed filters right now, means that users who are looking at a planting and wants to find other/historical plantings/seeds of the same variety has to manually click back to the plants/seeds view and select the relevant filter(s).
19:38symbioquine[m]It's at least 4 - 5 clicks compared to 1 in farmOS 1.x
19:38mstenta[m]> For example, "Crop/variety" in Plantings is analogous to "Species/breed" in animals, and "Mushroom species" in mushrooms. Could they be merged together into a general "Species/breed/variety" vocabulary? I like that from a data organization standpoint, but it could also cause confusion if your terms are mixed into one vocabulary.
19:38mstenta[m]True true
19:39mstenta[m]Maybe a simple shortcut link?
19:39symbioquine[m]Plus it's not obvious how to "get from here to there" unless the user already has a good mental map of the farmOS data structure.
19:39mstenta[m](not sure where/what)
19:39mstenta[m]yeaa
19:40symbioquine[m]Well, I'll keep playing around with it some... Maybe I can find a more elegant approach...
19:44mstenta[m]I wonder if you could create a menu item that essentially pre-fills the exposed filter
19:44mstenta[m]So `/taxonomy/term/%/assets/plant` == `/assets/plant?crop=%`
19:44mstenta[m]Basically show the same View but hard-code one of the filters
19:45mstenta[m]🤔
19:45mstenta[m](Still would need to be two separate paths for Plant vs Seed assets though)
19:54symbioquine[m]Maybe I could do that in a `DeriverBase` that populates `route_parameters` for the names of the taxonomy reference field table/etc
19:54mstenta[m]Yea potentially
19:54symbioquine[m]Then extend the `Taxonomy` view argument plugin to dynamically access those paramaters from the route.
19:55mstenta[m]Get a list of all term reference fields, then derive paths
19:55symbioquine[m]yeah
19:55symbioquine[m]Very similar to what I'm already doing with the access check
19:55mstenta[m]The tricky part will be the Views argument
19:55mstenta[m]But maybe it can just extend from the core term reference argument plugin
19:55symbioquine[m]Except that shouldn't be needed once only the relevant menu items are being generated.
19:55mstenta[m]and dynamically set the field somehow
19:56mstenta[m]where this might a bit more hairy, though, is if you have multiple fields on the same asset that reference the same term...???
19:56symbioquine[m]mstenta[m]: That's what I was trying to do, but it doesn't work for the "all" tab...
19:56mstenta[m]not sure why you'd ever need that, but it's a possible edge case
19:57mstenta[m]yea... the "all" tab would be the hardest i think - because it would require a bunch of `OR`s like you described... which feels like it's just asking for troublke
19:58mstenta[m]oh uh... another complication:
19:58mstenta[m]single-value vs multi-value reference fields :-/
19:58mstenta[m](maybe complicated? maybe not)
19:58mstenta[m]eg: `plant` assets can have multiple `plant_type` references, but `animal` assets can only have one `animal_type`
19:59mstenta[m]but maybe that wouldn't be hard in practice... i think they both structure their database tables the same
19:59mstenta[m](separate table with one row per reference)
20:01mstenta[m]> where this might a bit more hairy, though, is if you have multiple fields on the same asset that reference the same term...???
20:01mstenta[m]imagine an `example` asset type with two fields: `first_plant_type` and `second_plant_type` - the menu deriver would need to create two links, but they would both be for the same asset type essentially
20:02mstenta[m]that's doable... just need to figure out what to call the tabs... can't call them both "Example" - need to have some way to differentiate them so you knew which field was which
20:02mstenta[m](veeeeery much an edge case)
20:13paul121[m]just something worth noting here, if you enable the `node` module, it adds a view of nodes that reference a taxonomy term on `term` pages
20:14paul121[m]it doesn't do this in a fancy menu tab
20:14paul121[m]but maybe something work at to see how it works
20:14mstenta[m]oh good idea!
20:25paul121[m]I think it creates the path for each view to be taxonomy term page itself, and it's just appended

< 192021-10-20⋏21 >