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


{{ forms.textField({
    label: "Title"|t('app'),
    instructions: "Enter a custom widget title, or leave blank to use default."|t('freeform'),
    id: 'title',
    name: 'title',
    value: settings.title,
    errors: settings.getErrors('title')
}) }}

{{ forms.selectField({
    label: "Chart Type"|t('freeform'),
    id: 'chartType',
    name: 'chartType',
    options: chartTypes,
    value: settings.chartType,
    errors: settings.getErrors('chartType')
}) }}

{{ forms.selectField({
    label: "Chart Height"|t('freeform'),
    id: 'chartHeight',
    name: 'chartHeight',
    options: {
        10: "10%",
        20: "20%",
        30: "30%",
        40: "40%",
        50: "50%",
        60: "60%",
        70: "70%",
        80: "80%",
        90: "90%",
        100: "100%",
    },
    value: settings.chartHeight,
    errors: settings.getErrors('chartHeight')
}) }}

{{ forms.selectField({
    label: "Date Range"|t('freeform'),
    id: 'dateRange',
    name: 'dateRange',
    options: dateRangeOptions,
    value: settings.dateRange,
    errors: settings.getErrors('dateRange')
}) }}

{% if fieldValueSettings is defined and fieldValueSettings %}

    {{ forms.selectField({
        label: "Form"|t('freeform'),
        id: 'formId',
        name: 'formId',
        options: formOptions,
        value: settings.formId,
        errors: settings.getErrors('formId')
    }) }}

    {{ forms.selectField({
        label: "Field"|t('freeform'),
        id: 'fieldId',
        name: 'fieldId',
        options: fieldList,
        value: settings.fieldId,
        errors: settings.getErrors('fieldId')
    }) }}

    {{ forms.lightswitchField({
        label: "Include Empty Values"|t('freeform'),
        id: 'showEmpty',
        name: 'showEmpty',
        on: settings.showEmpty,
        errors: settings.getErrors('showEmpty')
    }) }}

{% else %}

    {{ forms.checkboxSelectField({
        label: "Forms"|t('freeform'),
        instructions: "Select the forms for which submission data should be included."|t('freeform'),
        id: 'formIds',
        name: 'formIds',
        options: formOptions,
        values: settings.formIds|length ? settings.formIds : '*',
        errors: settings.getErrors('formIds'),
        showAllOption: true,
    }) }}

{% endif %}
