Complete new interface

This commit is contained in:
Fu Matthew 2013-01-14 18:49:23 +08:00
parent ca51ebc08c
commit 46b1d55ff6
17 changed files with 178 additions and 57 deletions

View File

@ -0,0 +1,27 @@
.style_switch{}
.style_switch ul{}
.style_switch li{
float: left;
list-style: none outside none;
margin: 0 30px 0 0;
width: 103px;
}
.style_radio{
margin: 0 0 5px 10px;
}
.style_img{
display: block;
margin: 0 0 5px;
}
.style_description{
color: #6B6B6B;
display: block;
margin: 0 0 0 5px;
}
label{
   white-space: nowrap !important ;
}

View File

@ -26,6 +26,7 @@ class Admin::PagePartsController < ApplicationController
@part = PagePart.find(params[:id]) @part = PagePart.find(params[:id])
@module_apps = ModuleApp.excludes(widgets: nil).where(enable_frontend: true).order_by(:title, :asc) @module_apps = ModuleApp.excludes(widgets: nil).where(enable_frontend: true).order_by(:title, :asc)
@module_app = @part.module_app ? @part.module_app : @module_apps[0] @module_app = @part.module_app ? @part.module_app : @module_apps[0]
@user_choose = @part.widget_path
@r_tag = @part.public_r_tag.blank? ? LIST[:public_r_tags][0] : @part.public_r_tag @r_tag = @part.public_r_tag.blank? ? LIST[:public_r_tags][0] : @part.public_r_tag
@tag_objects = @r_tag.classify.constantize.all rescue nil @tag_objects = @r_tag.classify.constantize.all rescue nil
@ -41,6 +42,7 @@ class Admin::PagePartsController < ApplicationController
@tags = AnnouncementTag.all @tags = AnnouncementTag.all
when 'gallery' when 'gallery'
@albums = GalleryAlbum.all @albums = GalleryAlbum.all
@tags = []
when 'web_resource' when 'web_resource'
@categories = WebLinkCategory.all @categories = WebLinkCategory.all
@tags = WebResourceTag.all @tags = WebResourceTag.all
@ -103,6 +105,7 @@ class Admin::PagePartsController < ApplicationController
@tags = AnnouncementTag.all @tags = AnnouncementTag.all
when 'gallery' when 'gallery'
@albums = GalleryAlbum.all @albums = GalleryAlbum.all
@tags = []
when 'web_resource' when 'web_resource'
@categories = WebLinkCategory.all @categories = WebLinkCategory.all
@tags = WebResourceTag.all @tags = WebResourceTag.all
@ -119,7 +122,8 @@ class Admin::PagePartsController < ApplicationController
def reload_widget_styles def reload_widget_styles
@module_app = ModuleApp.find(params[:module_app_id]) @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]] @widget_style = @module_app.widgets[params[:id]]
respond_to do |format| respond_to do |format|

View File

@ -27,7 +27,7 @@ module Admin::PagePartsHelper
def category_checked_value(part,radio_value) def category_checked_value(part,radio_value)
part and (part[:tag] == radio_value) ? true : false part and (part[:category] == radio_value) ? true : false
end end
def style_checked_value(part,radio_value) def style_checked_value(part,radio_value)
@ -36,17 +36,21 @@ module Admin::PagePartsHelper
def nil_radio_button(part,tag_or_cate) def nil_radio_button(part,tag_or_cate)
content_tag :label,:class=>"radio inline" do content_tag :label,:class=>"radio inline" do
op = radio_button("page_part", tag_or_cate, nil, :checked => eval("#{tag_or_cate}_checked_value(part,nil)")) op = radio_button("page_part", tag_or_cate, '' , :checked => eval("#{tag_or_cate}_checked_value(part,'')"))
op << I18n.t("default_widget.no_value") op << I18n.t("default_widget.no_value")
end end
end end
def show_default_widget_setting_panel def show_default_widget_setting_panel
binding.pry if @module_app.has_default_widget? && (!@user_choose.nil? && @user_choose== 'default_widget') #&& @part.widget_path == 'default_widget'
false true
else
false
end
end end
def show_custom_widget_setting_panel def show_custom_widget_setting_panel
true
end end
end end

View File

@ -91,6 +91,16 @@ class ModuleApp
end end
end end
def has_default_widget?
case self[:widgets]
when Array
false
when Hash
self[:widgets].has_key? 'default_widget'
end
end
protected protected
def set_key def set_key

View File

@ -0,0 +1,12 @@
<div class="style_switch well">
<label><%= t("default_widget.select_widget_style") %></label>
<% if @module_app.widgets[@widget_path].blank? %>
<%= t("default_widget.no_support_setting")%>
<%else%>
<%= select('page_part', 'widget_style', @module_app.widgets[@widget_path]) %>
<% end %>
<% if(@module_app.widget_options && @module_app.widget_options.has_key?(@widget_path)) %>
<label><%= t("default_widget.select_widget_ext_option") %></label>
<%= render :partial=> "widget_ext_options" %>
<% end %>
</div>

View File

@ -1,18 +1,34 @@
<span id="widget_field"> <div id="widget_field" class="well clear">
<label for="widget_field"><%= t "default_widget.fields_order" %></label> <div class="rows clear">
<span class="span4">
<label for="widget_field"><%= t "default_widget.fields_order" %></label>
</span>
<span class="span3">
<label for="widget_field"><%= t "default_widget.fields_style" %></label>
</span>
<span class="span5"></span>
</div>
<% @module_app.widget_fields.each_with_index do |widget_field, i| %> <% @module_app.widget_fields.each_with_index do |widget_field, i| %>
<%= i+1 %> <div class="rows clear">
<%= select_tag "page_part[widget_field][]", widget_field_options(i), :include_blank => true %> <span class="span4">
<%= select_tag "page_part[widget_field_type][]", widget_fiield_type_options(i), :include_blank => true %> <br /> <%= i+1 %>
<%= select_tag "page_part[widget_field][]", 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 />
</span>
<span class="span5"></span>
</div>
<% end %> <% end %>
<br/><br/> <br/>
<div class="rows clear">
<%= label_tag t("default_widget.widget_data_count") %> <span class="span4"><%= label_tag t("default_widget.widget_data_count") %></span>
<%= text_field_tag :widget_data_count,@part.widget_data_count %> </div>
<div class="rows clear">
<br> <span class="span4"><%= text_field_tag :widget_data_count,@part.widget_data_count %></span>
</div>
</span> </div>

View File

@ -1,9 +1,9 @@
<label><%= t("default_widget.select_widget_style") %></label>
<div class="style_switch well"> <div class="style_switch well">
<label><%= t("default_widget.select_widget_style") %></label>
<ul class="clear"> <ul class="clear">
<li> <li>
<label class="radio style_radio"> <label class="radio style_radio">
<%= f.radio_button :widget_style,"typeA",:checked => style_checked_value(@part,"typeA") %> <%= radio_button_tag :widget_style,"typeA",:checked => style_checked_value(@part,"typeA") %>
1 1
</label> </label>
<span class="style_img"><%=image_tag 'module/default_widgets/style01.png'%></span> <span class="style_img"><%=image_tag 'module/default_widgets/style01.png'%></span>
@ -11,7 +11,7 @@
</li> </li>
<li> <li>
<label class="radio style_radio"> <label class="radio style_radio">
<%= f.radio_button :widget_style,"typeB_style2",:checked => style_checked_value(@part,"typeB_style2") %> <%= radio_button_tag :widget_style,"typeB_style2",:checked => style_checked_value(@part,"typeB_style2") %>
2 2
</label> </label>
<span class="style_img"><%=image_tag 'module/default_widgets/style02.png'%></span> <span class="style_img"><%=image_tag 'module/default_widgets/style02.png'%></span>
@ -19,7 +19,7 @@
</li> </li>
<li> <li>
<label class="radio style_radio"> <label class="radio style_radio">
<%= f.radio_button :widget_style,"typeB_style3",:checked => style_checked_value(@part,"typeB_style3") %> <%= radio_button_tag :widget_style,"typeB_style3",:checked => style_checked_value(@part,"typeB_style3") %>
3 3
</label> </label>
<span class="style_img"><%=image_tag 'module/default_widgets/style03.png'%></span> <span class="style_img"><%=image_tag 'module/default_widgets/style03.png'%></span>
@ -27,7 +27,7 @@
</li> </li>
<li> <li>
<label class="radio style_radio"> <label class="radio style_radio">
<%= f.radio_button :widget_style,"typeB_style4",:checked => style_checked_value(@part,"typeB_style4") %> <%= radio_button_tag :widget_style,"typeB_style4",:checked => style_checked_value(@part,"typeB_style4") %>
4 4
</label> </label>
<span class="style_img"><%=image_tag 'module/default_widgets/style04.png'%></span> <span class="style_img"><%=image_tag 'module/default_widgets/style04.png'%></span>
@ -35,7 +35,7 @@
</li> </li>
<li> <li>
<label class="radio style_radio"> <label class="radio style_radio">
<%= f.radio_button :widget_style,"typeC",:checked => style_checked_value(@part,"typeC") %> <%= radio_button_tag :widget_style,"typeC",:checked => style_checked_value(@part,"typeC") %>
5 5
</label> </label>
<span class="style_img"><%=image_tag 'module/default_widgets/style05.png'%></span> <span class="style_img"><%=image_tag 'module/default_widgets/style05.png'%></span>

View File

@ -1,3 +1,5 @@
<%= stylesheet_link_tag "admin/default_widget_setting" %>
<%= form_for @part, :url => admin_page_part_path(@part) do |f| %> <%= form_for @part, :url => admin_page_part_path(@part) do |f| %>
<% LIST[:page_part_kinds].each do |kind| %> <% LIST[:page_part_kinds].each do |kind| %>

View File

@ -32,7 +32,7 @@
</div> </div>
<div id="widget_setting"> <div id="widget_setting">
<%= render :partial => 'widget_setting' %> <%= render :partial => 'widget_setting' ,:locals=>{:f=>f} %>
</div> </div>
<!-- <span id="widget_options"> <!-- <span id="widget_options">

View File

@ -1,12 +1,12 @@
<label><%= t "default_widget.data_source.tag" %></label> <label><%= t "default_widget.data_source.tag" %></label>
<% if @categories %> <% if @categories %>
<fieldset> <fieldset>
<%= nil_radio_button(@part,:category) %> <%= nil_radio_button(@part,:category) %>
<%= content_tag_for(:label, @categories,:class=>"radio inline") do |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("page_part", "category", category.id, :checked => category_checked_value(@part,category.id) )%>
<%= category.title%> <%= category.title%>
<% end %> <% end %>
</fieldset> </fieldset>
<% else %> <% else %>
<%= t("default_widget.no_support_setting")%> <%= t("default_widget.no_support_setting")%>
<% end %> <% end %>

View File

@ -1,12 +1,12 @@
<label><%= t "default_widget.data_source.category" %></label> <label><%= t "default_widget.data_source.category" %></label>
<% if @categories %> <% if @categories %>
<fieldset> <fieldset>
<%= nil_radio_button(@part,:tag) %> <%= nil_radio_button(@part,:tag) %>
<%= content_tag_for(:label, @tags,:class=>"radio inline") do |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("page_part", "tag", tag.id, :checked => tag_checked_value(@part,tag.id) )%>
<%= tag[I18n.locale]%> <%= tag[I18n.locale]%>
<% end %> <% end %>
</fieldset> </fieldset>
<% else %> <% else %>
<%= t("default_widget.no_support_setting")%> <%= t("default_widget.no_support_setting")%>
<% end %> <% end %>

View File

@ -0,0 +1,13 @@
<% @module_app.widget_options[@widget_path].each do |key,options| %>
<%= label_tag(t(@module_app.widget_options_fields_i18n[@widget_path][key]))%>
<% case options%>
<% when Hash%>
<%= select_tag "page_part[widget_options][#{key}]", options_from_collection_for_select(eval(options["query"]), options["value"], options["label"].to_s, :selected => (@part.widget_options[key] rescue nil)) %>
<% else%>
<%= select_tag "page_part[widget_options][#{key}]", options_for_select(options,(@part.widget_options[key] rescue nil)) %>
<!-- (@part[:widget_field][i][0] if (@part && !@part[:widget_field].blank? && !@part[:widget_field][i].blank?)) ) -->
<% end %>
<% end %>

View File

@ -4,4 +4,7 @@
<%= render :partial => 'default_widget_setting' %> <%= render :partial => 'default_widget_setting' %>
</div> </div>
<% elsif show_custom_widget_setting_panel %> <% elsif show_custom_widget_setting_panel %>
<div id="custom_widget">
<%= render :partial => 'custom_widget_setting' %>
</div>
<% end %> <% end %>

View File

@ -1 +1,8 @@
$('#widget_style_list select').html("<%= j options_for_select(@module_app.widgets[params[:id]]) %>") <% 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' %>");
<% elsif show_custom_widget_setting_panel %>
$('#widget_setting').html("<%= j render :partial => 'custom_widget_setting' %>");
<% end %>
<% end %>

View File

@ -1,7 +1,13 @@
$('#widget_list select').html("<%= j options_for_select(@module_app.widgets.collect{|k,v| k}) %>"); $('#widget_list select').html("<%= j options_for_select(@module_app.widgets.collect{|k,v| k},@part.widget_path) %>");
$('#widget_style_list').html("<%= escape_javascript(select 'page_part', 'widget_style', @module_app.widgets[@widget_path]) if !@widget_path.blank? %>"); $("#widget_data_source_category").html("<%= j render :partial => 'widget_data_source_category' %>");
$('#widget_field').html("<%= j render 'widget_fields' %>"); $("#widget_data_source_tag").html("<%= j render :partial => 'widget_data_source_tag' %>");
$('#widget_category').html("<%= j render 'widget_categories' %>");
$('#widget_tag').html("<%= j render 'widget_tags' %>"); <% 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' %>");
<% elsif show_custom_widget_setting_panel %>
$('#widget_setting').html("<%= j render :partial => 'custom_widget_setting' %>");
<% end %>
<% end %>
$("#widget_options").html("<%= j render 'widget_options'%>");

View File

@ -154,10 +154,12 @@ zh_tw:
no_support_setting: 沒有可以使用的設定 no_support_setting: 沒有可以使用的設定
no_value: 不設定(全部) no_value: 不設定(全部)
fields_order: 輸出欄位順序 fields_order: 輸出欄位順序
fields_style: 輸出欄位樣式
select_module_app: 外掛模組選擇 select_module_app: 外掛模組選擇
select_widget_path: 外掛樣版選擇 select_widget_path: 外掛樣版選擇
select_widget_style: 排版樣式 select_widget_style: 排版樣式
widget_data_count: 模組輸出則數 widget_data_count: 模組輸出則數
select_widget_ext_option: 模組延伸選項
caption: caption:
typeA: 表格式排版,簡單明瞭呈現內容 typeA: 表格式排版,簡單明瞭呈現內容
typeB_style2: 一圖一文式,輸出欄位水平排列 typeB_style2: 一圖一文式,輸出欄位水平排列

View File

@ -390,4 +390,19 @@ namespace :migrate do
end end
task :correct_gallery_and_web_resoure_config => :environment do
a = ModuleApp.where(:key=>'web_resource').first
a.widgets = {}
a.widgets[:web_links] = []
a.widgets[:home_list] = []
a.save
a = ModuleApp.where(:key=>'gallery').first
a.widgets = {}
a.widgets[:widget1] = []
a.widget_options_fields_i18n = {"widget1"=>{"vertical"=>"gallery.widget_option.vertical", "horizontal"=>"gallery.widget_option.horizontal", "album_id"=>"gallery.widget_option.album"}}
a.widget_options = {"widget1"=>{"vertical"=>[1, 2], "horizontal"=>[1, 2, 3, 4, 5, 6], "album_id"=>{"query"=>"GalleryAlbum.all", "value"=>:id, "label"=>:name}}}
a.save
end
end end