diff options
author | Luke Shumaker <shumakl@purdue.edu> | 2014-05-01 16:19:34 -0400 |
---|---|---|
committer | Luke Shumaker <shumakl@purdue.edu> | 2014-05-01 16:19:34 -0400 |
commit | d7a0fffe1aab9de4b18db88c409fcd5dc486ab5c (patch) | |
tree | 753f097f582c262c75d2231f960e51c483bac15f | |
parent | d95a6526188f60562f8f7024592f5bbb85162fe6 (diff) |
clean up forms
-rw-r--r-- | app/views/layouts/application.html.erb | 6 | ||||
-rw-r--r-- | app/views/tournaments/_form.html.erb | 43 | ||||
-rw-r--r-- | app/views/tournaments/show.html.erb | 27 |
3 files changed, 40 insertions, 36 deletions
diff --git a/app/views/layouts/application.html.erb b/app/views/layouts/application.html.erb index 1b83e53..7cb7e0f 100644 --- a/app/views/layouts/application.html.erb +++ b/app/views/layouts/application.html.erb @@ -22,7 +22,7 @@ </div> <div class="navbar-collapse"> <div id="user-actions"> - <div> + <span> <% if signed_in? %> <%= link_to current_user.user_name, current_user, :class => "user", :role => :button %> <%= link_to "Sign out", session_path("current"), method: "delete", :class => "signout", :role => :button %> @@ -30,9 +30,9 @@ <%= link_to "Log in", new_session_path, :class => "signin", :role => :button %> <%= link_to "Sign up", new_user_path, :class => "signup", :role => :button %> <% end %> - </div> + </span> <% if current_user.can? :create_alert %> - <%= link_to "Create Alert", new_alert_path, :class => "create-alert", :role => :button %> + <span><%= link_to "Create Alert", new_alert_path, :class => "create-alert", :role => :button %></span> <% end %> </div> <% if signed_in? %> diff --git a/app/views/tournaments/_form.html.erb b/app/views/tournaments/_form.html.erb index fe2a5c6..93badeb 100644 --- a/app/views/tournaments/_form.html.erb +++ b/app/views/tournaments/_form.html.erb @@ -1,12 +1,20 @@ <%= render "common/error_messages", :target => @tournament %> <fieldset> - <legend>Game Type</legend> + <legend>Basic information</legend> <%= form_for(@tournament, url: new_tournament_path, method: "get") do |f| %> - <p> + <div class="field"> <%= f.label :game_id, "Select a Game Type" %> <%= f.select(:game_id, Game.all.map{|game| [game.name, game.id]}) %> - <%= f.submit("Select") %> - </p> + </div> + <div class="field"> + <label for="num_stages">Number of Tournament Stages</label> + <input type="number" id="num_stages" name="num_stages" min="1" value="<%= params[:num_stages].to_i %>"> + </div> + <% if @tournament.game %> + <%= f.submit("Update (Will reset the rest of the form)", class: "btn-danger") %> + <% else %> + <%= f.submit("Submit") %> + <% end %> <% end %> </fieldset> @@ -16,10 +24,10 @@ <legend>Attributes</legend> <%= f.hidden_field(:game_id) %> - <p> + <div class="field"> <%= f.label :name %> <%= f.text_field :name %> - </p> + </div> <table> <tbody> @@ -41,17 +49,17 @@ </tbody> </table> - <p> + <div class="field"> <%= f.label :scoring_method, :scoring_method.to_s.titleize %> <%= f.select(:scoring_method, @tournament.scoring_methods.map{|method| [method.humanize.titleize, method]}) %> - </p> + </div> </fieldset> <fieldset> <legend>Settings</legend> <%= f.fields_for :settings do |setting_fields| %> <% @tournament.tournament_settings.each do |setting| %> - <p> + <div class="field"> <%= setting_fields.label setting.name, setting.name.to_s.titleize %> <br> <% case setting.vartype %> @@ -77,7 +85,7 @@ <% when 5 %> <%= setting_fields.select( setting.name, setting.type_opt.split(',').collect {|opt| opt.humanize.titleize} ) %> <% end %> - </p> + </div> <% end %> <% end %> </fieldset> @@ -85,17 +93,18 @@ <%= f.fields_for :stages do |stages_fields| %> <fieldset> <legend>Stages</legend> - <label for="num_stages">Number of Tournament Stages</label> - <input type="number" id="num_stages" name="num_stages" min="1" value="<%= params[:num_stages].to_i %>"> - <%# stage_fields.submit("Set Stages") %> <% for i in 1..(params[:num_stages].to_i) do %> <%= stages_fields.fields_for i.to_s do |stage_fields| %> <fieldset> <legend>Stage <%= i %></legend> - <%= stage_fields.label :scheduling_method, :scheduling_method.to_s.titleize %> - <%= stage_fields.select(:scheduling_method, @tournament.scheduling_methods.map{|method| [method.humanize.titleize, method]}) %> - <%= stage_fields.label :seeding_method, :seeding_method.to_s.titleize %> - <%= stage_fields.select(:seeding_method, @tournament.seeding_methods.map{|method| [method.humanize.titleize, method]}) %> + <div class="field"> + <%= stage_fields.label :scheduling_method, :scheduling_method.to_s.titleize %> + <%= stage_fields.select(:scheduling_method, @tournament.scheduling_methods.map{|method| [method.humanize.titleize, method]}) %> + </div> + <div class="field"> + <%= stage_fields.label :seeding_method, :seeding_method.to_s.titleize %> + <%= stage_fields.select(:seeding_method, @tournament.seeding_methods.map{|method| [method.humanize.titleize, method]}) %> + </div> </fieldset> <% end %> <% end %> diff --git a/app/views/tournaments/show.html.erb b/app/views/tournaments/show.html.erb index 7e3fbae..6cb9783 100644 --- a/app/views/tournaments/show.html.erb +++ b/app/views/tournaments/show.html.erb @@ -1,3 +1,5 @@ +<%= link_to '« Back to all tournaments', tournaments_path, class: :breadcrumb %> + <h2 id="tournament-name"> <%= @tournament.name %> </h2> @@ -72,33 +74,26 @@ <% end %> </div> -<div class="leave-buttons"> - <%# If user can join, and user hasn't joined already, show the join tournment tag %> +<div class="tournament_actions"> + <%# If user can join, and user hasn't joined already, show a join tournment button %> <% if @tournament.joinable_by?(current_user) && !@tournament.players.include?(current_user) %> - <%= form_tag(tournament_path(@tournament), method: "put") do %> + <%= form_tag(tournament_path(@tournament), method: "put", role: :button) do %> <input type="hidden" name="update_action" value="join"> <%= submit_tag("Join Tournament") %> <% end %> <% elsif @tournament.players.include?(current_user) %> - <%= form_tag(tournament_path(@tournament), method: "put") do %> + <%= form_tag(tournament_path(@tournament), method: "put", role: :button) do %> <input type="hidden" name="update_action" value="leave"> <%= submit_tag("Leave Tournament") %> <% end %> <% end %> - <%# If user is the host, let them start the tournment %> - <% if @tournament.hosts.include?(current_user) %> - <%= form_tag(tournament_path(@tournament), method: "put") do %> + <% if @tournament.check_permission(current_user, :edit) %> + <%= form_tag(tournament_path(@tournament), method: "put", role: :button) do %> <input type="hidden" name="update_action" value="start"> - <% if @tournament.players.count >= @tournament.min_players_per_team * @tournament.min_teams_per_match %> - <%= submit_tag("Start Tournament") %> - <% else %> - <%= submit_tag("Start Tournament", disabled: true) %> - <% end %> + <%= submit_tag("Start Tournament", disabled: (@tournament.players.count < @tournament.min_players_per_team * @tournament.min_teams_per_match)) %> <% end %> - <%= link_to 'Edit', edit_tournament_path(@tournament) %> | - <%= link_to 'Cancel Tournament', @tournament, method: :delete, data: { confirm: 'Are you sure?' } %> + <%= link_to 'Edit Tournament', edit_tournament_path(@tournament), role: :button %> + <%= link_to 'Cancel Tournament', @tournament, method: :delete, data: { confirm: 'Are you sure?' }, role: :button %> <% end %> </div> - -<%= link_to 'Back', tournaments_path %> |