Complete new interface
This commit is contained in:
parent
16cfd27fe9
commit
e1e003af6e
|
@ -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 ;
|
||||
}
|
|
@ -26,6 +26,7 @@ class Admin::PagePartsController < ApplicationController
|
|||
@part = PagePart.find(params[:id])
|
||||
@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]
|
||||
@user_choose = @part.widget_path
|
||||
@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
|
||||
|
||||
|
@ -41,6 +42,7 @@ class Admin::PagePartsController < ApplicationController
|
|||
@tags = AnnouncementTag.all
|
||||
when 'gallery'
|
||||
@albums = GalleryAlbum.all
|
||||
@tags = []
|
||||
when 'web_resource'
|
||||
@categories = WebLinkCategory.all
|
||||
@tags = WebResourceTag.all
|
||||
|
@ -103,6 +105,7 @@ class Admin::PagePartsController < ApplicationController
|
|||
@tags = AnnouncementTag.all
|
||||
when 'gallery'
|
||||
@albums = GalleryAlbum.all
|
||||
@tags = []
|
||||
when 'web_resource'
|
||||
@categories = WebLinkCategory.all
|
||||
@tags = WebResourceTag.all
|
||||
|
@ -119,9 +122,10 @@ 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]]
|
||||
|
||||
|
||||
respond_to do |format|
|
||||
format.js {}
|
||||
end
|
||||
|
|
|
@ -27,7 +27,7 @@ module Admin::PagePartsHelper
|
|||
|
||||
|
||||
def category_checked_value(part,radio_value)
|
||||
part and (part[:tag] == radio_value) ? true : false
|
||||
part and (part[:category] == radio_value) ? true : false
|
||||
end
|
||||
|
||||
def style_checked_value(part,radio_value)
|
||||
|
@ -36,17 +36,21 @@ module Admin::PagePartsHelper
|
|||
|
||||
def nil_radio_button(part,tag_or_cate)
|
||||
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")
|
||||
end
|
||||
end
|
||||
|
||||
def show_default_widget_setting_panel
|
||||
binding.pry
|
||||
false
|
||||
if @module_app.has_default_widget? && (!@user_choose.nil? && @user_choose== 'default_widget') #&& @part.widget_path == 'default_widget'
|
||||
true
|
||||
else
|
||||
false
|
||||
end
|
||||
end
|
||||
|
||||
def show_custom_widget_setting_panel
|
||||
true
|
||||
end
|
||||
|
||||
end
|
|
@ -91,6 +91,16 @@ class ModuleApp
|
|||
end
|
||||
end
|
||||
|
||||
def has_default_widget?
|
||||
case self[:widgets]
|
||||
when Array
|
||||
false
|
||||
when Hash
|
||||
self[:widgets].has_key? 'default_widget'
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
protected
|
||||
|
||||
def set_key
|
||||
|
|
|
@ -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>
|
|
@ -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| %>
|
||||
<%= i+1 %>
|
||||
<%= select_tag "page_part[widget_field][]", widget_field_options(i), :include_blank => true %>
|
||||
<%= select_tag "page_part[widget_field_type][]", widget_fiield_type_options(i), :include_blank => true %> <br />
|
||||
<div class="rows clear">
|
||||
<span class="span4">
|
||||
<%= 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 %>
|
||||
<br/><br/>
|
||||
|
||||
<%= label_tag t("default_widget.widget_data_count") %>
|
||||
<%= text_field_tag :widget_data_count,@part.widget_data_count %>
|
||||
|
||||
<br>
|
||||
|
||||
</span>
|
||||
<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 :widget_data_count,@part.widget_data_count %></span>
|
||||
</div>
|
||||
</div>
|
||||
|
|
|
@ -1,9 +1,9 @@
|
|||
<label><%= t("default_widget.select_widget_style") %></label>
|
||||
<div class="style_switch well">
|
||||
<label><%= t("default_widget.select_widget_style") %></label>
|
||||
<ul class="clear">
|
||||
<li>
|
||||
<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
|
||||
</label>
|
||||
<span class="style_img"><%=image_tag 'module/default_widgets/style01.png'%></span>
|
||||
|
@ -11,7 +11,7 @@
|
|||
</li>
|
||||
<li>
|
||||
<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
|
||||
</label>
|
||||
<span class="style_img"><%=image_tag 'module/default_widgets/style02.png'%></span>
|
||||
|
@ -19,7 +19,7 @@
|
|||
</li>
|
||||
<li>
|
||||
<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
|
||||
</label>
|
||||
<span class="style_img"><%=image_tag 'module/default_widgets/style03.png'%></span>
|
||||
|
@ -27,7 +27,7 @@
|
|||
</li>
|
||||
<li>
|
||||
<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
|
||||
</label>
|
||||
<span class="style_img"><%=image_tag 'module/default_widgets/style04.png'%></span>
|
||||
|
@ -35,7 +35,7 @@
|
|||
</li>
|
||||
<li>
|
||||
<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
|
||||
</label>
|
||||
<span class="style_img"><%=image_tag 'module/default_widgets/style05.png'%></span>
|
||||
|
|
|
@ -1,3 +1,5 @@
|
|||
<%= stylesheet_link_tag "admin/default_widget_setting" %>
|
||||
|
||||
<%= form_for @part, :url => admin_page_part_path(@part) do |f| %>
|
||||
|
||||
<% LIST[:page_part_kinds].each do |kind| %>
|
||||
|
|
|
@ -32,7 +32,7 @@
|
|||
</div>
|
||||
|
||||
<div id="widget_setting">
|
||||
<%= render :partial => 'widget_setting' %>
|
||||
<%= render :partial => 'widget_setting' ,:locals=>{:f=>f} %>
|
||||
</div>
|
||||
<!-- <span id="widget_options">
|
||||
|
||||
|
|
|
@ -1,12 +1,12 @@
|
|||
<label><%= t "default_widget.data_source.tag" %></label>
|
||||
<% if @categories %>
|
||||
<fieldset>
|
||||
<%= nil_radio_button(@part,: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) )%>
|
||||
<%= category.title%>
|
||||
<% end %>
|
||||
</fieldset>
|
||||
<% else %>
|
||||
<%= t("default_widget.no_support_setting")%>
|
||||
<% end %>
|
||||
<label><%= t "default_widget.data_source.tag" %></label>
|
||||
<% if @categories %>
|
||||
<fieldset>
|
||||
<%= nil_radio_button(@part,: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) )%>
|
||||
<%= category.title%>
|
||||
<% end %>
|
||||
</fieldset>
|
||||
<% else %>
|
||||
<%= t("default_widget.no_support_setting")%>
|
||||
<% end %>
|
|
@ -1,12 +1,12 @@
|
|||
<label><%= t "default_widget.data_source.category" %></label>
|
||||
<% if @categories %>
|
||||
<fieldset>
|
||||
<%= nil_radio_button(@part,: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) )%>
|
||||
<%= tag[I18n.locale]%>
|
||||
<% end %>
|
||||
</fieldset>
|
||||
<% else %>
|
||||
<%= t("default_widget.no_support_setting")%>
|
||||
<% end %>
|
||||
<% if @categories %>
|
||||
<fieldset>
|
||||
<%= nil_radio_button(@part,: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) )%>
|
||||
<%= tag[I18n.locale]%>
|
||||
<% end %>
|
||||
</fieldset>
|
||||
<% else %>
|
||||
<%= t("default_widget.no_support_setting")%>
|
||||
<% end %>
|
|
@ -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 %>
|
||||
|
|
@ -3,5 +3,8 @@
|
|||
<%= render :partial => 'default_widget_style_panel',:locals=>{:f=>f} %>
|
||||
<%= render :partial => 'default_widget_setting' %>
|
||||
</div>
|
||||
<% elsif show_custom_widget_setting_panel %>
|
||||
<% elsif show_custom_widget_setting_panel %>
|
||||
<div id="custom_widget">
|
||||
<%= render :partial => 'custom_widget_setting' %>
|
||||
</div>
|
||||
<% end %>
|
||||
|
|
|
@ -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 %>
|
||||
|
|
|
@ -1,7 +1,13 @@
|
|||
$('#widget_list select').html("<%= j options_for_select(@module_app.widgets.collect{|k,v| k}) %>");
|
||||
$('#widget_style_list').html("<%= escape_javascript(select 'page_part', 'widget_style', @module_app.widgets[@widget_path]) if !@widget_path.blank? %>");
|
||||
$('#widget_field').html("<%= j render 'widget_fields' %>");
|
||||
$('#widget_category').html("<%= j render 'widget_categories' %>");
|
||||
$('#widget_tag').html("<%= j render 'widget_tags' %>");
|
||||
$('#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' %>");
|
||||
|
||||
<% 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'%>");
|
|
@ -154,10 +154,12 @@ zh_tw:
|
|||
no_support_setting: 沒有可以使用的設定
|
||||
no_value: 不設定(全部)
|
||||
fields_order: 輸出欄位順序
|
||||
fields_style: 輸出欄位樣式
|
||||
select_module_app: 外掛模組選擇
|
||||
select_widget_path: 外掛樣版選擇
|
||||
select_widget_style: 排版樣式
|
||||
widget_data_count: 模組輸出則數
|
||||
select_widget_ext_option: 模組延伸選項
|
||||
caption:
|
||||
typeA: 表格式排版,簡單明瞭呈現內容
|
||||
typeB_style2: 一圖一文式,輸出欄位水平排列
|
||||
|
|
|
@ -390,4 +390,19 @@ namespace :migrate do
|
|||
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
|
||||
|
|
Reference in New Issue