すべてのバージョン
Gadgets and Dashboards 3.0Gadgets and Dashboards 2.0
Gadgets and Dashboards 1.0
More...
This page gives more detail about the field types that were introduced in Creating a Gadget JavaScript Object.
On this page:
Sometimes you want to pass values back to the server from a form submission, but you do not want the user to be able to change those values. You can use hidden fields to achieve this.
The following code defines a hidden field:
fields: [ { userpref: "isConfigured", type: "hidden", value: "true" /* This example is hard coded but it could be dynamically generated or retrieved from the gadget prefs.*/ }, ... /* Other fields */ ]
ここで:
"hidden"
to specify that this field is hidden.This field type will be displayed as a simple text field. If the the type
attribute is not defined, the field will be of this type by default.
fields: [ { id: "numToDisplay", userpref: "numToDisplay", class: "numField" label: gadget.getMsg("gadget.common.num.label"), description: gadget.getMsg("gadget.common.num.description"), type: "text", value: gadget.getPref("numToDisplay") }, ... /* Other fields */ ]
ここで:
id
to give this field. Defaults to the value of the userpref
field."text"
or omitted, a text field (i.e. the type discussed in this paragraph) is rendered.This field type creates a text input area in the form, used for large text inputs.
fields: [ { id: "textToDisplay", userpref: "textToDisplay", class: "textBox" label: gadget.getMsg("gadget.common.display.text.label"), description: gadget.getMsg("gadget.common.display.text.description"), type: "textarea", value: gadget.getPref("textToDisplay") }, ... /* Other fields */ ]
ここで:
id
to give this field. Defaults to the value of the userpref
field."textarea"
for this type of field.
This field type is a simple selection list. As the AJAX options have been retrieved and are available during the creation of the field decscriptor, it is trivial to use them as options for the selection list. The results can be used raw or transformed.
fields: [ { id: "cumulative-field", class: "cumulative-select-list", userpref: "isCumlative", label: gadget.getMsg("gadget.common.cumulative.label"), description:gadget.getMsg("gadget.common.cumulative.description"), type: "select", selected: gadget.getPref("isCumlative"), options:[ { /* These options are hard-coded but could easily be the results of an AJAX call (E.g. args.projects) or be calculated at run time (E.g. the next three days) /* label:gadget.getMsg("gadget.common.yes"), value:"true" }, { label:gadget.getMsg("gadget.common.no"), value:"false" } ] }, ... /* Other fields */ ]
ここで:
id
to give this field. Defaults to the value of the userpref
field."select"
."select"
for this type of field.option
pairs or groups.An option is defined as:
{ id : "option-id", label: "A human readable label", value: "option-value", selected: true }
ここで:
id
of the option.Option groups are used in the following example:
fields: [ { userpref: "groupedOptions", label: gadget.getMsg("gadget.common.grouped.label"), type: "select", selected: gadget.getPref("groupedOptions"), options:[ { group: { label: "First Option Group", options: [ { label: "First Group -> First Option", value: "group-1_opt-1", }, { label: "First Group -> Second Option", value: "group-1_opt-2", } ] } }, { /* You can mix groups and non-group options */ label:"No Group Options", value:"group-N/A_opt-1" }, { group: { label: "Second Option Group", options: [ { label: "Second Group -> First Option", value: "group-2_opt-1", } ] } } ] }, ... /* Other fields */ ]
ここで:
This field type produces a multi-select input value.
fields: [ { id: "version-field", class: "multiVersionField", userpref: "selectedVersions", label: gadget.getMsg("gadget.common.versions.label"), description:gadget.getMsg("gadget.common.versions.description"), type: "multiselect", selected: gadget.getPref("selectedVersions"), /* Only use this if you only want value selected. Otherwise specify selection state on the option itself */ options:[ /* See Select Field for valid options */] }, ... /* Other fields */ ]
ここで:
id
to give this field. Defaults to the value of the userpref
field."multi-select"
."multiselect"
for this type of field.options
pairs or groups. See the Select field type (above) for valid options.This field type produces a group of radio buttons for selecting a unique value from a list of choices.
fields: [ { id: "security-level", class: "security-radio", userpref: "securityLevel", label: gadget.getMsg("gadget.common.security.label"), description:gadget.getMsg("gadget.common.security.description"), type: "radio", selected: gadget.getPref("securityLevel"), options:[ { /* See Select Field for valid options */ label: "Publicly Available", value:"public" }, { label:"Private", value:"private" } ] }, ... /* Other fields */ ]
ここで:
id
to give this fieldset. Defaults to the value of the userpref
field."radio"
for this type of field.options
pairs or groups. See the Select field type (above) for valid options.This field type produces a group of checkboxes for selecting multiple values.
fields: [ { id: "group-select", class: "group-selector-checkboxes", userpref: "selectedGroups", label: gadget.getMsg("gadget.common.groups.label"), description:gadget.getMsg("gadget.common.groups.description"), type: "checkbox", options:[ { /* See Select Field for valid options */ id: "group-users", label: "Users", value: "users" }, { id: "group-devs", label: "Developers", value: "developers", selected : true }, { id: "group-admins", label: "Administrators", value: "admins", selected : true } ] }, ... /* Other fields */ ]
ここで:
id
to give this fieldset. Defaults to the value of the userpref
field."checkbox"
for this type of field.options
pairs or groups. See the Select field type (above) for valid options.This field type simply injects the string into the form as HTML.
fields: [ { label: gadget.getMsg("gadget.common.groups.label"), description:gadget.getMsg("gadget.common.groups.description"), type: "custom", template: function(){ /* Returned string is injected into form */ return "<div>An example of a custom field</div>"; } }, ... /* Other fields */ ]
ここで:
"custom"
for this type of field.This is the most powerful and flexible type of field for configuration. The callback enables you to construct any HTML and attach event listeners to it.
fields: [ { id: "my-callback-field", label: gadget.getMsg("gadget.common.builder.label"), description:gadget.getMsg("gadget.common.builder.description"), type: "callbackBuilder", callback: function(parentDiv){ parentDiv.append( AJS.$("<input/>").attr({ id: "call-back-hidden-field", type: "hidden", name: userpref }).val(gadget.getPref("myCallback)) ); } }, ... /* Other fields */ ]
ここで:
id
given to the div
that is passed into the builder."callbackBuilder"
for this type of field.div
. You can then manipulate the contents of that div
and attach event handlers, e.g. click handlers.Using the Atlassian Gadgets JavaScript Framework
Writing an Atlassian Gadget
Gadgets and Dashboards Development Hub