{#
/**
 * Preparse Field plugin for Craft CMS
 *
 *  Field Settings
 *
 * @author    Steadfast Design Firm
 * @copyright Copyright (c) Steadfast Design Firm
 * @link      https://www.steadfastdesignfirm.com/
 * @package   PreparseField
 * @since     1.0.0
 */
#}

{% import "_includes/forms" as forms %}

{{ forms.textareaField( {
    label: "Twig code to parse"|t,
    instructions: "Enter the twig code that you want to parse after the entry has been saved."|t,
    id: 'fieldTwig',
    name: 'fieldTwig',
    value: field['fieldTwig'],
    class: 'code',
    rows: 10
}) }}

{% set columnType %}
    {{ forms.select({
        id: 'columnType',
        name: 'columnType',
        options: columns,
        value: field['columnType'],
    }) }}
{% endset %}

{{ forms.field({
    label: "Column Type"|t,
    instructions: "The underlying database column type to use when saving content."|t,
    id: 'columnType',
    warning: (existing ? "Changing this may result in data loss."|t),
}, columnType) }}

{{ forms.textField({
    label: 'Decimals'|t,
    instructions: "Only relevant if the column type is Number (float)."|t,
    id: 'decimals',
    name: 'decimals',
    size: 2,
    maxlength: 2,
    value: field['decimals']
}) }}

{{ forms.lightswitchField({
    label: "Parse before save"|t,
    instructions: "If you turn this on, the field will be parsed before the element is saved."|t,
    id: 'parseBeforeSave',
    name: 'parseBeforeSave',
    on: field['parseBeforeSave'],
    onLabel: "Yes"|t,
    offLabel: "no"|t
}) }}

{{ forms.lightswitchField({
    label: "Parse on move"|t,
    instructions: "If you turn this on, elements that contain this field will be resaved when an element is moved in a structure. Necessary if you use .parent() or similar structure-related code in your twig."|t,
    id: 'parseOnMove',
    name: 'parseOnMove',
    on: field['parseOnMove'],
    onLabel: "Yes"|t,
    offLabel: "no"|t
}) }}

{% set displayType %}
    {{ forms.select({
        id: 'displayType',
        name: 'displayType',
        options: displayTypes,
        value: field['displayType'],
    }) }}
{% endset %}

{{ forms.field({
    label: "Display Type"|t,
    instructions: "Select how this field is to be shown in the edit page."|t,
    id: 'displayType',
}, displayType) }}

{{ forms.textField({
    label: 'Textarea rows'|t,
    instructions: "Only relevant if the display type is Textarea."|t,
    id: 'textareaRows',
    name: 'textareaRows',
    size: 2,
    maxlength: 2,
    value: field['textareaRows']
}) }}

{{ forms.lightswitchField({
    label: "Allow text selection"|t,
    instructions: "If you turn this on and the field is visible, the output of the field will be selectable by the user."|t,
    id: 'allowSelect',
    name: 'allowSelect',
    on: field['allowSelect'],
    onLabel: "Yes"|t,
    offLabel: "no"|t
}) }}
