From cba4c47e7cca06434742fc5fd282c40973c546d1 Mon Sep 17 00:00:00 2001 From: tkimia Date: Wed, 23 Apr 2014 20:26:37 -0400 Subject: started with advanced search --- app/assets/stylesheets/custom.css.scss | 13 +++++++++++++ app/assets/stylesheets/scaffolds.css.scss | 2 +- app/controllers/search_controller.rb | 19 +++++++++++++++++-- app/views/common/_show_user.html.erb | 4 ++-- app/views/search/go.html.erb | 16 ++++++++++++++-- app/views/tournaments/new.html.erb | 2 +- 6 files changed, 48 insertions(+), 8 deletions(-) diff --git a/app/assets/stylesheets/custom.css.scss b/app/assets/stylesheets/custom.css.scss index d299dda..4104235 100644 --- a/app/assets/stylesheets/custom.css.scss +++ b/app/assets/stylesheets/custom.css.scss @@ -1,5 +1,11 @@ @import "bootstrap"; +$page-color: #444; +$toolbar-color: black; +$orange: #DD9125; +$darker-orange: #9D4102; +$link-yellow: #FFC50D; + header > nav { @extend .navbar; @extend .navbar-inverse; @@ -41,6 +47,13 @@ input[type="text"], input[type="password"]{ margin: 0 0 5px 0; } +select { + background-color: #333; + padding: 5px; + border: none; + color: #DD9125 !important; +} + p.errors { background-color: rgba(0,0,0,0.5);; color: red; diff --git a/app/assets/stylesheets/scaffolds.css.scss b/app/assets/stylesheets/scaffolds.css.scss index e8fe9c5..eb1f751 100644 --- a/app/assets/stylesheets/scaffolds.css.scss +++ b/app/assets/stylesheets/scaffolds.css.scss @@ -19,7 +19,7 @@ body { height: 100%; } -h1, h2, h3, h4, h5, p, li{ +h1, h2, h3, h4, h5, p, li, label{ color: $orange; } diff --git a/app/controllers/search_controller.rb b/app/controllers/search_controller.rb index 51aee9e..d312623 100644 --- a/app/controllers/search_controller.rb +++ b/app/controllers/search_controller.rb @@ -1,13 +1,28 @@ class SearchController < ApplicationController def go + stringMade = false; + @games = Game.all @query = params[:query] + @gametype = params[:game_type] - if (@query.nil?) then + if ( @gametype.nil? and (@query.nil? or @query.empty?)) then return end - @tournaments = Tournament.where("name LIKE '%#{@query}%'") + qstring = "" + if (!@query.empty?) + qstring += "name LIKE '%#{@query}%'" + stringMade = true + end + if (!@gametype.nil? and !@gametype.empty?) + if (stringMade) + qstring += " AND " + end + qstring += "game_id=#{@gametype}" + end + + @tournaments = Tournament.where(qstring) @players = User.where("name LIKE '%#{@query}%'") end diff --git a/app/views/common/_show_user.html.erb b/app/views/common/_show_user.html.erb index 70f1ca4..dd136a0 100644 --- a/app/views/common/_show_user.html.erb +++ b/app/views/common/_show_user.html.erb @@ -1,8 +1,8 @@
-
<%= image_tag ('http://www.gravatar.com/avatar/' + Digest::MD5.hexdigest(target.email) + '?s=100&d=mm') %>
+
<%= image_tag ('http://www.gravatar.com/avatar/' + Digest::MD5.hexdigest(target.email) + '?s=100&d=mm') %>
-
+
<%# "header" %> <%= link_to(target) do %>

<%= target.user_name %>

<% end %> diff --git a/app/views/search/go.html.erb b/app/views/search/go.html.erb index d2bf8f3..ea2dabf 100644 --- a/app/views/search/go.html.erb +++ b/app/views/search/go.html.erb @@ -4,12 +4,24 @@
Advanced Search [hide]
-

This is where the advancedsearch will go.

+ <%= form_tag("/search", method: "get") do %> +
+ <%= label_tag :query, 'Find:' %> + <%= text_field_tag(:query, params[:query]) %> +
+
+ <%= label_tag :game_type, 'Game Type:' %> + <%= select_tag(:game_type, options_from_collection_for_select(@games, 'id', 'name'), :prompt => 'All Games') %> +
+
+ <%= submit_tag("Search", :name=>nil) %> +
+ <% end %>
<%# Show search results if a query was not nill %> -<% if !@query.empty? %> +<% if !@query.nil? and !@query.empty? %> <% if @tournaments.empty? and @players.empty? %>

No results found for "<%= @query %>"

diff --git a/app/views/tournaments/new.html.erb b/app/views/tournaments/new.html.erb index 8c74068..c2b9904 100644 --- a/app/views/tournaments/new.html.erb +++ b/app/views/tournaments/new.html.erb @@ -4,7 +4,7 @@ <%= select_tag('game', options_from_collection_for_select(@games, 'id', 'name', @tournament.game.nil? || @tournament.game.id), :prompt => "Select a Game Type") %> - <%= submit_tag("Select", :class => "btn btn-success btn-xs") %> + <%= submit_tag("Select", :class => "btn") %> <% end %>
-- cgit v1.1-4-g5e80