themen scope+ fix search
This commit is contained in:
@@ -23,9 +23,9 @@ class ThemengruppenController < ApplicationController
|
|||||||
def show
|
def show
|
||||||
@themengruppe = Themengruppe.find(params[:id])
|
@themengruppe = Themengruppe.find(params[:id])
|
||||||
if can? :showdraft , Thema
|
if can? :showdraft , Thema
|
||||||
@themen = @themengruppe.themen.order(:priority).reverse
|
@themen = @themengruppe.themen
|
||||||
else
|
else
|
||||||
@themen = @themengruppe.themen.where(:isdraft=>false).order(:priority).reverse
|
@themen = @themengruppe.themen.public
|
||||||
end
|
end
|
||||||
@toolbar_elements = []
|
@toolbar_elements = []
|
||||||
@toolbar_elements << {:icon=>:pencil, :hicon=>'icon-pencil', :text=>I18n.t("themengruppe.manage"), :path=>themengruppe_verwalten_path(@themengruppe)} if can? :edit, @themengruppe
|
@toolbar_elements << {:icon=>:pencil, :hicon=>'icon-pencil', :text=>I18n.t("themengruppe.manage"), :path=>themengruppe_verwalten_path(@themengruppe)} if can? :edit, @themengruppe
|
||||||
|
|||||||
@@ -21,7 +21,8 @@ include Rails.application.routes.url_helpers
|
|||||||
validates :themengruppe, :presence => true
|
validates :themengruppe, :presence => true
|
||||||
validates :title, :presence => true
|
validates :title, :presence => true
|
||||||
validates :text, :presence => true
|
validates :text, :presence => true
|
||||||
|
scope :public, where(:isdraft=>false)
|
||||||
|
default_scope order(:priority).reverse_order
|
||||||
scope :search, ->(query) {where("text like ? or title like ?", "%#{query}%", "%#{query}%")}
|
scope :search, ->(query) {where("text like ? or title like ?", "%#{query}%", "%#{query}%")}
|
||||||
scope :outdated, -> {includes(:translations).where("thema_translations.updated_at<?",2.month.ago).where("thema_translations.locale"=>I18n.t.locale)
|
scope :outdated, -> {includes(:translations).where("thema_translations.updated_at<?",2.month.ago).where("thema_translations.locale"=>I18n.t.locale)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,17 +1,20 @@
|
|||||||
<div class="content-wrap content-column">
|
<div class="content-wrap content-column">
|
||||||
|
<p>
|
||||||
<%= semantic_form_for :search,:remote=>true, :url=>search_home_index_path, :html=>{:id=>"search_form",:class=>"navbar-search", :method=>'get'} do |f| %>
|
<%= semantic_form_for :search,:remote=>true, :url=>search_home_index_path, :html=>{:id=>"search_form",:class=>"navbar-search", :method=>'get'} do |f| %>
|
||||||
<%= f.input :query, :input_html => { :name => 'query' } , :label=>false, :class=>"search-query" %>
|
<%= f.input :query, :input_html => { :name => 'query' } , :label=>false, :class=>"search-query" %>
|
||||||
|
<%= f.actions do %>
|
||||||
|
<%= f.action :submit, :as => :input %>
|
||||||
<% end %>
|
<% end %>
|
||||||
<script>
|
|
||||||
$( document ).ready(function() {
|
<% end %>
|
||||||
$("#search_query").bind("keyup", function(event){
|
|
||||||
$("#search_form").submit();
|
</p>
|
||||||
});
|
<p>
|
||||||
$("#search_query").value="df"
|
|
||||||
});
|
|
||||||
</script>
|
|
||||||
<div id="searchresults">
|
<div id="searchresults">
|
||||||
<%= render :partial=>"home/search_results" %>
|
<%= render :partial=>"home/search_results" %>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|
||||||
|
</p>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -34,8 +34,9 @@
|
|||||||
|
|
||||||
<div class="span6">
|
<div class="span6">
|
||||||
<!--<b><%= I18n.t("themengruppe.themen") %></b>
|
<!--<b><%= I18n.t("themengruppe.themen") %></b>
|
||||||
--><ul>
|
-->
|
||||||
<% themengruppe.themen.where(" (NOT hidelink) and ( NOT isdraft) ").order(:priority).reverse.each do |t| %>
|
<ul>
|
||||||
|
<% themengruppe.themen.where(:hidelink=>false).where(:isdraft=>false).each do |t| %>
|
||||||
<li>
|
<li>
|
||||||
<%= render t %>
|
<%= render t %>
|
||||||
</li>
|
</li>
|
||||||
|
|||||||
Reference in New Issue
Block a user