<%page args="element, widgetstyle" /> <%namespace file="../_helpers.html" import="wireElementEvents"/> <% from splunk.appserver.mrsparkle.lib import eai import splunk.util as util option_map = util.OrderedDict() selected_options = [] try: caseSensitive = True if 'caseSensitiveMatch' in element and element['caseSensitiveMatch'].lower() == 'true' else False fetch_error = False # Ensure that only valid options can be selected option_values = set([ (caseSensitive and option['value'] or option['value'].lower()) for option in element['options'] ]) if element['elementName'] in form_defaults and isinstance(form_defaults[element['elementName']], (tuple, list)): selected_options = [ val for val in form_defaults[element['elementName']] if (caseSensitive and val or val.lower()) in option_values ] for option in element["options"]: option_map[option['value']] = option['label'] except eai.EAIFetchError, e: fetch_error = e for selection in selected_options: if selection not in option_map: option_map[selection] = selection option_list = option_map.items() if 'sort' in element: method = element.get('sort') .lower() if method != 'none': option_list.sort(key=(lambda x: x[1].lower())) available_heading = _("Available %(fields)s") % { 'fields': _(element.get('label', '')) or _(element.get('elementName', ''))} selected_heading = _("Selected %(fields)s") % { 'fields': _(element.get('label', '')) or _(element.get('elementName', ''))} %> ## Note: onChange events are wired up by initAccumulators() in admin.js
% if fetch_error:
${_('Failed to fetch data: ')}${str(fetch_error)|h}
% endif
% if element.get('disabled') is None: ${_('add all')} » % endif

${available_heading|h}

## This ul contains all options that are NOT currently selected
    % for (value, label) in option_list:
  • ${label | h}
  • % endfor
% if element.get('disabled') is None: « ${_('clear all')} % endif

${selected_heading|h}

## This ul contains all options that are ARE currently selected
    % for (value, label) in option_list: % if value in selected_options:
  • ${label | h}
  • % endif % endfor
% if 'exampleText' in element:

${_(element['exampleText']) | extract_help_links }

% endif