From 338f3a0a06ea1bd99fc25828b123c0c2aa706e21 Mon Sep 17 00:00:00 2001 From: HausdorffHimself Date: Tue, 27 Aug 2013 18:35:50 +0200 Subject: [PATCH] CHANGE: Attachment-Einbindung in TinyMCE mit Thumbnails und eigenem Partial-View --- app/assets/images/pdf-logo.jpg | Bin 0 -> 1629 bytes app/views/attachments/_show_image_list.erb | 12 ++++++++++ app/views/themen/_form.html.erb | 14 +++++++---- app/views/themen/_select.html.erb | 26 +++++++++++++++++++++ app/views/themen/edit.html.erb | 3 +-- app/views/themen/show.html.erb | 10 +------- 6 files changed, 49 insertions(+), 16 deletions(-) create mode 100644 app/assets/images/pdf-logo.jpg create mode 100644 app/views/attachments/_show_image_list.erb create mode 100644 app/views/themen/_select.html.erb diff --git a/app/assets/images/pdf-logo.jpg b/app/assets/images/pdf-logo.jpg new file mode 100644 index 0000000000000000000000000000000000000000..729b9a7053bfd2d46e42c15f8b9318aae56d2115 GIT binary patch literal 1629 zcmb7BKDG?8|~hI2}~tT}F_5>cymoc`$bI)9$e^XL2Xyr0)2`%Cr$toCyEbO$gP3~XH) zAo~WKHv5xZxBL1#K#}2Q(ee8up(B>-Eg<6rM%2Mb$kWRM^712lKu2t>OiZEh{SmZ; z*uxM#ffgHeI7vx11~vml1qGynydn~bM4=RwRMgQb%E~I*ST$93ypG;acpV%LGFWc} z5lo3VoUyHmsf8tpMA9>|-(+XyxZav%^{)hmLZMWYRkYA(Eh~MTzSaMZtP5ZifeUbf z!w5hQ1A}8=GCsfoASVZ3`SwQ;3i3#p99$8sP>0n(4hENl%fnHM@b8Tkf{@1mtb)EJ zQjOqBQ>O?uhz3^HbVhCy$&DI%npxJJme;tls{;f76$3Z|z~mIIBSrK zuL|as6UwivJ}e|pPfDNE+O^F@Esrk!M9*lEfx8?hMP9n?ZEs4|T)p7ipjuKU-_a#$ zT6HRk^IJj*CVGq#lDZB3xtnoNG^JUm311?73DWTyjhhwf=16=qDRKOq;25!P&Z@fc z`G+1l4sN#nPw!d!t+LfK(~Ymc)+~CDXdLaRtM`Tqr=dV4uc7_JCK9V-Q>hh?ZoZ#g z$WORZ>!TT9Ez)G$;lF9xZ=_w_bDk~(^-g9!?=Bs%cs^0!Z!c|*FD!70WtI|>)7zIE zrQ_!fBzbw0wW>|s@`eenc9>B?go)4CXz3kAZlm`#T|EqOv=LDwf||T@Jl&d3x<<;7IkTI~(B2YJ z-177lE0Hl>J^DIy_Se+Ss%mEfPi2t34)KOd&Y}g!qTdcCnm^w8K41~8Y^VaC_|nTo{zuzHiw7`qPGJE**L`1T!@UX&uW)hX z;jLX`wGSf6dx#9{%opZP!N-m3+O|Jpjt|kY%Y*19>_A3Mk`5NeeKY7q#mh)n?R!;2H3y*;Z)as=afN6uU@Dj#Q)v+6uP%T)^RPLCTp8F` zno(MPpk6s1{d$b4-S5yjGUH-DQ4d|~G;OH&s);t{L_fMLjz_up=xx z$T~gNKNu>ix#2ON6^ORDaFjrK5b8TYc{nVYD!o*?OzxdG>bc&z=j2OGy}r^ljcI?J zt3u!H?>~^;Ap_W4q7OK<}hN6p&l0iJK7;wy^+ ziS>mwP6;P6Rg(#nFUtlC^N7ze8`daO$)A9cbqQYPYUDUS8Zr+8x{2mDM9`lxf|Qxwu%M}`f4c)X`0s3 zQ{fD!kgueXP@YF}cF}}-1gYpsJ0dL=$I-^SyG~ACJKB0|9BcP+owT)=P9z=Y^yPI3 ql0O~&^kIO 0 %> + +<% else %> + No Images Uploaded Yet. +<% end %> diff --git a/app/views/themen/_form.html.erb b/app/views/themen/_form.html.erb index 7185578..b967041 100644 --- a/app/views/themen/_form.html.erb +++ b/app/views/themen/_form.html.erb @@ -9,6 +9,13 @@

Attachments:

+<%= render :partial => "themen/select", :object => @thema,:locals =>{ :editor => :true} %> + +<%= f.actions do %> +<%= f.action :submit, :as => :input %> +<% end %> + + - diff --git a/app/views/themen/_select.html.erb b/app/views/themen/_select.html.erb new file mode 100644 index 0000000..4964693 --- /dev/null +++ b/app/views/themen/_select.html.erb @@ -0,0 +1,26 @@ +
+ <% select.attachments.each_slice(6) do |row| %> +
+ <% row.each do |attachment| + data_ext = attachment.datei.file.extension.downcase %> +
+ <%= link_to attachment.name, edit_thema_attachment_path(@thema,attachment) %>
+ <% if (!["jpg","png","jpeg"].find_index(data_ext).nil?) %> + <%= image_tag attachment.datei.thumb.url %> + <% else %> + <%= image_tag "pdf-logo.jpg" %> + <% end %> + <% if(editor) %> +
+ <% else %> +
<%= link_to 'Destroy',[@thema,attachment], method: :delete, data: { confirm: 'Are you sure?' } %> + <% end %> +
+ <% end %> +
+
+ <% end %> +
+
+<%= link_to 'Neues Attachment', new_thema_attachment_path(@thema) %> +
diff --git a/app/views/themen/edit.html.erb b/app/views/themen/edit.html.erb index 9230c28..5376cfb 100644 --- a/app/views/themen/edit.html.erb +++ b/app/views/themen/edit.html.erb @@ -2,5 +2,4 @@ <%= render 'form' %> -<%= link_to 'Show', @thema %> | -<%= link_to 'Back', themen_path %> +
<%= link_to 'Back', @thema %> diff --git a/app/views/themen/show.html.erb b/app/views/themen/show.html.erb index 6fe1cd7..aaf3fa6 100644 --- a/app/views/themen/show.html.erb +++ b/app/views/themen/show.html.erb @@ -24,12 +24,4 @@

Attachments:

-<% @thema.attachments.each do |attachment| %> -
    -
  • - <%= link_to attachment.name, edit_thema_attachment_path(@thema,attachment) %> | <%= link_to 'Destroy',[@thema,attachment], method: :delete, data: { confirm: 'Are you sure?' } %> -
  • -
-<% end %> -<%= link_to 'Neues Attachment', new_thema_attachment_path(@thema) %> -
+<%= render :partial => "themen/select", :object => @thema, :locals => { :editor => :false }%>