Problem/Motivation

The extra module jsonapi_defaults contains options to add in default filters but not default sorting.
Would be good if changes could be made to also add this feature.

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

Eli.Stone created an issue. See original summary.

3li’s picture

Have added options for default sorting, inside the jsonapi_defaults module.

3li’s picture

Status: Active » Needs review
bbrala’s picture

Status: Needs review » Needs work

Thanks for helping out! This is quite usefull.

Looking good but is missing tests. Could you add a test that applies the sort and one that then overrides it? Have a look at JsonApiExtrasFunctionalTest::testSortOverwrittenField for inspiration :)

3li’s picture

Sure will look at adding test ASAP.

3li’s picture

Status: Needs work » Needs review
StatusFileSize
new8.26 KB

Have added some tests for checking default sorting and confirming overriding default sorting takes priority.

3li’s picture

Opened up merge request as easier to review & test :)

abu-zakham’s picture

Status: Needs review » Reviewed & tested by the community

Worked for me.

bbrala’s picture

Status: Reviewed & tested by the community » Fixed

Thanks for the work! Reviewed and pushes :)

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.