{
  "id": "submit-on-select-example",
  "formKey": "",
  "title": {
    "en": "submit-on-select-example"
  },
  "description": {},
  "customModule": "",
  "typeRef": "",
  "width": "m",
  "system": false,
  "i18n": {},
  "definition": {
    "components": [
      {
        "label": {
          "ru": "Select With Submit"
        },
        "key": "selectWithSubmit",
        "validate": {
          "select": false
        },
        "dataSrc": "values",
        "data": {
          "values": [
            {
              "label": {
                "ru": "First"
              },
              "value": "first"
            },
            {
              "label": {
                "ru": "Second"
              },
              "value": "second"
            },
            {
              "label": {
                "ru": "Third"
              },
              "value": "third"
            }
          ],
          "headers": [
            {}
          ]
        },
        "defaultValue": "",
        "optionalWhenDisabled": false,
        "type": "ecosSelect",
        "input": true,
        "reorder": false,
        "reference": false
      },
      {
        "label": {
          "ru": "Submit on checkbox"
        },
        "key": "submitOnCheckBox",
        "refreshOn": [],
        "optionalWhenDisabled": false,
        "type": "checkbox",
        "input": true,
        "reorder": false,
        "dataGridLabel": false
      },
      {
        "type": "columns",
        "key": "buttons-columns",
        "columns": [
          {
            "md": 3,
            "type": "column",
            "input": false,
            "index": 0,
            "components": [],
            "key": "column"
          },
          {
            "md": 3,
            "type": "column",
            "input": false,
            "index": 1,
            "key": "column",
            "components": []
          },
          {
            "md": 3,
            "type": "column",
            "input": false,
            "index": 2,
            "components": [
              {
                "type": "button",
                "key": "cancel",
                "label": {
                  "ru": "Отменить",
                  "en": "Cancel"
                },
                "action": "event",
                "event": "cancel",
                "block": true,
                "input": true
              }
            ],
            "key": "column"
          },
          {
            "md": 3,
            "type": "column",
            "input": false,
            "index": 3,
            "components": [
              {
                "label": {
                  "ru": "Включить автосабмит",
                  "en": "Enable auto-submit"
                },
                "key": "enableAutoSubmit",
                "state": "",
                "hidden": false,
                "theme": "primary",
                "block": true,
                "refreshOn": [],
                "action": "custom",
                "optionalWhenDisabled": false,
                "type": "button",
                "input": true,
                "showValidations": false,
                "event": "",
                "custom": "const form = instance.root;\nif (!form._autoSubmitOnSelection) {\n  const keys = new Set(['selectWithSubmit', 'submitOnCheckBox']);\n  let timer;\n  let pending = false;\n  let busy = false;\n\n  const flush = () => {\n    timer = null;\n    if (!form.element || !form.element.isConnected) {\n      pending = false;\n      return;\n    }\n    if (!pending || busy) {\n      return;\n    }\n    if (form.submitting) {\n      timer = setTimeout(flush, 200);\n      return;\n    }\n    pending = false;\n    busy = true;\n    Promise.resolve()\n      .then(() => form.submit())\n      .catch(error => console.error('Auto-submit failed', error))\n      .finally(() => {\n        busy = false;\n        if (pending) {\n          timer = setTimeout(flush, 200);\n        }\n      });\n  };\n\n  const onChange = event => {\n    const flags = event && event.flags || {};\n    if (!event || !keys.has(event.component && event.component.key) ||\n        !(flags.modified || flags.changeByUser)) {\n      return;\n    }\n    pending = true;\n    clearTimeout(timer);\n    timer = setTimeout(flush, 200);\n  };\n  form._autoSubmitOnSelection = onChange;\n  form.on('componentChange', onChange);\n}\ninstance.disabled = true;",
                "url": "",
                "headers": [
                  {}
                ],
                "reorder": false,
                "dataGridLabel": false
              }
            ],
            "key": "column"
          }
        ],
        "input": false
      }
    ],
    "formId": "submit-on-select-example"
  },
  "attributes": {},
  "notExists": false
}
