module Project
  module CopyModalCommon
    include PageObject

    text_field(:product_code, id: "product-code")
    text_field(:product_name, id: "product-name")
    text_field(:product_version, id: "product-version")
    text_field(:version_notes, id: "version")
    button(:full_length_format, text: "Full Length")
    button(:ep_format, text: "EP")
    button(:single_format, text: "Single")
    button(:create_copy, id: "digital-product-copy-confirm-submit")
    radio_button(
      :orchard_generated_upc,
      name: "upc-assignment", value: "ORCHARD"
    )
    radio_button(
      :use_own_upc,
      name: "upc-assignment", value: "OWN"
    )

    def format=(format_data)
      # Added below line to ensure hover popup is not over below buttons
      product_name_element.click
      case format_data
      when "Full Length"
        full_length_format
      when "EP"
        ep_format
      when "Music Video"
        music_video_format
      else
        fail "unknown format: #{format_data}!"
      end
    end
  end
end
