attachments view

This commit is contained in:
Andreas Stephanides
2014-05-02 18:55:38 +02:00
parent ad704aacd5
commit 667f5b680e
7 changed files with 42 additions and 6 deletions

View File

@@ -16,17 +16,19 @@ class ThemenController < ApplicationController
# GET /themen/1.json # GET /themen/1.json
def show def show
@thema = Thema.find(params[:id]) @thema = Thema.find(params[:id])
redirect_to :controller=>'themengruppen', :id=>@thema.themengruppe.id, :action=>:show, :anchor=> "thema_"+params[:id].to_s
@fragen=@thema.fragen @fragen=@thema.fragen
@toolbar_elements = [{:icon=>:pencil, :hicon=>'icon-pencil', :text=>"Verwalten", :path=>verwalten_thema_path(@thema)}] @toolbar_elements = [{:icon=>:pencil, :hicon=>'icon-pencil', :text=>"Verwalten", :path=>verwalten_thema_path(@thema)}]
@toolbar_elements = [{:icon=>:pencil, :hicon=>'icon-pencil', :text=>I18n.t('thema.edit'), :path=>edit_thema_path(@thema)}] @toolbar_elements = [{:icon=>:pencil, :hicon=>'icon-pencil', :text=>I18n.t('thema.edit'), :path=>edit_thema_path(@thema)}]
@toolbar_elements << {:hicon=>'icon-remove-circle', :text=>I18n.t('thema.remove'), :path=>thema_path(@thema), :method=>:delete, :confirm=>I18n.t('thema.sure')} @toolbar_elements << {:hicon=>'icon-remove-circle', :text=>I18n.t('thema.remove'), :path=>thema_path(@thema), :method=>:delete, :confirm=>I18n.t('thema.sure')}
# respond_to do |format| respond_to do |format|
# format.html # show.html.erb format.html {
# format.json { render json: @thema } redirect_to :controller=>'themengruppen', :id=>@thema.themengruppe.id, :action=>:show, :anchor=> "thema_"+params[:id].to_s
# end }
format.js
end
end end
def verwalten def verwalten
@thema = Thema.find(params[:id]) @thema = Thema.find(params[:id])
@@ -83,6 +85,13 @@ class ThemenController < ApplicationController
format.js format.js
end end
end end
def attachments
@thema = Thema.find(params[:id])
@attachments=@thema.attachments
respond_to do |format|
format.js
end
end
# PUT /themen/1 # PUT /themen/1
# PUT /themen/1.json # PUT /themen/1.json
def update def update

View File

@@ -0,0 +1,9 @@
<% data_ext = attachment.datei.file.extension.downcase %>
<%= attachment.name %> </br>
<% if (!["jpg","png","jpeg"].find_index(data_ext).nil?) %>
<%= image_tag attachment.datei.thumb.url %>
<% else %>
<%= image_tag "pdf-logo.jpg" %>
<% end %>

View File

@@ -0,0 +1,12 @@
<table>
<% attachment_list.each do |a| %>
<tr>
<td>
<%= render a %>
</td>
<td>
<%= link_to "Edit", edit_thema_attachment_path(a.thema,a) %>
</td>
</tr>
<% end %>
</table>

View File

@@ -1,3 +1,4 @@
<% verw_liste.each do |thema| %> <% verw_liste.each do |thema| %>
<li id="themen_<%= thema.id %>" class="sort" ><div class="contentbox handle" ><h2><%= thema.title %></h2> </div> <%= link_to edit_thema_path(thema),:remote=>true do %> Edit <% end %> <%= link_to fragen_thema_path(thema),:remote=>true do %> Fragen <% end %></li> <li id="themen_<%= thema.id %>" class="sort" ><div class="contentbox handle" ><h2><%= thema.title %></h2> </div>
<%= link_to thema_path(thema),:remote=>true do %> Show <% end %> <%= link_to edit_thema_path(thema),:remote=>true do %> Edit <% end %> <%= link_to fragen_thema_path(thema),:remote=>true do %> Fragen <% end %><%= link_to attachments_thema_path(thema),:remote=>true do %> Attachments <% end %></li>
<% end %> <% end %>

View File

@@ -0,0 +1 @@
$("#themaview").html("<%= escape_javascript(raw("<h2>"+I18n.t('thema.show')+"</h2>")+render(:partial=>"themen/attachment_list", :object=>@attachments) )%>");

View File

@@ -0,0 +1 @@
$("#themaview").html("<%= escape_javascript(raw("<h2>"+I18n.t('thema.show')+"</h2>")+render(:partial=>"themen/small", :object=>@thema) )%>");

View File

@@ -28,6 +28,9 @@
<% thema.nlinks.each do |l| %> <% thema.nlinks.each do |l| %>
<li><%= render l.neuigkeit %></li> <li><%= render l.neuigkeit %></li>
<% end %> <% end %>
<% thema.nlinks.each do |l| %>
<li><%= render l.neuigkeit %></li>
<% end %>
</ul> </ul>
</div> </div>
</li> </li>