Pocket Query: Question on Dynamic Parameters

  • Is it possible to have Dropdown for parameters out of the box? I did some change to the template example and made it work but it's very rough. Needs lot of structuring.
<form method="get" class="aui pq-dynamic-parameter-form" action="">
  <button type="submit" class="pq-change-button aui-button aui-style aui-button-primary">Change!</button>
  #foreach($key in $queryParameters.keySet())
  #set($reqKey = "pq_$key")
  <div>
    <label for="$reqKey">$key</label>
    <select class="text" id="$reqKey" name="$reqKey" value="$!req.getParameter($reqKey)">
		<option value="CRITICAL">CRITICAL</option>
		<option value="MAJOR">MAJOR</option>
		<option value="WARNING">WARNING</option>
		</select>
  </div>
  #end
</form>
$PocketQuery.template("default")
  • When i try to draw a chart (Using Confluence Chart Macro and Using PC Templates to draw charts) with results of a query that has dynamic parameters, i don't see an option to change the parameter. I'd like to re-draw a chart based on changed parameters.
  • How do i provide value in LIKE clause using dynamic parameters?
  • How do i bring in Date Picker in the parameters?

5 answers

This widget could not be displayed.

Felix,

Any views on above queries??

This widget could not be displayed.

Felix,

Since i had one field in the form, i hardcoded the field and here it is like.

<form method="get" class="aui pq-dynamic-parameter-form" action="">
  <button type="submit" class="pq-change-button aui-button aui-style aui-button-primary">Change!</button>
  <div>
    <label for="pq_Severity">Severity</label>
    <select id="pq_Severity" name="pq_Severity" selected="$!req.getParameter("pq_Severity")">
		    <option value="CRITICAL">CRITICAL</option>
        <option value="MAJOR">MAJOR</option>
        <option value="WARNING">WARNING</option>
		</select>
  </div>
</form>
<script>
PocketQuery.chart('BarChart', {
	title: "Alerts by Severity",
	width: 600,
	height: 400,
	bar: {groupWidth: "95%"},
	legend: { position: "none" },
});
</script>
  • The form works as expected when "Load Macro Dynamically" is Unchecked but the parameters does not get appended to the URL when is "Load Macro Dynamically" is checked.

My requirement is, based on the value of Severity Chosen, the char should get refreshed without page reload.

Any help on Dynamic Parameters with different form type elements would help. May be another article from your side on this would be beneficial from your side.

 

This widget could not be displayed.

P4:

Actually, I think this is an issue very similar to this one: https://answers.atlassian.com/questions/32997105

Maybe you can first evaluate if this helps you?

I just found that it could be the JS Code in the template in my answer might not work in PQ >= 2.0.2. I asked the author of the question if it still works.

...I'm actually working on a better solution currently...

Communication on the other ticket ongoing. Please check...

This widget could not be displayed.

Felix,

In my initial question i asked for 3 points. On first one, discussion is going on. Could you please answer the remaining two i.e. 

  • How do i provide value in LIKE clause using dynamic parameters?
  • How do i bring in Date Picker in the parameters?
This widget could not be displayed.

P5: DatePicker

Put this in your template:

<div class="field-group">
	<label for="input-date">Choose Date:</label>
	<input id="input-date" class="pq-datepicker" />
</div>

Then later in the script tag call this:

jQuery('.pq-datepicker').datePicker({overrideBrowserDefault: true});

P6: LIKE

1.) Full LIKE clause

Example Query:

SELECT Name, Population
FROM Country
WHERE Name LIKE :CountryNameFullLike

For CountryName "Germany" you could enter this in your macro, for example: %erma%

2.) Only part of the LIKE clause

SELECT Name, Population
FROM Country
WHERE Name LIKE CONCAT('%',:CountryNameMiddlePart,'%')

For CountryName "Germany" you could enter this in your macro, for example: erma

===

Let me know if this helps!

Suggest an answer

Log in or Sign up to answer
Community showcase
Posted Sep 17, 2018 in Confluence

Why start from scratch? Introducing four new templates for Confluence Cloud

Hi my Community friends!  For those who don't know me, I'm a product marketer on the Confluence Cloud team - nice to meet you! For those of you who do, you know that I've been all up in your Co...

601 views 8 6
Join discussion

Atlassian User Groups

Connect with like-minded Atlassian users at free events near you!

Find a group

Connect with like-minded Atlassian users at free events near you!

Find my local user group

Unfortunately there are no AUG chapters near you at the moment.

Start an AUG

You're one step closer to meeting fellow Atlassian users at your local meet up. Learn more about AUGs

Groups near you