af83/chouette-core

View on GitHub
app/views/sources/_form.html.slim

Summary

Maintainability
Test Coverage
= simple_form_for [@workbench, @source], html: { class: 'tailwind-form', id: 'source_form', 'x-data': "{downloader_type: '#{@source.downloader_type}' }" }, wrapper: :horizontal_form_tailwind do |f|
  .row
    .col-lg-12
      = f.input :name
      = f.input :url
      = f.input :downloader_type, as: :select, include_blank: false, input_html: { 'x-model': 'downloader_type' }
      template[x-if="downloader_type == 'authorization'"]
        = f.input :downloader_option_raw_authorization, as: :toggable_password
      template[x-if="['direct','ftp','sftp'].includes(downloader_type)"]
        div
          = f.input :downloader_option_username, as: :string
          = f.input :downloader_option_password, as: :password
  .row
    h2
      = t("sources.form.sections.retrieval")
    .simple-separator.mb-5
    .col-lg-12 x-data="{ retrieval_frequency: '#{@source.retrieval_frequency}' }"
      = f.input :retrieval_frequency, as: :radio_buttons, wrapper: :vertical_radio_and_checkboxes_tailwind, input_html: { "x-model" => "retrieval_frequency" }
      = f.input :retrieval_time_of_day, as: :time_of_day, input_html: { "x-bind:disabled" => "retrieval_frequency != 'daily'" }
      .flex.items-center.mb-10
        = f.label :retrieval_days_of_week, class: "flex justify-end w-2/6 mr-8 mb-0 control-label pt-0 required"
        .flex.items-center
          = f.simple_fields_for :retrieval_days_of_week, wrapper: false do |days_of_week_form|
            - Cuckoo::Timetable::DaysOfWeek.each_day do |day|
                = days_of_week_form.input day, as: :boolean, boolean_style: :inline, wrapper: :horizontal_boolean_tailwind, wrapper_html: { class: "week-day-checkboxes mr-4" }, label_html: { class: "bg-light-grey text-gray-400 rounded-lg border border-gray-400 p-4 mb-0 cursor-pointer flex items-center justify-center" }, label: t("point_of_interests.days.#{day}")
      = f.input :ignore_checksum, as: :switchable_checkbox
  .row
    h2
      = t("sources.form.sections.import_options")
    .simple-separator.mb-5
    .col-lg-12
      = f.input :import_option_automatic_merge, as: :switchable_checkbox
      = f.input :import_option_archive_on_fail, as: :switchable_checkbox
      - if resource_policy.update_workgroup_providers? && !@source.update_workgroup_providers?
        = f.input :import_option_update_workgroup_providers, as: :switchable_checkbox
      - else
        = f.input :import_option_update_workgroup_providers, as: :switchable_checkbox, disabled: true
      - if has_feature?("import_netex_store_xml")
        = f.input :import_option_store_xml, as: :switchable_checkbox
      = f.input :import_option_disable_missing_resources, as: :switchable_checkbox
      = f.input :import_option_strict_mode, as: :switchable_checkbox
      = f.input :import_option_ignore_particulars, as: :switchable_checkbox
      = f.input :import_option_process_gtfs_route_ids, as: :editable_select, collection: @source.import_option_process_gtfs_route_ids, selected: @source.import_option_process_gtfs_route_ids, include_blank: false, wrapper: :horizontal_input_editable_select_tailwind, input_html: { multiple: true }
      = f.input :import_option_stop_area_provider_id, as: :select, collection: @source.candidate_stop_area_providers.order(:name), include_blank: false
      = f.input :import_option_line_provider_id, as: :select, collection: @source.candidate_line_providers.order(:name), include_blank: false
      - if has_feature?("import_with_code_space")
        = f.input :import_option_code_space_id, as: :select, collection: @workbench.workgroup.code_spaces, include_blank: true

  = cancel_button
  = f.button :submit, t('actions.submit'), class: 'btn btn-default formSubmitr', form: 'source_form'