View Issue Details

IDProjectCategoryView StatusLast Update
0033520mantisbtplug-inspublic2024-03-27 20:14
Reportercas Assigned Todregad  
PrioritynormalSeverityminorReproducibilityalways
Status closedResolutionno change required 
Product Version2.25.2 
Summary0033520: Cannot add option to MantisGraph
Description

I cannot add option to the graphics tab MantisGraph. Apparently one can add items there using the EVENT_MANTISGRAPH_SUBMENU event.
In my plugin I have added a hook to that event and refered to a function which returns the required <a> tags.
Unfortunately no new button shows up.

Steps To Reproduce

Add this hook to a plugin :
'EVENT_MANTISGRAPH_SUBMENU' => 'extension'

Add function extension to the same plugin as:
function extension() {
return '<a class="btn btn-sm btn-primary btn-white %s" href="'. plugin_page( 'project_graph.php','','MantisGraphExt' ) . '">' . "<i class='fa fa-bar-chart'> " . lang_get( 'by_project' ) . '</a>' ;
}
This should lead to another button on that page with the title "By Project" but it does not appear.

TagsNo tags attached.

Relationships

related to 0026139 closeddregad Move MantisGraph pages to their own tab 
related to 0034008 closeddregad MantisGraph: document usage of EVENT_MANTISGRAPH_SUBMENU 

Activities

dregad

dregad

2024-02-19 19:02

developer   ~0068571

@cas please have a look at 0026139:0062802 where I included a sample plugin that I used to test the hook when I introduced the new EVENT_MANTISGRAPH_SUBMENU event.

I tried to copy/paste your return value in my test plugin and the button shows.

atrol

atrol

2024-03-08 03:03

developer   ~0068629

cas,

You did not provide feedback; I am therefore resolving this issue as "no change required".

Feel free to reopen the issue at a later time and provide information how to reproduce.

cas

cas

2024-03-09 09:39

reporter   ~0068630

Last edited: 2024-03-09 09:39

@dregad, the solution as demonstrated through the TestSummarySubmenu plugin indeed works nicely. However graphs are not shown in the added page. I hae adjusted a sample page2.php which should show the category graphs. Is this a bug or should other settings be defined?

cas

cas

2024-03-09 09:40

reporter   ~0068631

The mentioned sample page for my previous comment.

page2.zip (929 bytes)
dregad

dregad

2024-03-10 08:19

developer   ~0068633

graphs are not shown in the added page. [...] Is this a bug or should other settings be defined?

For charts to be displayed, 2 things need to be done:

  1. include chart.js library
  2. initialize the <canvas> elements containing the graphs with the appropriate JavaScript code

In the MantisGraph plugin, this is handled by the resource() method, calling the include_chartjs() function for (1), and the MantisGraph.js script which takes care of (2).

Now whether this not working for your child plugin should be considered a bug or not is debatable.

I believe that a plugin hooking EVENT_MANTISGRAPH_SUBMENU to show additional graphs may want to use some other chart library to do its work, in which case it would not make sense to forcefully and systematically include chart.js and in this case it would be better to let the plugin decide what to do.

I agree this could be better documented; I'm not sure where to put that though. Maybe in the PHPDoc for MantisGraph's events(), unless you have a better idea ?

See proposed doc below, suggestions for improving this text are welcome.

EVENT_MANTISGRAPH_SUBMENU (Default): allows 3rd-party plugins to add
additional graphs {@see https://mantisbt.org/bugs/view.php?id=26139#c62802}.
NOTE: If the child plugin wishes to use the chart.js library to display
its graphs, then it is responsible to
  1. include the library as appropriate for its needs
     (the {@see include_chartjs()} method can be used for this purpose)
  2. initialize the <canvas> elements containing the graphs
This is typically done in the hook for EVENT_LAYOUT_RESOURCES,
({@see resources()} method for details).
cas

cas

2024-03-11 03:32

reporter   ~0068639

Clear answer. As for the doc proposed, to me that is clear enough and indeed would add it in the sectionof the mantisGraph events. issue can be clsed again.

Related Changesets

MantisBT: master-2.26 5e08259e

2024-03-10 08:58

dregad


Details Diff
MantisGraph: document EVENT_MANTISGRAPH_SUBMENU

As discussed in issue 0033520 (see note 0033520:0068633).

Fixes 0034008
Affected Issues
0033520, 0034008
mod - plugins/MantisGraph/MantisGraph.php Diff File