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