link to more

This commit is contained in:
Fu Matthew 2013-02-23 18:29:50 +08:00
parent 73bca03b33
commit 0be1c45c81
12 changed files with 46 additions and 27 deletions

View File

@ -46,11 +46,7 @@
<%= render :partial => 'widget_setting' ,:locals=>{:f=>f,:object=>@part} %> <%= render :partial => 'widget_setting' ,:locals=>{:f=>f,:object=>@part} %>
</div> </div>
<div class="control-group"> <div class="control-group" id='data_count'>
<label for="page_part[widget_data_count]" class="control-label"> <%= render :partial=>'admin/pages/data_count_field',:locals=>{:field_name=>"page_part[widget_data_count]",:field_value=>@part.widget_data_count } %>
<%= t("default_widget.widget_data_count") %>
</label>
<div class="controls">
<%= text_field_tag "page_part[widget_data_count]",@part.widget_data_count %>
</div>
</div> </div>

View File

@ -2,7 +2,7 @@
$('#widget_list select').html("<%= j options_for_select(@module_app.widgets.collect{|k,v| [I18n.t(v['i18n']),k]},@part.widget_path) %>"); $('#widget_list select').html("<%= j options_for_select(@module_app.widgets.collect{|k,v| [I18n.t(v['i18n']),k]},@part.widget_path) %>");
$("#widget_data_source_category").html("<%= j render :partial => 'widget_data_source_category',:locals=>{:object=>@part} %>"); $("#widget_data_source_category").html("<%= j render :partial => 'widget_data_source_category',:locals=>{:object=>@part} %>");
$("#widget_data_source_tag").html("<%= j render :partial => 'widget_data_source_tag',:locals=>{:object=>@part} %>"); $("#widget_data_source_tag").html("<%= j render :partial => 'widget_data_source_tag',:locals=>{:object=>@part} %>");
$("#data_count").html("<%= j render :partial => 'admin/pages/data_count_field',:locals=>{:field_name=>'page_part[widget_data_count]',:field_value=>@part.widget_data_count } %>");
<% if @part %> <% if @part %>
<% if show_default_widget_setting_panel %> <% if show_default_widget_setting_panel %>
$('#widget_setting').html("<%= j render :partial => 'default_widget_style_panel' %>"); $('#widget_setting').html("<%= j render :partial => 'default_widget_style_panel' %>");

View File

@ -66,16 +66,10 @@
<%= render :partial => 'frontend_setting', :locals=>{:object=>@item,:f=>f} %> <%= render :partial => 'frontend_setting', :locals=>{:object=>@item,:f=>f} %>
</div> </div>
<div class="control-group"> <div class="control-group" id='data_count'>
<label for="page[widget_data_count]" class="control-label"> <%= render :partial=>'data_count_field',:locals=>{:field_name=>"page[frontend_data_count]",:field_value=>@item.frontend_data_count} %>
<%= t("default_widget.widget_data_count") %>
</label>
<div class="controls">
<%= text_field_tag "page[frontend_data_count]",@item.frontend_data_count %>
</div>
</div> </div>
<div class="control-group"> <div class="control-group">
<%= f.label :is_published, "#{t('front_page.is_published')} ?", :class => 'control-label' %> <%= f.label :is_published, "#{t('front_page.is_published')} ?", :class => 'control-label' %>
<div class="controls"> <div class="controls">

View File

@ -1,6 +1,7 @@
<% if @module_app %> <% if @module_app %>
$('#app_page_category').html("<%= j render :partial => 'admin/page_parts/widget_data_source_category' ,:locals=>{:object=>@page}%>"); $('#app_page_category').html("<%= j render :partial => 'admin/page_parts/widget_data_source_category' ,:locals=>{:object=>@page}%>");
$('#app_page_tag').html("<%= j render :partial => 'admin/page_parts/widget_data_source_tag',:locals=>{:object=>@page} %>"); $('#app_page_tag').html("<%= j render :partial => 'admin/page_parts/widget_data_source_tag',:locals=>{:object=>@page} %>");
$("#data_count").html("<%= j render :partial => 'admin/pages/data_count_field',:locals=>{:field_name=>'page[frontend_data_count]',:field_value=>@page.frontend_data_count} %>");
<% if !@module_app.app_pages.blank? %> <% if !@module_app.app_pages.blank? %>
$('#app_page_url').html("<%= escape_javascript(select 'page', 'app_frontend_url', options_for_select(@app_frontend_urls, @app_frontend_urls.first)) %>"); $('#app_page_url').html("<%= escape_javascript(select 'page', 'app_frontend_url', options_for_select(@app_frontend_urls, @app_frontend_urls.first)) %>");

View File

@ -13,5 +13,4 @@
<% end %> <% end %>
<% end %> <% end %>
</ul> </ul>
<div class="more">more</div>
<% end %> <% end %>

View File

@ -11,5 +11,4 @@
<% end %> <% end %>
<% end %> <% end %>
</ul> </ul>
<div class="more">more</div>
<% end %> <% end %>

View File

@ -2,3 +2,6 @@
<% if @paginate %> <% if @paginate %>
<%= paginate @data, :param_name => :page_main, :params => {:same_page_id => @page_id} %> <%= paginate @data, :param_name => :page_main, :params => {:same_page_id => @page_id} %>
<% end %> <% end %>
<% if @page_part.module_app %>
<%= @page_part.module_app.get_registration.default_widget_setting.link_to_more_tag(request,params) %>
<% end %>

View File

@ -3,6 +3,7 @@ require "orbit_app/dsl"
require "orbit_app/helper/renderer" require "orbit_app/helper/renderer"
require "orbit_app/helper/side_bar_renderer" require "orbit_app/helper/side_bar_renderer"
require "orbit_app/helper/context_link_renderer" require "orbit_app/helper/context_link_renderer"
require "orbit_app/helper/default_widget_tag_helper"
require "orbit_app/module/side_bar" require "orbit_app/module/side_bar"
require "orbit_app/module/widget" require "orbit_app/module/widget"
require "orbit_app/module/front_end" require "orbit_app/module/front_end"

View File

@ -28,7 +28,7 @@ module OrbitApp
end end
class DataSheet class DataSheet
attr_reader :name,:key,:base_path,:module_label attr_reader :name,:key,:base_path,:module_label,:data_count
def initialize(name, &block) def initialize(name, &block)
@name = name @name = name
@ -36,6 +36,7 @@ module OrbitApp
@side_bar = nil @side_bar = nil
@front_end_app_pages = nil @front_end_app_pages = nil
@module_label = 'rulingcom.errors.init.module_app_noname' @module_label = 'rulingcom.errors.init.module_app_noname'
@data_count = 1..3 # as default
block.arity < 1 ? instance_eval(&block) : block.call(self) if block_given? block.arity < 1 ? instance_eval(&block) : block.call(self) if block_given?
setup_module_app setup_module_app
end end
@ -86,6 +87,10 @@ module OrbitApp
@front_end_app_pages.nil? ? [] : @front_end_app_pages.to_module_app_format @front_end_app_pages.nil? ? [] : @front_end_app_pages.to_module_app_format
end end
def get_data_count
@data_count
end
def get_widget_by_path(path) def get_widget_by_path(path)
if @widget_set if @widget_set
@widget_set.find_by_path(path) @widget_set.find_by_path(path)
@ -94,6 +99,14 @@ module OrbitApp
end end
end end
def default_widget_setting
@widget_set.default_widget_setting
end
def widget_setting
@widget_set
end
def get_widgets def get_widgets
@widget_set.nil? ? {} : @widget_set.to_module_app_format @widget_set.nil? ? {} : @widget_set.to_module_app_format
end end
@ -127,7 +140,7 @@ module OrbitApp
# @default_widget = widget_set.default_widget # @default_widget = widget_set.default_widget
end end
%w{module_label category base_url version organization author intro update_info}.each do |field| %w{data_count module_label category base_url version organization author intro update_info}.each do |field|
define_method(field){|var| instance_variable_set( "@" + field, var)} define_method(field){|var| instance_variable_set( "@" + field, var)}
end end

View File

@ -34,6 +34,10 @@ module OrbitApp
define_method(field){|var| instance_variable_set( "@" + field, var)} define_method(field){|var| instance_variable_set( "@" + field, var)}
end end
# def data_count(var)
# @data_count = var
# end
def find_by_path(path) def find_by_path(path)
@widgets.each do |widget| @widgets.each do |widget|
return widget if widget.name == path return widget if widget.name == path
@ -48,6 +52,10 @@ module OrbitApp
eval(@tags_query) rescue nil eval(@tags_query) rescue nil
end end
def default_widget_setting
@default_widget
end
def default_widget(&block) def default_widget(&block)
@default_widget = DefaultWidget.new(&block) @default_widget = DefaultWidget.new(&block)
end end
@ -85,6 +93,7 @@ module OrbitApp
end end
class DefaultWidget class DefaultWidget
include DefaultWidgetTagHelper
STYLE = ["typeA","typeB_style2","typeB_style3","typeB_style4","typeC"] STYLE = ["typeA","typeB_style2","typeB_style3","typeB_style4","typeC"]
def initialize(&block) def initialize(&block)
@ -95,9 +104,10 @@ module OrbitApp
block.arity < 1 ? instance_eval(&block) : block.call(self) if block_given? block.arity < 1 ? instance_eval(&block) : block.call(self) if block_given?
end end
def more_link_to(label_i18n,path_method)
@more_link[:label_i18n] = label_i18n def link_to_more(*args)
@more_link[:path_method] = path_method @more_link[:label_i18n] = (args[1] ? args[1][:title_i18n] : 'default_widget.default_link_to_more' )
@more_link[:path_method] = args[0]
end end
def self.get_interface_args def self.get_interface_args
@ -106,7 +116,7 @@ module OrbitApp
end end
def to_module_app_format def to_module_app_format
{"query"=>@query,"image"=>@image} rescue nil {"query"=>@query,"image"=>@image,"more_link"=>@more_link} rescue nil
end end
def link_field(field_name,setting) def link_field(field_name,setting)

View File

@ -27,6 +27,7 @@ zh_tw:
approval_setting: 審核權限 approval_setting: 審核權限
tags: 標籤 tags: 標籤
default_widget: default_widget:
to_more: 更多
bulletin_category_with_title: 分類 bulletin_category_with_title: 分類
title: 標題 title: 標題
postdate: 張貼日期 postdate: 張貼日期

View File

@ -18,6 +18,7 @@ module Announcement
end end
category ["BulletinCategory"] category ["BulletinCategory"]
data_count 3..10
widgets do widgets do
default_widget do default_widget do
@ -26,6 +27,7 @@ module Announcement
field :postdate field :postdate
link_field :title,{:method => 'panel_announcement_front_end_bulletin_path',:args=>:self} link_field :title,{:method => 'panel_announcement_front_end_bulletin_path',:args=>:self}
link_field :bulletin_category_with_title,{:method => 'panel_announcement_front_end_bulletins_path',:args=>{:category_id => [:bulletin_category,:id]}} link_field :bulletin_category_with_title,{:method => 'panel_announcement_front_end_bulletins_path',:args=>{:category_id => [:bulletin_category,:id]}}
link_to_more 'panel_announcement_front_end_bulletins_path',:title_i18n=> 'announcement.default_widget.to_more'
end end
categories_query 'BulletinCategory.all' categories_query 'BulletinCategory.all'