page can use default widget

This commit is contained in:
Fu Matthew 2013-01-21 16:56:37 +08:00
parent 9630d0a841
commit 0cc616f988
28 changed files with 305 additions and 154 deletions

View File

@ -1,5 +1,11 @@
function get_part_id(){
return $(".edit_page_part").attr("action").split('/').pop();
return $(".edit_page_part,.edit_page").attr("action").split('/').pop();
}
function get_object_path(){
a = window.location.href.split('/');
a.pop();
return a.join('/');
}
$("div.editable").live("mouseenter mouseleave", function (event) {
@ -10,26 +16,26 @@ $("#page_design").live('change', function() {
$.getScript($(this).attr('rel') + '/' + $(this).val() + '/reload_themes');
});
$("#page_module_app_id").live('change', function() {
var app_id = $(this).val();
if(app_id!=''){
$.getScript($(this).attr('rel') + '/' + $(this).val() + '/reload_frontend_pages',function(data, textStatus){
if(textStatus == 'success'){
$(this).after(data);
}
});
}
else{
$("#app_page_url").children().remove();
}
});
// $("#page_module_app_id").live('change', function() {
// var app_id = $(this).val();
// if(app_id!=''){
// $.getScript($(this).attr('rel') + '/' + $(this).val() + '/reload_after_module_changed',function(data, textStatus){
// if(textStatus == 'success'){
// $(this).after(data);
// }
// });
// }
// else{
// $("#app_page_url").children().remove();
// }
// });
$("#module_app_list select").live('change', function() {
$.getScript($(this).attr('rel') + '/' + $(this).val() + '/reload_widgets?part_id=' + get_part_id());
$.getScript(get_object_path() + '/reload_after_module_changed?module_app_id='+$(this).val()); //?part_id=' + get_part_id());
});
$("#widget_list select").live('change', function() {
$.getScript($(this).attr('rel') + '/' + $(this).val() + '/reload_widget_styles?module_app_id=' + $("#module_app_list select").val() + '&part_id=' + get_part_id());
$("#widget_list select,#frontend_list select").live('change', function() {
$.getScript(get_object_path() +'/reload_after_list_changed?frontend=' + $(this).val() + '&module_app_id=' + $("#module_app_list select").val() );//+ '&part_id=' + get_part_id());
});
$("#tag_list select").live('change', function() {

View File

@ -9,32 +9,6 @@ class Admin::ModuleAppsController < ApplicationController
end
def reload_frontend_pages
@categories =[]
@module_app = ModuleApp.find(params[:id])
@frontend_path = @module_app.widgets.keys[0] if ( !@module_app.widgets.blank? && @module_app.widgets[0].blank? )
@frontend_style = @module_app.widgets[@frontend_path] if ( !@frontend_path.blank? )
case @module_app.key
when 'announcement'
@categories = BulletinCategory.all
@tags = AnnouncementTag.all
when 'news'
@categories = NewsBulletinCategory.all
@tags = NewsTag.all
when 'web_resource'
@categories = WebLinkCategory.all
@tags = WebResourceTag.all
when 'archive'
@categories = ArchiveFileCategory.all
@tags = ArchiveTag.all
end
respond_to do |format|
format.js {}
end
end
def module_auth_proc
@module_app = ModuleApp.find(params[:id])
@ -138,5 +112,4 @@ class Admin::ModuleAppsController < ApplicationController
flash[:notice] = t('app_auth.operation_not_permitted')
render :nothing => true,:status => 403
end
end

View File

@ -91,9 +91,9 @@ class Admin::PagePartsController < ApplicationController
end
def reload_widgets
@part = PagePart.find params[:part_id]
@part = PagePart.find params[:id]
@categories =[]
@module_app = ModuleApp.find(params[:id])
@module_app = ModuleApp.find(params[:module_app_id])
@widget_path = @module_app.widgets.keys[0] if ( @module_app.widgets[0].blank? )
@ -122,9 +122,9 @@ class Admin::PagePartsController < ApplicationController
def reload_widget_styles
@module_app = ModuleApp.find(params[:module_app_id])
@part = PagePart.find params[:part_id]
@user_choose =@widget_path= params[:id]
@widget_style = @module_app.widgets[params[:id]]
@part = PagePart.find params[:id]
@user_choose =@widget_path= params[:frontend]
@widget_style = @module_app.widgets[@widget_path]
respond_to do |format|
format.js {}

View File

@ -19,14 +19,20 @@ helper Admin::PagePartsHelper
end
def edit
@item = Page.find(params[:id])
@item = @page =Page.find(params[:id])
@user_choose = @item.app_frontend_url
@apps = ModuleApp.excludes(app_pages: nil).entries
@module_apps = ModuleApp.excludes(widgets: nil).where(enable_frontend: true).order_by(:title, :asc)
@designs = Design.all.entries
@design = @item.design ? @item.design : @designs.first
@app_frontend_urls = @item.module_app.app_pages if @item.module_app
if @item.module_app
@app_frontend_urls = @item.module_app.app_pages
@app_frontend_urls << 'default_widget' if @item.module_app.has_default_widget?
end
if @item.module_app
@module_app = @item.module_app
@ -124,6 +130,43 @@ helper Admin::PagePartsHelper
end
end
def reload_front_end_setting
@page = Page.find params[:id]
@module_app = ModuleApp.find params[:module_app_id]
@chosen_frontend = @user_choose = params[:frontend]
end
def reload_frontend_pages
@page = Page.find params[:id]
# @categories =[]
@module_app = ModuleApp.find(params[:module_app_id])
@app_frontend_urls = @module_app.app_pages
@app_frontend_urls << 'default_widget' if @module_app.has_default_widget?
case @module_app.key
when 'announcement'
@categories = BulletinCategory.all
@tags = AnnouncementTag.all
when 'news'
@categories = NewsBulletinCategory.all
@tags = NewsTag.all
when 'web_resource'
@categories = WebLinkCategory.all
@tags = WebResourceTag.all
when 'archive'
@categories = ArchiveFileCategory.all
@tags = ArchiveTag.all
else
@categories = []
@tags = []
end
respond_to do |format|
format.js {}
end
end
def reload_themes
@design = Design.find(params[:id])
@themes = @design.themes

View File

@ -1,7 +1,12 @@
class DefaultWidgetController< OrbitWidgetController
def front_end_available(var)
@page_part = PagePart.find params[:part_id]
@page_part = case params[:item_type]
when "page"
Page.find params[:page_id]
when "page_part"
PagePart.find params[:part_id]
end
@page_part.module_app.enable_frontend?
end
@ -9,10 +14,17 @@ class DefaultWidgetController< OrbitWidgetController
@tag_class = nil
@default_widget = @page_part.module_app.get_default_widget
@widget_image_field = @default_widget[:image]
data_limit = @page_part.widget_data_count.is_a?(Fixnum) ? @page_part.widget_data_count : (@page_part.widget_data_count.to_i rescue 3)
@data = eval(@default_widget["query"]).limit(data_limit).includes(@widget_image_field)
@widget_image_field = @default_widget["image"] || @default_widget[:image]
data_limit = case @page_part
when Page
@fields = @page_part.frontend_field
@page_part.frontend_data_count.is_a?(Fixnum) ? @page_part.frontend_data_count : (@page_part.frontend_data_count.to_i rescue 3)
when PagePart
@fields = @page_part.widget_field
@page_part.widget_data_count.is_a?(Fixnum) ? @page_part.widget_data_count : (@page_part.widget_data_count.to_i rescue 3)
end
@data = eval(@default_widget["query"]).limit(data_limit).includes(@widget_image_field)
case params[:type]
when "typeA"

View File

@ -10,33 +10,60 @@ module Admin::PagePartsHelper
end
def widget_field_options(i,local_item=nil)
local_item = @part if local_item.nil?
local_item = @part if local_item.nil? && @part
local_item = @page if local_item.nil? && @page
options = @module_app.widget_fields.collect{|widget_field| [I18n.t(widget_field[1]), widget_field[0]]}
case local_item
when Page
options_for_select(options, (local_item[:frontend_field][i][0] if (local_item && !local_item[:frontend_field].blank? && !local_item[:frontend_field][i].blank?)) )
when PagePart
options_for_select(options, (local_item[:widget_field][i][0] if (local_item && !local_item[:widget_field].blank? && !local_item[:widget_field][i].blank?)) )
end
end
def widget_fiield_type_options(i,local_item=nil)
options = LIST[:widget_field_type].collect{|widget_field| [widget_field.humanize, widget_field]}
local_item = @part if local_item.nil?
local_item = @part if local_item.nil? && @part
local_item = @page if local_item.nil? && @page
case local_item
when Page
options_for_select(options, (local_item[:frontend_field][i][1] if (local_item && !local_item[:frontend_field].blank? && !local_item[:frontend_field][i].blank?)) )
when PagePart
options_for_select(options, (local_item[:widget_field][i][1] if (local_item && !local_item[:widget_field].blank? && !local_item[:widget_field][i].blank?)) )
end
end
def tag_checked_value(part,radio_value)
part and (part[:tag] == radio_value) ? true : false
part and (part[:tag] == radio_value.to_s) ? true : false
end
def category_checked_value(part,radio_value)
part and (part[:category] == radio_value) ? true : false
part and (part[:category] == radio_value.to_s) ? true : false
end
def style_checked_value(part,radio_value)
part and (part.widget_style == radio_value) ? true : false
case part
when Page
(part.frontend_style == radio_value) ? true : false
when PagePart
(part.widget_style == radio_value) ? true : false
when nil
false
end
end
def nil_radio_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 = radio_button("page_part", tag_or_cate, '' , :checked => eval("#{tag_or_cate}_checked_value(part,'')"))
op = radio_button(field_name, tag_or_cate, '' , :checked => eval("#{tag_or_cate}_checked_value(part,'')"))
op << I18n.t("default_widget.no_value")
end
end

View File

@ -1,5 +0,0 @@
$('#app_page_url').html("<%= escape_javascript(select 'page', 'app_frontend_url', @module_app.app_pages) %>");
$('#app_page_frontend_style').html("<%= escape_javascript(select 'page', 'frontend_style', @module_app.widgets[@frontend_path]) if !@frontend_path.blank? %>");
$('#app_page_category').html("<%= j (select 'page', 'category', @categories.collect{|category| [category.title, category.id]}, {:include_blank => true}) if @categories %>");
$('#app_page_tag').html("<%= j (select 'page', 'tag', @tags.collect{|tag| [tag[I18n.locale], tag.id]}, {:include_blank => true}) if @tags %>");
$('#app_page_frontend_field').html("<%= j render '../admin/pages/frontend_fields' %>")

View File

@ -3,14 +3,13 @@
<%= t("default_widget.select_widget_style") %>
</label>
<div class="controls well">
<% if @module_app.widgets[@widget_path].blank? %>
<% if @module_app.widgets.nil? || (@module_app.widgets[@widget_path].blank? rescue true) %>
<%= t("default_widget.no_support_setting")%>
<%else%>
<%= select('page_part', 'widget_style', @module_app.widgets[@widget_path]) %>
<% end %>
</div>
</div>
<% if(@module_app.widget_options && @module_app.widget_options.has_key?(@widget_path)) %>
<div class="style_switch control-group">
<label class="control-label"><%= t("default_widget.select_widget_ext_option") %></label>

View File

@ -1,6 +1,17 @@
<% case object%>
<% 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">
<label class="control-label">
<%= t("default_widget.NoName") %>
<%= t("default_widget.fields_") %>
</label>
<div id="widget_field" class="well clear controls">
@ -20,20 +31,24 @@
<div class="rows clear">
<span class="span4">
<%= i+1 %>
<%= select_tag "page_part[widget_field][]", widget_field_options(i), :include_blank => true %>
<%= select_tag "#{object_name}[#{field_name}][]", widget_field_options(i), :include_blank => true %>
</span>
<span class="span3">
<%= select_tag "page_part[widget_field_type][]", widget_fiield_type_options(i), :include_blank => true %> <br />
<%= select_tag "#{object_name}[#{field_name}_type][]", widget_fiield_type_options(i), :include_blank => true %> <br />
</span>
<span class="span5"></span>
</div><br/>
<% end %>
<br/>
<div class="rows clear">
<span class="span4"><%= label_tag t("default_widget.widget_data_count") %></span>
<span class="span4">
<%= label_tag t("default_widget.widget_data_count") %>
</span>
</div>
<div class="rows clear">
<span class="span4"><%= text_field_tag :widget_data_count,@part.widget_data_count %></span>
<span class="span4">
<%= text_field_tag "#{object_name}[#{data_count}]",object.send(data_count) %>
</span>
</div>
</div>
</div>

View File

@ -1,3 +1,11 @@
<% field_name='' %>
<% case object %>
<% when Page %>
<% field_name = "page[frontend_style]" %>
<% when PagePart %>
<% field_name = "page_part[widget_style]" %>
<% end %>
<div class="style_switch control-group">
<label class="control-label">
<%= t("default_widget.select_widget_style") %>
@ -6,7 +14,7 @@
<ul class="clear">
<li>
<label class="radio style_radio">
<%= radio_button_tag :widget_style,"typeA",:checked => style_checked_value(@part,"typeA") %>
<%= radio_button_tag field_name,"typeA",style_checked_value(object,"typeA") %>
1
<span class="style_img"><%=image_tag 'module/default_widgets/style01.png'%></span>
<span class="style_description"><%= t("default_widget.caption.typeA") %></span>
@ -15,7 +23,7 @@
</li>
<li>
<label class="radio style_radio">
<%= radio_button_tag :widget_style,"typeB_style2",:checked => style_checked_value(@part,"typeB_style2") %>
<%= radio_button_tag field_name,"typeB_style2",style_checked_value(object,"typeB_style2") %>
2
<span class="style_img"><%=image_tag 'module/default_widgets/style02.png'%></span>
<span class="style_description"><%= t("default_widget.caption.typeA") %></span>
@ -23,7 +31,7 @@
</li>
<li>
<label class="radio style_radio">
<%= radio_button_tag :widget_style,"typeB_style3",:checked => style_checked_value(@part,"typeB_style3") %>
<%= radio_button_tag field_name,"typeB_style3",style_checked_value(object,"typeB_style3") %>
3
<span class="style_img"><%=image_tag 'module/default_widgets/style03.png'%></span>
<span class="style_description"><%= t("default_widget.caption.typeB_style3") %></span>
@ -31,7 +39,7 @@
</li>
<li>
<label class="radio style_radio">
<%= radio_button_tag :widget_style,"typeB_style4",:checked => style_checked_value(@part,"typeB_style4") %>
<%= radio_button_tag field_name,"typeB_style4",style_checked_value(object,"typeB_style4") %>
4
<span class="style_img"><%=image_tag 'module/default_widgets/style04.png'%></span>
<span class="style_description"><%= t("default_widget.caption.typeB_style4") %></span>
@ -39,7 +47,7 @@
</li>
<li>
<label class="radio style_radio">
<%= radio_button_tag :widget_style,"typeC",:checked => style_checked_value(@part,"typeC") %>
<%= radio_button_tag field_name,"typeC",style_checked_value(object,"typeC") %>
5
<span class="style_img"><%=image_tag 'module/default_widgets/style05.png'%></span>
<span class="style_description"><%= t("default_widget.caption.typeC") %></span>

View File

@ -17,7 +17,7 @@
<%= t "default_widget.select_module_app" %>
</label>
<div class="controls">
<%= f.select :module_app, options_from_collection_for_select(@module_apps, :id, :title, :selected => @module_app.id), {}, {:rel => admin_page_parts_path} %>
<%= f.select :module_app, options_from_collection_for_select(@module_apps, :id, :title, :selected => @module_app.id), {}, {:rel => admin_page_parts_path,:id=>"page_module_app_id"} %>
</div>
</div>
@ -32,17 +32,17 @@
<div id="widget_option">
<div id="widget_data_source_category" class="control-group">
<%= render :partial => 'widget_data_source_category' %>
<%= render :partial => 'widget_data_source_category' ,:locals=>{:object=>@part}%>
</div>
<div id="widget_data_source_tag" class="control-group">
<%= render :partial => 'widget_data_source_tag' %>
<%= render :partial => 'widget_data_source_tag' ,:locals=>{:object=>@part} %>
</div>
</div>
<div id="widget_setting">
<%= render :partial => 'widget_setting' ,:locals=>{:f=>f} %>
<%= render :partial => 'widget_setting' ,:locals=>{:f=>f,:object=>@part} %>
</div>
<!-- <span id="widget_options">

View File

@ -1,14 +1,22 @@
<% case object %>
<% when Page %>
<% field_name = 'page' %>
<% when PagePart %>
<% field_name = 'page_part' %>
<% end %>
<label class="control-label"><%= t "default_widget.data_source.category" %></label>
<% if @categories %>
<div class="well controls">
<% if @categories %>
<fieldset>
<%= nil_radio_button(@part,:category) %>
<%= nil_radio_button(object,:category) %>
<%= content_tag_for(:label, @categories,:class=>"radio inline") do |category|%>
<%= radio_button("page_part", "category", category.id, :checked => category_checked_value(@part,category.id) )%>
<%= radio_button_tag("#{field_name}[category]", category.id, category_checked_value(object,category.id) )%>
<%= category.title%>
<% end %>
</fieldset>
</div>
<% else %>
<%= t("default_widget.no_support_setting")%>
<% end %>
</div>

View File

@ -1,14 +1,22 @@
<% case object %>
<% when Page %>
<% field_name = 'page' %>
<% when PagePart %>
<% field_name = 'page_part' %>
<% end %>
<label class="control-label"><%= t "default_widget.data_source.tag" %></label>
<% if @categories %>
<div class="well controls">
<% if @categories %>
<fieldset>
<%= nil_radio_button(@part,:tag) %>
<%= nil_radio_button(object,:tag) %>
<%= content_tag_for(:label, @tags,:class=>"radio inline") do |tag|%>
<%= radio_button("page_part", "tag", tag.id, :checked => tag_checked_value(@part,tag.id) )%>
<%= radio_button_tag("#{field_name}[tag]", tag.id, tag_checked_value(object,tag.id) ) %>
<%= tag[I18n.locale]%>
<% end %>
</fieldset>
</div>
<% else %>
<%= t("default_widget.no_support_setting")%>
<% end %>
</div>

View File

@ -1,10 +1,10 @@
<% if show_default_widget_setting_panel %>
<div id="default_widget">
<%= render :partial => 'default_widget_style_panel',:locals=>{:f=>f} %>
<%= render :partial => 'default_widget_setting' %>
<%= render :partial => 'admin/page_parts/default_widget_style_panel',:locals=>{:f=>f,:object=>object} %>
<%= render :partial => 'admin/page_parts/default_widget_setting',:locals=>{:object=>object} %>
</div>
<% elsif show_custom_widget_setting_panel %>
<div id="custom_widget">
<%= render :partial => 'custom_widget_setting' %>
<%= render :partial => 'admin/page_parts/custom_widget_setting',:locals=>{:object=>object} %>
</div>
<% end %>

View File

@ -1 +0,0 @@
<%= select 'page_part', 'category', @categories.collect{|category| [category.title, category.id]}, :selected => (@part ? @part[:category] : nil), :include_blank => true if @categories && @categories.size > 0 %>

View File

@ -1 +0,0 @@
<%= select 'page_part', 'tag', @tags.collect{|tag| [tag[I18n.locale], tag.id]}, :selected => (@part ? @part[:tag] : nil), :include_blank => true if @tags && @tags.size > 0 %>

View File

@ -1,7 +1,7 @@
<% if show_default_widget_setting_panel %>
$('#widget_setting').html("<%= j render :partial => 'default_widget_style_panel' %>");
$('#widget_setting').append("<%= j render :partial => 'default_widget_setting' %>");
$('#widget_setting').html("<%= j render :partial => 'default_widget_style_panel',:locals=>{:object=>@part} %>");
$('#widget_setting').append("<%= j render :partial => 'default_widget_setting',:locals=>{:object=>@part} %>");
<% elsif show_custom_widget_setting_panel %>
$('#widget_setting').html("<%= j render :partial => 'custom_widget_setting' %>");
<% end %>

View File

@ -1,11 +1,11 @@
$('#widget_list select').html("<%= j options_for_select(@module_app.widgets.collect{|k,v| k},@part.widget_path) %>");
$("#widget_data_source_category").html("<%= j render :partial => 'widget_data_source_category' %>");
$("#widget_data_source_tag").html("<%= j render :partial => 'widget_data_source_tag' %>");
$("#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} %>");
<% if !@part.widget_path.blank? %>
<% if show_default_widget_setting_panel %>
$('#widget_setting').html("<%= j render :partial => 'default_widget_style_panel' %>");
$('#widget_setting').append("<%= j render :partial => 'default_widget_setting' %>");
$('#widget_setting').append("<%= j render :partial => 'default_widget_setting',:locals=>{:object=>@part} %>");
<% elsif show_custom_widget_setting_panel %>
$('#widget_setting').html("<%= j render :partial => 'custom_widget_setting' %>");
<% end %>

View File

@ -1 +1 @@
<%= f.select :module_app_id, @apps.collect { |t| [t.title.capitalize, t.id] }, {:include_blank => true} ,{:rel => admin_module_apps_path } %>
<%= f.select :module_app_id, @apps.collect { |t| [t.title.capitalize, t.id] }, {:include_blank => true} ,{:rel => admin_pages_path } %>

View File

@ -35,34 +35,42 @@
<!-- <p class="help-block">In addition to freeform text, any HTML5 text-based input appears like so.</p> -->
</div>
</div>
<div class="control-group">
<%= f.label :name, t(:module), :class => 'control-label' %>
<div class="control-group" id="module_app_list">
<%= f.label '',t("default_widget.select_module_app"), :class => 'control-label' %>
<div class="controls">
<%= render :partial => "app_selector", :locals => { :f => f } %>
<span id="app_page_url">
</div>
</div>
<div class="control-group" id="frontend_list">
<%= f.label '', t("page.select_app_url"), :class => 'control-label' %>
<div class="controls" id="app_page_url">
<%= select('page','app_frontend_url', @app_frontend_urls, :selected => @item.app_frontend_url ) rescue ''%>
</span>
<span id="app_page_frontend_style">
</div>
</div>
<!-- <div class="control-group">
<%= f.label '', "FRONT STYLE", :class => 'control-label' %>
<div class="controls" id="app_page_frontend_style">
<%= select('page','frontend_style', @frontend_style, :selected => @item[:frontend_style], :include_blank => true ) rescue ''%>
</span>
<span id="app_page_category">
<%= select('page','category', @categories.collect{|category| [category.title, category.id]}, :selected => @item[:category], :include_blank => true ) rescue ''%>
</span>
<span id="app_page_tag">
<%= select('page','tag', @tags.collect{|tag| [tag[I18n.locale], tag.id]}, :selected => @item[:tag], :include_blank => true ) rescue ''%>
</span>
<span id="app_page_frontend_field">
<%= render 'frontend_fields' %>
</span>
<!-- <p class="help-block">In addition to freeform text, any HTML5 text-based input appears like so.</p> -->
</div>
</div>
<div class="control-group">
<%= f.label :frontend_data_count, t(:frontend_data_count), :class => 'control-label' %>
<div class="controls">
<%= f.text_field :frontend_data_count %>
-->
<div id="app_page_category" class="control-group">
<%= render :partial=>"admin/page_parts/widget_data_source_category",:locals=>{:object=>@item} %>
</div>
<div id="app_page_tag" class="control-group">
<%= render :partial=>"admin/page_parts/widget_data_source_tag" ,:locals=>{:object=>@item}%>
</div>
<div id="frontend_setting">
<%= render :partial => 'frontend_setting', :locals=>{:object=>@item,:f=>f} %>
</div>
<div class="control-group">
<%= f.label :is_published, "#{t(:is_published)} ?", :class => 'control-label' %>
<div class="controls">

View File

@ -0,0 +1,3 @@
<% if show_default_widget_setting_panel %>
<%= render :partial=>'admin/page_parts/widget_setting',:locals=>{:object=>object,:f=>f} %>
<% end %>

View File

@ -1,3 +1,4 @@
<%= stylesheet_link_tag "admin/default_widget_setting" %>
<% content_for :sidebar do %>
<%= render 'admin/items/site_map_left_bar' %>
<% end -%>

View File

@ -0,0 +1,8 @@
<% if show_default_widget_setting_panel %>
// $('#app_page_tag').html("<%= j render :partial => 'admin/page_parts/widget_data_source_tag',:locals=>{:object=>@page} %>");
$('#frontend_setting').html("<%= j render :partial => 'admin/page_parts/default_widget_style_panel',:locals=>{:object=>@page} %>");
$('#frontend_setting').append("<%= j render :partial => 'admin/page_parts/default_widget_setting',:locals=>{:object=>@page} %>");
<% else %>
$('#frontend_setting').html("<%= j render :partial => 'custom_frontend_setting' %>");
<% end %>

View File

@ -0,0 +1,24 @@
$('#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} %>");
<% 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 %>
$('#app_page_url').html("<%= t('default_widget.no_support_setting')%>");
<% end %>
<% if @app_frontend_urls.first =='default_widget' %>
$('#app_page_frontend_style').html("<%= escape_javascript(select 'page', 'frontend_style', @module_app.widgets[@frontend_path]) if !@frontend_path.blank? %>");
<% else %>
$('#app_page_frontend_style').html("<%= t('default_widget.no_support_setting')%>");
<% end %>
<% if show_default_widget_setting_panel %>
$('#app_page_tag').html("<%= j render :partial => 'admin/page_parts/widget_data_source_tag',:locals=>{:object=>@page} %>");
$('#frontend_setting').html("<%= j render :partial => 'admin/page_parts/default_widget_style_panel',:locals=>{:object=>@page} %>");
$('#frontend_setting').append("<%= j render :partial => 'admin/page_parts/default_widget_setting',:locals=>{:object=>@page} %>");
<% else %>
$('#frontend_setting').html("<%= j render :partial => 'custom_frontend_setting' %>");
<% end %>

View File

@ -153,6 +153,7 @@ zh_tw:
default_widget:
no_support_setting: 沒有可以使用的設定
no_value: 不設定(全部)
fields_: 前台輸出欄位
fields_order: 輸出欄位順序
fields_style: 輸出欄位樣式
select_module_app: 外掛模組選擇

View File

@ -82,6 +82,8 @@ Orbit::Application.routes.draw do
member do
get 'delete'
get 'reload_themes'
get 'reload_after_module_changed',:action=>'reload_frontend_pages'
get 'reload_after_list_changed',:action=> 'reload_front_end_setting'
end
end
@ -101,14 +103,13 @@ Orbit::Application.routes.draw do
match 'remove_manager/:app_manager_id' ,:action=> 'remove_manager',:via => "delete",:as =>:remove_manager
match 'remove_sub_manager/:app_sub_manager_id' ,:action=> 'remove_sub_manager',:via => "delete",:as =>:remove_sub_manager
get 'reload_frontend_pages'
end
end
resources :page_parts do
member do
get 'reload_widgets'
get 'reload_widget_styles'
get 'reload_after_module_changed',:action=>'reload_widgets'
get 'reload_after_list_changed',:action=> 'reload_widget_styles'
get 'reload_r_tag_options'
end
end

View File

@ -184,14 +184,20 @@ module ParserCommon
# page_contents
def parse_contents_edit(body, page, edit=nil)
public_r_tags = []
url = ''
body.css('.page_content').each do |content|
ret = ''
category = params[:category_id].blank? ? page[:category] : params[:category_id]
tag = params[:tag_id].blank? ? page[:tag] : params[:tag_id]
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}"
if page.app_frontend_url == 'default_widget'
url = "/panel/orbit_app/widget/#{page.frontend_style}?inner=true"
else
url = "/panel/#{page.module_app.key}/front_end/#{page.app_frontend_url}"
end
ret << "<div id='appfrontend' class='dymanic_load' path='#{url}"
ret << "/#{params[:id]}" if params[:id] && !params[:id].eql?(page.id.to_s)
ret << "?inner=true&page_id=#{page.id}&category_id=#{category}&tag_id=#{tag}&preview=#{params[:preview]}&page_main=#{params[:page_main]}&search_query=#{params[:search_query]}&name=#{params[:name]}"
ret << "?inner=true&page_id=#{page.id}&category_id=#{category}&tag_id=#{tag}&preview=#{params[:preview]}&page_main=#{params[:page_main]}&search_query=#{params[:search_query]}&name=#{params[:name]}&item_type=page"
ret << "'></div>"
else
part = page.page_parts.detect{ |p| p.name.to_s == content['name'].to_s } rescue nil
@ -213,7 +219,7 @@ module ParserCommon
raise ModuleAppError,"PagePart can't find ModuleApp" if part.module_app.nil?
"/panel/#{part.module_app.key}/widget/#{part.widget_path}?inner=true"
end
options = "&part_id=#{part.id}&category_id=#{!part[:category].blank? ? part[:category].blank? : category}&tag_id=#{!part[:tag].blank? ? part[:tag] : tag}&page=#{params[:page]}&search_query=#{params[:search_query]}&part_title=#{Rack::Utils.escape(part_title).gsub("+", "%20") rescue nil}"
options = "&part_id=#{part.id}&category_id=#{!part[:category].blank? ? part[:category].blank? : category}&tag_id=#{!part[:tag].blank? ? part[:tag] : tag}&page=#{params[:page]}&search_query=#{params[:search_query]}&part_title=#{Rack::Utils.escape(part_title).gsub("+", "%20") rescue nil}&item_type=page_part"
ret << "<div class='dymanic_load widget' path='#{url + options}'></div>"
when 'public_r_tag'
ret << "<r:#{part.public_r_tag} id='#{part.public_r_tag_object_id}'/>"

View File

@ -95,11 +95,18 @@ module ParserFrontEnd
# page_contents
def parse_contents(body, page, edit=nil, locale)
public_r_tags = []
url = ''
body.css('.page_content').each do |content|
ret = ''
if (content["main"] == "true" && !page.module_app.nil?)
url = "/panel/#{page.module_app.key}/front_end/#{page.app_frontend_url}\#{(\"/\" + params[:id]) if params[:id] && !params[:id].eql?(page.id.to_s)}\#{(\"/\" + params[:controller_action]) if params[:controller_action] && params[:id]}?inner=true"
options = "&page_id=#{page.id}&category_id=\#{category}&tag_id=\#{tag}&preview=\#{params[:preview]}&page_main=\#{params[:page_main]}&search_query=\#{params[:search_query]}&name=\#{params[:name]}"
if page.app_frontend_url == 'default_widget'
url = "/panel/orbit_app/widget/#{page.frontend_style}?inner=true"
else
"/panel/#{page.module_app.key}/front_end/#{page.app_frontend_url}\#{(\"/\" + params[:id]) if params[:id] && !params[:id].eql?(page.id.to_s)}\#{(\"/\" + params[:controller_action]) if params[:controller_action] && params[:id]}?inner=true"
end
options = "&page_id=#{page.id}&category_id=\#{category}&tag_id=\#{tag}&preview=\#{params[:preview]}&page_main=\#{params[:page_main]}&search_query=\#{params[:search_query]}&name=\#{params[:name]}&item_type=page"
ret << "<orbit_front path='#{url + options}'></div>"
else
part = page.page_parts.detect{ |p| p.name.to_s == content['name'].to_s } rescue nil
@ -116,7 +123,7 @@ module ParserFrontEnd
else
"/panel/\#{part.module_app.key}/widget/\#{part.widget_path}?inner=true"
end
options = "&part_id=\#{part.id}&category_id=\#{!part[:category].blank? ? part[:category].blank? : category}&tag_id=\#{!part[:tag].blank? ? part[:tag] : tag}&page=\#{params[:page]}&search_query=\#{params[:search_query]}&part_title=\#{Rack::Utils.escape(part_title).gsub(\"\+\", \"\%20\") rescue nil}"
options = "&part_id=\#{part.id}&category_id=\#{!part[:category].blank? ? part[:category].blank? : category}&tag_id=\#{!part[:tag].blank? ? part[:tag] : tag}&page=\#{params[:page]}&search_query=\#{params[:search_query]}&part_title=\#{Rack::Utils.escape(part_title).gsub(\"\+\", \"\%20\") rescue nil}&item_type=page_part"
ret << "<orbit_front path='#{url + options}' part_id=#{part.id} class='dymanic_load widget'></orbit_front>"
when 'public_r_tag'