? ? ? Pending

User tests: Successful: Unsuccessful:

avatar laoneo
laoneo
15 Dec 2021

Summary of Changes

This PR adds the possibility to define the location of the category while saving it through the API. A location can be one of the following values:

  • before
  • after
  • first-child
  • last-child

If before or after is used it is advisable to also set the location_reference parameter which defines the sibling the category should be located.

Testing Instructions

Run the following curl command:

curl --location --request POST 'https://[your J4 website]/api/index.php/v1/content/categories' \
--header 'Content-Type: application/json' \
--header 'X-Joomla-Token: [your user token]' \
--data-raw '{
    "title": "test",
    "location": "first-child",
    "published": "1",
    "language": "*"
}'

Actual result BEFORE applying this Pull Request

The new category appears as last item in the list in the back end UI.

Expected result AFTER applying this Pull Request

The new category appears as first item in the list in the back end UI.

Documentation Changes Required

The new location and location_reference arguments need to be documented.

avatar laoneo laoneo - open - 15 Dec 2021
avatar laoneo laoneo - change - 15 Dec 2021
Status New Pending
avatar laoneo laoneo - change - 15 Dec 2021
The description was changed
avatar laoneo laoneo - edited - 15 Dec 2021
avatar laoneo
laoneo - comment - 16 Dec 2021

@alikon , @khu5h1 can you guys give this one here a test too? Similar procedure as the other ones. Thanks!!

avatar alikon
alikon - comment - 17 Dec 2021

i guess we should do the same for endpoint POST {{base_path}}/api/index.php/v1/menus/{app}

avatar alikon alikon - test_item - 17 Dec 2021 - Tested successfully
avatar alikon
alikon - comment - 17 Dec 2021

I have tested this item successfully on b51641d

CS issue apart


This comment was created with the J!Tracker Application at issues.joomla.org/tracker/joomla-cms/36318.

avatar laoneo
laoneo - comment - 20 Dec 2021

@alikon if accepted, then I can do also for menus.

avatar HLeithner
HLeithner - comment - 20 Dec 2021

While testing this it seems that api can by-pass the alias naming restrictions is this intended?

curl --location --request POST 'https://[domain]/api/index.php/v1/content/categories' \
--header 'Content-Type: application/json' \
--header 'X-Joomla-Token: [key]' \
--data-raw '{"location_reference":2,
    "title": "test before Uncategorised",
    "location": "before",
    "published": "1",
    "language": "*"
}

executing this command 2 times ends, in one item before and one (the second call) as last item... I know unrelated to this PR...

What the rest is working find but could we get some variable validation in this function because passing location and location_reference without input validation is wrong.

avatar laoneo laoneo - change - 20 Dec 2021
Labels Added: ? ?
avatar laoneo
laoneo - comment - 20 Dec 2021

Validation is done on the model level, so there is no reason to do it on the controller level as well. So if there is something missing on the validation side, it must be fixed in the model. But I casted to int in the controller to be double save.

323a846 20 Dec 2021 avatar laoneo cs
avatar laoneo
laoneo - comment - 22 Dec 2021

@HLeithner can you mark your test as successful please.

avatar HLeithner HLeithner - test_item - 22 Dec 2021 - Tested successfully
avatar HLeithner
HLeithner - comment - 22 Dec 2021

I have tested this item successfully on 323a846


This comment was created with the J!Tracker Application at issues.joomla.org/tracker/joomla-cms/36318.

avatar alikon alikon - test_item - 23 Dec 2021 - Tested successfully
avatar alikon
alikon - comment - 23 Dec 2021

I have tested this item successfully on 323a846


This comment was created with the J!Tracker Application at issues.joomla.org/tracker/joomla-cms/36318.

avatar alikon alikon - change - 23 Dec 2021
Status Pending Ready to Commit
avatar alikon
alikon - comment - 23 Dec 2021

RTC


This comment was created with the J!Tracker Application at issues.joomla.org/tracker/joomla-cms/36318.

avatar wilsonge wilsonge - change - 30 Dec 2021
Status Ready to Commit Fixed in Code Base
Closed_Date 0000-00-00 00:00:00 2021-12-30 21:13:27
Closed_By wilsonge
Labels Added: ?
avatar wilsonge wilsonge - close - 30 Dec 2021
avatar wilsonge wilsonge - merge - 30 Dec 2021
avatar wilsonge
wilsonge - comment - 30 Dec 2021

Thanks!

Add a Comment

Login with GitHub to post a comment