Skip to content
carl edited this page May 10, 2019 · 8 revisions

Pattern

The pattern generator is used to generate text values. It can take input from different fields and use the input to generate a new value. A typical example would be to take input from a first name and last name element and use those values to generate an email address as output.

Field Value Information
Generator ID Automatic A unique id for the generator, used internally to keep track of dependencies between generators.
Generator type Pattern Specifies what kind of generator it is, diffrent types performs diffrent tasks.
Settings _Contains specific settings for the selected generator._See the Settings section.
Triggers _Determines which elements that should be used as triggers for the generator._See the Triggers section.
Outputs _Determines which elements that should be used as outputs for the generator._See the Outputs section.
Active On Determines if the generator is active or not, if its not then the generator wont be triggered even if the specified elements values is changed.

Settings

Field Value Information
Pattern

Element dependencies

By specifying an element id within curly brackets you will create a element dependency. This will automatically add the element as an input/trigger for the generator and when the generator is triggered the elements value will be injected into the pattern.

In other words you can return advanced patterns such as '{firstname} {lastname}'.

Special functions

After an generator has generated its value it is possible to apply special functions to the value, ex: uppercase({elementid}).

Available functions:

  • uppercase(), upper(), uc()
  • lowercase(), lower(), lc()
  • trim()

Metadata injection

Metadata injection is used to retrieve info about the logged in user and inject it into the generators result.

Available metadata:

  • {user.id}
  • {user.name}
  • {user.email}
  • {user.picture}
  • {user.language}

Triggers

Mark the elements that should be used as triggers for the generator. If an marked elements value is changed then this generator will be triggered as long as the value is valid.

A list of elements from the form is presented as possible triggers.

This is one of the reason to give the form elements a good descriptive name.

Outputs

Mark the elements that should be used as outputs for the generator. When the generator has generated its value these elements will be updated with the generated value.

A list of elements from the form is presented as possible outputs.

**Note: **This is one of the reason to give the form elements a good descriptive name.

Visibility

The visibility generator can hide or show elements depending on values on other elements. A typical scenario where this could be used is having a checkbox list populated with different computer peripherals if you select that you want to order peripherals to your order.

Field Value Information
Generator ID Automatic A unique id for the generator, used internaly to keep track of dependencies between generators.
Generator type Visibility Specifies what kind of generator it is, diffrent types performs diffrent tasks.
Settings _Contains specific settings for the selected generator._See the Settings section.
Triggers _Determines which elements that should be used as triggers for the generator._See the Triggers section.
Outputs _Determines which elements that should be used as outputs for the generator._See the Outputs section.
Active On Determines if the generator is active or not, if its not then the generator wont be triggered even if the specified elements values is changed.

Settings

Field Value Information
Regular expression <value> Specified as an regular expression, respects the rules for element dependencies, special functions and metadata injection. If the regular expression holds for the pattern specified below, the element(s) [Outputs] _are visible, hidden otherwise._There are implicit flags set already, case insensitive, global scope.No normal regular expression can be used.
Pattern {dropdown}

Triggers

Mark the elements that should be used as triggers for the generator. If an marked elements value is changed then this generator will be triggered as long as the value is valid.

A list of elements from the form is presented as possible triggers.
**Note: **This is one of the reason to give the form elements a good descriptive ID.

Outputs

Mark the elements that should be used as outputs for the generator. When the generator has generated its value these elements will be updated with the generated value.

A list of elements from the form is presented as possible outputs.
**Note: **This is one of the reason to give the form elements a good descriptive name.

HTTP

A HTTP generator is used to post HTTP requests to an external API and use the results directly. For this to work you need to get a specific format of output from the HTTP call. The format of the HTTP call output should correspond to the one for a Hook generator, see below.

Hook

A Hook generator is used to send or retrieve data with a call to a Zephyr internal code snipped called a "Hook". This generator can attach one of your hooks to an element and thus for example populate elements with information from an external system, or from your own code, or both (see Hooks for more information).

Field Value Information
Generator ID Automatic A unique id for the generator, used internally to keep track of dependencies between generators.
Generator type Hook Specifies what kind of generator it is, different types performs different tasks.
Settings _Contains specific settings for the selected generator._See the Settings section.
Inputs _Define the inputs for the hook_See the Inputs section.
Outputs _Define the outputs for the hook_See the Outputs section.
Active On Determines if the generator is active or not, if its not then the generator won't be triggered even if the specified elements values is changed.

Settings

Inputs

Outputs

Hook example - PowerShell

@{"element1"=@{"hidden"=$True}} | ConvertTo-Json

Specific Generator output for Hook and HTTP generators

The output (response) from a Hook or HTTP call in Zephyr can be used to generate in the form. Each line of response will count as a generated result, and be handled to set element values, or other options, as follows.

Single value

"This is a value"
The value will be considered as a string and set to all configured Outputs for the Generator

Single value (numeric)

999
The value will be considered as a number, will be multiplied by 1000, and set to all configured Outputs for the Generator

Array value (as JSON)

["Value1", "Value2", ... ]
The output element (only one is supported) will get its options (only applicable to a drop-down list type element) set according to array. If the options include the current element value, this one is selected. If not, the element is set to the first option.

Array of Objects (as JSON)

[{"text":"Value1", "value":"val1"}, {"text":"Value2", "value":"val2"}, ... ]
The output element (only one is supported) will get its options (only applicable to a drop-down list type element) set according to array, with text properties as visible values and value properties as actual element values. If the options include the current element value, this one is selected. If not, the element is set to the first option.

Object (as JSON)

{"elementID1": {"hidden": true, "size": 6, "value":"val1", ... }, {"elementID2": { "options": ["x", "y", ... ], ... }, ... }
The output element(s) represented in the object by their id will have their value, options or other properties set according to data structure. The elements support the following properties:

{
    label: string;  
    type: string;  
    size: number;  
    required: boolean;  
    regex: string;  
    errorMessage: string;  
    value: any;  
    options: [{"text":"", "value": ""}, ... ];  
    isLoading: boolean;  
    hidden: boolean;  
    errors: ["", ... ];  
    minStartDate: string;  
    maxEndDate: string;  
    useUnixTs: boolean;  
    tooltip: string;  
    maximize: boolean;  
    maskInput: boolean;  
}

Form generation

`{"formData": {"name": {"en": "NewEnglishName", ... }, "description": {"en": "NewEnglishDesc", ... }, "elements":[ { ... }, ... ], ... }
This is a special case of Object generation above, which is able to set properties on the form itself.

Form data structure

There are som caveats in this, especially if you change elements who act as inputs to other generators, etc. But in general the properties supported in the form data structure are (note that the element data structure is different than the above case):

{  
    id: string;  
    name: {"en":"EnglishName", "sv: "SwedishName", ... };  
    description: {"en":"EnglishDesc", ... };  
    price: {"en":"Englishprice", ... };  
    imageURL: string;  
    requestable: boolean;  
    hideSummary: boolean;  
    icon?: string, eg. "fi-cloud" or "fas fa-tree";  
    settings: {"setting1":"SettingValue", ... };  
    elements: [ {"id": "elementID1", <see below> }, ... ];  
    steps?: [{"en":"EnglishStep1Name", ... }, {"en":"EnglishStep2Name", ... }, ... ];  
    breadcrumbs?: [ {"id": "breadcrumbID1", <see below> } ];  
    confirmationHeader?: {"en":"EnglishConfHeader", ... };  
    confirmationText?: {"en":"EnglishConfText", ... };  
    confirmationButtonLink?: {"en":"EnglishConfBLink", ... };  
    confirmationButtonText?: {"en":"EnglishConfBText", ... };  
    maximize?: boolean;  
}

Element data structure

Elements will be merged/overwritten if their IDs correspond to one that already exists. Because of this, there is no way to remove elements through this generator type, but they can be hidden/disabled.

Elements should have the following structure Note: it differs from the one in the above section:

{
    id: string;  
    defaultValue: {"en":"EnglishDefValue", ... };  
    errorMessage: {"en":"EnglishErrorMessage", ... }; 
    hidden: boolean;  
    required: boolean;  
    hideInOrderEmail: boolean;  
    options: [{"name":"", "value": ""}, ... ];  
    question:  {"en":"EnglishQuestionLabel", ... };  
    regex:  {"en":"EnglishRegex", ... };  
    type: string;  
    width: string;  
    value: any;  
    step?: number;  
    multiple?: boolean;  
    useUnixTs: boolean;  
    minStartDate: string eg. valid date;  
    maxEndDate: string, eg. valid date;  
    tooltip:  {"en":"EnglishTooltip", ... };  
    disabled: boolean;  
    maximize: boolean;  
    elementOptions: [{"name":"OptionName", "value":"OptionValue"}, ... ];  
    maskInput: boolean;  
}

Breadcrumb data structure

The array of breadcrumbs replaces the current one (it's not merged like the elements). The breadcrumbs should look like this:

{  
    id: string;  
    defaultText: string;  
    defaultLink: string;  
    texts: {"en":"EnglishText", ... };  
    links: {"en":"EnglishLink", ... };  
}