Hi,

Seems the code for the action button which triggers the Jira Issue Collector is not being injected.

In the admin form section in "Code" field we have this code:

<script type="text/javascript" src="<jira_js_url>"></script>
<script type="text/javascript">
jQuery(document).ready(function() {
window.ATL_JQ_PAGE_PROPS =  {
  "triggerFunction": function(showCollectorDialog) {
    //Requires that jQuery is available! 
    jQuery("#myTrigger").click(function(e) {
      e.preventDefault();
      showCollectorDialog();
    });
}};
});
</script>

The url is generated and is injected properly in the code, but the function which triggers the showCollectorDialog() is not being embedded.

In the page where we need the JIC, we added a button with this code:

<p><button class="btn btn-info" id="myTrigger">Click to Report</button></p>

When we click it, nothing happens, no errors shown in console.

We tried to add manually the JS which reacts to the button click in jira_issue_collector.js file and it works.
But I'm not sure if that's the way to go.

Is this a problem of the module?
Or am I using it in the wrong way?

Thanks in advance.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

SalvadorP created an issue. See original summary.

SalvadorP’s picture

Issue summary: View changes
kasperg’s picture

The code you pasted does not look right to me. I wonder how you ended up with that?

I would expect it to be in the format:

// Requires jQuery!
jQuery.ajax({
    url: "<jira-js-url>",
    type: "get",
    cache: true,
    dataType: "script"
});

The <jira-js-url> should be picked up when pasted in the JIRA Issue Collector module settings form.

I have attached screenshots of how I would expect it to appear in the JIRA administration and in the Drupal module settings page. Perhaps that will be helpful to you.

SalvadorP’s picture

Hi @kasperg,

Thanks for your answer, and the screen captures!

The code I'm using is the one which the Jira Issue Collector generator page gives. (Tried with both versions HTML and JS)
But does not work, I tried with the format you say, but it's the same, no errors, but no button or button reaction to launch the issue collector.

Looking at the JIRA documentation, seems that starting from version 1.2 they included this extra code to personalize the trigger.

I'm using version 1.4 of the Jira Issue Collector, maybe that's the reason why is not working for me.

If I include the "extra" code at the JS file or in the rendered page the issue collector works and appears when clicking the button.

SalvadorP’s picture

Hi @kasperg,

Your module works fine always if you select "Prominent, Subtle or Vertical" in the Trigger style options of the Jira Issue Collector.

The problem comes when you select the Custom format.
In that format you need to attach the custom code for the trigger.
And the module is not attaching it, I suppose is out of the scope of the module.

So, the module seems to be working as expected always you use the other 3 options.
I'll close the ticket as working as expected.

Thanks for your time,

Kind Regards.

SalvadorP’s picture

Status: Active » Closed (works as designed)
kasperg’s picture

Title: Jira Issue Collector Button Code not injected » Jira Issue Collector is not activated for Custom trigger style
Status: Closed (works as designed) » Active

@SalvadorP: Good catch.

We could add an option to the JIRA Issue Collector module mentioning the "Custom" option. If the user checks the "Use custom trigger style" checkbox and enters the ID for the trigger element, then the trigger is added.

SalvadorP’s picture

Hi @kasperg,

Thanks!

I think it will be a really good addition to the module, it will provide more flexibility to it.

Maybe it will be better to add a textarea to let the user add all the Custom JS code.
This will allow the user to personalize the behaviour of the button or fill some fields by default with some data.

In case you need some help with this, just tell me, I'll gladly help you.

kasperg’s picture

I get your point but I would like to avoid injection of arbitrary code in the module.

Arbitrary code injection is a potential security problem. If users really want to inject code there are better solutions for that. Either through development or modules like JS injector.

Filling fields by default is interesting but I would prefer settings for that as well. Combining this with Tokens could be quite neat - but that is a topic for another issue.

If you are up for it I would appreciate a patch for better handling of the "Custom" trigger style.

SalvadorP’s picture

FileSize
4.91 KB

Hi,

Here is the patch which gives the functionality for the custom trigger.

ravibarnwal’s picture

patch #10 is working fine with custom trigger style. I am using 7.1.4 version of the module.

JeroenT’s picture

Category: Bug report » Feature request