ILIAS icon indicating copy to clipboard operation
ILIAS copied to clipboard

UI: Add Column Type List

Open kergomard opened this issue 8 months ago • 2 comments

Hi all

To implement Move Role-Permissions-Table to DataTable. It would be very helpful to have a column-type "Listing". This PR adds it.

...but there is more: There was also the wish to have the columns be truncated. I added some function to the interface to make this possible, although I must admit that I've a hard time to find the right structure and nomenclature. I did not implement much of it as I would kindly ask you for your opinion before investing the time to programming the whole thing:

  • I think it is a good idea for it to be enabled with one single and clear function call even though we actually need to have two things happening: The truncation needs to be enabled and we need to have a text to be presented, when the cell is truncated. We could also provide a default text, but I would have no clue what it should be and I don't think there even is a viable option. I thus added a single mutator withTruncation(\Closure $truncated_text_closure), but two getters isTruncationEnabled(): bool and getTruncatedTextClosure(): ?\Closure. As said: nomenclature is tentative. All Column-types up to this points get all their properties through the constructor. I don't think this is the right solution in this case.
  • When it comes to the implementation, right now I thinking along the lines of internally expanding Listing\Ordered and Listing\Unordered with a function withTruncation(string $truncated_text) without exposing it on the interface. The Closure passed to Table\Column\Listing::withTruncation() would then be called in the Table\Column\Listing::format() and would receive the value as parameter. More complex context could be accessed by leveraging the fact that the value comes from a Generator. I don't think this is going to be beautiful, but right now it is the best I could think of, without breaking the separation of concerns.

I'm very grateful for any feedback!

Thank you very much and best, @kergomard

kergomard avatar May 07 '25 14:05 kergomard

Hi @kergomard

Thank you a lot for contributing to ILIAS. You will get some further feedback, nevertheless, I would like to point out that the HTML validator spits out a few errors if you want to take this into account already (Line 5506-5621):

  • [ ] The role attribute must not be used on a tr element which has a table ancestor with no role attribute, or with a role attribute whose value is table, grid, or treegrid.
  • [ ] The role attribute must not be used on a th element which has a table ancestor with no role attribute, or with a role attribute whose value is table, grid, or treegrid.
  • [ ] The role attribute must not be used on a td element which has a table ancestor with no role attribute, or with a role attribute whose value is table, grid, or treegrid,
  • [ ] Attribute aria-colindex not allowed on element th at this point.
  • [ ] Bad value Ascending for attribute aria-sort on element th.
  • [ ] Bad value 0 for attribute aria-colindex on element td: Zero is not a positive integer.

If I can support you with finding these errors, please contact me.

kindly @yvseiler

yvseiler avatar Jun 24 '25 08:06 yvseiler

Thank you very much for the feedback @yvseiler ! I will check this once we are clear on the interface, I'm not really sure this issue really is related to my changes, but I will figure it out, when I get there.

Thanks again and best, @kergomard

kergomard avatar Jun 25 '25 06:06 kergomard

Hi everyone,

@kergomard and I quickly discussed this today. We agreed that we want to try to treat the "truncation"-issue as a strictly visual problem, i.e. not exposing any functionality for truncation to PHP developers for the moment.

General idea is that for a List Column the table would e.g. show the first three entries of the list and then a button saying "show all 10 entries" to expand the row to show the rest.

I'm sure @kergomard will want to elaborate at some point, this is just a quick marker to keep everyone updated on the progress here.

Kind regards!

klees avatar Jul 15 '25 15:07 klees

@kergomard Please pass back to me and ping me for the next iteration. Thanks!

klees avatar Jul 15 '25 15:07 klees

Thank you very much @klees for the talk and feedback!

I now implemented a approach that is fully based on convention:

  • Lists in Tables are currently always reduced to 2 items + a "Show 4 more items"-shy-button.
  • This is true for the column types 'List' and 'LinkList'.
  • The changes are actually mostly in ILIAS\UI\Implementation\Listing. I have not surfaced them to the interface though, but I think it could be an option to do so. I would then stick to the "convention over configuration"-approach and not make the amount of items configurable.
  • The implementation is kept minimal on purpose, there e.g. is no styling. I right now believe this to be the right approach here, but clearly we could do a lot of moving around.
  • The implementation looks like this: Bildschirmaufzeichnung vom 2025-08-11 10-02-38.webm

Thanks again and best, @kergomard

kergomard avatar Aug 11 '25 08:08 kergomard