renderView:

  - type: div
    actions:
      - what: hide
        orConditions:
          - when: ~~.isProduction
            isNot: true
          - when: ~~._formState.editAnyway
            is: true

    content:
      - type: p
        content: Editing the advanced settings on this production instance is not recommended.
          By updating the settings, you will have to update your already exported bundles
          to match the new tracker config.

      - type: div
        content:
          type: BsButton
          content: Edit anyway
          actions:
            - what: setData
              on: click
              path: ~~._formState.editAnyway
              value: true

  - type: div
    actions:
      - what: hide
        andConditions:
          - when: ~~.isProduction
            is: true
          - when: ~~._formState.editAnyway
            isNot: true

    content:
      - type: h2
        attributes:
          class: pb-2 row
        content:
          - type: div
            attributes:
              class: col
            content: Advanced settings
          - type: div
            attributes:
              class: col col-auto
            content:
              type: BsButton
              content: Update
              attributes:
                  class: btn-update
              actions:
                - what: submitData
                  on: click
                  url: ~~.submitEndpoint

      - type: div # Container for status messages.

      - type: Tabs
        attributes:
          defaultActiveKey: schema
        tabs:
          - attributes:
              eventKey: schema
              title: Schema
            content:
              - type: BsAccordion
                content:
                  attributes:
                    class: col
                  type: Switch
                  content: ~~.tracker_group_list
                  options:
                    tracker_group:
                      load: tracker_group
          - attributes:
              eventKey: options
              title: Options
            content:
              load: options_tab
          - attributes:
              eventKey: exclusions
              title: Exclusion rules
            content:
              load: exclusions_tab
          - attributes:
              eventKey: shortcodes
              title: Shortcodes
            content:
              load: shortcodes_tab

templates:
  # Standard field label.
  field_label:
    type: div
    attributes:
      class: fw-bold mt-2

  tracker_group:
    type: AccordionItem
    header:
      - type: div
        content: ~.group_label
    body:
      type: table
      attributes:
        class: table
      content:
        - type: tbody
          content:
            type: Switch
            content: ~.schema
            options:
              tracker_schema_item:
                load: tracker_schema_item

  tracker_schema_item_label:
    - type: span
      content: ~.tracker_id
      actions:
        - what: hide
          when: ~.tracker_label
          isEmpty: not
    - type: span
      content:
        - ~.tracker_label
        - " "
        - (
        - ~.tracker_id
        - )
      actions:
        - what: hide
          when: ~.tracker_label
          isEmpty:

  tracker_schema_item:
    type: tr
    content:
      - type: td
        content:
          type: CheckBoxField
          dataLocation: ~.isEnabled
          options:
            - value: true
              label:
                - load: tracker_schema_item_label
                  keepTemplateContext: true
                - type: BsButton
                  content: ✎
                  attributes:
                    class: btn-icon btn-edit
                  actions:
                    - what: setData
                      on: click
                      path: ~._openLabelEditModal
                      value: true
                - type: Modal
                  attributes:
                    style:
                      zIndex: 1050 # Modal backdrop fix.
                  closeButton: true
                  body:
                    type: div
                    attributes:
                      class: row
                    content:
                      - type: div
                        content: Custom label
                      - type: TextField
                        placeholder: Type to customize the label...
                        dataLocation: ~.tracker_label
                  headerTitle:
                    - "Edit the label of "
                    - type: span
                      attributes:
                        class: fst-italic
                      content: ~.tracker_id
                  showBoolPath: ~._openLabelEditModal

      - type: td
        content:
          - type: div
            actions:
              - what: hide
                when: ~.isEnabled
                isNot: true
            content:
              - # Track / Follow switch.
                type: section
                content:
                  type: CheckBoxField
                  attributes:
                    class: form-check
                  controlType: radio
                  dataLocation: ~.excluded
                  options:
                    - label: Track
                      attributes:
                        class: form-check-inline
                    - label: Follow
                      value: true
                      attributes:
                        class: form-check-inline

      - type: td
        content:
          - type: div
            attributes:
              class: d-flex justify-content-end w-100
            actions:
              - what: hide
                when: ~.isEnabled
                isNot: true
            content:
              - # Configure button.
                type: BsButton
                content: Configure
                attributes:
                  class: btn-yellow btn-rounded float-end
                actions:
                  - what: setData
                    on: click
                    path: ~._openEditModal
                    value: true

              - type: Modal
                closeButton: true
                attributes:
                  class: modal-lg
                  style:
                    # This fixes the backdrop going under the parent modal instead of above when having nested modals.
                    # Use a CSS file to set this zIndex on all modals (using the var --bs-modal-zindex: 1050).
                    zIndex: 1050
                showBoolPath: ~._openEditModal
                headerTitle:
                  - "Configure "
                  - type: span
                    attributes:
                      class: fst-italic
                    content:
                      - load: tracker_schema_item_label
                        keepTemplateContext: true
                body:
                  - # Local ID section.
                    type: section
                    content:
                      - type: CheckBoxField
                        dataLocation: ~.uuid_random_generation
                        options:
                          - label: Force UUID random generation
                            value: true

                  - # Screen label formatter.
                    load: screen_label_formatter__edit
                    keepTemplateContext: true

                  - # Field definition overrides (schema).
                    type: section
                    content:
                      - load: field_label
                        content: Field schema
                      - type: BsAccordion
                        content:
                          type: Switch
                          content: ~.field_definitions_overrides
                          options:
                            field_definition_override:
                              load: field_definition_override

  field_definition_override:
    type: AccordionItem
    header:
      - type: div
        content: ~.field
    body:
      - # Field exclusion from export.
        load: field_deployment_exclusion_edit
        keepTemplateContext: true

      - # Local ID.
        type: CheckBoxField
        dataLocation: ~.isLocalIdField
        options:
          - label: Use as identifier
            value: true

      - # UUID source field.
        load: uuid_source_field_edit
        keepTemplateContext: true

      - # Item value handler.
        load: item_value_handler_edit
        keepTemplateContext: true

      - type: hr

      - # Processors section.
        load: processors_edit
        keepTemplateContext: true

  field_deployment_exclusion_edit:
    type: CheckBoxField
    dataLocation: ~.exclude
    options:
      - label: Do not deploy this field
        value: true

  uuid_source_field_edit:
    type: CheckBoxField
    dataLocation: ~.isUuidSourceField
    options:
      - label: Use as UUID source field
        value: true

  item_value_handler_edit:
    type: div
    content:
      label:
        load: field_label
        content: Value handler
      select:
        type: SelectField
        dataLocation: ~.value_handler
        options:
          - label: Default
            value: ""
          - label: Option
            value: option
          - label: Post GUID
            value: post_guid
          - label: Reference
            value: reference
          - label: Reference field
            value: reference_field

      reference_ivh: # Reference item value handler additions.
        load: item_value_handler__reference__edit
        keepTemplateContext: true

      reference_field_ivh: # Reference field.
        load: item_value_handler__reference_field__edit
        keepTemplateContext: true

      option_ivh: # Option item value handler additions.
        load: item_value_handler__option__edit
        keepTemplateContext: true

  # Item value handler form used in the option item value handler.
  option_item_value_handler_edit:
    type: div
    content:
      label:
        load: field_label
        content: Value handler
      select:
        type: SelectField
        dataLocation: ~.value_handler
        options:
          - label: Default
            value: ""
          - label: Post GUID
            value: post_guid
          - label: Reference
            value: reference
          - label: Reference field
            value: reference_field

      reference_ivh: # Reference item value handler additions.
        load: item_value_handler__reference__edit
        keepTemplateContext: true

      reference_field_ivh: # Reference field.
        load: item_value_handler__reference_field__edit
        keepTemplateContext: true

  item_value_handler__option__edit:
    type: div
    actions:
      - what: hide
        when: ~.value_handler
        isNot: option
    content:
      - type: div
        attributes:
          class: fw-bold mt-2
        content: Field which contains the key
      - type: SelectField
        dataLocation: ~.option_name_field_name
        dynamicOptions: ~>tracker_schema_item._meta.column_names

  item_value_handler__reference__edit:
    type: div
    actions:
      - what: hide
        when: ~.value_handler
        isNot: reference
    content:
      label:
        load: field_label
        content: Reference to...
      select:
        type: SelectField
        dataLocation: ~.reference_tracker_id
        dynamicOptions: ~~.enabledTrackers
      subitem:
        type: CheckBoxField
        dataLocation: ~.isSubitemOf
        options:
          - label:
              # TODO: Add the tooltip.
              - Set as dependency
            value: true
      nullable:
        field:
          type: CheckBoxField
          dataLocation: ~.nullable
          options:
            - label: Nullable
              value: true

  item_value_handler__reference_field__edit:
    type: div
    actions:
      - what: hide
        when: ~.value_handler
        isNot: reference_field
    content:
      reference_to:
        label:
          load: field_label
          content: Reference to...
        field:
          type: SelectField
          dataLocation: ~.reference_tracker_id
          dynamicOptions: ~~.enabledTrackers
      field_in_reference:
        label:
          load: field_label
          content: Field in reference
        field:
          type: SelectField
          actions:
            - what: hide
              when: ~.reference_tracker_id
              isNot: e_submissions
          dataLocation: ~.field_in_reference
          options:
            - label: valeur 1
              value: valeur 1
            - label: valeur 2
              value: valeur 2
      nullable:
        field:
          type: CheckBoxField
          dataLocation: ~.nullable
          options:
            - label: Nullable
              value: true

  processors_edit:
    type: div
    content:

      table:
        type: table
        attributes:
          class: table
        content:
          - type: thead
            content:
              - type: tr
                content:
                  - type: th
                    content: Processor
                  - type: th
                    attributes:
                      class: text-end
                    content: Actions
          - type: tbody
            content:
              # Loop over processors.
              type: Switch
              content: ~.processors
              options:

                attachment:
                  load: processor_item_row
                  content:
                    - type: td
                      content: Convert GUID into its represented file
                    - type: td
                      content:
                        load: processor_item_action_buttons_wrapper
                        keepTemplateContext: true
                        content:
                          load: processor_item_three_action_buttons
                          keepTemplateContext: true

                import_author:
                  load: processor_item_row
                  content:
                    - type: td
                      content: Map to import author
                    - type: td
                      content:
                        load: processor_item_action_buttons_wrapper
                        keepTemplateContext: true
                        content:
                          load: processor_item_three_action_buttons
                          keepTemplateContext: true

                transmutation:
                  load: processor_item_row
                  content:
                    - type: td
                      content: Transmutation
                    - type: td
                      content:
                        buttons:
                          load: processor_item_action_buttons_wrapper
                          keepTemplateContext: true
                          content:
                            - load: processor_item_edit_button
                              keepTemplateContext: true
                            - load: processor_item_three_action_buttons
                              keepTemplateContext: true
                        modal:
                          type: Modal
                          attributes:
                            style:
                              zIndex: 1050 # Modal backdrop fix.
                          closeButton: true
                          showBoolPath: ~._openEditModal
                          headerTitle:
                            - Edit this processor
                          body:
                            data_walker_pattern:
                              label:
                                load: field_label
                                content: Data walker pattern
                              field:
                                type: TextField
                                dataLocation: ~.data_walker_pattern
                            transmutation_handler:
                              label:
                                load: field_label
                                content: Transmutation handler
                              field:
                                type: SelectField
                                dataLocation: ~.transmutation_handler
                                dynamicOptions: ~~.transmutationHandlers
                            transmutation_handler_options:
                              reference:
                                type: div
                                actions:
                                  - what: hide
                                    when: ~.transmutation_handler
                                    isNot: reference
                                content:
                                  label:
                                    load: field_label
                                    content: Reference to...
                                  field:
                                    type: SelectField
                                    dataLocation: ~.transmutation_handler_options.tracker
                                    dynamicOptions: ~~.enabledTrackers


                url_host_name:
                  load: processor_item_row
                  content:
                    - type: td
                      content: Strip host name from URL
                    - type: td
                      content:
                        load: processor_item_action_buttons_wrapper
                        keepTemplateContext: true
                        content:
                          load: processor_item_three_action_buttons
                          keepTemplateContext: true

      no_processor_message: # No processor message.
        type: div
        content: There is no processor set on this field.
        attributes:
          class: text-muted fst-italic text-center m-2
        actions:
          - what: hide
            whenDataCountOf: $.processors[*]
            inContext: template
            isNot: 0

      add_processor:
        load: add_processor
        keepTemplateContext: true

  processor_item_wrapper:
    type: div
    attributes:
      class: border p-3 bg-light mb-1

  processor_item_row:
    type: tr

  processor_item_header:
    type: div
    attributes:
      class: row justify-content-between

  processor_item_action_buttons_wrapper:
    type: div
    attributes:
      class: d-flex gap-3 justify-content-end

  processor_item_three_action_buttons:
    - load: processor_item_move_up_button
      keepTemplateContext: true
    - load: processor_item_move_down_button
      keepTemplateContext: true
    - load: processor_item_delete_button
      keepTemplateContext: true

  processor_item_edit_button:
    type: BsButton
    attributes:
      class: btn-icon btn-edit
    content: Edit
    actions:
      - what: setData
        on: click
        path: ~._openEditModal
        value: true

  processor_item_delete_button:
    type: BsButton
    attributes:
      class: btn-icon btn-delete
    content: 🗑
    actions:
      - what: removeData
        on: click
        target: currentTemplateData
        parentLevel: 1

  processor_item_move_up_button:
    type: BsButton
    attributes:
      class: btn-icon btn-arrow-top
    content: ⋀
    actions:
      - what: moveData
        on: click
        target: currentTemplateData
        parentLevel: 1
        increment: -1

  processor_item_move_down_button:
    type: BsButton
    attributes:
      class: btn-icon btn-arrow-bottom
    content: ⋁
    actions:
      - what: moveData
        on: click
        target: currentTemplateData
        parentLevel: 1
        increment: 1

  add_processor:
    main:
      type: div
      attributes:
        class: d-flex justify-content-center
      content:
        type: div
        attributes:
          class: row align-items-center
        content:

          select:
            type: SelectField
            attributes:
              class: mb-3 col col-auto
            dataLocation: ~._selectedProcessor
            options:
              - label: Select a processor...
                value: ""
              - label: Convert GUID into its represented file
                value: attachment
              - label: Map to import author
                value: import_author
              - label: Transmutation
                value: transmutation
              - label: Strip host name from URL
                value: url_host_name

          button:
            type: div
            attributes:
              class: mb-3 col col-auto
            content:
              disabledButton:
                type: BsButton
                attributes:
                  disabled: disabled
                content: Ajouter le processeur sélectionné
                actions:
                  - what: hide
                    when: ~._selectedProcessor
                    isEmpty: not
              enabledButton:
                type: BsButton
                content: Ajouter le processeur sélectionné
                actions:
                  - what: hide
                    when: ~._selectedProcessor
                    isEmpty: null
                  - what: addData
                    when: ~._selectedProcessor
                    is: attachment
                    on: click
                    path: ~.processors
                    value:
                      attachment:
                  - what: addData
                    when: ~._selectedProcessor
                    is: import_author
                    on: click
                    path: ~.processors
                    value:
                      import_author:
                  - what: addData
                    when: ~._selectedProcessor
                    is: transmutation
                    on: click
                    path: ~.processors
                    value:
                      transmutation:
                        data_walker_pattern:
                  - what: addData
                    when: ~._selectedProcessor
                    is: url_host_name
                    on: click
                    path: ~.processors
                    value:
                      url_host_name:




  options_tab:
    - type: div
      content:
        - type: table
          attributes:
            class: table
          content:
            - type: thead
              content:
                - type: tr
                  content:
                    - type: th
                      content: Plugin
                    - type: th
                      content: Tracker
                    - type: th
                      content: Option field
                    - type: th
                      content: Actions
            - type: tbody
              content:
                type: Switch
                content: ~~.options
                options:
                  options_item:
                    load: options_item_row

        - # Button to add a new option definition.
          type: div
          attributes:
            class: d-flex justify-content-center
          content:
            type: div
            attributes:
              class: d-flex
            content:
              type: BsButton
              attributes:
                class: btn-add btn-rounded
              content: Add a new option definition
              actions:
                - what: addData
                  on: click
                  path: ~~.options
                  value:
                    options_item:
                      plugin: ""
                      tracker: ""
                      field: ""
                      field_definitions_overrides: []

  options_item_row:
    type: tr
    content:
      - type: td
        content:
          type: LabelFromValue
          dataLocation: ~.plugin
          dynamicOptions: ~~.pluginList
      - type: td
        content:
          type: LabelFromValue
          dataLocation: ~.tracker
          dynamicOptions: ~~.enabledTrackers
      - type: td
        content: ~.field
      - type: td
        content:
          - type: div
            attributes:
              class: d-flex gap-3
            content:
              - type: BsButton
                content: Edit
                attributes:
                  class: btn-edit btn-icon
                actions:
                  - what: setData
                    on: click
                    path: ~._openEditModal
                    value: true
              - type: BsButton
                content: Delete
                attributes:
                  class: btn-delete btn-icon
                actions:
                  - what: removeData
                    on: click
                    target: currentTemplateData
                    parentLevel: 1

          - type: Modal
            attributes:
              class: modal-lg
              style:
                zIndex: 1050 # Modal backdrop fix.
            showBoolPath: ~._openEditModal
            headerTitle: Edit the options field definition
            closeButton: true
            body:
              - load: field_label
                content: Plugin
              - type: SelectField
                dataLocation: ~.plugin
                dynamicOptions: ~~.pluginList
                allowEmptyStringAsValue: true

              - load: field_label
                content: Tracker
              - type: SelectField
                dataLocation: ~.tracker
                dynamicOptions: ~~.enabledTrackers
                allowEmptyStringAsValue: true

              - # This is the field representing the "option_name" / "meta_key" value.
                load: field_label
                content: Options field
              - type: TextField
                dataLocation: ~.field
                placeholder: Usually "option_name" or "meta_key".

              - load: field_label
                content: Field definition overrides

              - # No overrides message.
                type: div
                content: There is no override.
                attributes:
                  class: text-muted fst-italic text-center m-2
                actions:
                  - what: hide
                    whenDataCountOf: $.field_definitions_overrides[*]
                    inContext: template
                    isNot: 0

              - type: BsAccordion
                content:
                  type: Switch
                  content: ~.field_definitions_overrides
                  options:
                    options_field_definition_override:
                      load: options_field_definition_override

              - # Button to add a new override.
                type: div
                attributes:
                  class: d-flex justify-content-center mt-2
                content:
                  type: div
                  attributes:
                    class: d-flex
                  content:
                    type: BsButton
                    attributes:
                      class: btn-sm btn-secondary
                    content: Add an override
                    actions:
                      - what: addData
                        on: click
                        path: ~.field_definitions_overrides
                        value:
                          options_field_definition_override:
                            exclude: false
                            field: ""
                            processors: []
                            value_handler: ""


  # This template is exactly like field_definition_override,
  # without the "local ID" field and "UUID source field" fields,
  # and with an added field to edit the option_name / meta_key.
  options_field_definition_override:
    type: AccordionItem
    header:
      - type: div
        content: ~.field
    body:
      - # Field to define the value of the "option_name".
        type: TextField
        dataLocation: ~.field
        placeholder: Type the "option_name" / "meta_key" value...

      - # Field exclusion from export.
        load: field_deployment_exclusion_edit
        keepTemplateContext: true

      - # Item value handler.
        load: option_item_value_handler_edit
        keepTemplateContext: true

      - type: hr

      - # Processors section.
        load: processors_edit
        keepTemplateContext: true





  exclusions_tab:
    - type: div
      content:
        - type: table
          attributes:
            class: table
          content:
            - type: thead
              content:
                - type: tr
                  content:
                    - type: th
                      content: Plugin
                    - type: th
                      content: Tracker
                    - type: th
                      content: Field
                    - type: th
                      content: Actions
            - type: tbody
              content:
                type: Switch
                content: ~~.exclusions
                options:
                  exclusion_item:
                    load: exclusion_item_row

        - # Button to add a new exclusion definition.
          type: div
          attributes:
            class: d-flex justify-content-center
          content:
            type: div
            attributes:
              class: d-flex
            content:
              type: BsButton
              attributes:
                class: btn-add btn-rounded
              content: +
              actions:
                - what: addData
                  on: click
                  path: ~~.exclusions
                  value:
                    exclusion_item:
                      plugin: ""
                      tracker: ""
                      field:
                      conditions: []

  exclusion_item_row:
    type: tr
    content:
      - type: td
        content:
          type: LabelFromValue
          dataLocation: ~.plugin
          dynamicOptions: ~~.pluginList
      - type: td
        content:
          type: LabelFromValue
          dataLocation: ~.tracker
          dynamicOptions: ~~.enabledTrackers
      - type: td
        content: ~.field
      - type: td
        content:
          - type: div
            attributes:
              class: d-flex gap-3
            content:
              - type: BsButton
                content: Edit
                attributes:
                  class: btn-edit btn-icon
                actions:
                  - what: setData
                    on: click
                    path: ~._openEditModal
                    value: true
              - type: BsButton
                content: Delete
                attributes:
                  class: btn-delete btn-icon
                actions:
                  - what: removeData
                    on: click
                    target: currentTemplateData
                    parentLevel: 1

          - type: Modal
            attributes:
              style:
                zIndex: 1050 # Modal backdrop fix.
            showBoolPath: ~._openEditModal
            headerTitle: Edit the exclusion
            closeButton: true
            body:
              - load: field_label
                content: Plugin
              - type: SelectField
                dataLocation: ~.plugin
                dynamicOptions: ~~.pluginList
                allowEmptyStringAsValue: true

              - load: field_label
                content: Tracker
              - type: SelectField
                dataLocation: ~.tracker
                dynamicOptions: ~~.enabledTrackers
                allowEmptyStringAsValue: true

              - load: field_label
                content: Field
              - type: TextField
                dataLocation: ~.field

              - load: field_label
                content: Exclusion patterns

              - # No condition message.
                type: div
                content: There is no exclusion pattern set.
                attributes:
                  class: text-muted fst-italic text-center m-2
                actions:
                  - what: hide
                    whenDataCountOf: $.conditions[*]
                    inContext: template
                    isNot: 0
              - type: table
                attributes:
                  class: table
                content:
                  type: tbody
                  content:
                    type: Switch
                    content: ~.conditions
                    options:
                      condition:
                        load: exclusion_condition

              - # Button to add a new condition.
                type: div
                attributes:
                  class: d-flex justify-content-center
                content:
                  type: div
                  attributes:
                    class: d-flex
                  content:
                    type: BsButton
                    attributes:
                      class: btn-add btn-rounded
                    content: +
                    actions:
                      - what: addData
                        on: click
                        path: ~.conditions
                        value:
                          condition:
                            value:

  exclusion_condition:
    type: tr
    content:
      type: td
      content:
        type: div
        attributes:
          class: d-flex
        content:
          - type: TextField
            attributes:
              class: col me-2
            dataLocation: ~.value
            placeholder: Type a condition pattern here...
          - type: BsButton
            attributes:
              class: btn-icon btn-delete
            content: Suppr
            actions:
              - what: removeData
                on: click
                target: currentTemplateData
                parentLevel: 1







  shortcodes_tab:
    - type: div
      content:
        - type: table
          attributes:
            class: table
          content:
            - type: thead
              content:
                - type: tr
                  content:
                    - type: th
                      content: Plugin
                    - type: th
                      content: Shortcode name
                    - type: th
                      content: Shortcode attribute
                    - type: th
                      content: Referenced tracker
                    - type: th
                      content: Actions
            - type: tbody
              content:
                type: Switch
                content: ~~.shortcodes
                options:
                  shortcode_item:
                    load: shortcode_item_row

        - # No shortcode message.
          type: div
          content: There is no shortcode definition.
          attributes:
            class: text-muted fst-italic text-center m-2
          actions:
            - what: hide
              whenDataCountOf: $.shortcodes[*]
              inContext: global
              isNot: 0

        - # Button to add a new shortcode definition.
          type: div
          attributes:
            class: d-flex justify-content-center
          content:
            type: div
            attributes:
              class: d-flex
            content:
              type: BsButton
              attributes:
                class: btn-add btn-rounded
              content: +
              actions:
                - what: addData
                  on: click
                  path: ~~.shortcodes
                  value:
                    shortcode_item:
                      plugin: ""
                      name: ""
                      attribute: ""
                      tracker: ""

  shortcode_item_row:
    type: tr
    content:
      - type: td
        content:
          type: LabelFromValue
          dataLocation: ~.plugin
          dynamicOptions: ~~.pluginList
      - type: td
        content: ~.name
      - type: td
        content: ~.attribute
      - type: td
        content: ~.tracker
      - type: td
        content:
          - type: div
            attributes:
              class: d-flex gap-3
            content:
              - type: BsButton
                content: Edit
                attributes:
                  class: btn-edit btn-icon
                actions:
                  - what: setData
                    on: click
                    path: ~._openEditModal
                    value: true
              - type: BsButton
                content: Delete
                attributes:
                  class: btn-delete btn-icon
                actions:
                  - what: removeData
                    on: click
                    target: currentTemplateData
                    parentLevel: 1

          - type: Modal
            attributes:
              style:
                zIndex: 1050 # Modal backdrop fix.
            showBoolPath: ~._openEditModal
            headerTitle: Edit the shortcode
            closeButton: true
            body:
              - load: field_label
                content: Plugin
              - type: SelectField
                dataLocation: ~.plugin
                dynamicOptions: ~~.pluginList
                allowEmptyStringAsValue: true

              - load: field_label
                content: Shortcode name
              - type: TextField
                dataLocation: ~.name

              - load: field_label
                content: Shortcode attribute
              - type: TextField
                dataLocation: ~.attribute

              - load: field_label
                content: Tracker
              - type: TextField
                dataLocation: ~.tracker


  # Edit form for screen label formatters on trackers.
  screen_label_formatter__edit:
    type: section
    attributes:
      class: p-4 border
    content:
      label:
        load: field_label
        content: Screen label formatter
      select:
        type: SelectField
        dataLocation: ~.screen_label_formatter.id
        dynamicOptions: ~~.screenLabelFormatterList
        allowEmptyStringAsValue: true
      additionalSubForms: # Dynamic part.

        field__slf:
          type: Phantom
          actions:
            - what: hide
              when: ~.screen_label_formatter.id
              isNot: field
          content:
            field_name:
              label:
                load: field_label
                content: Field name
              select:
                type: SelectField
                dataLocation: ~.screen_label_formatter.config.field_name
                dynamicOptions: ~._meta.column_names

            prefix_field_name:
              label:
                load: field_label
                content: Field name for the prefix (optional)
              select:
                type: SelectField
                dataLocation: ~.screen_label_formatter.config.prefix_field_name
                dynamicOptions: ~._meta.column_names

        referenced_item__slf:
          type: Phantom
          actions:
            - what: hide
              when: ~.screenLabelFormatter.id
              isNot: referenced_item
          content:
            field_name:
              label:
                load: field_label
                content: Field where to get the reference from
              select:
                type: SelectField
                dataLocation: ~.screen_label_formatter.field_name
                dynamicOptions: ~._meta.column_names






data:
  enabledTrackers:
    - label: Select a value...
      value: ""
    - label: comment_meta
      value: comment_meta
    - label: comments
      value: comments
    - label: e_submissions
      value: e_submissions
    - label: e_submissions_actions_log
      value: e_submissions_actions_log
    - label: options
      value: options
    - label: postmeta
      value: postmeta

  pluginList:
    - label: Core
      value: ""
    - label: Deploy & Sync Content (deploy-sync-content)
      value: deploy-sync-content
    - label: Elementor (elementor)
      value: elementor
    - label: WPML
      value: sitepress-multilingual-cms

  screenLabelFormatterList:
    - label: Default
      value: ""
    - label: Field
      value: field
    - label: Referenced item
      value: referenced_item

  transmutationHandlers:
    - label: Select a handler...
      value: ""
    - label: References in shortcodes
      value: shortcode_references

  tracker_group_list:
    - tracker_group:
        group_label: Core
        schema:
          - tracker_schema_item:
              _meta:
                column_names:
                  - label: Select a field...
                    value: ''
                  - label: comment_ID
                    value: comment_ID
                  - label: comment_post_ID
                    value: comment_post_ID
                  - label: comment_author
                    value: comment_author
                  - label: comment_author_email
                    value: comment_author_email
                  - label: comment_author_url
                    value: comment_author_url
              isEnabled: true
              field_definitions_overrides:
                - field_definition_override:
                    field: comment_ID
                    value_handler: option
                    processors: []
                - field_definition_override:
                    field: comment_author
                    value_handler: reference
                    processors:
                      - import_author:
                      - transmutation:
                          data_walker_pattern: rec
                          transmutation_handler: shortcode_references
                          transmutation_handler_options: [ ]
                      - url_host_name:
              local_id_field:
                name: _meta_id
                type: bigint(20) unsigned
              plugin: ''
              tracker_id: comment_meta
          - tracker_schema_item:
              isEnabled: true
              field_definitions_overrides: [ ]
              local_id_field:
                name: comment_ID
                type: bigint(20) unsigned
              plugin: ''
              tracker_id: comments
          - tracker_schema_item:
              isEnabled: true
              field_definitions_overrides:
                - field: main__meta_id
                  value_handler: 'reference:e_submissions_values'
                - field: post_id
                  value_handler: 'reference:posts'
                - field: user_id
                  value_handler: 'reference:users'
              local_id_field:
                name: id
                type: bigint(20) unsigned
              plugin: pro-elements
              tracker_id: e_submissions
              tracker_label: ''
          - tracker_schema_item:
              isEnabled: true
              field_definitions_overrides:
                - field: submission_id
                  value_handler: 'reference:e_submissions'
              local_id_field:
                name: id
                type: bigint(20) unsigned
              plugin: pro-elements
              tracker_id: e_submissions_actions_log
              tracker_label: ''
          - tracker_schema_item:
              isEnabled: true
              field_definitions_overrides:
                - field: submission_id
                  value_handler: 'reference:e_submissions'
              local_id_field:
                name: id
                type: bigint(20) unsigned
              plugin: pro-elements
              tracker_id: e_submissions_values
              tracker_label: ''
          - tracker_schema_item:
              isEnabled: true
              field_definitions_overrides: [ ]
              local_id_field:
                name: link_id
                type: bigint(20) unsigned
              plugin: ''
              tracker_id: links
          - tracker_schema_item:
              isEnabled: true
              field_definitions_overrides:
                - field: option_value
                  option_name_field_name: option_name
                  value_handler: option
              item_exclusion_patterns:
                option_name:
                  - _transient_%
                  - _site_transient_%
                  - cron
                  - deploy_sync_content__current_config__%
                  - deploy_sync_content__import_author
              local_id_field:
                name: option_id
                type: bigint(20) unsigned
              plugin: ''
              screen_label_formatter:
                config:
                  field_name: option_name
                id: field
              tracker_id: options
              uuid_source_fields:
                - option_name
          - tracker_schema_item:
              isEnabled: true
              field_definitions_overrides:
                - field: guid
                  value_handler: post_guid
                  processors:
                    - attachment:
                    - url_host_name:
                - field: post_author
                  processors:
                    - id: import_author
                - field: post_content
                  processors:
                    - transmutation:
                        data_walker_pattern: rec
                        transmutation_handler: shortcode_references
                        transmutation_handler_options: [ ]
                    - url_host_name:
                - field: post_parent
                  value_handler: 'reference:posts'
              local_id_field:
                name: ID
                type: bigint(20) unsigned
              plugin: ''
              screen_label_formatter:
                config:
                  field_name: post_title
                  prefix_field_name: post_type
                id: field
              tracker_id: posts
          - tracker_schema_item:
              isEnabled: true
              local_id_field:
                name: term_id
                type: bigint(20) unsigned
              plugin: ''
              screen_label_formatter:
                config:
                  field_name: name
                id: field
              tracker_id: terms
          - tracker_schema_item:
              isEnabled: true
              excluded: true
              local_id_field:
                name: ID
                type: bigint(20) unsigned
              plugin: ''
              screen_label_formatter:
                config:
                  field_name: user_nicename
                id: field
              tracker_id: users
          - tracker_schema_item:
              isEnabled: true
              field_definitions_overrides:
                - field: _meta_value
                  option_name_field_name: _meta_key
                  value_handler: option
                - field: post_id
                  value_handler: 'reference:posts'
              local_id_field:
                name: _meta_id
                type: bigint(20) unsigned
              plugin: ''
              screen_label_formatter:
                config:
                  field_name: _meta_key
                id: field
              subordination:
                primary_item_id_field: post_id
                primary_tracker_id: posts
              tracker_id: post_meta
              uuid_source_fields:
                - _meta_key
          - tracker_schema_item:
              isEnabled: true
              field_definitions_overrides:
                - field: parent
                  value_handler: 'reference:term_taxonomy'
                - field: term_id
                  value_handler: 'reference:terms'
              local_id_field:
                name: term_taxonomy_id
                type: bigint(20) unsigned
              plugin: ''
              screen_label_formatter:
                config:
                  field_name: term_id
                  prefix_field_name: taxonomy
                id: field
              tracker_id: term_taxonomy
              uuid_source_fields:
                - taxonomy
                - term_id
          - tracker_schema_item:
              isEnabled: true
              field_definitions_overrides:
                - field: _meta_value
                  option_name_field_name: _meta_key
                  value_handler: option
                - field: term_id
                  value_handler: 'reference:terms'
              local_id_field:
                name: _meta_id
                type: bigint(20) unsigned
              plugin: ''
              screen_label_formatter:
                config:
                  field_name: _meta_key
                id: field
              subordination:
                primary_item_id_field: term_id
                primary_tracker_id: terms
              tracker_id: term_meta
              uuid_source_fields:
                - _meta_key
          - tracker_schema_item:
              isEnabled: true
              field_definitions_overrides:
                - field: _meta_value
                  option_name_field_name: _meta_key
                  value_handler: option
                - field: user_id
                  value_handler: 'reference:users'
              local_id_field:
                name: u_meta_id
                type: bigint(20) unsigned
              plugin: ''
              screen_label_formatter:
                config:
                  field_name: _meta_key
                id: field
              subordination:
                primary_item_id_field: user_id
                primary_tracker_id: users
              tracker_id: user_meta
              uuid_source_fields:
                - _meta_key
          - tracker_schema_item:
              isEnabled: true
              field_definitions_overrides:
                - field: object_id
                  value_handler: 'reference:posts'
                - field: term_taxonomy_id
                  value_handler: 'reference:term_taxonomy'
              local_id_field:
                name: '["object_id","term_taxonomy_id"]'
                type: text
              plugin: ''
              screen_label_formatter:
                config:
                  field_name: term_taxonomy_id
                id: referenced_item
              subordination:
                primary_item_id_field: object_id
                primary_tracker_id: posts
              tracker_id: term_relationships
              uuid_source_fields:
                - object_id
                - term_taxonomy_id

  exclusions:
    - exclusion_item:
        plugin: ""
        tracker: options
        field: option_name
        conditions:
          - condition:
              value: _site_transient_%
          - condition:
              value: _transient_%
          - condition:
              value: cron
          - condition:
              value: deploy_sync_content__current_config__%
          - condition:
              value: deploy_sync_content__import_author
    - exclusion_item:
        plugin: ""
        tracker: postmeta
        field: meta_key
        conditions:
          - condition:
              value: _edit_lock
    - exclusion_item:
        plugin: sitepress-multilingual-cms
        tracker: options
        field: option_name
        conditions:
          - condition:
              value: wpml-cache-translators-%
