fix widget and fronted setting interface. checked with Spen

This commit is contained in:
Matt K. Fu 2013-04-02 18:39:46 +08:00
parent 3476237fa7
commit 20bdeb3c2d
9 changed files with 20 additions and 17 deletions

View File

@ -2,11 +2,11 @@ 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').attr('disabled',"disabled");
$(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').attr('disabled',"disabled");
$(this).parent().siblings('label').find('.select_all').removeAttr('checked');
});
}

View File

@ -31,7 +31,7 @@ class Admin::PagePartsController < OrbitBackendController
@selected={
:module_app=> @part.module_app ? @part.module_app : nil,
:app_frontend_url=> @part.widget_path, #@module_apps.first
:app_frontend_url=> @part.widget_path || "default_widget", #@module_apps.first
:category=>nil, #fetch by method: get_categories_and_tags
:tag=>nil, #fetch by method: get_categories_and_tags
:page_frontend_data_count=>nil,

View File

@ -121,7 +121,7 @@ include Admin::FrontendWidgetInterface
@index = params[:field_seri].to_i
@item = Page.find(params[:id]) rescue Page.new
@selected = {
:module_app=> (@item.module_app || ModuleApp.find(params[:module_app_id]) ),
:module_app=> (ModuleApp.find(params[:module_app_id]) || @item.module_app ),
:default_widget_field=>params[:widget_field_value]
}
# @choosen_field = params[:widget_field_value]
@ -160,7 +160,6 @@ include Admin::FrontendWidgetInterface
if @item.module_app && @item.module_app.key == 'page_content' && @item.page_contexts.blank?
@item.page_contexts.build(:create_user_id => current_user.id, :update_user_id => current_user.id )
end
if @item.update_attributes(params[:page])
flash[:notice] = t('update.success.page')
respond_to do |format|

View File

@ -21,15 +21,14 @@ protected
def clean_tags_and_category_params
field_name = set_field_name
if self.class==Admin::PagePartsController and params[field_name][:module_app].blank?
params[field_name][:module_app] = nil
end
if params[field_name][:tag].nil? || params[:page][:tag].include?("nil")
if params[field_name][:tag].nil? || params[field_name][:tag].include?("nil")
params[field_name][:tag] = []
end
if params[field_name][:category].nil? || params[:page][:category].include?("nil")
if params[field_name][:category].nil? || params[field_name][:category].include?("nil")
params[field_name][:category] = []
end
end #of clean_tags_and_category_params

View File

@ -33,7 +33,6 @@ module Admin::PagePartsHelper
unless field_is_checked.nil? and assign_field_name_value.nil?
origin_field = nil
origin_field = @selected[:module_app].widget_fields.select{|t| t.first.to_s==(assign_field_name_value || local_item.default_widget_field_name[i])}.first
if origin_field and origin_field[2]==:link #choosen_field_is_link

View File

@ -20,10 +20,17 @@ class ModuleApp
end
scope :for_frontend_select,where(:key.in => OrbitApp::Module::FrontendUtility.all.keys).excludes(widgets: nil).where(enable_frontend: true).order_by(:title, :asc)
scope :for_widget_select,where(:key.in=>OrbitApp::Module::WidgetUtility.all.keys).order_by(:title, :asc)
# scope :for_frontend_select,
scope :standard_sorting ,order_by(:title, :asc)
def self.for_widget_select
where(:key.in=>OrbitApp::Module::WidgetUtility.all.keys).order_by(:title, :asc)
end
def self.for_frontend_select
where(:key.in => OrbitApp::Module::FrontendUtility.all.keys).excludes(widgets: nil).where(enable_frontend: true).order_by(:title, :asc)
end
def enable_frontend?
self[:enable_frontend]
end

View File

@ -5,7 +5,6 @@
<% 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") %>

View File

@ -1,11 +1,11 @@
<% if @selected[:module_app]%>
$('#widget_list select').html("<%= j options_for_select(@selected[:module_app].widgets.collect{|k,v| [I18n.t(v['i18n']),k]},@part.widget_path) %>");
$('#widget_list select').html("<%= j options_for_select(@selected[:module_app].widgets.collect{|k,v| [I18n.t(v['i18n']),k]},@selected[:app_frontend_url]) %>");
$("#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' %>");
$('#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' %>");

View File

@ -16,10 +16,10 @@
<% end %>
<% if show_default_widget_setting_panel %>
$('#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=>@item} %>");
$('#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} %>");
$('#frontend_setting').html("<%= j render :partial => 'admin/page_parts/default_widget_style_panel',:locals=>{:object=>@item} %>");
$('#frontend_setting').append("<%= j render :partial => 'admin/page_parts/default_widget_setting',:locals=>{:object=>@item} %>");
<% else %>
$('#frontend_setting').html("<%= j render :partial => 'custom_frontend_setting' %>");
<% end %>