I think it makes sense to display more information (title, pager, style, etc...) about the view inside the meta, instead of just 'count'.

Command icon Show commands

Start within a Git clone of the project using the version control instructions.

Or, if you do not have SSH keys set up on git.drupalcode.org:

Comments

YahyaAlHamad created an issue. See original summary.

yahyaalhamad’s picture

Status: Active » Needs review
StatusFileSize
new2.5 KB

Status: Needs review » Needs work
yahyaalhamad’s picture

Some views don't necessarily have a pager, this will attempt to fix this fatel error.

markwittens’s picture

Thanks for this patch! I needed the pager info in the output and this patch adds just that plus some more useful data.

Tests should be fixed however and there should be some new tests added for the new output.

deciphered’s picture

There is already a good amount of this information available from the `view--view` resource, so it's best not to duplicate work too much.

The biggest issue with the `view--view` resource is that it contains too much unfilterable data, and returns all displays. I think it would be better to concentrate on improvements in that area and then using the relationship from this resource to get that data as required.

markwittens’s picture

Then what do you propose? The pager information is loaded directly from the view itself, so there's hardly any code duplication. A pager is often essential for a view and I think it actually shouldn't take any extra work for it to be added to the API resource.

martindavi’s picture

Glad to see others talking about this - our use case would be to know what exposed filters exist on the view and what vocabularies they reference in order to programmatically build those exposed filters on the front end, rather than hardcoding.

I can get this information from the `view--view` like you say, but it would be pretty slick if the metadata of the view was available alongside the data.

Edit:

What makes that difficult though is that the /jsonapi/view/view/${view_id} endpoint returns: "The current user is not allowed to GET the selected resource. The 'administer views' permission is required." to anonymous requests - I obviously don't want to give that permission to anonymous requests.

vhin0210 made their first commit to this issue’s fork.

vhin0210’s picture

Noticed that the count is missing after the patch. Tweaked #4 a little bit.

anybody’s picture

Status: Needs work » Needs review