<commit_before>- if question.key == :org_chart
  = render "shared/non_js_dynamic_list_redirect_warning", add_message: "Upload"

.js-upload-wrapper data-max-attachments=question.max_attachments data-form-name=question.form_name data-name=question.key data-description=(question.description ? '1' : nil) data-list-namespace=(question.key == :org_chart ? "organisational_charts" : "form_attachments")
  ul.js-uploaded-list.list-add
    - (question.input_value(json: true) || {}).to_a.sort_by{|o| o.first.to_i}.each do |(idx, el)|

      - if el['file'].present? || el['link'].present?
        li class="#{'js-file-uploaded' if el['file'].present?}"
          div
            - if el['file'].present?
              = render "form/form_attachments/file", el: el, attachments: attachments
              input type='hidden' name=question.input_name(suffix: 'file', index: idx) value=attachments[el['file'].to_i].id

              - if question.key == :org_chart
                = link_to "Remove", form_form_answer_organisational_chart_confirm_deletion_url(@form_answer.id, el['file'].to_i), class: "remove-link if-js-hide"

                = link_to "Remove", form_form_answer_organisational_chart_url(@form_answer.id, el['file'].to_i),
                                    possible_read_only_ops.merge({class: "remove-link if-no-js-hide",
                                                                  remote: true,
                                                                  method: :delete})
              - else
                = link_to "Remove", form_form_answer_form_attachment_url(@form_answer.id, el['file'].to_i),
                                    possible_read_only_ops.merge({class: "remove-link",
                                                                  remote: true,
                                                                  method: :delete})

            - elsif el['link'].present?
              a.remove-link href="#" *possible_read_only_ops
                | Remove
              label
                ' Website address
                input.large type="text" name=question.input_name(suffix: 'link', index: idx) value=question.input_value(suffix: 'link', index: idx)
          - if question.description
            div
              label for=question.input_name(suffix: 'description', index: idx)
                span.label-char-count-reposition
                  ' Description
                / (optional)
              textarea.js-char-count rows="2" maxlength="600" data-word-max="100" name=question.input_name(suffix: 'description', index: idx) id=question.input_name(suffix: 'description', index: idx)
                = question.input_value(suffix: 'description', index: idx)

  ul.errors-container
  .clear

  .if-no-js-hide
    span.button.button-add *possible_read_only_ops
      span
        | + Upload
      input.fileinput-button.js-file-upload type="file" name="form[file]" id="q_#{question.key}" *possible_read_only_ops data-question-key=question.key
    - if question.links
      | &nbsp;
      a.button.button-add.js-file-upload data-add-link="1" href="#" *possible_read_only_ops
        | + Add website address

  - if question.key == :org_chart && @form_answer.document["org_chart"].blank?
    .if-js-hide
      = link_to "+ Upload", new_form_form_answer_organisational_chart_url(@form_answer.id),
                            class: "button button-add"
<commit_msg>[FORM | UPLOAD QUESTION] fixed missing attachment issue<commit_after>- if question.key == :org_chart
  = render "shared/non_js_dynamic_list_redirect_warning", add_message: "Upload"

.js-upload-wrapper data-max-attachments=question.max_attachments data-form-name=question.form_name data-name=question.key data-description=(question.description ? '1' : nil) data-list-namespace=(question.key == :org_chart ? "organisational_charts" : "form_attachments")
  ul.js-uploaded-list.list-add
    - (question.input_value(json: true) || {}).to_a.sort_by{|o| o.first.to_i}.each do |(idx, el)|

      - if (el['file'].present? && attachments[el['file'].to_i].present?) || el['link'].present?
        li class="#{'js-file-uploaded' if el['file'].present?}"
          div
            - if el['file'].present?
              = render "form/form_attachments/file", el: el, attachments: attachments
              input type='hidden' name=question.input_name(suffix: 'file', index: idx) value=attachments[el['file'].to_i].id

              - if question.key == :org_chart
                = link_to "Remove", form_form_answer_organisational_chart_confirm_deletion_url(@form_answer.id, el['file'].to_i), class: "remove-link if-js-hide"

                = link_to "Remove", form_form_answer_organisational_chart_url(@form_answer.id, el['file'].to_i),
                                    possible_read_only_ops.merge({class: "remove-link if-no-js-hide",
                                                                  remote: true,
                                                                  method: :delete})
              - else
                = link_to "Remove", form_form_answer_form_attachment_url(@form_answer.id, el['file'].to_i),
                                    possible_read_only_ops.merge({class: "remove-link",
                                                                  remote: true,
                                                                  method: :delete})

            - elsif el['link'].present?
              a.remove-link href="#" *possible_read_only_ops
                | Remove
              label
                ' Website address
                input.large type="text" name=question.input_name(suffix: 'link', index: idx) value=question.input_value(suffix: 'link', index: idx)
          - if question.description
            div
              label for=question.input_name(suffix: 'description', index: idx)
                span.label-char-count-reposition
                  ' Description
                / (optional)
              textarea.js-char-count rows="2" maxlength="600" data-word-max="100" name=question.input_name(suffix: 'description', index: idx) id=question.input_name(suffix: 'description', index: idx)
                = question.input_value(suffix: 'description', index: idx)

  ul.errors-container
  .clear

  .if-no-js-hide
    span.button.button-add *possible_read_only_ops
      span
        | + Upload
      input.fileinput-button.js-file-upload type="file" name="form[file]" id="q_#{question.key}" *possible_read_only_ops data-question-key=question.key
    - if question.links
      | &nbsp;
      a.button.button-add.js-file-upload data-add-link="1" href="#" *possible_read_only_ops
        | + Add website address

  - if question.key == :org_chart && @form_answer.document["org_chart"].blank?
    .if-js-hide
      = link_to "+ Upload", new_form_form_answer_organisational_chart_url(@form_answer.id),
                            class: "button button-add"

{'fraction_non_alphanumeric': 0.12667724715048334, 'fraction_numerical': 0.0025970278459096813, 'mean_word_length': 2.097408400357462, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 20, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1779976', 'n_tokens_mistral': 1996, 'n_tokens_neox': 1923, 'n_words': 331}