- Issue created by @danielspeicher
- ๐บ๐ธUnited States luke.leber Pennsylvania
luke.leber โ made their first commit to this issueโs fork.
- ๐บ๐ธUnited States luke.leber Pennsylvania
I've taken a slightly different stab at this in the issue fork. Rather than providing various flags for the
\sort
function, the action operates at a slightly higher level by allowing users to pick different sorting functions.Jurgen also mentioned in a slack thread...
I'd like to add that there should also be sorting based on either keys, values, or callbacks. The latter would allow sorting based on properties or other logic when values are complex data types.
This might be a crazy idea, but I think that this could be feasible by linking to another ECA action that acts to compare two values with arbitrary steps!
I know that the actual sorting implementation isn't correct -- but it at least allows the kernel tests to pass.
I'll open a draft PR to get some feedback on this feature request.
Thanks!
- Merge request !484Issue #3352398 by luke.leber, mysdiir, jurgenhaas, danielspeicher: New Action List Sort โ (Open) created by luke.leber
- ๐บ๐ธUnited States luke.leber Pennsylvania
Added some example model configuration files to aid in review.
I'll mark as NR for the concept check anyhow.
- ๐ฉ๐ชGermany jurgenhaas Gottmadingen
This looks great, thanks @luke.leber for your contribution. Just a minor suggestion in the MR, everything else is ready to be merged.
- ๐บ๐ธUnited States luke.leber Pennsylvania
I gave this a manual test (via the attached model) and everything still seems to be in order. Switching back to NR - thanks Jรผrgen!
- ๐ฉ๐ชGermany Istari
I tested it and idk if documentation about my testing is a little too much :)
Feel free to feedbackTesting Results:
- Tested with new Drupal 11.1.6
- ECA 2.1.x
- BPMN_IO 2.0Test scenario:
= Triggering event:
- Update Content entity, Type: Content Article
- Building a list with 4 values in random order
- Build up list with names
(Order of List: add item actions, method: append)
- Daniel
- Clara
- Anna
- BenExecuting test with creating and updating new Node of type Article
Testing created list
:
Expected result
Daniel,Clara,Anna,Ben
Result:(Type in logs: testing)
Daniel, Clara, Anna, Ben
Sort method: Ascending by value
Expected result
Anna, Ben, Clara, Daniel
Result: (Type in logs: test_asc)
Anna, Ben, Clara, Daniel
Sort method: Descending by value
Expected result
Daniel, Clara, Ben, Anna
Result: (Type in logs: test_desc)
Daniel, Clara, Ben, Anna
Sort method: Ascending by key
Expected result
Daniel, Clara, Anna, Ben
Result: (Type in logs: test_asc_k)
Daniel, Clara, Anna, Ben
Sort method: Descending by key
Expected result
Ben, Anna, Clara, Daniel
Result: (Type in logs: test_dsc_k)
Ben, Anna, Clara, Daniel
Sort method: natural
Expected result (Type in logs: test_nat)
Anna, Ben, Clara, Daniel
Result:
Anna, Ben, Clara, Daniel
- Building a list with 4 values in random order
- Build up list with letters
(Order of List: add item actions, method: append)
- A
- B
- b
- aTesting created list
:
Expected result
a,A,b,B
Result: (Type in logs: testing)
Daniel, Clara, Ben, Anna, A, B, b, a
Sort method: natural case sensitive
Expected result
A,a,B,bResult: (Type in logs: test_nat_cs)
A,a,Anna,B,b,Ben,Clara,Daniel
Results:
All results as expected
Except natural case sensitive where I expected not to have any values of the first list.
Both lists are separated by a gateway (see screenshot) and no tokens from list one are in the list two process contained - ๐ฉ๐ชGermany jurgenhaas Gottmadingen
@mysdiir regarding tests, as discussed in Leuven, I've looked for some existing tests that could be used as examples for how the tests should be written for this issue. The best example is
modules/base/tests/src/Kernel/ListOperationTest.php
with tests called\Drupal\Tests\eca_base\Kernel\ListOperationTest::testListCount
, etc.You can copy that file into
ListSortTest.php
and then remove the test methods before adding your own test methods that initialize the action plugin with the configuration that you wrote about in #12, then execute the action and afterwards assert the result being what you expect. - ๐ฉ๐ชGermany jurgenhaas Gottmadingen
Updated so that this works against the 3.0.x branch.