diff options
author | David Gay <david@davidgay.org> | 2021-04-07 20:44:30 -0400 |
---|---|---|
committer | David Gay <david@davidgay.org> | 2021-04-07 20:44:30 -0400 |
commit | f27be0dce605412440b6317cd568610f01079f32 (patch) | |
tree | 85d81e8e6325cf6ee4209ef87efa0aa5b337e62e /app/views/games/ptu | |
parent | e3bc8b4a01c1615bbe4cade564760cb97bcc2a25 (diff) |
PTU pokemon controller and view basic setup
Diffstat (limited to 'app/views/games/ptu')
-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 |
5 files changed, 47 insertions, 28 deletions
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> |