diff options
Diffstat (limited to 'app')
-rw-r--r-- | app/controllers/games/ptu/pokemon_controller.rb | 11 | ||||
-rw-r--r-- | app/javascript/stylesheets/core.css | 3 | ||||
-rw-r--r-- | app/views/games/ptu/pokemon/_form.html.erb | 30 | ||||
-rw-r--r-- | app/views/games/ptu/pokemon/edit.html.erb | 3 | ||||
-rw-r--r-- | app/views/games/ptu/pokemon/index.html.erb | 9 | ||||
-rw-r--r-- | app/views/games/ptu/pokemon/new.html.erb | 29 | ||||
-rw-r--r-- | app/views/games/ptu/pokemon/show.html.erb | 4 |
7 files changed, 60 insertions, 29 deletions
diff --git a/app/controllers/games/ptu/pokemon_controller.rb b/app/controllers/games/ptu/pokemon_controller.rb index 485f03d..e5329a7 100644 --- a/app/controllers/games/ptu/pokemon_controller.rb +++ b/app/controllers/games/ptu/pokemon_controller.rb @@ -1,4 +1,8 @@ class Games::Ptu::PokemonController < ApplicationController + def index + @pokemons = PtuPokemon.all + end + def show @pokemon = PtuPokemon.find(params[:id]) end @@ -18,6 +22,13 @@ class Games::Ptu::PokemonController < ApplicationController end end + def edit + @pokemon = PtuPokemon.find(params[:id]) + end + + def update + end + private def pokemon_params params.require(:ptu_pokemon).permit(:name, :base_hp, :base_atk, :base_def, :base_spatk, :base_spdef, diff --git a/app/javascript/stylesheets/core.css b/app/javascript/stylesheets/core.css index 15b234b..ec06839 100644 --- a/app/javascript/stylesheets/core.css +++ b/app/javascript/stylesheets/core.css @@ -10,7 +10,8 @@ p { } label { - @apply mb-2; + @apply mt-2; + display: block; } input { diff --git a/app/views/games/ptu/pokemon/_form.html.erb b/app/views/games/ptu/pokemon/_form.html.erb new file mode 100644 index 0000000..aeb4dea --- /dev/null +++ b/app/views/games/ptu/pokemon/_form.html.erb @@ -0,0 +1,30 @@ +<%= form_with model: @pokemon, + url: @pokemon.new_record? ? games_ptu_pokemon_index_path : games_ptu_pokemon_path do |f| %> + <%= f.label :name %> + <%= f.text_field :name, required: true %> + + <%= f.label :base_hp, "Base HP" %> + <%= f.number_field :base_hp, value: @pokemon.base_hp, min: 1, required: true %> + + <%= f.label :base_atk, "Base ATK" %> + <%= f.number_field :base_atk, value: @pokemon.base_atk, min: 1, required: true %> + + <%= f.label :base_def, "Base DEF" %> + <%= f.number_field :base_def, value: @pokemon.base_def, min: 1, required: true %> + + <%= f.label :base_spatk, "Base SPATK" %> + <%= f.number_field :base_spatk, value: @pokemon.base_spatk, min: 1, required: true %> + + <%= f.label :base_spdef, "Base SPDEF" %> + <%= f.number_field :base_spdef, value: @pokemon.base_spdef, min: 1, required: true %> + + <%= f.label :base_speed, "Base SPEED" %> + <%= f.number_field :base_speed, value: @pokemon.base_speed, min: 1, required: true %> + + <%= f.label :male_chance, "Male Chance" %> + <%= f.number_field :male_chance, value: @pokemon.male_chance, min: 0, step: 0.01 %> % + + <%= f.submit "Save", class: "block mt-4" %> +<% end %> +<%= button_to "Cancel", @pokemon.new_record? ? games_ptu_pokemon_index_path : games_ptu_pokemon_path(@pokemon), + method: :get, class: "mt-4" %> diff --git a/app/views/games/ptu/pokemon/edit.html.erb b/app/views/games/ptu/pokemon/edit.html.erb new file mode 100644 index 0000000..684ee4d --- /dev/null +++ b/app/views/games/ptu/pokemon/edit.html.erb @@ -0,0 +1,3 @@ +<h1>New Pokemon - <%= @pokemon.name %> </h1> + +<%= render "form" %> diff --git a/app/views/games/ptu/pokemon/index.html.erb b/app/views/games/ptu/pokemon/index.html.erb new file mode 100644 index 0000000..a1d7443 --- /dev/null +++ b/app/views/games/ptu/pokemon/index.html.erb @@ -0,0 +1,9 @@ +<h1>Pokemon</h1> + +<div class="my-4"><%= link_to "New", new_games_ptu_pokemon_path %></div> + +<ul class="list-disc"> + <% @pokemons.each do |p| %> + <li><%= link_to p.name, games_ptu_pokemon_path(p) %></li> + <% end %> +</ul> diff --git a/app/views/games/ptu/pokemon/new.html.erb b/app/views/games/ptu/pokemon/new.html.erb index 7ba0426..404bd47 100644 --- a/app/views/games/ptu/pokemon/new.html.erb +++ b/app/views/games/ptu/pokemon/new.html.erb @@ -1,30 +1,3 @@ <h1>New Pokemon</h1> -<%= form_with model: @pokemon, url: games_ptu_pokemon_index_path do |f| %> - <%= f.label :name %> - <%= f.text_field :name, required: true %> - - <%= f.label :base_hp, "Base HP" %> - <%= f.number_field :base_hp, min: 1, required: true %> - - <%= f.label :base_atk, "Base ATK" %> - <%= f.number_field :base_atk, min: 1, required: true %> - - <%= f.label :base_def, "Base DEF" %> - <%= f.number_field :base_def, min: 1, required: true %> - - <%= f.label :base_spatk, "Base SPATK" %> - <%= f.number_field :base_spatk, min: 1, required: true %> - - <%= f.label :base_spdef, "Base SPDEF" %> - <%= f.number_field :base_spdef, min: 1, required: true %> - - <%= f.label :base_speed, "Base SPEED" %> - <%= f.number_field :base_speed, min: 1, required: true %> - - <%= f.label :male_chance, "Male Chance" %> - <%= f.number_field :male_chance, min: 0, step: 0.01 %> % - - <%= f.submit "Save" %> - -<% end %> +<%= render "form" %> diff --git a/app/views/games/ptu/pokemon/show.html.erb b/app/views/games/ptu/pokemon/show.html.erb index e7b80ce..c4454cd 100644 --- a/app/views/games/ptu/pokemon/show.html.erb +++ b/app/views/games/ptu/pokemon/show.html.erb @@ -1,5 +1,9 @@ +<div class="my-4"><%= link_to "Back", games_ptu_pokemon_index_path %></div> + <h1><%= @pokemon.name %></h1> +<div class="my-2"><%= link_to "Edit", edit_games_ptu_pokemon_path(@pokemon) %></div> + <table> <tr> <td>Base HP</td> |