From b483ff56c663e2d346df8f1f243100007c2c93c9 Mon Sep 17 00:00:00 2001 From: Ben Harris Date: Mon, 31 Jan 2022 14:28:00 -0500 Subject: [PATCH] tidy up, add git hash to src link --- app/controllers/machines_controller.rb | 2 +- app/controllers/players_controller.rb | 2 +- app/views/machines/show.html.erb | 6 ++++-- app/views/pages/index.html.erb | 2 +- app/views/players/index.html.erb | 2 +- app/views/players/show.html.erb | 6 ++++-- config/initializers/constants.rb | 2 ++ test/system/machines_test.rb | 2 +- test/system/players_test.rb | 2 +- 9 files changed, 16 insertions(+), 10 deletions(-) create mode 100644 config/initializers/constants.rb diff --git a/app/controllers/machines_controller.rb b/app/controllers/machines_controller.rb index 33dcd3b..9d47832 100644 --- a/app/controllers/machines_controller.rb +++ b/app/controllers/machines_controller.rb @@ -52,7 +52,7 @@ class MachinesController < ApplicationController @machine.destroy respond_to do |format| - format.html { redirect_to machines_url, notice: 'Machine was successfully destroyed.' } + format.html { redirect_to machines_url, notice: 'Machine was successfully removed.' } format.json { head :no_content } end end diff --git a/app/controllers/players_controller.rb b/app/controllers/players_controller.rb index cebe2a1..4e1195d 100644 --- a/app/controllers/players_controller.rb +++ b/app/controllers/players_controller.rb @@ -49,7 +49,7 @@ class PlayersController < ApplicationController @player.destroy respond_to do |format| - format.html { redirect_to players_url, notice: 'Player was successfully destroyed.' } + format.html { redirect_to players_url, notice: 'Player was successfully removed.' } format.json { head :no_content } end end diff --git a/app/views/machines/show.html.erb b/app/views/machines/show.html.erb index 19e5f19..4bba20c 100644 --- a/app/views/machines/show.html.erb +++ b/app/views/machines/show.html.erb @@ -1,7 +1,9 @@ -

<%= notice %>

+<% if not notice.nil? %>

<%= notice %>

<% end %> <%= render "form", machine: @machine %>
- <%= button_to "Delete #{@machine.name}", @machine, method: :delete %> + <%= link_to "Delete #{@machine.name} ❌", @machine, data: { + turbo_method: :delete, + turbo_confirm: "Are you sure you want to remove #{@machine.name}?"} %>
diff --git a/app/views/pages/index.html.erb b/app/views/pages/index.html.erb index ddfa22f..e9456ca 100644 --- a/app/views/pages/index.html.erb +++ b/app/views/pages/index.html.erb @@ -1,3 +1,3 @@

Knockout

To start the tournament, add players and make sure that the pins are up to date. Then hit randomize to automatically pick teams!

-

The source code for this app can be found here.

\ No newline at end of file +

The source code for this app can be found <%= link_to 'here', "#{GIT_REPO}/src/commit/#{GIT_SHA}" %>.

diff --git a/app/views/players/index.html.erb b/app/views/players/index.html.erb index eb209b0..a635ded 100644 --- a/app/views/players/index.html.erb +++ b/app/views/players/index.html.erb @@ -18,7 +18,7 @@ <% if player.paid %>✓ <% end %> <%= player.strikes %> - <%= link_to "X", player, data: { + <%= link_to "❌", player, data: { turbo_method: :delete, turbo_confirm: "Are you sure you want to remove #{player.name}?" } %> diff --git a/app/views/players/show.html.erb b/app/views/players/show.html.erb index e031050..3d0bb78 100644 --- a/app/views/players/show.html.erb +++ b/app/views/players/show.html.erb @@ -1,7 +1,9 @@ -

<%= notice %>

+<% if not notice.nil? %>

<%= notice %>

<% end %> <%= render "form", player: @player %>
- <%= button_to "Delete #{@player.name}", @player, method: :delete %> + <%= link_to "Delete #{@player.name} ❌", @player, data: { + turbo_method: :delete, + turbo_confirm: "Are you sure you want to remove #{@player.name}?"} %>
diff --git a/config/initializers/constants.rb b/config/initializers/constants.rb new file mode 100644 index 0000000..86a4a1b --- /dev/null +++ b/config/initializers/constants.rb @@ -0,0 +1,2 @@ +GIT_SHA = `git rev-parse HEAD`.chomp +GIT_REPO = 'https://tildegit.org/ben/pinrails' \ No newline at end of file diff --git a/test/system/machines_test.rb b/test/system/machines_test.rb index 1a8414a..43c1949 100644 --- a/test/system/machines_test.rb +++ b/test/system/machines_test.rb @@ -37,6 +37,6 @@ class MachinesTest < ApplicationSystemTestCase visit machine_url(@machine) click_on "Delete #{@machine.name}", match: :first - assert_text 'Machine was successfully destroyed' + assert_text 'Machine was successfully removed' end end diff --git a/test/system/players_test.rb b/test/system/players_test.rb index 69f08e9..4ea9751 100644 --- a/test/system/players_test.rb +++ b/test/system/players_test.rb @@ -39,6 +39,6 @@ class PlayersTest < ApplicationSystemTestCase visit player_url(@player) click_on "Delete #{@player.name}", match: :first - assert_text 'Player was successfully destroyed' + assert_text 'Player was successfully removed' end end