フロントエンドプレイアブル
This commit is contained in:
42
app/views/turns/_form.html.erb
Normal file
42
app/views/turns/_form.html.erb
Normal file
@@ -0,0 +1,42 @@
|
||||
<%= form_with(model: turn) do |form| %>
|
||||
<% if turn.errors.any? %>
|
||||
<div style="color: red">
|
||||
<h2><%= pluralize(turn.errors.count, "error") %> prohibited this turn from being saved:</h2>
|
||||
|
||||
<ul>
|
||||
<% turn.errors.each do |error| %>
|
||||
<li><%= error.full_message %></li>
|
||||
<% end %>
|
||||
</ul>
|
||||
</div>
|
||||
<% end %>
|
||||
|
||||
<div>
|
||||
<%= form.label :number, style: "display: block" %>
|
||||
<%= form.number_field :number %>
|
||||
</div>
|
||||
|
||||
<div>
|
||||
<%= form.label :phase, style: "display: block" %>
|
||||
<%= form.text_field :phase %>
|
||||
</div>
|
||||
|
||||
<div>
|
||||
<%= form.label :game_state, style: "display: block" %>
|
||||
<%= form.text_field :game_state %>
|
||||
</div>
|
||||
|
||||
<div>
|
||||
<%= form.label :svg_date, style: "display: block" %>
|
||||
<%= form.textarea :svg_date %>
|
||||
</div>
|
||||
|
||||
<div>
|
||||
<%= form.label :game_id, style: "display: block" %>
|
||||
<%= form.text_field :game_id %>
|
||||
</div>
|
||||
|
||||
<div>
|
||||
<%= form.submit %>
|
||||
</div>
|
||||
<% end %>
|
||||
39
app/views/turns/_turn.html.erb
Normal file
39
app/views/turns/_turn.html.erb
Normal file
@@ -0,0 +1,39 @@
|
||||
<div id="<%= dom_id turn %>">
|
||||
<div>
|
||||
<strong>Number:</strong>
|
||||
<%= turn.number %>
|
||||
</div>
|
||||
|
||||
<div>
|
||||
<strong>Phase:</strong>
|
||||
<%= turn.phase %>
|
||||
</div>
|
||||
|
||||
<div>
|
||||
<strong>Game state:</strong>
|
||||
<pre><%= JSON.pretty_generate(turn.game_state) if turn.game_state %></pre>
|
||||
</div>
|
||||
|
||||
<div>
|
||||
<strong>Possible orders:</strong>
|
||||
<pre><%= JSON.pretty_generate(turn.possible_orders) if turn.possible_orders %></pre>
|
||||
</div>
|
||||
|
||||
<div>
|
||||
<strong>Orders:</strong>
|
||||
<pre><%= JSON.pretty_generate(turn.orders) if turn.orders %></pre>
|
||||
</div>
|
||||
|
||||
<div>
|
||||
<strong>Map View:</strong>
|
||||
<div class="game-map">
|
||||
<%= turn.svg_date.html_safe if turn.svg_date %>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div>
|
||||
<strong>Game ID:</strong>
|
||||
<%= turn.game_id %>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
2
app/views/turns/_turn.json.jbuilder
Normal file
2
app/views/turns/_turn.json.jbuilder
Normal file
@@ -0,0 +1,2 @@
|
||||
json.extract! turn, :id, :number, :phase, :game_state, :possible_orders, :orders, :svg_date, :game_id, :created_at, :updated_at
|
||||
json.url turn_url(turn, format: :json)
|
||||
12
app/views/turns/edit.html.erb
Normal file
12
app/views/turns/edit.html.erb
Normal file
@@ -0,0 +1,12 @@
|
||||
<% content_for :title, "Editing turn" %>
|
||||
|
||||
<h1>Editing turn</h1>
|
||||
|
||||
<%= render "form", turn: @turn %>
|
||||
|
||||
<br>
|
||||
|
||||
<div>
|
||||
<%= link_to "Show this turn", @turn %> |
|
||||
<%= link_to "Back to turns", turns_path %>
|
||||
</div>
|
||||
19
app/views/turns/index.html.erb
Normal file
19
app/views/turns/index.html.erb
Normal file
@@ -0,0 +1,19 @@
|
||||
<p style="color: green"><%= notice %></p>
|
||||
|
||||
<% content_for :title, "Turns" %>
|
||||
|
||||
<h1>Turns</h1>
|
||||
|
||||
<div id="turns">
|
||||
<% @turns.each do |turn| %>
|
||||
<%= turn.id %>
|
||||
<%= turn.game_id %>
|
||||
<%= turn.number %>
|
||||
<%= turn.phase %>
|
||||
<p>
|
||||
<%= link_to "Show this turn", turn %>
|
||||
</p>
|
||||
<% end %>
|
||||
</div>
|
||||
|
||||
<%= link_to "New turn", new_turn_path %>
|
||||
1
app/views/turns/index.json.jbuilder
Normal file
1
app/views/turns/index.json.jbuilder
Normal file
@@ -0,0 +1 @@
|
||||
json.array! @turns, partial: "turns/turn", as: :turn
|
||||
11
app/views/turns/new.html.erb
Normal file
11
app/views/turns/new.html.erb
Normal file
@@ -0,0 +1,11 @@
|
||||
<% content_for :title, "New turn" %>
|
||||
|
||||
<h1>New turn</h1>
|
||||
|
||||
<%= render "form", turn: @turn %>
|
||||
|
||||
<br>
|
||||
|
||||
<div>
|
||||
<%= link_to "Back to turns", turns_path %>
|
||||
</div>
|
||||
42
app/views/turns/show.html.erb
Normal file
42
app/views/turns/show.html.erb
Normal file
@@ -0,0 +1,42 @@
|
||||
<div class="max-w-7xl mx-auto px-4 sm:px-6 lg:px-8 py-8">
|
||||
<div class="mb-6 flex justify-between items-start">
|
||||
<div>
|
||||
<h1 class="text-2xl font-bold text-gray-900">Turn <%= @turn.number %> Details</h1>
|
||||
<%= link_to 'Back to Game', game_path(@turn.game), class: "mt-2 inline-block text-indigo-600 hover:text-indigo-900" %>
|
||||
</div>
|
||||
<div class="flex space-x-2">
|
||||
<%= link_to 'Edit', edit_turn_path(@turn), class: "inline-flex items-center px-4 py-2 border border-gray-300 shadow-sm text-sm font-medium rounded-md text-gray-700 bg-white hover:bg-gray-50 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-indigo-500" %>
|
||||
<%= button_to "Destroy this turn", @turn, method: :delete, class: "inline-flex items-center px-4 py-2 border border-transparent text-sm font-medium rounded-md text-white bg-red-600 hover:bg-red-700 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-red-500", data: { turbo_confirm: "Are you sure?" } %>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="bg-white shadow overflow-hidden sm:rounded-lg mb-6">
|
||||
<div class="px-4 py-5 sm:px-6">
|
||||
<h3 class="text-lg leading-6 font-medium text-gray-900">SVG Orders Data</h3>
|
||||
<p class="mt-1 max-w-2xl text-sm text-gray-500">Stored SVG images for each power.</p>
|
||||
</div>
|
||||
<div class="border-t border-gray-200 px-4 py-5 sm:p-0">
|
||||
<dl class="sm:divide-y sm:divide-gray-200">
|
||||
<% if @turn.svg_orders.present? %>
|
||||
<% @turn.svg_orders.each do |key, svg| %>
|
||||
<%= key %>
|
||||
<%= svg.html_safe %>
|
||||
<% end %>
|
||||
<% else %>
|
||||
<div class="py-4 sm:py-5 sm:px-6">
|
||||
<p class="text-sm text-gray-500">No SVG orders data found.</p>
|
||||
</div>
|
||||
<% end %>
|
||||
</dl>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="bg-white shadow overflow-hidden sm:rounded-lg">
|
||||
<div class="px-4 py-5 sm:px-6">
|
||||
<h3 class="text-lg leading-6 font-medium text-gray-900">Debug Info</h3>
|
||||
</div>
|
||||
<div class="border-t border-gray-200 px-4 py-5 sm:p-6">
|
||||
<pre class="text-xs bg-gray-100 p-2 rounded overflow-auto"><%= JSON.pretty_generate(@turn.attributes.except("svg_orders", "svg_date")) %></pre>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
1
app/views/turns/show.json.jbuilder
Normal file
1
app/views/turns/show.json.jbuilder
Normal file
@@ -0,0 +1 @@
|
||||
json.partial! "turns/turn", turn: @turn
|
||||
Reference in New Issue
Block a user