Closed Farcasut closed 11 months ago
or each analytics gadget outputs its description hidden somewhere (e.g. as a data attribute) and you have some common JavaScript / CSS that shows that description after the gadget title
For me, option 2 would be best. This allows users to simply use analytics macros on separate dashboards without losing the info icon if they don't add it manually.
Also, make sure to display a title + info icon also when the analytics macros are used outside of a dashboard
Hi @Farcasut, while I understand the need expressed in #52, I'm a bit surprised by the implementation choice. Can you explain why you chose to use a macro? Did you evaluate other alternative solutions? How is this macro used by the user? Macros are rendering transformations, but they are normally localized, meaning that the transformation is done in the place where the macro is called, so that the macro output is correctly delimited and protected. Making changes / transformations in other places can cause serious editing issues. For instance, you can end up with those transformations saved in the wiki syntax.
Moreover, it feels wrong for the "description" macro to know about all analytics macros. It should be the other way around. Each analytics macro should be responsible for specifying its description and some shared code is responsible for displaying it. In other words
* either you have a generic macro to display an icon and a message on hover, and each analytics gadget calls this macro in the gadget title * or each analytics gadget outputs its description hidden somewhere (e.g. as a `data` attribute) and you have some common JavaScript / CSS that shows that description after the gadget title
In any case it should be the gadget / macro that decides whether to show or not the icon and what text to display on hover.
I took this approach of creating a macro to add the information button to all the analytics macros because I thought it was a simple solution to solve the issue, while also being easy to expand when adding other macros. However, it never occurred to me that this approach could break the view by saving XWiki syntax. As for a better implementation, I'll go with the second option because Lavina also suggested it.
Previews:
I have added a new macro that introduces an additional element to all the dashboard gadgets composed of Analytics macros. The new element is an anchor that redirects the user to the individual page of that macro. When hovered, it will display a description of the macro. Currently, I have included this macro in the 'Analytics category', but I am uncertain whether users should be able to utilize this macro as it only functions when the macros are placed in a dashboard. Preview: