Merge branch 'desktop' of https://github.com/Rulingcom/orbit into desktop
* 'desktop' of https://github.com/Rulingcom/orbit: fix widget field reload link to more fix default widget link fixed Widget data count should be available for other widgets, not only for default widget. The availability of this option must be set in the init fix javascript disable checkbox failed after cate and tags being reloaded. first version of multi categories and tags fix widget field reload link to more fix default widget link fixed Widget data count should be available for other widgets, not only for default widget. The availability of this option must be set in the init fix javascript disable checkbox failed after cate and tags being reloaded. first version of multi categories and tags
This commit is contained in:
commit
ee4b94ace0
|
@ -0,0 +1,21 @@
|
|||
function update_cates_and_tags()
|
||||
{
|
||||
$('.select_option,.select_all').removeAttr('disabled');
|
||||
$(".select_all:checked").each(function( obj ) {
|
||||
$(this).parent().siblings('label').find('.select_option').attr('disabled',true);
|
||||
$(this).parent().siblings('label').find('.select_option').removeAttr('checked');
|
||||
});
|
||||
$(".select_option:checked").each(function( obj ) {
|
||||
$(this).parent().siblings('label').find('.select_all').attr('disabled',true);
|
||||
$(this).parent().siblings('label').find('.select_all').removeAttr('checked');
|
||||
});
|
||||
}
|
||||
|
||||
function rebind(){
|
||||
$("#widget_data_source_category,#widget_data_source_tag,#app_page_category,#app_page_tag").find('input').change(function(){update_cates_and_tags()});
|
||||
}
|
||||
|
||||
$(document).ready(function(){
|
||||
update_cates_and_tags();
|
||||
rebind();
|
||||
});
|
|
@ -43,7 +43,7 @@ $("#tag_list select").live('change', function() {
|
|||
});
|
||||
|
||||
$("select.widget_field_select").live('change', function() {
|
||||
$.getScript(get_object_path() + '/reload_after_widget_field_changed?widget_field_value='+ $(this).val()+'&dom_id=' + $(this).attr("id") + '&field_seri=' +$(this).attr('field_seri'));
|
||||
$.getScript(get_object_path() + '/reload_after_widget_field_changed?widget_field_value='+ $(this).val()+'&dom_id=' + $(this).attr("id") + '&field_seri=' +$(this).attr('field_seri')+ '&module_app_id=' +$("#page_module_app_id,page_part_module_app_id").val());
|
||||
});
|
||||
|
||||
$('.part_kind').live('click', function() {
|
||||
|
|
|
@ -54,6 +54,7 @@ class Admin::PagePartsController < ApplicationController
|
|||
end
|
||||
|
||||
def update
|
||||
|
||||
@part = PagePart.find(params[:id])
|
||||
params[:page_part][:widget_field] = params[:page_part][:widget_field].zip( params[:page_part][:widget_field_type],params[:page_part][:widget_field_is_link] ) if params[:page_part][:widget_field]
|
||||
|
||||
|
@ -63,6 +64,17 @@ class Admin::PagePartsController < ApplicationController
|
|||
if params[:page_part][:module_app].blank?
|
||||
params[:page_part][:module_app] = nil
|
||||
end
|
||||
|
||||
if params[:page_part][:tag].include?("nil")
|
||||
params[:page_part][:tag] = []
|
||||
end
|
||||
|
||||
if params[:page_part][:category].include?("nil")
|
||||
params[:page_part][:category] = []
|
||||
end
|
||||
|
||||
params[:page_part][:widget_field].each{|t| t[2] = (t[2]=="true" ? true : false )}
|
||||
|
||||
if @part.update_attributes(params[:page_part])
|
||||
set_children_sub_menu(@part) if @part.public_r_tag && @part.public_r_tag.eql?('sub_menu')
|
||||
flash.now[:notice] = t('update.success.content')
|
||||
|
@ -96,6 +108,7 @@ class Admin::PagePartsController < ApplicationController
|
|||
@part = PagePart.find params[:id]
|
||||
@choosen_field = params[:widget_field_value]
|
||||
@module_app = @part.module_app
|
||||
@module_app = ModuleApp.find params[:module_app_id] if @module_app.nil?
|
||||
end
|
||||
|
||||
def reload_widgets
|
||||
|
|
|
@ -96,6 +96,14 @@ helper Admin::PagePartsHelper
|
|||
params[:page][:frontend_field] = params[:page][:frontend_field].zip( params[:page][:frontend_field_type] ) if params[:page][:frontend_field]
|
||||
params[:page][:frontend_field_type] = nil
|
||||
|
||||
if params[:page][:tag].include?("nil")
|
||||
params[:page][:tag] = []
|
||||
end
|
||||
|
||||
if params[:page][:category].include?("nil")
|
||||
params[:page][:category] = []
|
||||
end
|
||||
|
||||
if @item.update_attributes(params[:page])
|
||||
flash[:notice] = t('update.success.page')
|
||||
respond_to do |format|
|
||||
|
@ -172,4 +180,12 @@ helper Admin::PagePartsHelper
|
|||
end
|
||||
end
|
||||
|
||||
def reload_widget_field
|
||||
@index = params[:field_seri].to_i
|
||||
@page = Page.find params[:id]
|
||||
@choosen_field = params[:widget_field_value]
|
||||
@module_app = @page.module_app
|
||||
@module_app = ModuleApp.find params[:module_app_id] if @module_app.nil?
|
||||
end
|
||||
|
||||
end
|
||||
|
|
|
@ -10,12 +10,33 @@ class DefaultWidgetController< OrbitWidgetController
|
|||
@page_part.module_app.enable_frontend?
|
||||
end
|
||||
|
||||
def query_for_default_widget
|
||||
ori_class_name = @default_widget["query"].split('.')[0]
|
||||
result = nil
|
||||
result_objects = nil
|
||||
if !params["tag_id"].blank?
|
||||
@tags = Tag.find(params["tag_id"]) rescue nil
|
||||
result_ids = nil
|
||||
if params["category_id"].blank?
|
||||
result_ids = @tags.collect{|tag| tag.send(ori_class_name.downcase.pluralize).entries.collect{|t| t.id}}.flatten
|
||||
else
|
||||
result_ids = @tags.collect{|tag| tag.send(ori_class_name.downcase.pluralize).where(:category_id=>params["category_id"]).available_for_lang(I18n.locale).can_display.collect{|t| t.id}}.flatten
|
||||
end
|
||||
result = eval("#{ori_class_name}.where(:id=>result_ids)")
|
||||
elsif params["category_id"].blank?
|
||||
result = eval(@default_widget["query"])
|
||||
else
|
||||
result = eval("#{ori_class_name}.where(:category_id=>params['category_id'])")
|
||||
end
|
||||
result.available_for_lang(I18n.locale).can_display
|
||||
end
|
||||
|
||||
def default_widget
|
||||
|
||||
if !params[:id].blank?
|
||||
redirect_to eval("#{@page_part.module_app.widget_fields_link_method['title']['method']}('#{params[:id]}', {inner: #{params[:inner] || true}})")
|
||||
else
|
||||
@tag_class = nil
|
||||
|
||||
@default_widget = @page_part.module_app.get_default_widget
|
||||
@widget_image_field = @default_widget["image"] || @default_widget[:image]
|
||||
case @page_part
|
||||
|
@ -29,9 +50,11 @@ class DefaultWidgetController< OrbitWidgetController
|
|||
@data_limit = @page_part.widget_data_count.is_a?(Fixnum) ? @page_part.widget_data_count : (@page_part.widget_data_count.to_i rescue 3)
|
||||
end
|
||||
if @paginate
|
||||
@data = eval(@default_widget["query"]).includes(@widget_image_field).page(params[:page_main]).per(@data_limit).desc(:created_at)
|
||||
@data = query_for_default_widget.includes(@widget_image_field).page(params[:page_main]).per(@data_limit)
|
||||
# @data = query_for_default_widget.limit(@data_limit).includes(@widget_image_field)
|
||||
else
|
||||
@data = eval(@default_widget["query"]).limit(@data_limit).includes(@widget_image_field).desc(:created_at)
|
||||
@data = eval(@default_widget["query"]).includes(@widget_image_field).page(params[:page_main]).per(@data_limit).desc(:created_at)
|
||||
# @data = eval(@default_widget["query"]).limit(@data_limit).includes(@widget_image_field).desc(:created_at)
|
||||
end
|
||||
case params[:type]
|
||||
when "typeA"
|
||||
|
|
|
@ -21,11 +21,10 @@ module Admin::PagePartsHelper
|
|||
end
|
||||
end
|
||||
|
||||
def field_link_switch(i,object_name,field_name,local_item=nil,prefill_value=nil)
|
||||
def link_to_field_switch(i,object_name,field_name,local_item=nil,prefill_value=nil) #link_to_field is for showing
|
||||
local_item = @part if local_item.nil? && @part
|
||||
local_item = @page if local_item.nil? && @page
|
||||
res = ''
|
||||
|
||||
choosen_value = prefill_value || (local_item[:widget_field][i][0] rescue nil)
|
||||
|
||||
if choosen_value
|
||||
|
@ -38,13 +37,13 @@ module Admin::PagePartsHelper
|
|||
if choosen_field_is_link
|
||||
value = case local_item
|
||||
when Page
|
||||
local_item[:frontend_field][i][2]
|
||||
local_item[:frontend_field][i][2] rescue false
|
||||
when PagePart
|
||||
local_item[:widget_field][i][2]
|
||||
local_item[:widget_field][i][2] rescue false
|
||||
end
|
||||
|
||||
|
||||
res = label_tag '' do
|
||||
check_box_tag("#{object_name}[#{field_name}_is_link][]", value = "true", value) + I18n.t("default_widget.field_is_link")
|
||||
check_box_tag("#{object_name}[#{field_name}_is_link][]", "true", value) + I18n.t("default_widget.field_is_link")
|
||||
end
|
||||
else # choosen_field_not_link
|
||||
res = hidden_field_tag "#{object_name}[#{field_name}_is_link][]", 'false'
|
||||
|
@ -84,17 +83,17 @@ module Admin::PagePartsHelper
|
|||
|
||||
def tag_checked_value(part,radio_value)
|
||||
if radio_value.blank?
|
||||
(part.nil? || part[:tag].blank?)? true : false
|
||||
(part.nil? || part[:tag].blank?) ? true : false
|
||||
else
|
||||
part and (part[:tag] == radio_value.to_s) ? true : false
|
||||
part and (part[:tag].include?(radio_value.to_s)) ? true : false
|
||||
end
|
||||
end
|
||||
|
||||
def category_checked_value(part,radio_value)
|
||||
if radio_value.blank?
|
||||
(part.nil? || part[:category].blank?)? true : false
|
||||
(part.nil? || part[:category].blank?) ? true : false
|
||||
else
|
||||
part and (part[:category] == radio_value.to_s) ? true : false
|
||||
part and (part[:category].include?(radio_value.to_s)) ? true : false
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -117,6 +116,19 @@ module Admin::PagePartsHelper
|
|||
end
|
||||
end
|
||||
|
||||
def nil_checkbox_button(part,tag_or_cate)
|
||||
field_name = case part
|
||||
when PagePart
|
||||
'page_part'
|
||||
when Page
|
||||
'page'
|
||||
end
|
||||
content_tag :label,:class=>"radio inline" do
|
||||
op = check_box_tag("#{field_name}[#{tag_or_cate}][]", 'nil' , eval("#{tag_or_cate}_checked_value(part,'')"),:class=>'select_all')
|
||||
op << I18n.t("default_widget.no_value")
|
||||
end
|
||||
end
|
||||
|
||||
def nil_radio_button(part,tag_or_cate)
|
||||
field_name = case part
|
||||
when PagePart
|
||||
|
|
|
@ -6,7 +6,7 @@ module DefaultWidgetHelper
|
|||
def link_to_field(row_data,field, switch, options=nil)
|
||||
method_ary = @page_part.module_app.widget_fields_link_method
|
||||
field = field.to_sym
|
||||
if(method_ary.has_key?(field) and (switch == "true"))
|
||||
if(method_ary.has_key?(field) and (switch == true))
|
||||
url = case method_ary[field][:args]
|
||||
when nil # no args
|
||||
get_data_link(method_ary[field]["method"], options)
|
||||
|
@ -51,7 +51,7 @@ module DefaultWidgetHelper
|
|||
eval eval("#{method_entry}(#{options})")
|
||||
when BSON::ObjectId
|
||||
object = "'#{object.to_s}'"
|
||||
eval("#{method_entry}(#{{:id => object}.merge options})")
|
||||
eval("#{method_entry}(#{{:id => object}.merge options})")
|
||||
when Hash
|
||||
eval("#{method_entry}(#{object.merge options})")
|
||||
else
|
||||
|
|
|
@ -8,8 +8,8 @@ class Page < Item
|
|||
field :content, localize: true
|
||||
field :app_frontend_url
|
||||
field :theme_id, :type => BSON::ObjectId, :default => nil
|
||||
field :category, :default => ''
|
||||
field :tag, :default => ''
|
||||
field :category,type: Array, :default => []
|
||||
field :tag, type: Array,:default => []
|
||||
field :view_count, :type => Integer, :default => 0
|
||||
field :page_title, localize: true
|
||||
|
||||
|
|
|
@ -11,6 +11,8 @@ class PagePart
|
|||
field :public_r_tag_option, :default => nil
|
||||
field :page_title, localize: true
|
||||
field :widget_path
|
||||
field :category,type: Array, :default => []
|
||||
field :tag, type: Array,:default => []
|
||||
|
||||
field :widget_style
|
||||
field :widget_field , :type => Array
|
||||
|
|
|
@ -2,11 +2,9 @@
|
|||
<% when PagePart %>
|
||||
<% object_name = 'page_part' %>
|
||||
<% field_name = 'widget_field' %>
|
||||
<% data_count = 'widget_data_count' %>
|
||||
<% when Page %>
|
||||
<% object_name = 'page' %>
|
||||
<% field_name = 'frontend_field' %>
|
||||
<% data_count = 'frontend_data_count' %>
|
||||
<% end %>
|
||||
|
||||
<div class="style_switch control-group">
|
||||
|
@ -37,20 +35,9 @@
|
|||
<%= select_tag "#{object_name}[#{field_name}_type][]", widget_fiield_type_options(i), :include_blank => true %> <br />
|
||||
</span>
|
||||
<span class="span5 link_switch_holder">
|
||||
<%= field_link_switch(i,object_name,field_name) %>
|
||||
<%= link_to_field_switch(i,object_name,field_name) %>
|
||||
</span>
|
||||
</div><br/>
|
||||
<% end %>
|
||||
<br/>
|
||||
<div class="rows clear">
|
||||
<span class="span4">
|
||||
<%= label_tag t("default_widget.widget_data_count") %>
|
||||
</span>
|
||||
</div>
|
||||
<div class="rows clear">
|
||||
<span class="span4">
|
||||
<%= text_field_tag "#{object_name}[#{data_count}]",object.send(data_count) %>
|
||||
</span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
|
@ -19,3 +19,5 @@
|
|||
|
||||
</div>
|
||||
<% end %>
|
||||
|
||||
<%=javascript_include_tag "inc/update_cates_and_tags.js" %>
|
|
@ -45,3 +45,8 @@
|
|||
<div id="widget_setting">
|
||||
<%= render :partial => 'widget_setting' ,:locals=>{:f=>f,:object=>@part} %>
|
||||
</div>
|
||||
|
||||
<div class="control-group" id='data_count'>
|
||||
<%= render :partial=>'admin/pages/data_count_field',:locals=>{:field_name=>"page_part[widget_data_count]",:field_value=>@part.widget_data_count } %>
|
||||
</div>
|
||||
|
||||
|
|
|
@ -10,9 +10,9 @@
|
|||
<div class="well controls">
|
||||
<% if @categories %>
|
||||
<fieldset>
|
||||
<%= nil_radio_button(object,:category) %>
|
||||
<%= nil_checkbox_button(object,:category) %>
|
||||
<%= content_tag_for(:label, @categories,:class=>"radio inline") do |category|%>
|
||||
<%= radio_button_tag("#{field_name}[category]", category.id, category_checked_value(object,category.id) )%>
|
||||
<%= check_box_tag("#{field_name}[category][]", category.id, category_checked_value(object,category.id),:class=>'select_option' )%>
|
||||
<%= category.title%>
|
||||
<% end %>
|
||||
</fieldset>
|
||||
|
|
|
@ -10,9 +10,9 @@
|
|||
<div class="well controls">
|
||||
<% if @categories %>
|
||||
<fieldset>
|
||||
<%= nil_radio_button(object,:tag) %>
|
||||
<%= nil_checkbox_button(object,:tag) %>
|
||||
<%= content_tag_for(:label, @tags,:class=>"radio inline") do |tag|%>
|
||||
<%= radio_button_tag("#{field_name}[tag]", tag.id, tag_checked_value(object,tag.id) ) %>
|
||||
<%= check_box_tag("#{field_name}[tag][]", tag.id, tag_checked_value(object,tag.id),:class=>'select_option' ) %>
|
||||
<%= tag[I18n.locale]%>
|
||||
<% end if @tags%>
|
||||
</fieldset>
|
||||
|
|
|
@ -2,4 +2,8 @@
|
|||
<%= render 'admin/items/site_map_left_bar' %>
|
||||
<% end -%>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<%= render 'edit' %>
|
|
@ -1 +1 @@
|
|||
$("#<%= params[:dom_id] %>").parents(".rows").find(".link_switch_holder").html("<%= j field_link_switch(@index,'page_part','widget_field',nil,@choosen_field) %>");
|
||||
$("#<%= params[:dom_id] %>").parents(".rows").find(".link_switch_holder").html("<%= j link_to_field_switch(@index,'page_part','widget_field',nil,@choosen_field) %>");
|
|
@ -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_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} %>");
|
||||
|
||||
$("#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 show_default_widget_setting_panel %>
|
||||
$('#widget_setting').html("<%= j render :partial => 'default_widget_style_panel' %>");
|
||||
|
@ -16,3 +16,5 @@
|
|||
$('#widget_setting').html("<%=j render :partial=> 'reset',:locals=>{:label_i18n=>'default_widget.select_widget_style'}%>");
|
||||
$('#widget_list select').html("<%= j options_for_select([]) %>");
|
||||
<% end %>
|
||||
update_cates_and_tags();
|
||||
rebind();
|
|
@ -0,0 +1,6 @@
|
|||
<label for="<%= field_name %>" class="control-label">
|
||||
<%= t("default_widget.widget_data_count") %>
|
||||
</label>
|
||||
<div class="controls">
|
||||
<%= select_tag(field_name,options_for_select(@module_app.get_registration.get_data_count,field_value )) %>
|
||||
</div>
|
|
@ -66,6 +66,9 @@
|
|||
<%= render :partial => 'frontend_setting', :locals=>{:object=>@item,:f=>f} %>
|
||||
</div>
|
||||
|
||||
<div class="control-group" id='data_count'>
|
||||
<%= render :partial=>'data_count_field',:locals=>{:field_name=>"page[frontend_data_count]",:field_value=>@item.frontend_data_count} %>
|
||||
</div>
|
||||
|
||||
<div class="control-group">
|
||||
<%= f.label :is_published, "#{t('front_page.is_published')} ?", :class => 'control-label' %>
|
||||
|
@ -109,3 +112,4 @@
|
|||
</div>
|
||||
</div>
|
||||
|
||||
<%=javascript_include_tag "inc/update_cates_and_tags.js" %>
|
|
@ -3,4 +3,4 @@
|
|||
<%= render 'admin/items/site_map_left_bar' %>
|
||||
<% end -%>
|
||||
|
||||
<%= render 'edit' %>
|
||||
<%= render 'edit' %>
|
|
@ -1,7 +1,8 @@
|
|||
<% if @module_app %>
|
||||
$('#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} %>");
|
||||
|
||||
$("#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? %>
|
||||
$('#app_page_url').html("<%= escape_javascript(select 'page', 'app_frontend_url', options_for_select(@app_frontend_urls, @app_frontend_urls.first)) %>");
|
||||
<%else %>
|
||||
|
@ -31,3 +32,5 @@
|
|||
$('#app_page_url').html("<%= t('default_widget.no_support_setting')%>");
|
||||
$('#frontend_setting').html("<%= j render :partial => 'custom_frontend_setting' %>");
|
||||
<% end %>
|
||||
update_cates_and_tags();
|
||||
rebind();
|
|
@ -0,0 +1 @@
|
|||
$("#<%= params[:dom_id] %>").parents(".rows").find(".link_switch_holder").html("<%= j link_to_field_switch(@index,'page','frontend_field',nil,@choosen_field) %>");
|
|
@ -13,5 +13,4 @@
|
|||
<% end %>
|
||||
<% end %>
|
||||
</ul>
|
||||
<div class="more">more</div>
|
||||
<% end %>
|
||||
|
|
|
@ -11,5 +11,4 @@
|
|||
<% end %>
|
||||
<% end %>
|
||||
</ul>
|
||||
<div class="more">more</div>
|
||||
<% end %>
|
||||
|
|
|
@ -1,4 +1,7 @@
|
|||
<%= render @partial %>
|
||||
<% if @paginate %>
|
||||
<%= 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 %>
|
||||
|
|
|
@ -90,6 +90,7 @@ Orbit::Application.routes.draw do
|
|||
get 'reload_themes'
|
||||
get 'reload_after_module_changed',:action=>'reload_frontend_pages'
|
||||
get 'reload_after_list_changed',:action=> 'reload_front_end_setting'
|
||||
get 'reload_after_widget_field_changed',:action=> 'reload_widget_field'
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
@ -3,6 +3,7 @@ require "orbit_app/dsl"
|
|||
require "orbit_app/helper/renderer"
|
||||
require "orbit_app/helper/side_bar_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/widget"
|
||||
require "orbit_app/module/front_end"
|
||||
|
|
|
@ -0,0 +1,12 @@
|
|||
module DefaultWidgetTagHelper
|
||||
include Renderer
|
||||
include AdminHelper
|
||||
|
||||
def link_to_more_tag(req,params)
|
||||
@request = req
|
||||
@params =params
|
||||
content_tag :div,:class=> 'more' do
|
||||
link_to I18n.t(@more_link[:label_i18n]),eval(@more_link[:path_method])
|
||||
end
|
||||
end
|
||||
end
|
|
@ -28,7 +28,7 @@ module OrbitApp
|
|||
end
|
||||
|
||||
class DataSheet
|
||||
attr_reader :name,:key,:base_path,:module_label
|
||||
attr_reader :name,:key,:base_path,:module_label,:data_count
|
||||
|
||||
def initialize(name, &block)
|
||||
@name = name
|
||||
|
@ -36,6 +36,7 @@ module OrbitApp
|
|||
@side_bar = nil
|
||||
@front_end_app_pages = nil
|
||||
@module_label = 'rulingcom.errors.init.module_app_noname'
|
||||
@data_count = 1..15 # as default
|
||||
block.arity < 1 ? instance_eval(&block) : block.call(self) if block_given?
|
||||
setup_module_app
|
||||
end
|
||||
|
@ -86,6 +87,10 @@ module OrbitApp
|
|||
@front_end_app_pages.nil? ? [] : @front_end_app_pages.to_module_app_format
|
||||
end
|
||||
|
||||
def get_data_count
|
||||
@data_count
|
||||
end
|
||||
|
||||
def get_widget_by_path(path)
|
||||
if @widget_set
|
||||
@widget_set.find_by_path(path)
|
||||
|
@ -94,6 +99,14 @@ module OrbitApp
|
|||
end
|
||||
end
|
||||
|
||||
def default_widget_setting
|
||||
@widget_set.default_widget_setting
|
||||
end
|
||||
|
||||
def widget_setting
|
||||
@widget_set
|
||||
end
|
||||
|
||||
def get_widgets
|
||||
@widget_set.nil? ? {} : @widget_set.to_module_app_format
|
||||
end
|
||||
|
@ -127,7 +140,7 @@ module OrbitApp
|
|||
# @default_widget = widget_set.default_widget
|
||||
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)}
|
||||
end
|
||||
|
||||
|
|
|
@ -34,6 +34,10 @@ module OrbitApp
|
|||
define_method(field){|var| instance_variable_set( "@" + field, var)}
|
||||
end
|
||||
|
||||
# def data_count(var)
|
||||
# @data_count = var
|
||||
# end
|
||||
|
||||
def find_by_path(path)
|
||||
@widgets.each do |widget|
|
||||
return widget if widget.name == path
|
||||
|
@ -44,10 +48,14 @@ module OrbitApp
|
|||
eval(@categories_query) rescue nil
|
||||
end
|
||||
|
||||
def get_tags
|
||||
def get_tags
|
||||
eval(@tags_query) rescue nil
|
||||
end
|
||||
|
||||
def default_widget_setting
|
||||
@default_widget
|
||||
end
|
||||
|
||||
def default_widget(&block)
|
||||
@default_widget = DefaultWidget.new(&block)
|
||||
end
|
||||
|
@ -85,6 +93,7 @@ module OrbitApp
|
|||
end
|
||||
|
||||
class DefaultWidget
|
||||
include DefaultWidgetTagHelper
|
||||
STYLE = ["typeA","typeB_style2","typeB_style3","typeB_style4","typeC"]
|
||||
|
||||
def initialize(&block)
|
||||
|
@ -95,9 +104,10 @@ module OrbitApp
|
|||
block.arity < 1 ? instance_eval(&block) : block.call(self) if block_given?
|
||||
end
|
||||
|
||||
def more_link_to(label_i18n,path_method)
|
||||
@more_link[:label_i18n] = label_i18n
|
||||
@more_link[:path_method] = path_method
|
||||
|
||||
def link_to_more(*args)
|
||||
@more_link[:label_i18n] = (args[1] ? args[1][:title_i18n] : 'default_widget.default_link_to_more' )
|
||||
@more_link[:path_method] = args[0]
|
||||
end
|
||||
|
||||
def self.get_interface_args
|
||||
|
@ -106,7 +116,7 @@ module OrbitApp
|
|||
end
|
||||
|
||||
def to_module_app_format
|
||||
{"query"=>@query,"image"=>@image} rescue nil
|
||||
{"query"=>@query,"image"=>@image,"more_link"=>@more_link} rescue nil
|
||||
end
|
||||
|
||||
def link_field(field_name,setting)
|
||||
|
|
|
@ -190,6 +190,25 @@ namespace :migrate do
|
|||
end
|
||||
end
|
||||
|
||||
task :convert_cate_tag_type => :environment do
|
||||
[Page,PagePart].each do |obj|
|
||||
obj.all.each do |pp|
|
||||
if pp.category.blank?
|
||||
pp.category = []
|
||||
else
|
||||
pp.category = [pp.category]
|
||||
end
|
||||
|
||||
if pp.tag.blank?
|
||||
pp.tag = []
|
||||
else
|
||||
pp.tag = [pp.tag]
|
||||
end
|
||||
pp.save
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
task :clean_parts => :environment do
|
||||
PagePart.where(widget_style: /\d/, kind: 'module_widget').each{|part| part.update_attributes({kind: 'text', widget_style: nil, widget_field: nil})}
|
||||
PagePart.where(widget_style: /\d/).each{|part| part.update_attributes({widget_style: nil, widget_field: nil})}
|
||||
|
|
|
@ -27,6 +27,7 @@ zh_tw:
|
|||
approval_setting: 審核權限
|
||||
tags: 標籤
|
||||
default_widget:
|
||||
to_more: 更多
|
||||
bulletin_category_with_title: 分類
|
||||
title: 標題
|
||||
postdate: 張貼日期
|
||||
|
|
|
@ -18,6 +18,7 @@ module Announcement
|
|||
end
|
||||
|
||||
category ["BulletinCategory"]
|
||||
data_count 3..10
|
||||
|
||||
widgets do
|
||||
default_widget do
|
||||
|
@ -26,6 +27,7 @@ module Announcement
|
|||
field :postdate
|
||||
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_to_more 'panel_announcement_front_end_bulletins_path',:title_i18n=> 'announcement.default_widget.to_more'
|
||||
end
|
||||
|
||||
categories_query 'BulletinCategory.all'
|
||||
|
|
Loading…
Reference in New Issue