How do I use JS to create a dynamic dropdown to select a list of statuses

Nicky February 11, 2021

Hi all, I'd like to add a dropdown that will allow users to select from a list of predefined status types.  I do not have access to create user macros so I was wondering if there's a way to use the HTML macro and add some JavaScript (maybe leverage Ajax) to define the various status types and colors and then pass that to the status macro to display.

I did find a solution to do this using a user macro but since I have no access to that, I was wondering if anyone can give me the JS alternative that I can add to an HTML include. 

I've added the user macro code below.

Thank you all very much for the help:

 

##
 @param Status:title=Status|type=enum|required=true|enumValues=NOT 
STARTED,IN PROGRESS,PASS,FAIL,BLOCKED|desc=Test Case Status.

#if ( $paramStatus == "NOT STARTED" )
#set ( $color = "Grey" )

#elseif ( $paramStatus == "IN PROGRESS" )
#set ( $color = "Yellow" )

#elseif ( $paramStatus == "PASS" )
#set ( $color = "Green" )

#elseif ( $paramStatus == "FAIL" )
#set ( $color = "Red" )

#elseif ( $paramStatus == "BLOCKED" )
#set ( $color = "Red" )

#else
#set ( $color = "Grey" )
#end

<ac:macro ac:name="status">
    <ac:parameter ac:name="colour">$color</ac:parameter>
    <ac:parameter ac:name="title">$paramStatus</ac:parameter>
</ac:macro>

 

1 answer

2 votes
Katerina Kovriga _Stiltsoft_
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
February 12, 2021

Hi @Nicky ,

I can suggest using one of our apps - Handy Macros for Confluence.

The add-on provides the Handy Status macro that fully accomplishes your case: you create pre-defined sets of statuses and switch them in the page view mode.

Besides you'll be able to use Handy Dates - clever datepickers that allow you to change dates also on the fly without going to the page edit mode.

Nicky February 12, 2021

I appreciate the answer but I need a solution that will work with an HTML macro.  I do not have the ability to add new macros.

Thanks again.

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events