how to set default category in space list macro

Stacy Ajouri
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
November 4, 2019

The space list macro provides a list of spaces however the category value changes apparently to whatever was last used.

 

I need to set the value for the category list to a default value whenever the page is refreshed.

 

Tried the following but it had no effect.

<div>
	<script>
		let teamOptions = document.getElementsByName("spacesSelectedTeam")[0].options;
		for (let i = 0; i < teamOptions.length; i++) {
			if (teamOptions[i].value == "ttgkb") {
				// Item is found, set its property and exit
				//teamOptions[i].selected = true;
				break;
			}
		}
	</script>
</div> 

 

1 answer

0 votes
Dominic Lagger
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.
November 5, 2019

Hi @Stacy Ajouri 

Your approach is not very bad at first sight. But I have some questions.

  • Where did you add your code?
  • Would a user macro be acceptable?

Perhaps my little input helps you already to figure something out.

When I change the category it reloads the whole page with a new URL:

conflueceURL/page/viewpage.action?spaceKey=KEY&title=Space+Category&spacesSelectedTab=category&spacesSelectedTeam=ttgkb

With this URL, you will always get to the page where the team "ttgkb" is selected. 

Hope it helps, Regards,

Dominic

Stacy Ajouri
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
November 6, 2019

Hi, I just added it inside the page.  

A user macro may be possible.

The URL is okay but the user may go directory to the page from another path.

Dominic Lagger
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.
November 6, 2019

Hi @Stacy Ajouri 

I think I know why the Javascript directly in the page did'nt work, because the space category macro wasn't loaded at this time. 

I added it in end of the body in the "Custom HTML" section in the administration console. There it worked, but not very user friendly... 
When you go to the page, it sets the category as excpected --> ttgkb. But because a manual change of the dropdown reloads the page, the script is executed again and the category ttgkb is selected again... That means you would never be able to change the category. 

The user macro didn't work out for me either. Because in the settings you cannot change the default dropdown value.

The only really dirty way I can think off would be:

  • Reload the page by javascript with the URL i gave to you
  • That would mean, when a person comes to this page, it would reload automatically and the right space category is set. 
  • Redirect with Javascript

Regards, Dominic

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events