| 06:20 | * | polo has joined |
| 06:35 | * | polo has quit (Quit: My MacBook has gone to sleep. ZZZzzz…) |
| 13:07 | mstenta[m] | www.drupal.org/project/farm/issues/33102 |
| 13:35 | symbioquine[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:36 | mstenta[m] | Oh interesting question... I'm not sure |
| 13:36 | symbioquine[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:36 | mstenta[m] | label callback may still be available? |
| 13:36 | symbioquine[m] | ah! :) |
| 13:36 | symbioquine[m] | I'll look |
| 13:36 | mstenta[m] | your approach might actually still work almost as-is |
| 13:37 | symbioquine[m] | www.drupal.org/node/2196275 |
| 13:38 | symbioquine[m] | Seems like there's something similar anyway without necessarily overriding the whole class... |
| 13:38 | symbioquine[m] | I'll have to try it I guess |
| 13:39 | mstenta[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:40 | mstenta[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:40 | symbioquine[m] | `EntityTypeInterface::setLabelCallback` is deprecated and will be removed < Drupal 9 |
| 13:40 | symbioquine[m] | mstenta[m]: That's okay as long as I can also get the existing handler and decorate it like I did before. |
| 13:42 | mstenta[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:43 | symbioquine[m] | Maybe, but it would be a lot of redundancy and I'd need to rewrite thousands of existing records... |
| 13:43 | symbioquine[m] | It feels more like a display concern to always show them together. |
| 13:43 | mstenta[m] | In v1 logs had the ability to auto-generate names using a token-based pattern |
| 13:44 | mstenta[m] | Wonder if something like that would be useful for assets |
| 13:44 | mstenta[m] | (maybe not for this, just thinking) |
| 13:44 | symbioquine[m] | Yeah |
| 13:44 | mstenta[m] | Well we could also consider adding an alter hook for asset labels |
| 13:44 | mstenta[m] | To our asset class |
| 13:45 | mstenta[m] | So modules would have the ability to alter the label |
| 13:45 | mstenta[m] | api.drupal.org/api/drupal/core%21lib%21D |
| 13:46 | symbioquine[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:47 | symbioquine[m] | mstenta[m]: That might be a pretty good strategy! Drupal core has api.drupal.org/api/drupal/core%21modules for users |
| 13:49 | mstenta[m] | Makes sense! |
| 13:49 | mstenta[m] | I like this: |
| 13:49 | mstenta[m] | > Can be used to ensure user privacy in situations where $account->getDisplayName() is too revealing. |
| 13:49 | mstenta[m] | Not sure if asset name privacy would ever be a concern, but a neat idea! |
| 13:49 | mstenta[m] | Perhaps this could be used for anonymization purposes |
| 13:50 | mstenta[m] | eg: under certain conditions change it to a random string |
| 13:50 | symbioquine[m] | > <@mstenta:matrix.org> I like this: |
| 13:50 | symbioquine[m] | > |
| 13:50 | symbioquine[m] | > > Can be used to ensure user privacy in situations where $account->getDisplayName() is too revealing. |
| 13:50 | symbioquine[m] | Interesting. I'm not totally sure I understand the use-case where that comment would make sense... |
| 13:51 | mstenta[m] | Maybe something like: "Only show username to select roles, otherwise set it to `User $id`" |
| 13:53 | mstenta[m] | Similar to the "anonymization" I mentioned above |
| 13:53 | mstenta[m] | Dunno when that would be useful exactly, but maybe |
| 13:54 | symbioquine[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:54 | mstenta[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:54 | mstenta[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:54 | symbioquine[m] | Hmmm |
| 13:55 | mstenta[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:58 | symbioquine[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:41 | mstenta[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:41 | symbioquine[m] | Yum! |
| 17:42 | mstenta[m] | 😄 |
| 17:42 | mstenta[m] | I've always wanted to try frying one up... haven't yet |
| 17:43 | mstenta[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:43 | symbioquine[m] | Cool |
| 17:46 | symbioquine[m] | <symbioquine[m]> "That might be a pretty good..." <- It turns out that this probably wouldn't solve my problem... |
| 17:46 | symbioquine[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:46 | mstenta[m] | Aw really? |
| 17:47 | mstenta[m] | Womp. Maybe it should be |
| 17:47 | symbioquine[m] | Yeah |
| 17:47 | symbioquine[m] | I think it's the distinction between things rendered by views and things rendered other ways |
| 17:47 | symbioquine[m] | e.g. the title of the edit page does use the label |
| 17:47 | mstenta[m] | Views doesnt? Hmm well that might be fixable |
| 17:47 | symbioquine[m] | but the view page and asset list views don't |
| 17:48 | mstenta[m] | Oh the view page doesnt? |
| 17:48 | mstenta[m] | Those seem like bugs then |
| 17:48 | * | uploaded an image: (29KiB) < libera.ems.host/_matrix/media/r0/downloa > |
| 17:49 | mstenta[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:52 | mstenta[m] | That's neat |
| 17:53 | mstenta[m] | Trying to figure out where the asset view page title is generated... |
| 17:59 | mstenta[m] | git.drupalcode.org/project/drupal/-/blob |
| 17:59 | mstenta[m] | Maybe that? That's using label() |
| 17:59 | mstenta[m] | 🤔 |
| 18:00 | symbioquine[m] | It seems like that would have caused the title of the view page to include `zzz . ` |
| 18:01 | symbioquine[m] | Maybe this is relevant: github.com/farmOS/farmOS/blob/2b430c04b8 |
| 18:05 | symbioquine[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:09 | mstenta[m] | Ah interesting! |
| 18:09 | mstenta[m] | Well maybe deleting that line should be part of the same PR to add an alter hook |
| 18:09 | mstenta[m] | But yea I expect there will be other places we need to ensure uses label() |
| 18:09 | mstenta[m] | I'm surprised Views does not |
| 18:09 | mstenta[m] | But I'm sure we could fix that |
| 18:10 | mstenta[m] | Brb back to outside stuff |
| 18:10 | symbioquine[m] | Yeah, thanks talking through it :) |
| 20:50 | mstenta[m] | Curious if the API uses label() |
| 21:41 | symbioquine[m] | I'm not sure I'd expect it to |