wtform_fields module - Platform - BlueCat Gateway - 18.12.1

Gateway Administration Guide

prodname
BlueCat Gateway
version_custom
18.12.1

This is where all the UI Components Fields and their base classes are located.

Custom WTForm fields.

class wtform_fields.AliasRecord(label='', validators=None, result_decorator=None, **kwargs)

Bases: wtform_fields.ValidatingStringField

StringField for inputting Alias Records with client side validation and autochecks that it is available.

Parameter Description
label HTML label for the generated field.
validators WTForm validators for the field run on the server side.
result_decorator Function to manipulate result set instead of a server-side call.
kwargs Other keyword arguments for WTForms Fields.

class wtform_fields.Configuration(label=None, validators=None, **kwargs)

Bases: wtform_fields.CustomSelectField

SelectField that is auto-populated with configuration data.

Parameter Description
label HTML label for the generated field.
validators WTForm validators for the field run on the server side.
kwargs Other keyword arguments for WTForms Fields.

widget= <bluecat.ui_components.wtform_widgets.SuperSelect object>

class wtform_fields.CustomBooleanField(label='', validators=None, on_checked=None, on_unchecked=None, **kwargs)

Bases: wtforms.fields.core.BooleanField, wtform_fields.extended_field.ExtendedField

Custom boolean/checkbox class that extends WTForms to generate HTML and JavaScript checkbox code.

Parameter Description
label HTML label for the generated field.
validators WTForm validators for the field run on the server side.
on_checked JavaScript functions to call when checkbox is checked.
on_unchecked JavaScript functions to call when checkbox is unchecked.
kwargs Other keyword arguments for WTForms Fields.

generate_call_function_js()

Generate JavaScript for call function.

Returns: JavaScript for call function

generate_checkbox_javascript()

Generates JavaScript to handle the checking/un-checking and populating of the checkbox.

Returns: JavaScript code to handle changes to checkbox.

generate_event_listener_js()

Generate JavaScript to call side_effect function on change.

Returns: JavaScript to call side effect function on change.

generate_populate_function_js()

Generate JavaScript for populate function.

Returns: JavaScript for populate function.

widget= <bluecat.ui_components.wtform_widgets.SuperCheckboxInput object>

class wtform_fields.CustomButtonField(label=None, validators=None, **kwargs)

Bases: wtforms.fields.core.BooleanField, wtform_fields.ExtendedField

A simple button object with no attached JavaScript.

Parameter Description
label HTML label for the generated field.
validators WTForm validators for the field run on the server side.
kwargs Other keyword arguments for WTForms Fields.

widget= <bluecat.ui_components.wtform_widgets.SuperInput object>

class wtform_fields.CustomSearchButtonField(label=None, validators=None, message_field='', clear_below_on_change=False, **kwargs)

Bases: wtform_fields.CustomButtonField

Button implementing a remote query from input data of a single field.

Parameter Description
label HTML label for the generated field.
validators WTForm validators for the field run on the server side.
clear_below_on_change Whether to clear all fields below it when the user selects a different option.
message_field Deprecated. Use display_message from ExtendedField instead.

generate_call_function_js

Generate JavaScript for call function.

Returns: JavaScript for call function.

generate_clear_below_js

Add disable all below code.

Returns: JavaScript for CustomSearchButtonField.

generate_event_listener_js

Generate JavaScript to call side_effect function on change.

Returns: JavaScript to call side effect function on change.

generate_populate_function_js

Generate JavaScript for populate function. Generate empty populate function in case another js function tries to call the searchButtons populate function.

Returns: JavaScript for populate function.

generate_side_effect_function_js

Generate JavaScript for side effect function.

Returns: JavaScript for side_effect function.

class wtform_fields.CustomSelectField(label=None, validators=None, choices_function=None, default_not_selected='1', clear_below_on_change=False, **kwargs)

Bases: wtforms.fields.core.SelectField, wtform_fields.ExtendedField

SelectField that is auto-populated with configuration data.

Parameter Description
label HTML label for the generated field.
validators WTForm validators for the field run on the server side.
choices_function Python function for retrieving the choices used to populate the select field.
default_not_selected The default value for the SelectField when nothing is selected.
clear_below_on_change Whether to clear all fields below it when the user selects a different option.
kwargs Other keyword arguments for WTForms Fields.

generate_call_function_js()

Generate JavaScript for call function.

Returns: JavaScript for call function.

generate_clear_below_js()

Add disable all below code.

Returns: JavaScript.

generate_event_listener_js()

Generate JavaScript to call side_effect function on change.

Returns: JavaScript to call side effect function on change.

generate_populate_function_js

Generate JavaScript for populate function.

Returns: JavaScript for populate function.

generate_side_effect_function_js

Generate JavaScript for side effect function.

Returns: JavaScript for side_effect function.

widget= <bluecat.ui_components.wtform_widgets.SuperSelect object>

class wtform_fields.CustomStringField(label='', **kwargs)

Bases: wtforms.fields.core.StringField, wtform_fields.ExtendedField

String field which will fetch the value of another field as put it as it’s own when the call_{id} function is called.

Parameter Description
label HTML label for the generated field.
inputs Determines where to fetch the data from or what to pass to a server call. If no server_side_method is defined, then inputs must contain the id of itself mapping it to the field where to get the data from.
default_not_selected Server-side call to retrieve data.

generate_call_function_js()

Generate the call function.

Returns: JavaScript for call function.

generate_populate_function_js()

Generate JavaScript for populate function.

Returns: JavaScript for populate function

widget= <bluecat.ui_components.wtform_widgets.SuperTextInput object>

class wtform_fields.CustomSubmitField(label='', validators=None, **kwargs)

Bases: wtforms.fields.core.SubmitField, wtform_fields.extended_field.ExtendedField

Field to render submit button.

Parameter Description
label HTML label for the generated field.
validators WTForm validators for the field run on the server side.
kwargs Other keyword arguments for WTForms Fields.

generate_call_function_js()

Generate JavaScript for call function.

Returns: JavaScript for call function.

generate_populate_function_js()

Generate JavaScript for populate function.

Returns: JavaScript for populate function

widget= <bluecat.ui_components.wtform_widgets.SuperSubmit object>

class wtform_fields.ExtendedField(label=None, validators=None, inputs=None, enable_on_complete=None, on_complete=None, on_change=None, on_validate=None, on_click=None, classes='', required='', is_disabled_on_error=False, is_disabled_on_start=True, server_outputs=None, server_side_method=None, result_decorator=None, server_side_output_method=None, output_result_decorator=None, workflow_name='', permissions='', readonly=False, enable_dependencies=None, disable_dependencies=None, should_cascade_disable_on_change=False, clear_dependencies=None, should_cascade_clear_on_change=False, display_message=False, **kwargs)

Bases: wtforms.fields.core.Field

Base class for UI Component Fields that adds extra functionality.

Parameter Description
label HTML label for the generated field.
validators WTForm validators for the field run on the server side.
inputs Specific inputs to the server_side_method. Should be a dictionary of key and element id pairs.
enable_on_complete Fields to enable once user is done with a field and should then move on to other fields.
on_complete JavaScript functions to call once the user is done with a field and should move on to other fields.
on_change JavaScript functions to call when the user changes the value of a field.
on_validate JavaScript functions to call when the user on validation of field.
on_click JavaScript functions to call when the user on click of field.
classes Extra HTML classes to append to the element.
required Whether the field must be filled in or not. If True, users must put something in the field in order to submit the form.
is_disabled_on_error Whether the field should be disabled if the form is reloaded when an error occurs. The default is False.
is_disabled_on_start Whether the field should be disabled if the form is first loaded. The default is True.
Note: When using GatewayForm, all fields are disabled on start by default. This parameter should be True for at least one field to get the started.
server_outputs Mapping of returned data properties to which field they should go to.
server_side_method The server-side endpoint method the field uses to get the data it displays.
result_decorator Function to manipulate result set instead of a server-side call.
server_side_output_method The server-side endpoint method the field uses to populate other fields. Must be used in conjunction with server_outputs.
output_result_decorator Function to manipulate result set instead of an output server-side call.
workflow_name Name of the workflow the element is used in.
permissions Which workflow permissions the server_side_method should have.
readonly If True, the field will only be readable but not interactive. False by default.
enable_dependencies List of dependents from which the enable_disable_dependents_generator function generates a JavaScript function to enable those dependents.
disable_dependencies List of dependents from which the disable_dependents_generator function generates a JavaScript function to disable those dependents. The JavaScript function can then be triggered by being called in on_change, on_validate, or on_complete.
should_cascade_disable_on_change  
clear_dependencies Which workflow permissions the server_side_method should have.
should_cascade_clear_on_change  
display_message Flag on whether to display server endpoint messages.
kwargs Other keyword arguments for WTForms Fields.

clear_component_message()

Create JavaScript to clear a message for a UI component.

Returns: JavaScript code.

clear_dependents_generator(dependents, trigger)

Generates JavaScript function for clearing a field’s dependent fields.

Parameter Description
dependents List of ids of the field’s dependents.
trigger Type of event needed to occur on the field to trigger the function e.g. on_change, on_complete.

Returns: JavaScript function code as Python string.

clear_self_and_dependants_generator(has_dependents=False, trigger='on_change', cascade=False)

Generates JavaScript function for clearing a field and calling the generated function for clearing its dependent fields.

Parameter Description
has_dependents Whether the field has dependents to be cleared along with it.
trigger Type of event needed to occur on the field to trigger the function. For example, on_change, on_complete.
cascade Whether the field’s dependents should be cleared along with it. Will clear dependents if True.

Returns: JavaScript function code as Python string.

enable_disable_dependents_generator(dependents, trigger, should_disable=True)

Generates JavaScript function for enabling or disabling a field’s dependent fields.

Parameter Description
dependents List of ids of the field’s dependents.
trigger Type of event needed to occur on the field to trigger the function. For example, on_change, on_complete.
should_disable Whether the dependents should be enabled or disabled.

Returns: JavaScript function code as Python string.

enable_disable_self_and_dependants_generator(has_dependents=False, trigger='on_change', should_disable=True, cascade=False)

Generates JavaScript function for enabling or disabling a field and calling the generated function for disabling its dependent fields.

Parameter Description
has_dependents Whether the field has dependents to be disabled along with it.
trigger Type of event needed to occur on the field to trigger the function. For example, on_change, on_complete.
should_disable Whether the dependents should be enabled or disabled.
cascade Whether the field’s dependents should be disabled along with it. Disables dependents if True.

Returns: JavaScript function code as Python string.

classmethod fill_in_missing_triggers(trigger_dict)

Check the trigger_dict to see if it is missing any of the triggers defined for the class.

Parameter Description
trigger_dict A dictionary containing the triggers to be checked.

Returns: The given trigger_dict with missing triggers added as keys in the dictionary with an empty list as the value.

generate_call_function_js()

Generate JavaScript for call function

Returns: JavaScript for call function.

generate_common_clear_code()

Generator used to generate field clearing code, should be used by child classes that inherit it to generate complete JavaScript for fields.

Returns: Generated JavaScript for the field.

generate_common_disable_code()

Generator used to generate field disabling code, should be used by child classes that inherit it to generate complete JavaScript for fields.

Returns: Generated JavaScript for the field.

generate_common_display_message_code()

Generator used to generate field disabling code, should be used by child classes that inherit it to generate complete JavaScript for fields.

Returns: Generated JavaScript for the field.

generate_common_enable_code()

Generator used to generate field enabling code, should be used by child classes that inherit it to generate complete JavaScript for fields.

Returns: Generated JavaScript for the field.

generate_common_server_output_code()

Generator used to generate server output code, should be used by child classes that inherit it to generate complete JavaScript for fields.

Returns: Generated JavaScript for the field.

generate_event_listener_js()

Generate JavaScript to listen and execute code on events.

Returns: JavaScript for event listening.

generate_populate_function_js()

Generate JavaScript for populate function.

Returns: JavaScript for populate function.

javascript_generator()

Generates default JavaScript standard for every field.

Returns: Generated JavaScript for the field.

populate_component_message()

Create JS to populate a message for a ui component..

Returns: JavaScript code.

populate_fields_generator(outputs, trigger='on_complete')

Function for populating multiple fields from a mapping of given data to fields.

Parameter Description
outputs Mapping of data properties to which field they should go to.
trigger Type of event needed to occur on the field to trigger the function. For example, on_change, on_complete.

Returns: JavaScript function output_<element_id> that handles the populating of multiple fields.

post_call_generator(output_functions=None)

Generates JavaScript function that makes a one-off POST call to an endpoint generated from the workflow_name and element_io with the given inputs. On successfully callback, will call a function with name “populate_<element_id>” with the returned results.

Parameter Description
output_functions List of functions to call with data returned from POST call.

Returns: JavaScript function code as Python string.

server_output_javascript(outputs=None, trigger='on_complete')

JavaScript function for a specific field that can be called to populate an arbitrary number of other fields based on server output from the specified endpoint.

Parameter Description
outputs Mapping of returned data properties to which field they should go to.
trigger The trigger for when the function should be called.

Returns: JavaScript function code as Python string.

triggers= ['on_change', 'on_validate', 'on_complete', 'on_checked', 'on_unchecked']

class wtform_fields.FilteredSelectField(filter_field='', message_field='', label='', size=6, **kwargs)

Bases: wtform_fields.filtered_select_field.NoPreValidationSelectField, wtform_fields.extended_field.ExtendedField

FilteredSelectField a select field with an attached filter field that can provide hints by which to filter the results in the search field by. Provides functionality for passthrough fields as well.

Parameter Description
filter_field Mapping of returned data properties to which field they should go to.
message_field Deprecated. Use display_message from ExtendedField instead.
clear_fields The fields to clear when a new filter hint is typed.
label HTML label for the generated field.
kwargs Other keyword arguments for WTForms Fields.

generate_call_function_js()

Generate JavaScript for call function.

Returns: JavaScript for call function.

generate_event_listener_js()

Generate JavaScript to call other js functions on change event.

Returns: JavaScript to call functions on change event.

generate_filter_field_js()

Generate JavaScript to filter the field.

Returns: JavaScript for filtering the field.

generate_populate_function_js()

Generate JavaScript for populate function.

Returns: JavaScript for populate function.

widget= <bluecat.ui_components.wtform_widgets.SuperSelect object>

class wtform_fields.HostRecord(label='', validators=None, result_decorator=None, **kwargs

Bases: wtform_fields.ValidatingStringField

StringFIeld for inputing the host records.

Parameter Description
label HTML label for the generated field.
validators WTForm validators for the field run on the server side.
result_decorator Function to manipulate result set instead of a server-side call.
kwargs Other keyword arguments for WTForms Fields.

class wtform_fields.IP4Address(label='', validators=None, result_decorator=None, **kwargs

Bases: wtform_fields.ValidatingStringField

StringField for inputting IPv4 addresses with client-side validation and auto-checks that it is available.

Parameter Description
label HTML label for the generated field.
validators WTForm validators for the field run on the server side.
result_decorator Function to manipulate result set instead of a server-side call.
kwargs Other keyword arguments for WTForms Fields.

class wtform_fields.NoPreValidationSelectField(label=None, validators=None, coerce=<type 'unicode'>, choices=None, **kwargs)

Bases: wtforms.fields.core.SelectField

SelectField with no pre-validation of field value against possible choices. Useful if choices are dynamically populated.

pre_validate(form)

Pre-validate method being overwritten to no longer perform validation.

Parameter Description
form The form the field belongs to.

class wtform_fields.PlainHTML(plain_html='', **kwargs)

Bases: wtforms.fields.core.Field

Field to render plain HTML.

Parameter Description
text HTML text.
kwargs Other keyword arguments for WTForms Fields.

widget= <bluecat.ui_components.wtform_widgets.HTMLWidget object>

class wtform_fields.SimpleAutocompleteField(label=None, validators=None, one_off=False, source=None, start_initialized=False, clear_below_on_change=False, **kwargs)

Bases: wtforms.fields.core.StringField, wtform_fields.ExtendedField

Generic auto-complete enabled Field.

Parameter Description
label HTML label for the generated field.
validators WTForm validators for the field run on the server side.
one_off Whether the data from the server_side_method is only retrieved once or every time the input changes.
source A static list from which auto-complete should filter and display based on user input. Used instead of server_side_method.
clear_below_on_change Whether to clear all fields below it when the user selects a different option.
kwargs Other keyword arguments for WTForms Fields.

generate_call_function_js()

Override default JS for call function.

Returns: JavaScript function snippet.

generate_clear_below_js()

Add disable all below code.

Returns: JavaScript for CustomSearchButtonField.

generate_populate_function_js()

Override default JS for populate function.

widget= <bluecat.ui_components.wtform_widgets.SuperTextInput object>

Returns: JavaScript function snippet.

class wtform_fields.TableField(label=None, data_function=None, table_features=None, **kwargs

Bases: wtform_fields.ExtendedField

Field to render Table data.()

Parameter Description
label HTML label for the generated field.
data_function Function to pre-populate the table with data.
table_features Dictionary containing feature terms to enable in the table, more info: https://datatables.net/reference/option/.
server_side_method The server-side endpoint method the field uses to get the data it displays.
inputs Specific inputs to the server_side_method. Should be a dictionary of key and element id pairs.
workflow_name Name of the workflow the element is used in.
permissions Which workflow permissions the server_side_method should have.

generate_call_function_js()

Call function JS.

generate_common_clear_code()

Override the default clear code generation with Table specific logic.

generate_global_scope_js()

Global JS components.

generate_parse_data_function_js()

Parse data JS function.

generate_populate_function_js()

Populate function JS.

widget= <bluecat.ui_components.wtform_widgets.SuperTableWidget object>

class wtform_fields.ValidatingStringField(label='', validators=None, client_side_validator='', clear_below_on_change=False, **kwargs)

Bases: wtforms.fields.core.StringField, wtform_fields.ExtendedField

StringField with server side validation that can be attached to it, will show green when validated and red when not.

Parameter Description
label HTML label for the generated field.
validators WTForm validators for the field run on the server side.
client_side_validator JavaScript function name to call when validating field.
classes Extra HTML classes to append to the element.
kwargs Other keyword arguments for WTForms Fields.

generate_user_input_delay()

Generates generic JavaScript function for adding delay on input.

Return: The generated JavaScript for adding delay on input.

widget= <bluecat.ui_components.wtform_widgets.SuperTextInput object>

generate_call_function_js()

Override default JS for call function

Returns: JavaScript function snippet.

generate_clear_below_js

Add disable all below code.

Returns: JavaScript for clear below JS.

generate_client_and_server_validator()

Adds client and server side validation to a field. Listener for the field must be added separately and should call “populate_<element_id>” when it wants to validate the input.

Returns: JavaScript function code as Python string.

generate_populate_function_js

Override default JS for populate function.

Returns: JavaScript function snippet.

generate_user_input_delay

Generates generic JavaScript function for adding delay on input.

Returns: The generated JavaScript for adding delay on input.

class wtform_fields.View(label='', validators=None, result_decorator=None, **kwargs)

Bases: wtform_fields.SimpleAutocompleteField

Autocomplete enabled field for View entities.

Parameter Description
label HTML label for the generated field.
validators WTForm validators for the field run on the server side.
kwargs Other keyword arguments for WTForms Fields.

class wtform_fields.Zone(label='', validators=None, result_decorator=None, **kwargs)

Bases: wtform_fields.SimpleAutocompleteField

Autocomplete enabled field for Zone entities.

Parameter Description
label HTML label for the generated field.
validators WTForm validators for the field run on the server side.
kwargs Other keyword arguments for WTForms Fields.