Development question to view hooks

Added by Christian Dähn over 3 years ago

Hi,

I'm currently struggling with my missing Ruby + Rails + Redmine skills for solving a (maybe very simple) problem of extending the Gantt helper class to support view hooks for issues.

Therefore I used the issue #10485.

Any hints are very appreciated :) ...for an experienced developer my question maybe is just a case of a few seconds and a loud laugh ;)

Thanks in advance!

ciao,
Chris

Replies (7)

RE: Development question to view hooks - Added by Christian Dähn over 3 years ago

Has anyobody a hint for me - where I have to look / read / try?

ciao,
Chris

RE: Development question to view hooks - Added by Martin Denizet (redmine.org team member) over 3 years ago

Hi Christian,
It's often running into troubles that to patch Redmine core.
Did you think about a JavaScript solution? With JS you can edit the HTML that are not accessible with hook without patching Redmine files. Input JS without hacking with Custom JavaScript Plugin
Could you describe what is the ultimate goal you wish to archive? I didn't get it.

Cheers,

RE: Development question to view hooks - Added by Christian Dähn over 3 years ago

Hi,

thanks for the hint - I already thought about it, but just failed to realize it on the first try.

My target is to be able to open a context menu with a right click on the issue name exactly like it's available inside for each issues list/table in Redmine.

So a user can modify the status etc. of an issue directly inside the gantt view, like it's already possible inside the view "Issues" and "My Page".

Following your proposal would mean that I could write a jQuery script, which dynamically creates the context menu, like it's done already inside the other views, right?
Should be feasable - so I only need a special plugin/hack to insert the script only into the gantt view?

Many thanks (in advance) for your hints!

ciao,
Chris

RE: Development question to view hooks - Added by Martin Denizet (redmine.org team member) over 3 years ago

From what I saw, here is how it works:
In the view they call:
<%= context_menu issues_context_menu_path %>

It echoes something like:
<script type="text/javascript">
//<![CDATA[
contextMenuInit('/issues/context_menu')
//]]>
</script>


This will also load:
  • context_menu.js
  • context_menu.css

In context_menu.js, look the function named contextMenuInit.
This function initializes the contextual menus and other functions in context_menu.js manage the load, display and actions of the menu.

Time for the bad news:

This JS code is made to work with issue in a table/tr and issues in the Gantt are displayed in divs. See the function contextMenuRightClick to have an example of what I'm talking about.
So from what I show, I think you just have to copy adapt the content of context_menu.js

Custom JavaScript Plugin can help you to add JavaScript without creating a plugin or monkey-patching Redmine files.

Cheers!

RE: Development question to view hooks - Added by Christian Dähn over 3 years ago

Hi Martin,

many thanks! I should have been able to find it out by myself O:) ...just the point that the context menu currently sticks to table entries wasn't sooo clear...

But as often: If you're stuck to a problem for long time, you even don't recognize the real trivial things O:)

I'll give it a try and write it as plugin - would be really great, if the problem could be solved :)

Thanks again!

ciao,
Chris

RE: Development question to view hooks - Added by Jean-Baptiste Barth over 3 years ago

The "deface" gem from the spree ecosystem is an other option: https://github.com/spree/deface

Basically it hooks into the rendering process to add/remove/modify your views at compile time. I have some plugins using it, the most simple being probably redmine_refresh : https://github.com/jbbarth/redmine_refresh

Good luck

RE: Development question to view hooks - Added by Christian Dähn over 3 years ago

The deface gem sounds interesting - I'll check out your plugin, sounds really promising :)

Many thanks!

ciao,
Chris

(1-7/7)