diff --git a/app/assets/images/module/default_widgets/style01.png b/app/assets/images/module/default_widgets/style01.png new file mode 100755 index 00000000..ff8c4cd6 Binary files /dev/null and b/app/assets/images/module/default_widgets/style01.png differ diff --git a/app/assets/images/module/default_widgets/style02.png b/app/assets/images/module/default_widgets/style02.png new file mode 100755 index 00000000..1eb8f85a Binary files /dev/null and b/app/assets/images/module/default_widgets/style02.png differ diff --git a/app/assets/images/module/default_widgets/style03.png b/app/assets/images/module/default_widgets/style03.png new file mode 100755 index 00000000..5620f2ba Binary files /dev/null and b/app/assets/images/module/default_widgets/style03.png differ diff --git a/app/assets/images/module/default_widgets/style04.png b/app/assets/images/module/default_widgets/style04.png new file mode 100755 index 00000000..1ea44651 Binary files /dev/null and b/app/assets/images/module/default_widgets/style04.png differ diff --git a/app/assets/images/module/default_widgets/style05.png b/app/assets/images/module/default_widgets/style05.png new file mode 100755 index 00000000..bcb38f25 Binary files /dev/null and b/app/assets/images/module/default_widgets/style05.png differ diff --git a/app/helpers/admin/page_parts_helper.rb b/app/helpers/admin/page_parts_helper.rb index 3d71b9bb..0914939b 100644 --- a/app/helpers/admin/page_parts_helper.rb +++ b/app/helpers/admin/page_parts_helper.rb @@ -21,7 +21,32 @@ module Admin::PagePartsHelper 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 + def tag_checked_value(part,radio_value) + part and (part[:tag] == radio_value) ? true : false + end + def category_checked_value(part,radio_value) + part and (part[:tag] == radio_value) ? true : false + end + + def style_checked_value(part,radio_value) + part and (part.widget_style == radio_value) ? true : false + end + + 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 << I18n.t("default_widget.no_value") + end + end + + def show_default_widget_setting_panel + binding.pry + false + end + + def show_custom_widget_setting_panel + end end \ No newline at end of file diff --git a/app/views/admin/page_parts/_default_widget_setting.html.erb b/app/views/admin/page_parts/_default_widget_setting.html.erb new file mode 100644 index 00000000..5f001851 --- /dev/null +++ b/app/views/admin/page_parts/_default_widget_setting.html.erb @@ -0,0 +1,18 @@ + + + + + +<% @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 %>
+<% end %> +

+ + <%= label_tag t("default_widget.widget_data_count") %> + <%= text_field_tag :widget_data_count,@part.widget_data_count %> + +
+ +
diff --git a/app/views/admin/page_parts/_default_widget_style_panel.html.erb b/app/views/admin/page_parts/_default_widget_style_panel.html.erb new file mode 100644 index 00000000..b6a60139 --- /dev/null +++ b/app/views/admin/page_parts/_default_widget_style_panel.html.erb @@ -0,0 +1,45 @@ + +
+ +
\ No newline at end of file diff --git a/app/views/admin/page_parts/_module_widget.html.erb b/app/views/admin/page_parts/_module_widget.html.erb index a1cec8d0..77590997 100644 --- a/app/views/admin/page_parts/_module_widget.html.erb +++ b/app/views/admin/page_parts/_module_widget.html.erb @@ -1,51 +1,41 @@ -
- <%= f.fields_for :title_translations do |f| %> - <% @site_valid_locales.each do |locale| %> -

- <%= f.label :locale, "#{t(:title)} #{I18nVariable.from_locale(locale)}" %> - <%= f.text_field locale, :value => (@part.title_translations[locale] rescue nil) %> -

- <% end %> -<% end %> -
+
+
+ <%= f.fields_for :title_translations do |f| %> + <% @site_valid_locales.each do |locale| %> +

+ <%= f.label :locale, "#{t(:title)} #{I18nVariable.from_locale(locale)}" %> + <%= f.text_field locale, :value => (@part.title_translations[locale] rescue nil),:size=>30 %> +

+ <% end %> + <% end %> +
- - <%= 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} %> +

+ +

+ + <%= f.select :widget_path, @module_app.widgets.collect{|k,v| [k.humanize, k]}, {}, { :selected => @part.widget_path, :rel => admin_page_parts_path } %> +

- - <%#= f.select :widget_path, @module_app.widgets.collect{|widget| [widget.humanize, widget]}, :selected => @part.widget_path %> - <%= f.select :widget_path, @module_app.widgets.collect{|k,v| [k.humanize, k]}, {}, { :selected => @part.widget_path, :rel => admin_page_parts_path } %> - +
+
+ <%= render :partial => 'widget_data_source_category' %> +
+
+ <%= render :partial => 'widget_data_source_tag' %> +
- - <%#= f.select :widget_style, @widget_style, :selected => @part.widget_style %> - <%= select('page_part','widget_style', @widget_style, :selected => @part[:widget_style], :include_blank => true ) rescue ''%> - + +
-: +
+ <%= render :partial => 'widget_setting' %> +
+ - - - <%= render 'widget_fields' %> - - <%#= f.label :widget_field %> - <%# @module_app.widget_fields.each_with_index do |widget_field, i| %> - <%#= i+1 %> - <%#= select_tag "page_part[widget_field][]", options_for_select(@module_app.widget_fields.collect{|widget_field| [widget_field.humanize, widget_field]}, (@part.widget_field ? @part.widget_field[i] : nil) ), :include_blank => true %>
- <%# end %> - - <%#= select_tag "page_part[widget_field][]", options_for_select(@module_app.widget_fields.collect{|widget_field| [widget_field.humanize, widget_field]}, @part.widget_field.collect{|widget_field| widget_field}), {:multiple => :multiple, :size => 6} %> -
- - - <%= render 'widget_options' %> - +
\ No newline at end of file diff --git a/app/views/admin/page_parts/_widget_data_source_category.html.erb b/app/views/admin/page_parts/_widget_data_source_category.html.erb new file mode 100644 index 00000000..15cec6c2 --- /dev/null +++ b/app/views/admin/page_parts/_widget_data_source_category.html.erb @@ -0,0 +1,12 @@ + +<% if @categories %> +
+ <%= 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 %> +
+<% else %> + <%= t("default_widget.no_support_setting")%> +<% end %> \ No newline at end of file diff --git a/app/views/admin/page_parts/_widget_data_source_tag.html.erb b/app/views/admin/page_parts/_widget_data_source_tag.html.erb new file mode 100644 index 00000000..c54657ec --- /dev/null +++ b/app/views/admin/page_parts/_widget_data_source_tag.html.erb @@ -0,0 +1,12 @@ + +<% if @categories %> +
+ <%= 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 %> +
+<% else %> + <%= t("default_widget.no_support_setting")%> +<% end %> \ No newline at end of file diff --git a/app/views/admin/page_parts/_widget_setting.html.erb b/app/views/admin/page_parts/_widget_setting.html.erb new file mode 100644 index 00000000..75ac6a50 --- /dev/null +++ b/app/views/admin/page_parts/_widget_setting.html.erb @@ -0,0 +1,7 @@ +<% if show_default_widget_setting_panel %> +
+ <%= render :partial => 'default_widget_style_panel',:locals=>{:f=>f} %> + <%= render :partial => 'default_widget_setting' %> +
+<% elsif show_custom_widget_setting_panel %> +<% end %> diff --git a/app/views/admin/page_parts/_widget_categories.html.erb b/app/views/admin/page_parts/old_partials/_widget_categories.html.erb similarity index 100% rename from app/views/admin/page_parts/_widget_categories.html.erb rename to app/views/admin/page_parts/old_partials/_widget_categories.html.erb diff --git a/app/views/admin/page_parts/_widget_fields.html.erb b/app/views/admin/page_parts/old_partials/_widget_fields.html.erb similarity index 100% rename from app/views/admin/page_parts/_widget_fields.html.erb rename to app/views/admin/page_parts/old_partials/_widget_fields.html.erb diff --git a/app/views/admin/page_parts/_widget_options.html.erb b/app/views/admin/page_parts/old_partials/_widget_options.html.erb similarity index 100% rename from app/views/admin/page_parts/_widget_options.html.erb rename to app/views/admin/page_parts/old_partials/_widget_options.html.erb diff --git a/app/views/admin/page_parts/_widget_tags.html.erb b/app/views/admin/page_parts/old_partials/_widget_tags.html.erb similarity index 100% rename from app/views/admin/page_parts/_widget_tags.html.erb rename to app/views/admin/page_parts/old_partials/_widget_tags.html.erb diff --git a/config/locales/zh_tw.yml b/config/locales/zh_tw.yml index 9de7cc63..2ed3225e 100644 --- a/config/locales/zh_tw.yml +++ b/config/locales/zh_tw.yml @@ -150,6 +150,23 @@ zh_tw: deadline: 最後期限 default: Default default_css: 預設樣式表 + default_widget: + no_support_setting: 沒有可以使用的設定 + no_value: 不設定(全部) + fields_order: 輸出欄位順序 + select_module_app: 外掛模組選擇 + select_widget_path: 外掛樣版選擇 + select_widget_style: 排版樣式 + widget_data_count: 模組輸出則數 + caption: + typeA: 表格式排版,簡單明瞭呈現內容 + typeB_style2: 一圖一文式,輸出欄位水平排列 + typeB_style3: 一圖一文式,輸出欄位垂直排列,圖片在左方 + typeB_style4: 一圖一文式,輸出欄位垂直排列,圖片在右方 + typeC: 一圖多文式,輸出欄位垂直排列 + data_source: + category: 資料來源:類別 + tag: 資料來源:標籤 delete: file: 刪除檔案 success: @@ -407,3 +424,4 @@ zh_tw: visitors_this_year: 今年造訪人次 visitors_today: 今日造訪人次 yes_: "是" +