<% end %>
<%= form_with model: game, class: "space-y-6" do |f| %>
<% if game.errors.any? %>
<%= f.label :title, class: "block text-sm font-medium text-gray-700" %>
<% if game.new_record? && current_user.igdb_sync_enabled? %>
<%= f.text_field :title,
class: "mt-1 block w-full rounded-md border-gray-300 shadow-sm focus:border-indigo-500 focus:ring-indigo-500",
"data-igdb-search-target": "title" %>
Auto-filled from IGDB or enter manually
<% else %>
<%= f.text_field :title,
class: "mt-1 block w-full rounded-md border-gray-300 shadow-sm focus:border-indigo-500 focus:ring-indigo-500" %>
<% end %>
<%= f.label :platform_id, class: "block text-sm font-medium text-gray-700" %>
<% if game.new_record? && current_user.igdb_sync_enabled? %>
<%= f.collection_select :platform_id, @platforms, :id, :name,
{ prompt: "Select Platform" },
class: "mt-1 block w-full rounded-md border-gray-300 shadow-sm focus:border-indigo-500 focus:ring-indigo-500",
"data-igdb-search-target": "platformSelect",
"data-action": "change->igdb-search#search" %>
<% else %>
<%= f.collection_select :platform_id, @platforms, :id, :name,
{ prompt: "Select Platform" },
class: "mt-1 block w-full rounded-md border-gray-300 shadow-sm focus:border-indigo-500 focus:ring-indigo-500" %>
<% end %>
<%= f.label :format, class: "block text-sm font-medium text-gray-700" %>
<%= f.select :format, [["Physical", "physical"], ["Digital", "digital"]], { prompt: "Select Format", selected: 'physical' }, class: "mt-1 block w-full rounded-md border-gray-300 shadow-sm focus:border-indigo-500 focus:ring-indigo-500" %>
<%= f.label :date_added, class: "block text-sm font-medium text-gray-700" %>
<%= f.date_field :date_added, value: game.date_added || Date.current, class: "mt-1 block w-full rounded-md border-gray-300 shadow-sm focus:border-indigo-500 focus:ring-indigo-500" %>
<%= f.label :completion_status, class: "block text-sm font-medium text-gray-700" %>
<%= f.select :completion_status, [["Backlog", "backlog"], ["Currently Playing", "currently_playing"], ["Completed", "completed"], ["On Hold", "on_hold"], ["Not Playing", "not_playing"]], { prompt: "Select Status", selected: "backlog" }, class: "mt-1 block w-full rounded-md border-gray-300 shadow-sm focus:border-indigo-500 focus:ring-indigo-500" %>
<%= f.label :user_rating, "Rating (1-5 stars)", class: "block text-sm font-medium text-gray-700" %>
<%= f.number_field :user_rating, min: 1, max: 5, class: "mt-1 block w-full rounded-md border-gray-300 shadow-sm focus:border-indigo-500 focus:ring-indigo-500" %>
<%= f.label :genre_ids, "Genres", class: "block text-sm font-medium text-gray-700" %>
<%= f.collection_check_boxes :genre_ids, @genres, :id, :name do |b| %>
<%= b.check_box class: "rounded border-gray-300 text-indigo-600 focus:ring-indigo-500" %>
<%= b.label class: "ml-2 text-sm text-gray-700" %>
<% end %>
Physical Game Details
<%= f.label :condition, class: "block text-sm font-medium text-gray-700" %>
<%= f.select :condition, [["CIB (Complete in Box)", "cib"], ["Loose", "loose"], ["Sealed", "sealed"], ["Good", "good"], ["Fair", "fair"]], { prompt: "Select Condition", selected: "loose" }, class: "mt-1 block w-full rounded-md border-gray-300 shadow-sm focus:border-indigo-500 focus:ring-indigo-500" %>
<%= f.label :price_paid, class: "block text-sm font-medium text-gray-700" %>
<%= f.number_field :price_paid, step: 0.01, class: "mt-1 block w-full rounded-md border-gray-300 shadow-sm focus:border-indigo-500 focus:ring-indigo-500" %>
<%= f.label :location, class: "block text-sm font-medium text-gray-700" %>
<%= f.text_field :location,
placeholder: "e.g., Bedroom Shelf A",
class: "mt-1 block w-full rounded-md border-gray-300 shadow-sm focus:border-indigo-500 focus:ring-indigo-500",
autocomplete: "off",
data: {
location_autocomplete_target: "input",
action: "input->location-autocomplete#search"
} %>
Start typing to see previously used locations
<%= f.label :collection_ids, "Collections", class: "block text-sm font-medium text-gray-700 mb-2" %>
<% if defined?(@collections) && @collections.any? %>
<% @collections.each do |collection| %>
<%= check_box_tag "game[collection_ids][]", collection.id,
game.collection_ids.include?(collection.id),
id: "game_collection_ids_#{collection.id}",
class: "rounded border-gray-300 text-indigo-600 focus:ring-indigo-500 mt-1" %>
<%= label_tag "game_collection_ids_#{collection.id}", class: "ml-2 text-sm" do %>
<%= collection.name %>
<% if collection.subcollection? %>
(subcollection of <%= collection.parent_collection.name %>)
<% end %>
<% end %>
<% end %>
Select one or more collections for this game
<% else %>
No collections yet. <%= link_to "Create a collection", new_collection_path, class: "text-indigo-600 hover:text-indigo-800" %> to organize your games.
<% end %>
<%= f.label :notes, class: "block text-sm font-medium text-gray-700" %>
<% if game.new_record? && current_user.igdb_sync_enabled? %>
<%= f.text_area :notes,
rows: 4,
class: "mt-1 block w-full rounded-md border-gray-300 shadow-sm focus:border-indigo-500 focus:ring-indigo-500",
placeholder: "Optional notes about this game (can be auto-filled from IGDB)",
"data-igdb-search-target": "summary" %>
Can be auto-filled from IGDB or add your own notes
<% else %>
<%= f.text_area :notes,
rows: 4,
class: "mt-1 block w-full rounded-md border-gray-300 shadow-sm focus:border-indigo-500 focus:ring-indigo-500",
placeholder: "Optional notes about this game" %>
<% end %>
<%= f.submit class: "px-6 py-2 bg-indigo-600 text-white rounded-md hover:bg-indigo-700" %>
<%= link_to "Cancel", game.persisted? ? game : games_path, class: "px-6 py-2 bg-gray-200 text-gray-700 rounded-md hover:bg-gray-300" %>