How To: Dynamic Table View Labels?
finnito - 2 months ago
I've got a little bit of a feature request or I want to know if it's possible! When implementing a UI table with views you can get a nice set of view labels. What I would like to do is to add, say, a number in brackets which represents the number of items in that table where I to click on it and look. This would make a nice addition to the feature because it would let you see into that table at a glace without having to check. A use-case of this could be if there are comments that need to be approved, or anything really!
I have just spent some time seeing if I can insert something dynamically into the view definition but it seems a bit static and I couldn't get it to play nice!
protected $views = [ "enabled" => [ "query" => EnabledQuery::class, "text" => "finnito.module.nzen::view.enabled", ], "disabled" => [ "query" => DisabledQuery::class, 'text' => 'finnito.module.nzen::view.disabled', ], "all", ];
ryanthompson - 2 months ago
You'll need to use a
handler class for the views.
FooTableViews like this: https://github.com/anomalylabs/addons-module/blob/2.2/src/Addon/Table/AddonTableViews.php#L39
label is the value and you can change context with
context if needed (bootstrap contexts; info, success, danger, etc).