From ca51ebc08c9d9e16427f494b86e6427e117de0d1 Mon Sep 17 00:00:00 2001 From: Fu Matthew Date: Thu, 10 Jan 2013 18:00:58 +0800 Subject: [PATCH 1/2] apply view --- .../images/module/default_widgets/style01.png | Bin 0 -> 1825 bytes .../images/module/default_widgets/style02.png | Bin 0 -> 2187 bytes .../images/module/default_widgets/style03.png | Bin 0 -> 2183 bytes .../images/module/default_widgets/style04.png | Bin 0 -> 2154 bytes .../images/module/default_widgets/style05.png | Bin 0 -> 2142 bytes app/helpers/admin/page_parts_helper.rb | 25 ++++++ .../_default_widget_setting.html.erb | 18 ++++ .../_default_widget_style_panel.html.erb | 45 ++++++++++ .../admin/page_parts/_module_widget.html.erb | 80 ++++++++---------- .../_widget_data_source_category.html.erb | 12 +++ .../_widget_data_source_tag.html.erb | 12 +++ .../admin/page_parts/_widget_setting.html.erb | 7 ++ .../_widget_categories.html.erb | 0 .../_widget_fields.html.erb | 0 .../_widget_options.html.erb | 0 .../{ => old_partials}/_widget_tags.html.erb | 0 config/locales/zh_tw.yml | 18 ++++ 17 files changed, 172 insertions(+), 45 deletions(-) create mode 100755 app/assets/images/module/default_widgets/style01.png create mode 100755 app/assets/images/module/default_widgets/style02.png create mode 100755 app/assets/images/module/default_widgets/style03.png create mode 100755 app/assets/images/module/default_widgets/style04.png create mode 100755 app/assets/images/module/default_widgets/style05.png create mode 100644 app/views/admin/page_parts/_default_widget_setting.html.erb create mode 100644 app/views/admin/page_parts/_default_widget_style_panel.html.erb create mode 100644 app/views/admin/page_parts/_widget_data_source_category.html.erb create mode 100644 app/views/admin/page_parts/_widget_data_source_tag.html.erb create mode 100644 app/views/admin/page_parts/_widget_setting.html.erb rename app/views/admin/page_parts/{ => old_partials}/_widget_categories.html.erb (100%) rename app/views/admin/page_parts/{ => old_partials}/_widget_fields.html.erb (100%) rename app/views/admin/page_parts/{ => old_partials}/_widget_options.html.erb (100%) rename app/views/admin/page_parts/{ => old_partials}/_widget_tags.html.erb (100%) 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 0000000000000000000000000000000000000000..ff8c4cd6ec47550698c6e5c355de8d26c8bfde03 GIT binary patch literal 1825 zcmaJ?3s4hR6b<5Fr9cO@N*UB`02PIVgpinp03iVhV~~bGP!J8th6G49O%{Sti!Ba; zqC~A=fuVi|MM|++WB|iw3ZlqIN(DrVS``C@5(W_vhEF#L=uAs@cK7|xIrqMI&(5X? z2ko*nw>8ILFqW(UCI@X}jL%1A=zAkQauRJmL;S*#5Lkq$_zDO^7sAmHz>@M~AP&SA z9{Tbg z5G0O>m6UkZu9AW%uZ zR3>GS%Y+39Qb>j@a)s}?lx4X_D@f&NWG1ALBtk-e1uO;Tw+u>_&xN$C-U3&+d@khK>Komg` z(!=&e`&xWTKx$0Vt5Ph>R=@B^9+^)UDU=OzWz}6 zty}5+6AcrNg*J9J(?{>mD4n;so)5_av%u3}HhA_i@l-aiXjjqcj_Qt*4$`2e^Rk-r zaZ%dT>wVov1|<#1W#1Lf1-^L`-YcKpu;TGJF@}tj{`CmB@j-0a?$Spj4-XFuj#Exs zpU87l-gCKlYNjS<_m){F3a2me?csBA4`WNhGR#uwHzRTOZ$Z+Y*3i*0!=*tssFp}d}YG3ylDpSL{Dk~50hKEb=#W_t7)ojFEgEHtzM^A{GikB#h*)X zKK`P;ry5EO<;8gyeAQ6=i$=3*?Mjp8;%}_I_5J;g`x|C{>dv1t-;cAuVnXa*cqF3HZU5@&rL~5Nx)xwK_*O$j|W_3R!x_$(1GE5 z0)uCJ)|TdvojfJ=%T67-xuK$>qH(DCKva}|Y7&YH`T4u-4n?9$rJQkmJv%+DXm#M) z#Mj^(=~loh>M=VXD+Pwy_;p=CXV#UG$z%t~5s@KqYqgKQcHLyO-`pRUuEvQb>qX&$ z`zF1>s#B(myvE;Z?&)g7{O1h1af`o7+9OQ$cD)#*))G#ba;Na(NX||N+w&H2EoiI{ z*Ku#UEUL?Hf8HJ;_?Nc)V!5cl#L+7Kscp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=qd!zh+^xc)!IbO7wXk(-rn_C#PGB}rV0a_fAnG+J@ zyyH0GlKiWoGN*W}u3w8LE8{#F|Hr2G5`5BF zn(2%BI>pgSd0SiC`4HpFJDRnKo`A#B9Zz znVF4DOlUh?yBmJn> z85}eYa(s|{@?)V~E^l_3FK(9C)ZnAVVv3X2p^BMTjkby>XY?P`4?2by%}$J2M-(+# z=hmry#hs1jmYCR3g_wW-{1oC>1#ZvL=Z6%2 zk4j6eltV+-U0429SRwT$?46F&Xsm>I?B=GQ&ZEq0PTC2~|VwYf)wgBLl(KT!NroTUF%oaTi(i z1Cp`4-ahZZOjy-?iH}Xs{g<<{3V+u1*9PwpvTsgzKy|HE-?K3b%7K5L+=zm72hN@_ Tv@7dT{~ma{)2Y|V$G-b7y^Wbu literal 0 HcmV?d00001 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 0000000000000000000000000000000000000000..5620f2bac6a7d61a2cf9a860ff001cf6daacdc38 GIT binary patch literal 2183 zcmaJ@c~leU77yZ6RJ1^qO_mVEjgVwQ77|GENCFihl0u4zU>lNwL`)_m0|}e7E-Xbr z+k+y-BVa8B7wW=Nk;MfBkzJtnfIeg`peW))0?M1H*!Rcd&6$~Rnfv?w?sva?zcZ=) zU0-(Kv;;@$PUO=bPWUZo|lgFb<=nZ z`n?Gp!N7cQDv-xVb08&%CgYr)L<9gpQz$rqM5a&xESg9FhT+iB5=xlPX3I3pGx1mHi?E z7gULqQUxr97TdwU*_?j={jLb(X^;xaG@15PRxBhhpr0%S6c>`vqYfCtfqMkR6pEyG|oY!qtwoEO(!p!sv+OsjWj zi21$D@*H*nI>p32((V|6aNQ)#6t`T}gIUeiywyKc_QS@=fy*8XoEFc5kcucEjdH8@ zTm5w@0ojIZ*65aVGgVJqANNmZ}P6yef^O;{crwysX18D_q-K%%JKBh^VQX(p;rPYI9u0iFNX-a zY^FwE>4oIu;pdIn5|Xx2UhaQa&#KKLwtVW=X4Z~PCQwF3Mz#3bqw=Ykk{(CQi4=q7 z%WjXnN^NZP8ZNSl(P)fjZ%moppmRa#0d3g9_)PjATkpIIy^PB%%!zres z@~#~)ir4sU%G-b3-@-oZh4H4sieGGNwC2ADd*U`7UU{Plq{M&O_KhXaq4;W7*HE>$m;=fdQ*SmbjObSfC$cn#WS7RZ4Ha{PX#bWsm zX}<JC?kNx&$ly=GhBZkxY?F#7dG#J-%ql9 zIyN>|CvoukFW3eQwEdy@1b;n`tw%9-VED-_B%cj zg86#n7z_o$x`*9&#>XQf6^gtPxtp7tco1%|3BkWWf;2WYb#;Gqa;fQ2E&D`T+M3Iw zqrcT2c4Q_yWkuF)@s_exl6CpCyAQ3GJ-4t9K1+I+W46U7LZ|=Xi>?=1yy_plV@#Kd zt}}c4emc8c9yQ5qGLT2v;y4vu33rRhkJH1p@gAJ)C<&kt=@v8{CWB`B@Qr<(Ytr7n z)7=K%QcpzX$Z(t0ZRSW~Z=oSpS<%&Z=(7v|3Yf|N-bx-d5}*#HD6^;c?EE~3qcUi= zL-Zabn3UgezGR%^e1Ew2$rFF$HM1q}R=F6QY+HjhLKl-2DbQZ zf7(-|Zp^nRf4ACj)o4%Rn*v=8)u+PrX1_uYctTn3}QaYqZ7V@{IynUOn9n@>H z)@~eF8{ckwgq=TGK)W@7B!1AP`aLCj%c}A#``tS;zdk?R(b2(*t_-1$O-%S)EGe0h zT|)h32q!&mv#wqF=H;MQyJY&u5RhnNlk literal 0 HcmV?d00001 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 0000000000000000000000000000000000000000..1ea44651f6deb3da38994a9c0be1adfbc488f242 GIT binary patch literal 2154 zcmaJ?c~lek7LEo5K{42hB343BM3Jl{KuSWh7(@vmn;?s386bp7VlqgGoG4U8ARL~L zQWOdZ9F9jUQsk*DRjgJ)S;Pe&BJdSWv7?HE^U<2(9gMy?nP!dlLAQ(a^A3*znyjUO* z;0cqDJp?=v2qZ=n90rAPe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24L1B#Vex3_T4Q5lm1S>KbS@LDXzlI} zX<4_ek9Cw-|4ZJg6=fbqKg4bRX3@yvD#2AfzS^pgr7-J&{p(Qh>}*3RN<&IWjJ@(@ zME{A@>VG?)fuHmbqtLz5wZ)NR*->WVnxTnr=Uw^IAw!h2;fHS=HE{58mSrB_={0)K z^mC+@J)@GzRu~Y`|8i6k(=*zccFLGwoTW|fPLrAyHyTN>XHuumlTHt`LeADKn5$`# zrcEQ6aMi`lqmsIp>d~FoUhdgQM1`N6DX)*bYG=swb!4TlWxuey?c{gqU7Z?p!S|Xk zMb?R&hgGA6yT(wT*EaO?;Gq2nE&VpJ`gR;{W$K-zCt(LS_1P(^Z+g%O$re7TDD1S2iieJ0g`Ezr-$=Nyn<>12aL$9=l(9#+#wmm$m%U$EB hBN)FQP1AGEcMz>PlNl4*osjYG@3YsBeU*7M?Y~epknI2f literal 0 HcmV?d00001 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 0000000000000000000000000000000000000000..bcb38f2526d8e47db228abef83627e882f3d4c45 GIT binary patch literal 2142 zcmaJ?YgiLk8jgxo#l)B;*1l;T{%9SaAh0Boh)anUD++C>INhTmq%a zQWOf3`cPUcTESXH)~xUdT1=qOu+&E(R1}b zomUkYfSe~2Ng)v^K^YafNnkoeLBmdeOF=AsCo7S^ohEp~unMjei^t%MDXjuotUrf} z#qZE^CIQn zO+>jK6iN7CrhMNDp2Z@CO5_k%!UIAX6f~@W5sCODZ#pwD(1%X&4j?e_cqZWhfrtz6 zA_U?I0d!&j6SvA`fV^}uAc0o7{NK5rYjTaHAeO?B8GuZb0q}!lpcu81GD)M=gPD_gkpuJ8c~T6T@Q9U&QL<40WDiw>H9 zFuBd${hGc&SacU{D9mdm`OO~MOP#3&+CO@kt3FzCrrUC4HmjlUMULRp%ca2~F5AHU z)nTpin0(jjFm1{=r29fIlc|qRp0pg3UC(=!bJOw2rTMm=N1;uFQRx=T5~>{!aUxv}t8=9iqOS7+84?2)Zs zNxnVYD`@+B+mAnlygA;`zw_01+20z#v)_%|$HwZOz9dz@F7{8Hbe~>6Sk~3(Qi)$U z?r?$wBK(toL@h`!h4|}G&4i$PdgqYHG!I(dJYIIaJU+zK9IEL(w(wcwEw8#T4xm&j z-CNud?eu&EO|LA_jy_oTxK$%K7qbiTP^I3S6ODVHC-HZrU!V^;-W>jT^xl<>oE&$7 zK=8#W<_{^}ct5`ne5{)9RGqG>s^Z)UgP6?gdXqt^+x{QCB?Pj$N3%W8Gy zG_`XIqRvM2tKaDL{>Q}P-P3h-b$_WWZjJEK)jpJ1O;1l>+comS%F)50tfFG8D)`a4 z*j_g4&FJ4!o12@vbsc#XR)d3sKRthbYV7;UlnP4!mM@1)W14>9A3aN#Z_(q>BAFW_c?Xd4DH#or@U=(Ztf~Ju{@Pt)+s;7o3luW z-y9no8=sI+T2xfjke98<%fn=3WR%~qg+Gc@fyL1BxGg#5n_41`cIoA-EvXb_g)K8O zGExy7Tx?5L^h{U;n^jT6r}7iS)ZJeskN4X>KR;lj+#Y16fy48(Uw<-yU8fE6Y_a@g zpxiDHcB=CIN3PkgcAZy(h9__`WB;GWpIFqwNhEJlu$`QXpIB%uj4xLBh_I;|1okTa zPx<Cc}h6qs7z`wtEM>v7j81AVff!#U8SPLrY$RE5o1PHs+k%sJ82 z^u~T(&{TL!@3+)v+f=o&>$~e7&Sdz>W31|FHW3EAYfW_Z znL_mr>(NH_#oUQPrz?gB{~7FcxkeU$s5Sq*wYa3`(QLH0;Z?UeX2xm~nX7t1cOYl0 zs3$`@S~zZZW!GP;IBvdQ>7EMDeSh@g(`^RK=~Dp{m8RQsBS`hj_oqD7Cf11hMx"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 000000000..5f001851b --- /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 000000000..b6a601390 --- /dev/null +++ b/app/views/admin/page_parts/_default_widget_style_panel.html.erb @@ -0,0 +1,45 @@ + +
+
    +
  • + + <%=image_tag 'module/default_widgets/style01.png'%> + <%= t("default_widget.caption.typeA") %> +
  • +
  • + + <%=image_tag 'module/default_widgets/style02.png'%> + <%= t("default_widget.caption.typeA") %> +
  • +
  • + + <%=image_tag 'module/default_widgets/style03.png'%> + <%= t("default_widget.caption.typeB_style3") %> +
  • +
  • + + <%=image_tag 'module/default_widgets/style04.png'%> + <%= t("default_widget.caption.typeB_style4") %> +
  • +
  • + + <%=image_tag 'module/default_widgets/style05.png'%> + <%= t("default_widget.caption.typeC") %> +
  • +
+
\ 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 a1cec8d07..77590997e 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 000000000..15cec6c29 --- /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 000000000..c54657ec5 --- /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 000000000..75ac6a50d --- /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 9de7cc63a..2ed3225ed 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_: "是" + From 46b1d55ff66febaf3ce15e84733105bad2c31ffa Mon Sep 17 00:00:00 2001 From: Fu Matthew Date: Mon, 14 Jan 2013 18:49:23 +0800 Subject: [PATCH 2/2] Complete new interface --- .../admin/default_widget_setting.css | 27 ++++++++++++ .../admin/page_parts_controller.rb | 8 +++- app/helpers/admin/page_parts_helper.rb | 12 ++++-- app/models/module_app.rb | 10 +++++ .../_custom_widget_setting.html.erb | 12 ++++++ .../_default_widget_setting.html.erb | 42 +++++++++++++------ .../_default_widget_style_panel.html.erb | 12 +++--- app/views/admin/page_parts/_edit.html.erb | 2 + .../admin/page_parts/_module_widget.html.erb | 2 +- .../_widget_data_source_category.html.erb | 24 +++++------ .../_widget_data_source_tag.html.erb | 22 +++++----- .../page_parts/_widget_ext_options.html.erb | 13 ++++++ .../admin/page_parts/_widget_setting.html.erb | 5 ++- .../page_parts/reload_widget_styles.js.erb | 9 +++- .../admin/page_parts/reload_widgets.js.erb | 18 +++++--- config/locales/zh_tw.yml | 2 + lib/tasks/migrate.rake | 15 +++++++ 17 files changed, 178 insertions(+), 57 deletions(-) create mode 100644 app/assets/stylesheets/admin/default_widget_setting.css create mode 100644 app/views/admin/page_parts/_custom_widget_setting.html.erb create mode 100644 app/views/admin/page_parts/_widget_ext_options.html.erb diff --git a/app/assets/stylesheets/admin/default_widget_setting.css b/app/assets/stylesheets/admin/default_widget_setting.css new file mode 100644 index 000000000..e68bb3aad --- /dev/null +++ b/app/assets/stylesheets/admin/default_widget_setting.css @@ -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 ; +} \ No newline at end of file diff --git a/app/controllers/admin/page_parts_controller.rb b/app/controllers/admin/page_parts_controller.rb index da2de8276..af6b0ed8f 100644 --- a/app/controllers/admin/page_parts_controller.rb +++ b/app/controllers/admin/page_parts_controller.rb @@ -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 diff --git a/app/helpers/admin/page_parts_helper.rb b/app/helpers/admin/page_parts_helper.rb index 0914939be..e8a1afc4a 100644 --- a/app/helpers/admin/page_parts_helper.rb +++ b/app/helpers/admin/page_parts_helper.rb @@ -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 \ No newline at end of file diff --git a/app/models/module_app.rb b/app/models/module_app.rb index 15657b2cb..ab88cdea8 100644 --- a/app/models/module_app.rb +++ b/app/models/module_app.rb @@ -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 diff --git a/app/views/admin/page_parts/_custom_widget_setting.html.erb b/app/views/admin/page_parts/_custom_widget_setting.html.erb new file mode 100644 index 000000000..a257336e4 --- /dev/null +++ b/app/views/admin/page_parts/_custom_widget_setting.html.erb @@ -0,0 +1,12 @@ +
+ + <% 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)) %> + + <%= render :partial=> "widget_ext_options" %> + <% 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 index 5f001851b..728bf010d 100644 --- a/app/views/admin/page_parts/_default_widget_setting.html.erb +++ b/app/views/admin/page_parts/_default_widget_setting.html.erb @@ -1,18 +1,34 @@ - +
- +
+ + + + + + + + +
<% @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 %>
+
+ + <%= 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 %> - -
- - +
+
+ <%= 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 index b6a601390..3a4096b47 100644 --- a/app/views/admin/page_parts/_default_widget_style_panel.html.erb +++ b/app/views/admin/page_parts/_default_widget_style_panel.html.erb @@ -1,9 +1,9 @@ -
+
  • <%=image_tag 'module/default_widgets/style01.png'%> @@ -11,7 +11,7 @@
  • <%=image_tag 'module/default_widgets/style02.png'%> @@ -19,7 +19,7 @@
  • <%=image_tag 'module/default_widgets/style03.png'%> @@ -27,7 +27,7 @@
  • <%=image_tag 'module/default_widgets/style04.png'%> @@ -35,7 +35,7 @@
  • <%=image_tag 'module/default_widgets/style05.png'%> diff --git a/app/views/admin/page_parts/_edit.html.erb b/app/views/admin/page_parts/_edit.html.erb index 78a20b37c..0d96516ce 100644 --- a/app/views/admin/page_parts/_edit.html.erb +++ b/app/views/admin/page_parts/_edit.html.erb @@ -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| %> diff --git a/app/views/admin/page_parts/_module_widget.html.erb b/app/views/admin/page_parts/_module_widget.html.erb index 77590997e..658d2a621 100644 --- a/app/views/admin/page_parts/_module_widget.html.erb +++ b/app/views/admin/page_parts/_module_widget.html.erb @@ -32,7 +32,7 @@
- <%= render :partial => 'widget_setting' %> + <%= render :partial => 'widget_setting' ,:locals=>{:f=>f} %>
+ <% end %> + + + <% end %> + diff --git a/app/views/admin/page_parts/_widget_setting.html.erb b/app/views/admin/page_parts/_widget_setting.html.erb index 75ac6a50d..a84717b1b 100644 --- a/app/views/admin/page_parts/_widget_setting.html.erb +++ b/app/views/admin/page_parts/_widget_setting.html.erb @@ -3,5 +3,8 @@ <%= render :partial => 'default_widget_style_panel',:locals=>{:f=>f} %> <%= render :partial => 'default_widget_setting' %> -<% elsif show_custom_widget_setting_panel %> +<% elsif show_custom_widget_setting_panel %> +
+ <%= render :partial => 'custom_widget_setting' %> +
<% end %> diff --git a/app/views/admin/page_parts/reload_widget_styles.js.erb b/app/views/admin/page_parts/reload_widget_styles.js.erb index 41b2ad9cc..333765c9d 100644 --- a/app/views/admin/page_parts/reload_widget_styles.js.erb +++ b/app/views/admin/page_parts/reload_widget_styles.js.erb @@ -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 %> diff --git a/app/views/admin/page_parts/reload_widgets.js.erb b/app/views/admin/page_parts/reload_widgets.js.erb index 76f49d910..e046c1f09 100644 --- a/app/views/admin/page_parts/reload_widgets.js.erb +++ b/app/views/admin/page_parts/reload_widgets.js.erb @@ -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'%>"); \ No newline at end of file diff --git a/config/locales/zh_tw.yml b/config/locales/zh_tw.yml index 2ed3225ed..a79e78970 100644 --- a/config/locales/zh_tw.yml +++ b/config/locales/zh_tw.yml @@ -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: 一圖一文式,輸出欄位水平排列 diff --git a/lib/tasks/migrate.rake b/lib/tasks/migrate.rake index e55ab2961..a791b7b67 100644 --- a/lib/tasks/migrate.rake +++ b/lib/tasks/migrate.rake @@ -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