forked from RaVbaker/tolk
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Moved search actions into their own controller and fixed display of s…
…earch results.
- Loading branch information
Craig Davey
committed
Apr 21, 2010
1 parent
2e1cd6d
commit cd7dc65
Showing
7 changed files
with
118 additions
and
38 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
module Tolk | ||
class SearchesController < Tolk::ApplicationController | ||
before_filter :find_locale | ||
|
||
def show | ||
@phrases = @locale.search_phrases(params[:q], params[:page]) | ||
end | ||
|
||
private | ||
|
||
def find_locale | ||
@locale = Tolk::Locale.find_by_name!(params[:locale]) | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
<% content_for :locale do %> | ||
<span class="locale"><%= @locale.language_name %></span> | ||
<% end %> | ||
|
||
<h3 class="search"> | ||
<% form_tag "/tolk/search", :method => :get do %> | ||
<%= hidden_field_tag :locale, @locale.name %> | ||
Search for an English phrase: | ||
<%= text_field_tag :q, params[:q] %> | ||
<%= submit_tag "Search", :name => nil %> | ||
<% end %> | ||
</h3> | ||
|
||
<div class="search_exits"> | ||
<%= link_to "Phrases missing translation", @locale %> | ||
| ||
<%= link_to "Completed translations", all_tolk_locale_path(@locale) %> | ||
</div> | ||
|
||
<div class="translations"> | ||
<% if @phrases.any? %> | ||
<% form_for @locale do |locale_form| %> | ||
<table class="translations"> | ||
<tr> | ||
<th class="translation"><%= @locale.language_name -%></th> | ||
<th class="key"><%= Tolk::Locale.primary_language_name -%></th> | ||
</tr> | ||
<% @phrases.each do |phrase| %> | ||
<% if translation = phrase.translations.find_by_locale_id(@locale.id) || Tolk::Translation.new(:locale => @locale, :phrase => phrase) %> | ||
<tr> | ||
<td class="translation"> | ||
<%= hidden_field_tag :"translations[][id]", translation.id, :id => "#{translation.object_id}_id" %> | ||
<%= hidden_field_tag :"translations[][phrase_id]", phrase.id, :id => "#{translation.object_id}_phrase_id" %> | ||
<%= hidden_field_tag :"translations[][locale_id]", translation.locale_id, :id => "#{translation.object_id}_locale_id" %> | ||
<%= text_area_tag :"translations[][text]", translation.text, :class => "locale", :id => "#{translation.object_id}_text", :onfocus => "$(this).up('tr').addClassName('active');", :onblur => "$(this).up('tr').removeClassName('active');" %> | ||
</td> | ||
<td class="phrase"> | ||
<% if params[:q].present? -%> | ||
<%= highlight(format_i18n_value(phrase.translations.primary.text), params[:q]) -%> | ||
<% else -%> | ||
<%= format_i18n_value(phrase.translations.primary.text) -%> | ||
<% end -%> | ||
<span class="key" title="<%= phrase.key %>"><%= truncate(phrase.key, :length => 100) %></span> | ||
</td> | ||
</tr> | ||
<% end %> | ||
<% end %> | ||
</table> | ||
<div class="table_submit"> | ||
<p><%= locale_form.submit "Save changes" %></p> | ||
</div> | ||
<% end %> | ||
<div class="paginate"> | ||
<%= will_paginate @phrases, :renderer => Tolk::LinkRenderer %> | ||
</div> | ||
<% else %> | ||
<p style="text-align: left">No search results.</p> | ||
<% end %> | ||
</div> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters