Special (number) fields in gadget preferences

Christian_Schönert October 20, 2017

Hi,

 

I am currently developing a gadget plugin in Jira 7.2. After the troublesome work I have finally managed to get the preference page for my gadget to work properly.

For example I want the user to be able to chose a standard height for the gadget. Lets say it all works fine until someone decides to write non numerics into this field. That's the reason why it needs to be a number field only.

<UserPref name="custom_height" default_value="300" />

The basic idea applies to other fields too, i.e. date fields or other numeric fields in the user preferences. So a general approach would be appreciated.

 

The only thing I found about this topic was https://developer.atlassian.com/display/GADGETS/Field+Definitions

The 'class' definition should therefore create the number field restriction. First of all, I think they have a comma missing at the end there, as all other field definitions are separated with one.

class: "numField"

After trying with and without comma, both resulted in my gadget crashing. The browser console didn't have any error message and the server log exceptions don't really help, as an error inside the gadget always causes the rest resource to crash, thus resulting in a rest resource crashing exception.

My used resources:

#requireResource("com.atlassian.jira.gadgets:common")
#requireResource("com.atlassian.gadgets.publisher:ajs-gadgets")
#requireResource("com.atlassian.jira.gadgets:autocomplete")

(So far I couldn't find reasons or differences of using ajs-gadgets or gadgets:common. It just proved to be good to have both included, so if anyone has a good documentation link, I'll be happy to get it)

Some more search revealed this issue: https://jira.atlassian.com/browse/JRASERVER-21517 which exactly describes the problem with the use of classes in gadgets. Sadly it has been sitting there for 7 years without a resolution.

edit: now the link is dead. It said that classes are not working in gadget.

 

I assume I can't be the only one who needs this functionality in a gadget. Is there any workaround? Did I make some basic mistake or miss some resources? Thank you in advance for any helpful hints or solutions.

 

Regards

Christian

0 answers

Suggest an answer

Log in or Sign up to answer