How To: Dynamic Table View Labels?
Created 5 years ago by finnitoHey all!
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",
];
Thoughts?
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#L39label
is the value and you can change context withcontext
if needed (bootstrap contexts; info, success, danger, etc).