Add custom title to widgets
Fix pagination conflict with main_content and widgets
This commit is contained in:
parent
281cfa6518
commit
4ae8299949
|
@ -34,7 +34,7 @@ class PagesController < ApplicationController
|
|||
def index_from_link
|
||||
url = "/#{@item.path}"
|
||||
options = ''
|
||||
options << "?page=#{params[:page]}" unless params[:page].blank?
|
||||
options << "?page_main=#{params[:page_main]}" unless params[:page_main].blank?
|
||||
options << "#{options.blank? ? '?' : '&'}category_id=#{params[:category_id]}" unless params[:category_id].blank?
|
||||
options << "#{options.blank? ? '?' : '&'}tag_id=#{params[:tag_id]}" unless params[:tag_id].blank?
|
||||
redirect_to url + options
|
||||
|
|
|
@ -11,9 +11,27 @@ class PagePart
|
|||
field :public_r_tag_option, :default => nil
|
||||
field :widget_path
|
||||
|
||||
has_one :i18n_variable, :as => :language_value, :autosave => true, :dependent => :destroy
|
||||
has_one :i18n_variable, :class_name => "I18nVariable", :as => :language_value, :autosave => true, :dependent => :destroy
|
||||
has_one :title, :class_name => "I18nVariable", :as => :language_value, :autosave => true, :dependent => :destroy
|
||||
|
||||
belongs_to :page
|
||||
belongs_to :module_app
|
||||
|
||||
before_save :set_key
|
||||
|
||||
def i18n_variable
|
||||
@i18n_variable ||= I18nVariable.first(:conditions => {:key => 'i18n_variable', :language_value_id => self.id, :language_value_type => self.class}) rescue nil
|
||||
end
|
||||
|
||||
def title
|
||||
@title ||= I18nVariable.first(:conditions => {:key => 'title', :language_value_id => self.id, :language_value_type => self.class}) rescue nil
|
||||
end
|
||||
|
||||
protected
|
||||
|
||||
def set_key
|
||||
title.key = 'title' if title && (title.key.blank? rescue true)
|
||||
i18n_variable.key = 'i18n_variable' if i18n_variable && (i18n_variable.key.blank? rescue true)
|
||||
end
|
||||
|
||||
end
|
|
@ -1,3 +1,14 @@
|
|||
<div>
|
||||
<%= f.fields_for :title, @part.title do |f| %>
|
||||
<% @site_valid_locales.each do |locale| %>
|
||||
<p>
|
||||
<%= f.label :locale, "#{t('admin.title')} #{I18nVariable.from_locale(locale)}" %>
|
||||
<%= f.text_field locale %>
|
||||
</p>
|
||||
<% end %>
|
||||
<% end %>
|
||||
</div>
|
||||
|
||||
<span id='module_app_list'>
|
||||
<%= f.select :module_app, options_from_collection_for_select(@module_apps, :id, :title, :selected => @module_app.id), {}, {:rel => admin_page_parts_path} %>
|
||||
</span>
|
||||
|
|
|
@ -167,10 +167,11 @@ module ParserCommon
|
|||
if (content["main"] == "true" && !page.module_app.nil?)
|
||||
ret << "<div id='appfrontend' class='dymanic_load' path='/panel/#{page.module_app.key}/front_end/#{page.app_frontend_url}"
|
||||
ret << "/#{params[:id]}" if params[:id] && !params[:id].eql?(page.id.to_s)
|
||||
ret << "?inner=true&page_id=#{page.id}&category_id=#{params[:category_id]}&tag_id=#{params[:tag_id]}&preview=#{params[:preview]}&page=#{params[:page]}"
|
||||
ret << "?inner=true&page_id=#{page.id}&category_id=#{params[:category_id]}&tag_id=#{params[:tag_id]}&preview=#{params[:preview]}&page_main=#{params[:page_main]}"
|
||||
ret << "'></div>"
|
||||
else
|
||||
part = page.page_parts.detect{ |p| p.name.to_s == content['name'].to_s } rescue nil
|
||||
part_title = part.title[I18n.locale] rescue nil
|
||||
if edit
|
||||
ret << "<div id='#{content['name']}' part_id='#{part.id}' class='editable' style='border:solid 1px; margin:5px; padding:5px;'>" if part
|
||||
ret << "<div class='edit_link' style='display:none'>"
|
||||
|
@ -182,7 +183,7 @@ module ParserCommon
|
|||
ret << part.i18n_variable[I18n.locale] rescue ''
|
||||
when 'module_widget'
|
||||
url = "/panel/#{part.module_app.key}/widget/#{part.widget_path}?inner=true"
|
||||
options = "&category_id=#{!part[:category].blank? ? part[:category].blank? : params[:category_id]}&tag_id=#{!part[:tag].blank? ? part[:tag] : params[:tag_id]}&page=#{params[:page]}"
|
||||
options = "&category_id=#{!part[:category].blank? ? part[:category].blank? : params[:category_id]}&tag_id=#{!part[:tag].blank? ? part[:tag] : params[:tag_id]}&page=#{params[:page]}&part_title=part_title"
|
||||
ret << "<div class='dymanic_load' path='#{url + options}'></div>"
|
||||
when 'public_r_tag'
|
||||
ret << "<r:#{part.public_r_tag} id='#{part.public_r_tag_object_id}'/>"
|
||||
|
|
|
@ -12,14 +12,14 @@ class Panel::Announcement::FrontEnd::BulletinsController < OrbitWidgetController
|
|||
|
||||
date_now = Time.now
|
||||
if !params[:category_id].blank?
|
||||
@bulletins = Bulletin.can_display.where(:bulletin_category_id => params[:category_id]).any_of( {deadline: nil,:postdate.lte => date_now} , {:deadline.gte => date_now,:postdate.lte => date_now} ).desc( :is_top, :postdate).page( params[:page]).per(10)
|
||||
@bulletins = Bulletin.can_display.where(:bulletin_category_id => params[:category_id]).any_of( {deadline: nil,:postdate.lte => date_now} , {:deadline.gte => date_now,:postdate.lte => date_now} ).desc( :is_top, :postdate).page( params[:page_main]).per(10)
|
||||
@current_category = BulletinCategory.from_id(params[:category_id]) rescue nil
|
||||
elsif !params[:tag_id].blank?
|
||||
@tag = AnnouncementTag.find(params[:tag_id]) rescue nil
|
||||
@tag = AnnouncementTag.where(key: params[:tag_id])[0] unless @tag
|
||||
@bulletins = @tag.bulletins.can_display.any_of( {deadline: nil,:postdate.lte => date_now} , {:deadline.gte => date_now,:postdate.lte => date_now} ).desc( :is_top, :postdate).page( params[:page]).per(10)
|
||||
@bulletins = @tag.bulletins.can_display.any_of( {deadline: nil,:postdate.lte => date_now} , {:deadline.gte => date_now,:postdate.lte => date_now} ).desc( :is_top, :postdate).page( params[:page_main]).per(10)
|
||||
else
|
||||
@bulletins = Bulletin.can_display.any_of( {deadline: nil,:postdate.lte => date_now} , {:deadline.gte => date_now,:postdate.lte => date_now} ).desc( :is_top, :postdate).page( params[:page]).per(10)
|
||||
@bulletins = Bulletin.can_display.any_of( {deadline: nil,:postdate.lte => date_now} , {:deadline.gte => date_now,:postdate.lte => date_now} ).desc( :is_top, :postdate).page( params[:page_main]).per(10)
|
||||
end
|
||||
|
||||
end
|
||||
|
|
|
@ -9,7 +9,7 @@ class Panel::Announcement::Widget::BulletinsController < OrbitWidgetController
|
|||
# GET /bulletins.xml
|
||||
|
||||
def index
|
||||
|
||||
@title = params[:page_title]
|
||||
date_now = Time.now
|
||||
if !params[:category_id].blank?
|
||||
@bulletins = Bulletin.can_display.where(:bulletin_category_id => params[:category_id]).any_of( {deadline: nil,:postdate.lte => date_now} , {:deadline.gte => date_now,:postdate.lte => date_now} ).desc( :is_top, :postdate).page( params[:page]).per(10)
|
||||
|
|
|
@ -29,5 +29,5 @@
|
|||
|
||||
</table>
|
||||
|
||||
<%= paginate @bulletins, :params => {:inner => 'false'} %>
|
||||
<%= paginate @bulletins, :param_name => :page_main, :params => {:inner => 'false'} %>
|
||||
|
||||
|
|
|
@ -1,9 +1,5 @@
|
|||
<% if @current_category %>
|
||||
<h1 class="h1"><%= @current_category.i18n_variable[I18n.locale] + t('announcement.bulletin.list_lower') %></h1>
|
||||
<% elsif @tag %>
|
||||
<h1 class="h1"><%= @tag[I18n.locale] + t('announcement.bulletin.list_lower') %></h1>
|
||||
<% else %>
|
||||
<h1 class="h1"><%= t('announcement.list_announcement') %></h1>
|
||||
<% if @title %>
|
||||
<h1 class="h1"><%= @title %></h1>
|
||||
<% end %>
|
||||
|
||||
|
||||
|
|
|
@ -11,13 +11,13 @@ class Panel::News::FrontEnd::NewsBulletinsController < OrbitWidgetController
|
|||
def index
|
||||
date_now = Time.now
|
||||
if !params[:category_id].blank?
|
||||
@news_bulletins = NewsBulletin.can_display.where(:news_bulletin_category_id => params[:category_id]).any_of( {deadline: nil,:postdate.lte => date_now} , {:deadline.gte => date_now,:postdate.lte => date_now} ).desc( :is_top, :postdate).page( params[:page]).per(10)
|
||||
@news_bulletins = NewsBulletin.can_display.where(:news_bulletin_category_id => params[:category_id]).any_of( {deadline: nil,:postdate.lte => date_now} , {:deadline.gte => date_now,:postdate.lte => date_now} ).desc( :is_top, :postdate).page( params[:page_main]).per(10)
|
||||
elsif !params[:tag_id].blank?
|
||||
tmp = NewsTag.find(params[:tag_id]) rescue nil
|
||||
tmp = NewsTag.where(key: params[:tag_id])[0] unless tmp
|
||||
@news_bulletins = tmp.news_bulletins.can_display.any_of( {deadline: nil,:postdate.lte => date_now} , {:deadline.gte => date_now,:postdate.lte => date_now} ).desc( :is_top, :postdate).page( params[:page]).per(10) rescue nil
|
||||
@news_bulletins = tmp.news_bulletins.can_display.any_of( {deadline: nil,:postdate.lte => date_now} , {:deadline.gte => date_now,:postdate.lte => date_now} ).desc( :is_top, :postdate).page( params[:page_main]).per(10) rescue nil
|
||||
else
|
||||
@news_bulletins = NewsBulletin.can_display.any_of( {deadline: nil,:postdate.lte => date_now} , {:deadline.gte => date_now,:postdate.lte => date_now} ).desc( :is_top, :postdate).page( params[:page]).per(10)
|
||||
@news_bulletins = NewsBulletin.can_display.any_of( {deadline: nil,:postdate.lte => date_now} , {:deadline.gte => date_now,:postdate.lte => date_now} ).desc( :is_top, :postdate).page( params[:page_main]).per(10)
|
||||
end
|
||||
|
||||
get_categorys
|
||||
|
|
|
@ -9,6 +9,7 @@ class Panel::News::Widget::NewsBulletinsController < OrbitWidgetController
|
|||
# GET /news_bulletins.xml
|
||||
|
||||
def index
|
||||
@title = params[:page_title]
|
||||
date_now = Time.now
|
||||
if !params[:category_id].blank?
|
||||
@news_bulletins = NewsBulletin.can_display.where(:news_bulletin_category_id => params[:category_id]).any_of( {deadline: nil,:postdate.lte => date_now} , {:deadline.gte => date_now,:postdate.lte => date_now} ).desc( :is_top, :postdate).page( params[:page]).per(5)
|
||||
|
|
|
@ -28,5 +28,5 @@
|
|||
</tbody>
|
||||
</table>
|
||||
|
||||
<%= paginate @news_bulletins, :params => {:inner => 'false'} %>
|
||||
<%= paginate @news_bulletins, :param_name => :page_main, :params => {:inner => 'false'} %>
|
||||
|
||||
|
|
|
@ -1,13 +1,7 @@
|
|||
<% # encoding: utf-8 %>
|
||||
|
||||
<%= flash_messages %>
|
||||
|
||||
<% if @current_category %>
|
||||
<h1 class="h1"><%= @current_category.i18n_variable[I18n.locale] + t('news.news_bulletin.list_lower') %></h1>
|
||||
<% elsif @tag %>
|
||||
<h1 class="h1"><%= @tag[I18n.locale] + t('news.news_bulletin.list_lower') %></h1>
|
||||
<% else %>
|
||||
<h1 class="h1"><%= t('news.list_news') %></h1>
|
||||
<% if @title %>
|
||||
<h1 class="h1"><%= @title %></h1>
|
||||
<% end %>
|
||||
|
||||
<table class="table table-bordered">
|
||||
|
|
|
@ -25,6 +25,7 @@ class Panel::WebResource::Widget::WebLinksController < OrbitWidgetController
|
|||
|
||||
|
||||
def home_list
|
||||
@title = params[:page_title]
|
||||
|
||||
# deadline
|
||||
|
||||
|
|
|
@ -1,5 +1,7 @@
|
|||
<div class="quicklinks">
|
||||
<h3 class="link_title"><%= t("announcement.related_links") %></h3>
|
||||
<% if @title %>
|
||||
<h3 class="link_title"><%= @title %></h3>
|
||||
<% end %>
|
||||
|
||||
<div id='web_links_links'>
|
||||
<%= render 'web_links' %>
|
||||
|
|
Loading…
Reference in New Issue