< 172022-09-18⋎19 >

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:20*polo has joined
06:35*polo has quit (Quit: My MacBook has gone to sleep. ZZZzzz…)
13:07mstenta[m]www.drupal.org/project/farm/issues/33102
13:35symbioquine[m]What's the best way to change a specific asset's label in farmOS 2.x from a contrib module? In 1.x I had this;... (full message at <libera.ems.host/_matrix/media/r0/downloa>)
13:36mstenta[m]Oh interesting question... I'm not sure
13:36symbioquine[m]I found drupal.stackexchange.com/a/281941 but that seems a little extreme - and seems like no two contrib modules could use that same strategy for a given asset/entity type
13:36mstenta[m]label callback may still be available?
13:36symbioquine[m]ah! :)
13:36symbioquine[m]I'll look
13:36mstenta[m]your approach might actually still work almost as-is
13:37symbioquine[m]www.drupal.org/node/2196275
13:38symbioquine[m]Seems like there's something similar anyway without necessarily overriding the whole class...
13:38symbioquine[m]I'll have to try it I guess
13:39mstenta[m]hmm yea... I would be curious if you could just override a "label handler" like you can the other handlers (eg: `access` github.com/farmOS/farmOS/blob/2b430c04b8)
13:40mstenta[m]although I think it would still be overriding the handler for ALL assets essentially, which would be pretty heavy handed for something like this
13:40symbioquine[m]`EntityTypeInterface::setLabelCallback` is deprecated and will be removed < Drupal 9
13:40symbioquine[m]mstenta[m]: That's okay as long as I can also get the existing handler and decorate it like I did before.
13:42mstenta[m]The other thing I wonder... taking a step back... could you instead just try to save the label you want to the asset's`name` property automatically?
13:43symbioquine[m]Maybe, but it would be a lot of redundancy and I'd need to rewrite thousands of existing records...
13:43symbioquine[m]It feels more like a display concern to always show them together.
13:43mstenta[m]In v1 logs had the ability to auto-generate names using a token-based pattern
13:44mstenta[m]Wonder if something like that would be useful for assets
13:44mstenta[m](maybe not for this, just thinking)
13:44symbioquine[m]Yeah
13:44mstenta[m]Well we could also consider adding an alter hook for asset labels
13:44mstenta[m]To our asset class
13:45mstenta[m]So modules would have the ability to alter the label
13:45mstenta[m]api.drupal.org/api/drupal/core%21lib%21D
13:46symbioquine[m]My main objective is to store the `primary_id` separately, but almost always show it together. Some operations, like creating a planting from a seed asset or creating new seed assets derived from another seed asset don't persist the `primary_id` and I don't want to be parsing it back out of the name.
13:47symbioquine[m]mstenta[m]: That might be a pretty good strategy! Drupal core has api.drupal.org/api/drupal/core%21modules for users
13:49mstenta[m]Makes sense!
13:49mstenta[m]I like this:
13:49mstenta[m]> Can be used to ensure user privacy in situations where $account->getDisplayName() is too revealing.
13:49mstenta[m]Not sure if asset name privacy would ever be a concern, but a neat idea!
13:49mstenta[m]Perhaps this could be used for anonymization purposes
13:50mstenta[m]eg: under certain conditions change it to a random string
13:50symbioquine[m]> <@mstenta:matrix.org> I like this:
13:50symbioquine[m]>
13:50symbioquine[m]> > Can be used to ensure user privacy in situations where $account->getDisplayName() is too revealing.
13:50symbioquine[m]Interesting. I'm not totally sure I understand the use-case where that comment would make sense...
13:51mstenta[m]Maybe something like: "Only show username to select roles, otherwise set it to `User $id`"
13:53mstenta[m]Similar to the "anonymization" I mentioned above
13:53mstenta[m]Dunno when that would be useful exactly, but maybe
13:54symbioquine[m]Like if you had content creator users that weren't allowed to know who the other content creators were, but the admin can?
13:54mstenta[m]Looks like that's essentially what the test of that hook does... changes usernames to just show the user ID: api.drupal.org/api/drupal/core%21modules
13:54mstenta[m]Yea maybe? Or in the case of farmOS... imagine you want to be able to share records with another system, but didn't want to reveal user names
13:54symbioquine[m]Hmmm
13:55mstenta[m]Probably lots of ways to do that... but this could be one - I'd be curious to find the original feature request for that username hook to see if it describes a concrete use case
13:58symbioquine[m]It might take a bit of digging. It looks like it's been around for a while, just named differently before: www.drupal.org/node/1408514
17:41mstenta[m]In other news, check out this puffball :-)
17:41*uploaded an image: (246KiB) < libera.ems.host/_matrix/media/r0/downloa >
17:41*uploaded an image: (158KiB) < libera.ems.host/_matrix/media/r0/downloa >
17:41symbioquine[m]Yum!
17:42mstenta[m]😄
17:42mstenta[m]I've always wanted to try frying one up... haven't yet
17:43mstenta[m]We get one big one like this around the same area every year and I've just been letting it go to spore
17:43symbioquine[m]Cool
17:46symbioquine[m]<symbioquine[m]> "That might be a pretty good..." <- It turns out that this probably wouldn't solve my problem...
17:46symbioquine[m]I hacked up `Asset.php` to return a customized label just to test and it looks like it isn't used in many places.
17:46mstenta[m]Aw really?
17:47mstenta[m]Womp. Maybe it should be
17:47symbioquine[m]Yeah
17:47symbioquine[m]I think it's the distinction between things rendered by views and things rendered other ways
17:47symbioquine[m]e.g. the title of the edit page does use the label
17:47mstenta[m]Views doesnt? Hmm well that might be fixable
17:47symbioquine[m]but the view page and asset list views don't
17:48mstenta[m]Oh the view page doesnt?
17:48mstenta[m]Those seem like bugs then
17:48*uploaded an image: (29KiB) < libera.ems.host/_matrix/media/r0/downloa >
17:49mstenta[m]Probably just needs to use $asset->label()
17:49*uploaded an image: (11KiB) < libera.ems.host/_matrix/media/r0/downloa >
17:49*uploaded an image: (16KiB) < libera.ems.host/_matrix/media/r0/downloa >
17:51*uploaded an image: (50KiB) < libera.ems.host/_matrix/media/r0/downloa >
17:52*uploaded an image: (39KiB) < libera.ems.host/_matrix/media/r0/downloa >
17:52mstenta[m]That's neat
17:53mstenta[m]Trying to figure out where the asset view page title is generated...
17:59mstenta[m]git.drupalcode.org/project/drupal/-/blob
17:59mstenta[m]Maybe that? That's using label()
17:59mstenta[m]🤔
18:00symbioquine[m]It seems like that would have caused the title of the view page to include `zzz . `
18:01symbioquine[m]Maybe this is relevant: github.com/farmOS/farmOS/blob/2b430c04b8
18:05symbioquine[m]Deleting that and rebuilding the cache caused the view page for a single asset to include the `zzz .` prefix, but didn't appear to affect any of the other places I would have expected the label to be used...
18:06*uploaded an image: (12KiB) < libera.ems.host/_matrix/media/r0/downloa >
18:09mstenta[m]Ah interesting!
18:09mstenta[m]Well maybe deleting that line should be part of the same PR to add an alter hook
18:09mstenta[m]But yea I expect there will be other places we need to ensure uses label()
18:09mstenta[m]I'm surprised Views does not
18:09mstenta[m]But I'm sure we could fix that
18:10mstenta[m]Brb back to outside stuff
18:10symbioquine[m]Yeah, thanks talking through it :)
20:50mstenta[m]Curious if the API uses label()
21:41symbioquine[m]I'm not sure I'd expect it to

< 172022-09-18⋏19 >