Dashboard > Atlassian Plugins > ... > Macros > list-data
  Atlassian Plugins Log In | Sign Up   View a printable version of the current page.  
  list-data

Added by admin , last edited by David Peterson on Mar 01, 2008  (view change)
Labels: 

{list-data}

Plugin: Scaffolding Plugin

Allows selection of one or more options from a specific list.

Description

Must contain option-generating sub-macros (e.g. list-option or content-options).

Usage

{list-data:Name|type=[select, check]|multiple=[true, false]}
{xxx-options}
{list-data}

Parameters

Name Required Default Description
[default]/name
The name of the field.
type
select
The type of field to display. May be one of the following:
  • select - (default) A selectable list is displayed.
  • check - A list of checkable items are displayed.
multiple
false
If true, multiple options may be selected.
width
The width of the field. Any CSS width is allowed (e.g. 100px). Note: Only applies when type is 'select'.
height
The height of the field. Any CSS height is allowed (e.g. '20px'). Note: Only applies when type is 'select'.
required
false
If true, a non-empty item must be selected.
separator
(Since Scaffolding 2.3.2) If multiple items are selected, the type of separator to display between each item. Defaults to one item per line. May be one of the following:
  • bracket - Square brackets ('[', ']') surrounding each item.
  • brace - Braces ('{', '}') surrounding each item.
  • comma - A comma (',') between each item.
  • paren - Parentheses ('(', ')') surrounding each item.
  • pipe - A pipe ('|') between each item.
  • newline - A line break after each item.
  • "custom" - Any other character you wish, specified between quotes.
blank
false
If 'true', a blank item is added to the list. Only applies to 'select' lists. If the user saves while selecting the blank item and the list is 'required', the page cannot be saved.
blankText
If specified, and 'blank' is true, this text will be used for the blank option label. E.g. 'blankText=[None]'

Examples

Plain list options

Number: {list-data:List}
{list-option}One{list-option}
{list-option}Two{list-option}
{list-option}Three{list-option}
{list-data}

Wikified list options

Emoticon: {list-data:Emoticon}
{list-option:Star}(*){list-option}
{list-option:Plus}(+){list-option}
{list-option:Minus}(-){list-option}
{list-data}

Recipes

See Also

Anonymous

list (select):

list: (radio)

list (select): {list-data:list}
{list-option:AAAA}aaaa{list-option}
{list-option:BBBB}bbbb{list-option}
{list-option:CCCC}cccc{list-option}
{list-data}

list: (radio){list-data:listRadio|type=check|multiple=false}
{list-option:AAAA}aaaa{list-option}
{list-option:BBBB}bbbb{list-option}
{list-option:CCCC}cccc{list-option}
{list-data}

The two lists above seem to be inconsistent. When editing the data, the labels are reversed.
list (select) shows AAAA, BBBB, etc as options, whereas list (radio) is showing aaaa, bbbb, etc.

It would be more consistent if both lists show AAAA as options in edit/view mode but aaaa is the actual value stored in the database !?

Perhaps. The reason they are different is that you can't have fancy wiki/html code in a select box option, but you can when it's displayed as a label next to a checkbox. The fancy code (in this case 'aaaa') is what is displayed when HTML is available, the simple code ('AAAA') is displayed when it isn't available (i.e. select boxes) and both are stored in the database.

Don't know if that helps, but that's how it is at the moment...

I'm using the "plain list options" example. If I choose to edit the page, I see all the text fields and selections and so on. I can make a selection from the list. However, the saved page shows only the text fields. The lists are simply not there.

What's going on? This is with Confluence 2.2.3 and Scaffolding{{ 2.2-dr3.}}

Hm. If I use the wikified list options, it works as expected.

Whoops. Bad example code. I've updated the example above to use the wiki method.

As an aside, I'm not sure which is the preferred option - requiring wiki or non-wiki options. Any thoughts people?

I'm hoping someone can help me. What I am trying to do is create a select list

list-data: Please provide a name.

, then have the value of the selected item


 
TPM Overall Project Ranking: 0.0


I am looking for another way. Thanks!

Well..that made a mess. I thought I escaped the {

I am trying to create a select list, and use the selected value in an eval-data expression. I won't put my sample code here cuz I don't want to create another mess. I am just wondering if anybody has done this sort of thing.

It's been a while since I looked at {eval-data}, but I don't think that will work with list-data. However, you can probably use a number-data instead (unless you're associating text with a number value). Something like this:

{number-data:Value}
{number-data:Quantity|type=select|minValue=1|maxValue=20}

{eval-data:Price}${Value} * ${Quantity}{eval-data}

Thanks for the quick response. Yes,what I am trying to do is associate text with a number value, so the user selects the text from the select box and it is translated to a number for calculation. Thanks again for the help.

In that case, I don't think you'll have much joy then. If you'd like to see something along those lines in the future, please add a feature request, or it will get lost in the static...

Hi David!

Do you know a way to display the pages' excerpts behind the pagelinks.Perhaps together with the reporting plugin?!

I wanted to have a drop down list with all pages, where the user can select pages, which get linked with its excerpts in the view mode.

{list-data:selectPages\|type=select\|multiple=true\|separator=newline}
{content-options:branches=children}
{list-data}


 

Edit: I need the excerpt in the edit mode, too. Because the title is only an Requirement ID and the excerpt includes the requirement in a sentence.

So it would be really nice to display the excerpt behind the pages' title.

My code yet looks like:

{list-data:selectPages|type=check|multiple=true}
{content-options:branches=children}
{list-data}

Is there a way to specify a default option for the list? If I'm offering choices of A, B, C but I'd like the value to be B unless the user changes it?

Thanks.

Not at present. It could be difficult to specify which option is selected by default in the wiki markup. Each {xxx-option} macro would probably have to have its own 'default' parameter which it would interpret as best it could.

If you'd like to see something along those lines in a future version, please create a feature request so it is put into the pipeline.

Hi,

just a general question. Will or could the list-data macro be optimized for usage in future version. I think it's not necessary to have a label-option AND a list-option macro.
It could be easier when list-data has an label=true option.
So every content of list-data could be used as a label.
And list-option should be used like label-options. e.g. {list-option:label1, label2, label3}val1,val2,val3, so you don't have to type list-option twice for each value.

What do you think of this?

{list-option} and {label-option} serve different functions. One simply stores text, the other manages labels. The internals are quite different. The restrictions on what makes a legal label is also much more restrictive than what is possible for ordinary labels.

That said, I'm not opposed to some of the syntax crossing over. If you'd like to see a "label1, label2" style option for {list-option} in a future version, please create a feature request and we'll see what can be done.



Updated by Christian Nesemann
Apr 30, 2008 00:38

Hi,
it was just a thought to reduce the amount of syntax. I really can imagine that their internals are different.

So if list-option would have the same syntax as label-option it might be easier to put them together.

Will create a feature request for it.

Btw. if a page is created and "accepted" by confluence, the page title could be added as an label, or ? I think there are no cases where a pagetitle isn't label conform (except spaces, but in that case more labels would be added).

So {content-options} might work with a addlabel feature.

I think I have found a bug in the list-data macro.

I have built a select list which uses the content-options to build the list based on pages with a specific label, and I also need to have the option for the user to leave the field blank.  So I use the blank=true option which creates the blank item in the list.

The blank item appears as the default option which works fine, but if you select one of the other options and save, and then try to select the blank item again, on saving the value reverts to the previously selected item.  So if you select an option, you cannot then revert it to blank again.

Can anyone confirm if this is a bug or if there is any way around it?

Hi,

this bug is already reported here.

workaround:

{list-data:ldCONTENT}
{list-option} {list-option}
{content-options}
{list-data}

Is there a way of using the selected options from a list-data field on one page as the options for a list-data field on another?

Possibly like this (untested):

{list-data:A List}
{report-on:data:Other List|injected=true}{list-option:%reference:value%}%reference:value%{list-option}{report-on}
{list-data}

You may have to add extra keys after "reference:value" depending on what type of data is in the other list. For example, if it were users and you wanted the user name, you would put "%reference:value > user:name%".

Thanks David. I had to modify it slightly and use replace-and-render, but got it to work as follows:


{replace-and-render}
{replace-body}
...
{list-data:CheckList2|type=check|multiple=true}
%CheckList1opts% {list-data}
...
{replace-body}
{replace-item:%CheckList1opts%}
{report-on:data:CheckList1|injected=true}

{list-option}%reference:value%{list-option}{report-on}
{replace-item}{replace-and-render}


With "\" before the list-option tags inside the report-on.  (Sorry haven't worked out how to paste code in as text)

Too bad that it does not work on one page. There has to be a trigger that notices a change in the first list and automatically actualizes the second list.

True, although in my application the first list will not change that often so it is less of an issue - you can save and re-edit to get the same effect.

How can I populate the options inside a list-data dynamically? The post above seems to get at this, but I'm not entirely sure. It seems like a core building block of this type of application framework.

Here's what I'm trying to do:

On each project page, a list displaying all clients allows the project to be associated with one client. A page called Clients contains a {table-data} which lists all possible clients. How can I make the 'Client' {list-data} on the project page pull from the {table-data} on the Clients page?

It looks like {content-options} would work if each client was an individual page, but I'd like the flexibility of having the source being a {table-data} (or for that matter a {report-table} or a {sql-query}).

Any help and sample source code would be appreciated.

That's not directly supported at present I'm afraid. However, some people have approximated it using a combination of the Reporting Plugin and the Replace and Render Plugin. Can anyone who's actually done this post an example?

 Have a look at this example that works:

{replace-and-render}
{replace-body}
{list-data:Client Resources|type=check|multiple=true}%CliResources%{list-data}
{replace-body}
{replace-item:%CliResources%}{report-on:data:ClientTeam|source=@parent|injected=true}\{list-option}{report-info:Name}\{list-option}{report-on}{replace-item} 
{replace-and-render}

The ClientTeam variable is a list data variable itself so you would need to amend the reporting method to report on a table, but it should be doable.

Is it possible to conditionally render a list based on a value in another list.

For example, if I have a list: one, two, three, then if one is selected i'd have one list displayed elsewhere, and if two is selected I'd have another one.

More generally, I'd like to do the same thing with the label-options



Updated by Brandon Faloona
Jul 17, 2008 04:31

I've updated this post

I could not figure out how to create a report of items that contained a null property value when that property was a list of references. My use case is: Show unassigned items, where the assignment property is set like so:

{list-data:ListOfUsers|multiple=true|blank=true|separator=newline}{user-options:groups=mygroups}{list-data}

This report code does not work (and I've tried a dozen variations):

{content-reporter:space=foo|type=page|scope=Projects > children}
  {expand-on:data:ListOfUsers> value|as=User}
    {text-filter:data:User|exclude=.+}
  {expand-on}
{content-reporter}
...

To my surprise, this code worked (even though it does not explicitly handle the list of references):

{content-reporter:space=foo|type=page|scope=Projects > children}
 {text-filter:data:ListOfUsers|exclude=.+}
{content-reporter}

However, as soon as I test for a value rather than just excluding any value (.+) the filter again fails. How can I properly iterate through multiple list-data items in a filter?

Copyright(c) CustomWare Asia Pacific Pty Ltd
Powered by Atlassian Confluence 2.7.3, the Enterprise Wiki. Bug/feature request - Atlassian news - Contact administrators