Feature request: Provide list of nodes selected in widget controller req

I would like an addition to the request passed to widgets in content studio:

exports.get = function (req) {
   req.params.contentId // This is whats supported today: ID of last selected node in Content Studio
   req.params.selectedNodes // This is the parameter I would like. An array of IDs of nodes selected
}

//selectedNodes:
[
   "860738ad-75b0-45ed-84bc-c68ac5993e1b",
   "148d5be5-9e7c-4438-9001-e1fc0dba67d2",
   "a4e10e4c-54ce-45e8-a89a-db9a87c2bd4e"
]

I request this, because I would like to make widgets where you can do bulk operations like translate nodes, set owner/author, Import info from CRM etc.

Let me know if you have any questions :+1:

1 Like

This would be a really useful feature! And I don’t think this was the first time it was mentioned.

The one problem I see is that we run into the single vs multiple problem again.

If its a string on selcting one, and a list on selecting multiple we will have to check for the type / force its type when use use the node id(s).

1 Like

Yes, the “id” vs [“id”,“id”] challenge is something we often have to solve, but its not an issue for me. Alternatively you can omit the params.selectedNodes if only one node is selected :+1:

I don’t expect there to be any issues with this. If/when we change this, then all ids of selected nodes will be passed to widget as multiple parameters of the same name (contentId) in the query string (as opposed to just one parameter now).

Now:

Widget URL:

_/widgets/com.enonic.app.myapp/my-widget?contentId=3208d688-46ae-4a63-b009-8be8ffbc90d2&repository=com.enonic.cms.myrepo&branch=draft

req.params in the backend:

{
    "contentId": "3208d688-46ae-4a63-b009-8be8ffbc90d2",
    "repository": "com.enonic.cms.myrepo",
    "branch": "draft"
}

Future implementation:

Widget URL (note two contentId parameters in the URL):

_/widgets/com.enonic.app.myapp/my-widget?contentId=3208d688-46ae-4a63-b009-8be8ffbc90d2&contentId=4208d688-46ae-4a63-b009-8be8ffbc90d3&repository=com.enonic.cms.myrepo&branch=draft

req.params in the backend:

{
    "contentId": [
        "3208d688-46ae-4a63-b009-8be8ffbc90d2",
        "4208d688-46ae-4a63-b009-8be8ffbc90d3"
    ],
    "repository": "com.enonic.cms.myrepo",
    "branch": "draft"
}

As you can see, it’s a very simple check you’d have to do to figure out whether it’s one or multiple ids selected.

1 Like