▣🔗 Asset Link - Planting plugin

Continuing the discussion from ▣🔗 Asset Link - Use-case Drive:

1 Like

Yes that propably comes from chatgpt and when fixing the right way to load it I missed to cleanup.

That is copied either from another plugin or chatgpt and its only for the unitterm I had it that way for everything else I had $relateByName so I fixed that and cleaned up for now only in the development branch but will pull to main when I have fixed the other things you recommended.

This sounds great if I can get it to work, I also saw that my way had the problem with pagination because I had a script that imported lots of planttypes from openfarm… So for me I cleaned up my planttypes to only be the one I use. But doing it with the entity-select that you have already made sounds way better and will work for more people. However when I try

            label="Plant Type"

It dosen’t find any of my plant-types and I haven’t found anything more in the documentation about what I could be doing wrong.

I will try to work with the objects instead of the name since that would also make the other work with it way easier and more effective this was since I don’t have much experience in javascript and vue so I did it the way I could get it to work :slight_smile:

Fixed that, I hadn’t put much thought into it other than changing the plugin name, but it does make sense I have changed that for all my plugins now in the development branch. One thing I realized thou is that the actions are ordered by the namespace so that mine with se… will always end up in the end unless I put some other character in front which may or may not brake features that you add in the future… :slight_smile:

Now I have pushed over my changes to main and have changed getting seeds from name to object and adding the drupal internal ID so that it looks like in farmos so that you know which of the seed assets is which if you have multiple with the same name. While creating a new still works.

I started getting a weird error in the last but it seems unrelated to my last changes.

Error: Plugin route shorthand must be in the format 'alink-route[my.unique.identifier]="/my/path"'
    at s (VuePluginShorthandDecorator.js:97:11)
    at o.composeDecorator (VuePluginShorthandDecorator.js:26:13)
    at y.loadPlugin (AssetLinkPluginLoaderCore.js:88:66)
    at async AssetLink.js:197:55
    at async Promise.all (index 0)
    at async u.ackPluginReference (AssetLinkPluginListsCore.js:231:62)
    at async Promise.all (index 48)
    at async p.load (AssetLinkPluginListsCore.js:324:10)
    at async l.boot (AssetLinkPluginListsCore.js:56:15)
    at async m.boot (AssetLink.js:224:5)

I still havent gotten the entity-selector to work but haven’t looked to much into it yet. :slight_smile:

The entity-type should be just "taxonomy_term" and the entity-bundles param should be :entity-bundles="['plant_type']". i.e.

            label="Plant Type"

Those ids are only used as a secondary sorting mechanism. You shouldn’t be using the id to affect the order. Instead you should specify the weight for slots (and widget decorators) where the order is important.




See Asset Link docs Extension Model & Asset Link docs IAssetLinkPluginSlotHandle

That is related to your change, but it’s a bug in how Asset Link is parsing the “route shorthand” from the template tag here.

Right now, slots/routes/etc that are defined via that template tag shorthand mechanism doesn’t handle ids that contain the hyphen character. (Which is a perfectly valid character in a domain name.)

You could do one of the following for now;

  • Have that weather plugin be broken until I fix the bug
  • Avoid the shorthand mechanism for declaring routes/slots/etc
  • Use a different domain name temporarily
1 Like

Thank you :grinning:
Now hopefully I will be able to get it to work and better than before too :grinning:

With your entity-select is there a possibility to add a new taxonomiterm cause otherwise I might choose to look at the source for that and modify my version to search as yours are doing.

Yeah, it doesn’t support creating entities (including terms) at the moment.

Then I will look into modify my version based on your code :slight_smile:

I have been working multiple angles but I have some problem reusing your code from the entity-select that it complains.

TypeError: entityBundles.flatMap is not a function
    at eval (eval at P (vue3-sfc-loader.esm.js:81:9271), <anonymous>:3:1121)
    at u (query.js:17:27)
    at _e.query (sync-record-cache.js:80:23)
    at iteratePaginatedResults (eval at P (vue3-sfc-loader.esm.js:81:9271), <anonymous>:3:1098)
    at iteratePaginatedResults.next (<anonymous>)
    at r.peek (PeekableAsyncIterator.js:22:58)
    at i (AssetLinkFarmDataCore.js:259:57)
    at i.next (<anonymous>)
    at l.next (RacingLocalRemoteAsyncIterator.js:27:49)
    at async seasonsFilterFn (eval at P (vue3-sfc-loader.esm.js:81:9271), <anonymous>:3:3865)

I haven’t found where that comes from cause I don’t have .flatmap for the seasons at all now.

Another thing that I didn’t know how to do was that for creating replanting log, I thought that I could use the entity-select for choosing location, since its to complicated to create them on the fly anyway. But I cant find how I would make it to only show assets that are locations so for now I can either show all assets or just land assets…

These changes are for now just in the development branch since they don’t work but I changed the domain on all my plugins so that the shorthand bug don’t affect my plugins anymore.

The entityBundles parameter should be an array of strings in your code here.

You can pass the additional-filters property to the entity-select or entity-search components. Check out this example which is very similar to what you want in the MoveAssetActionProvider.alink.vue plugin.

Thank you, now that you say it I remember seeing it as array of strings somewhere but didn’t think of it now :wink:
Great I tried working with additional-filters but didn’t understood how I would make it to work. :slight_smile:

It feels like I should be able to get tis to work pretty good now and Then I will be pretty happy with it and start to thinking about what else I need assetLink plugins for :slight_smile:


I happened to have a browser tab still open to your repository and noticed your recent commit that appears to add some input validation…

You might want to check out the Quasar Form component which provides a nice/recommended pattern for doing that validation. Also see the :rules attribute for many input fields. e.g. Input - Validation

Thank you that sounds great, so far I have only been having that the submit button is disabled when not all fields are filled but that start to be complicated when I added transplanting and harvest logs and even more so when I try to make the planting log optional like in the quickform for planting… :sweat_smile:
Edit: Now when sitting at the computer again I saw which commit it was you was looking at and that one is because something is wrong with the rules for disabling the submit button when the planting isn’t on, it still requiring all the fields to be filled even if I have hidden them… :sweat_smile:

I ended up deleting the code for disabling the submit button and instead did validation on the input so that it show what is missing, that also worked way better with the possibility to choose what logs to create :grinning: