Interface Neuigkeiten & Attachment
This commit is contained in:
@@ -113,9 +113,14 @@ class NeuigkeitenController < ApplicationController
|
|||||||
render action:"show"
|
render action:"show"
|
||||||
end
|
end
|
||||||
def create_link
|
def create_link
|
||||||
Nlink.create(:link=>params[:link_type].constantize.find(params[:link_id]),:neuigkeit=>Neuigkeit.find(params[:id]))
|
@neuigkeit = Neuigkeit.find(params[:id])
|
||||||
|
|
||||||
redirect_to action:"show"
|
Nlink.create(:link=>params[:link_type].constantize.find(params[:link_id]),:neuigkeit=>Neuigkeit.find(params[:id]))
|
||||||
|
@nlinks=@neuigkeit.nlinks
|
||||||
|
respond_to do |format|
|
||||||
|
format.html { edirect_to action:"show" }
|
||||||
|
format.js
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def create
|
def create
|
||||||
@@ -159,12 +164,14 @@ private
|
|||||||
def load_toolbar_elements
|
def load_toolbar_elements
|
||||||
@neuigkeit=Neuigkeit.find(params[:id])
|
@neuigkeit=Neuigkeit.find(params[:id])
|
||||||
@toolbar_elements=[]
|
@toolbar_elements=[]
|
||||||
@toolbar_elements << {:hicon=>'icon-plus', :text=> I18n.t('neuigkeit.publish'),:path => publish_rubrik_neuigkeit_path(@neuigkeit.rubrik,@neuigkeit),:confirm=> I18n.t('neuigkeit.publish_sure') } if can?(:publish, @neuigkeit) && !@neuigkeit.published?
|
actions=[]
|
||||||
@toolbar_elements << {:hicon=>'icon-facebook', :text=> I18n.t('neuigkeit.publishfb'),:path => publish_to_facebook_rubrik_neuigkeit_path(@neuigkeit.rubrik,@neuigkeit),:confirm=>I18n.t('neuigkeit.publishfb_sure') } if can?(:publish, @neuigkeit) && @neuigkeit.published?
|
actions << {:hicon=>'icon-plus', :text=> I18n.t('neuigkeit.publish'),:path => publish_rubrik_neuigkeit_path(@neuigkeit.rubrik,@neuigkeit),:confirm=> I18n.t('neuigkeit.publish_sure') } if can?(:publish, @neuigkeit) && !@neuigkeit.published?
|
||||||
|
actions << {:hicon=>'ffi1-facebook1', :text=> I18n.t('neuigkeit.publishfb'),:path => publish_to_facebook_rubrik_neuigkeit_path(@neuigkeit.rubrik,@neuigkeit),:confirm=>I18n.t('neuigkeit.publishfb_sure') } if can?(:publish, @neuigkeit) && @neuigkeit.published?
|
||||||
|
|
||||||
@toolbar_elements << {:hicon=>'icon-facebook', :text=> I18n.t('neuigkeit.publishfetmail'),:path => mail_to_fet_rubrik_neuigkeit_path(@neuigkeit.rubrik,@neuigkeit),:confirm=>I18n.t('neuigkeit.publishfetmail_sure') } if can?(:publish, @neuigkeit) && @neuigkeit.published?
|
actions << {:hicon=>'icon-facebook', :text=> I18n.t('neuigkeit.publishfetmail'),:path => mail_to_fet_rubrik_neuigkeit_path(@neuigkeit.rubrik,@neuigkeit),:confirm=>I18n.t('neuigkeit.publishfetmail_sure') } if can?(:publish, @neuigkeit) && @neuigkeit.published?
|
||||||
|
|
||||||
|
actions << {:hicon=>'icon-minus', :text=> I18n.t('neuigkeit.unpublish'),:path => unpublish_rubrik_neuigkeit_path(@neuigkeit.rubrik,@neuigkeit),:confirm=> I18n.t('neuigkeit.unpublish_sure') } if can?(:unpublish, @neuigkeit) && @neuigkeit.published?
|
||||||
|
|
||||||
@toolbar_elements << {:hicon=>'icon-minus', :text=> I18n.t('neuigkeit.unpublish'),:path => unpublish_rubrik_neuigkeit_path(@neuigkeit.rubrik,@neuigkeit),:confirm=> I18n.t('neuigkeit.unpublish_sure') } if can?(:unpublish, @neuigkeit) && @neuigkeit.published?
|
|
||||||
|
|
||||||
|
|
||||||
@toolbar_elements << {:text=>I18n.t('common.edit'),:path=>edit_rubrik_neuigkeit_path(@neuigkeit.rubrik,@neuigkeit),:icon=>:pencil} if can? :edit, @neuigkeit.rubrik
|
@toolbar_elements << {:text=>I18n.t('common.edit'),:path=>edit_rubrik_neuigkeit_path(@neuigkeit.rubrik,@neuigkeit),:icon=>:pencil} if can? :edit, @neuigkeit.rubrik
|
||||||
@@ -172,8 +179,8 @@ private
|
|||||||
|
|
||||||
@toolbar_elements <<{:path=>rubrik_neuigkeit_path(@neuigkeit.rubrik,@neuigkeit),:method=>:versions,:versions=>@versions}
|
@toolbar_elements <<{:path=>rubrik_neuigkeit_path(@neuigkeit.rubrik,@neuigkeit),:method=>:versions,:versions=>@versions}
|
||||||
|
|
||||||
@toolbar_elements << {:hicon=>'icon-remove-circle', :text=> I18n.t('common.delete'),:path => rubrik_neuigkeit_path(@neuigkeit.rubrik,@neuigkeit), :method=> :delete,:confirm=>'Sure?' } if can? :delete, @neuigkeit
|
actions << {:hicon=>'icon-remove-circle', :text=> I18n.t('common.delete'),:path => rubrik_neuigkeit_path(@neuigkeit.rubrik,@neuigkeit), :method=> :delete,:confirm=>'Sure?' } if can? :delete, @neuigkeit
|
||||||
|
@toolbar_elements << {:text => "action", :method => :dropdown, :elements=> actions}
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -40,6 +40,7 @@ class Ability
|
|||||||
can :showintern, Thema
|
can :showintern, Thema
|
||||||
can :manage, Thema
|
can :manage, Thema
|
||||||
can :manage, Themengruppe
|
can :manage, Themengruppe
|
||||||
|
can :manage, Attachment
|
||||||
end
|
end
|
||||||
unless user.has_role?("fetadmin")
|
unless user.has_role?("fetadmin")
|
||||||
cannot :delete, Themengruppe
|
cannot :delete, Themengruppe
|
||||||
|
|||||||
@@ -18,6 +18,13 @@ class Attachment < ActiveRecord::Base
|
|||||||
validates :thema, :presence => true
|
validates :thema, :presence => true
|
||||||
validates :name, :presence => true
|
validates :name, :presence => true
|
||||||
|
|
||||||
|
def image?
|
||||||
|
|
||||||
|
# data_ext = datei.file.extension.downcase
|
||||||
|
# %w(jpg png jpeg).include?(data_ext)
|
||||||
|
datei.image?(datei.file)
|
||||||
|
end
|
||||||
|
|
||||||
def to_jq_upload
|
def to_jq_upload
|
||||||
{
|
{
|
||||||
"id" => read_attribute(:id),
|
"id" => read_attribute(:id),
|
||||||
|
|||||||
@@ -49,7 +49,9 @@ include Rails.application.routes.url_helpers
|
|||||||
|
|
||||||
def fix_links(host)
|
def fix_links(host)
|
||||||
full_url= URI.parse(root_url(:host=>host))
|
full_url= URI.parse(root_url(:host=>host))
|
||||||
self.text.gsub!(/src="[^"]*attachment\/datei\/(\d+)[^"]*"/){|s| full_url.path=Attachment.find($1.to_i).datei.url; 'src="'+full_url.to_s+'"'}
|
self.text.gsub!(/src="[\.\/]*uploads\/attachment\/datei\/(\d+)\/thumb_big[^"]*"/){|s| full_url.path=Attachment.find($1.to_i).datei.thumb_big.url; 'src="'+full_url.to_s+'"'}
|
||||||
|
self.text.gsub!(/src="[\.\/^"]*uploads\/attachment\/datei\/(\d+)\/[^"]*"/){|s| full_url.path=Attachment.find($1.to_i).datei.url; 'src="'+full_url.to_s+'"'}
|
||||||
|
|
||||||
self.text.gsub!(/href="[^"]*themen\/(\d+)[^"]*"/){|s| full_url.path=thema_path(Thema.find($1.to_i)); 'href="'+full_url.to_s+'"'}
|
self.text.gsub!(/href="[^"]*themen\/(\d+)[^"]*"/){|s| full_url.path=thema_path(Thema.find($1.to_i)); 'href="'+full_url.to_s+'"'}
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -89,8 +89,11 @@ end
|
|||||||
# def filename
|
# def filename
|
||||||
# "something.jpg" if original_filename
|
# "something.jpg" if original_filename
|
||||||
# end
|
# end
|
||||||
protected
|
def extention
|
||||||
def image?(file)
|
File.extname(full_filename(file.file)).downcase
|
||||||
%w(jpg png jpeg).include?(File.extname(full_filename(file)))
|
end
|
||||||
|
|
||||||
|
def image?(for_file)
|
||||||
|
%w(.jpg .png .jpeg).include?(File.extname(full_filename(for_file.file)).downcase)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -10,8 +10,26 @@ Verwendung: Aufruf mit
|
|||||||
--><div class="btn-group">
|
--><div class="btn-group">
|
||||||
<% toolbar_elements.each do |t| %>
|
<% toolbar_elements.each do |t| %>
|
||||||
<% unless t[:method]==:versions %>
|
<% unless t[:method]==:versions %>
|
||||||
<% text='<i class="'.html_safe+ t[:hicon].to_s.html_safe + '"></i>'.html_safe+t[:text] %>
|
<% unless t[:method]==:dropdown %>
|
||||||
|
|
||||||
|
<% text=ff_icon(t[:hicon])+t[:text] %>
|
||||||
<%= link_to text, t[:path], :method=>t[:method], :confirm=>t[:confirm].to_s, :data=>t[:data], :class=>((t[:method].to_s=='delete') ? "btn btn-danger" : "btn") ,:remote=>(t[:remote])?true : false %>
|
<%= link_to text, t[:path], :method=>t[:method], :confirm=>t[:confirm].to_s, :data=>t[:data], :class=>((t[:method].to_s=='delete') ? "btn btn-danger" : "btn") ,:remote=>(t[:remote])?true : false %>
|
||||||
|
<% else %>
|
||||||
|
<div class="btn-group">
|
||||||
|
<a class="btn dropdown-toggle" data-toggle="dropdown" href="#">
|
||||||
|
<%= t[:text] %><span class="caret"></span>
|
||||||
|
</a>
|
||||||
|
<ul class="dropdown-menu">
|
||||||
|
<% t[:elements].each do |t2| %>
|
||||||
|
<li>
|
||||||
|
<% text=ff_icon(t2[:hicon])+" ".html_safe + t2[:text] %>
|
||||||
|
<%= link_to text, t2[:path], :method=>t2[:method], :confirm=>t2[:confirm].to_s, :data=>t2[:data], :class=>((t2[:method].to_s=='delete') ? "btn-danger" : "") ,:remote=>(t2[:remote])?true : false %>
|
||||||
|
|
||||||
|
</li>
|
||||||
|
<% end %>
|
||||||
|
|
||||||
|
</ul>
|
||||||
|
<% end %>
|
||||||
<% else %>
|
<% else %>
|
||||||
<div class="btn-group">
|
<div class="btn-group">
|
||||||
<a class="btn dropdown-toggle" data-toggle="dropdown" href="#">
|
<a class="btn dropdown-toggle" data-toggle="dropdown" href="#">
|
||||||
@@ -30,7 +48,7 @@ Verwendung: Aufruf mit
|
|||||||
uri.query= URI.encode_www_form(q<<["version",i.to_s])
|
uri.query= URI.encode_www_form(q<<["version",i.to_s])
|
||||||
%>
|
%>
|
||||||
<%= link_to I18n.l(v[:created_at]).to_s,uri.to_s ,:version=>v[:id] %>
|
<%= link_to I18n.l(v[:created_at]).to_s,uri.to_s ,:version=>v[:id] %>
|
||||||
<% end %>
|
<% end %>
|
||||||
</li>
|
</li>
|
||||||
<% end %>
|
<% end %>
|
||||||
</ul>
|
</ul>
|
||||||
|
|||||||
@@ -1,11 +1,12 @@
|
|||||||
|
|
||||||
<li>
|
<li>
|
||||||
<%= link_to nlink_list_search.title, nlink_list_search %>
|
<%= link_to nlink_list_search.title, nlink_list_search %>
|
||||||
<%= link_to "add:"+nlink_list_search.title, create_link_rubrik_neuigkeit_path(@neuigkeit.rubrik,@neuigkeit, :link_id=>nlink_list_search.id, :link_type=>nlink_list_search.class.to_s) %>
|
<%= link_to create_link_rubrik_neuigkeit_path(@neuigkeit.rubrik, @neuigkeit, :link_id=>nlink_list_search.id, :link_type=>nlink_list_search.class.to_s), remote: true do %>
|
||||||
<div class="contentbox" >
|
<div class="contentbox" >
|
||||||
<% p = nlink_list_search.class.to_s.downcase.pluralize+"/nlink" %>
|
<% p = nlink_list_search.class.to_s.downcase.pluralize+"/nlink" %>
|
||||||
<%= render :partial=>p, :object=>nlink_list_search %>
|
<%= render :partial=>p, :object=>nlink_list_search %>
|
||||||
</div>
|
</div>
|
||||||
|
<% end %>
|
||||||
</li>
|
</li>
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
2
app/views/neuigkeiten/create_link.js.erb
Normal file
2
app/views/neuigkeiten/create_link.js.erb
Normal file
@@ -0,0 +1,2 @@
|
|||||||
|
$('#nlink_list_search').html("");
|
||||||
|
$('#nlink_list').html("<%= escape_javascript( render partial:"nlink_list", collection: @nlinks )%>");
|
||||||
@@ -8,9 +8,15 @@
|
|||||||
</td>
|
</td>
|
||||||
<% if editor %>
|
<% if editor %>
|
||||||
<td>
|
<td>
|
||||||
<%= link_to "Edit", edit_thema_attachment_path(a.thema,a) %>
|
<div class="dropdown">
|
||||||
<%= link_to "Delete", thema_attachment_path(a.thema,a), method: "DELETE", confirm: "Sure?" %>
|
<a class="dropdown-toggle" data-toggle="dropdown" href="#">Actions</a>
|
||||||
|
<ul class="dropdown-menu">
|
||||||
|
<li>
|
||||||
|
<%= link_to ff_icon("icon-pencil")+"Edit", edit_thema_attachment_path(a.thema,a) %>
|
||||||
|
</li><li>
|
||||||
|
<%= link_to "Delete Attachment", thema_attachment_path(a.thema,a), method: "DELETE", confirm: "Sure?" , class: "btn-danger " %>
|
||||||
|
</li></ul>
|
||||||
|
</div>
|
||||||
</td>
|
</td>
|
||||||
<% end %>
|
<% end %>
|
||||||
</tr>
|
</tr>
|
||||||
|
|||||||
@@ -2,19 +2,33 @@
|
|||||||
<% select.attachments.each_slice(6) do |row| %>
|
<% select.attachments.each_slice(6) do |row| %>
|
||||||
<div class="row-fluid">
|
<div class="row-fluid">
|
||||||
<% row.each do |attachment|
|
<% row.each do |attachment|
|
||||||
data_ext = attachment.datei.file.extension.downcase %>
|
%>
|
||||||
<div class="span2" align="center">
|
<div class="span2" align="center">
|
||||||
<%= link_to attachment.name, edit_thema_attachment_path(@thema,attachment) %></br>
|
<div class="dropdown">
|
||||||
<% if (!["jpg","png","jpeg"].find_index(data_ext).nil?) %>
|
<a class="dropdown-toggle" data-toggle="dropdown" href="#">
|
||||||
|
<% if attachment.image? %>
|
||||||
<%= image_tag attachment.datei.thumb.url %>
|
<%= image_tag attachment.datei.thumb.url %>
|
||||||
<% else %>
|
<% else %>
|
||||||
<%= image_tag "pdf-logo.jpg" %>
|
<%= image_tag "pdf-logo.jpg" %>
|
||||||
<% end %>
|
<% end %>
|
||||||
|
</a>
|
||||||
<% if(editor) %>
|
<% if(editor) %>
|
||||||
</br><button type="button" onclick="insertAttachment(<%="\"" + attachment.datei.url + "\""%>,<%="\""+attachment.name+"\""%>)">Insert Me!</button>
|
</br>
|
||||||
<% else %>
|
<ul class="dropdown-menu">
|
||||||
</br><%= link_to 'Destroy',[@thema,attachment], method: :delete, data: { confirm: 'Are you sure?' } %>
|
<li>
|
||||||
|
<a href="#" onclick="insertAttachment(<%="\"" + attachment.datei.url + "\""%>,<%="\""+attachment.name+"\""%>)"> Datei einfügen</a></li>
|
||||||
|
<% if attachment.image? %>
|
||||||
|
<li><a type="button" onclick="insertAttachment(<%="\"" + attachment.datei.thumb_big.url + "\""%>,<%="\""+attachment.name+"\""%>)">Thumb einfügen</a></li>
|
||||||
<% end %>
|
<% end %>
|
||||||
|
</ul>
|
||||||
|
|
||||||
|
<% else %>
|
||||||
|
<ul class="dropdown-menu">
|
||||||
|
<li>
|
||||||
|
<%= link_to 'Destroy',[@thema,attachment], method: :delete, data: { confirm: 'Are you sure?' } %>
|
||||||
|
</li>
|
||||||
|
</ul> <% end %>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<% end %>
|
<% end %>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -1,8 +1,13 @@
|
|||||||
<% verw_liste.each do |thema| %>
|
<% verw_liste.each do |thema| %>
|
||||||
<li id="themen_<%= thema.id %>" class="sort" ><div class="contentbox handle" ><b><%= thema.title %></b> </div>
|
<li id="themen_<%= thema.id %>" class="sort" >
|
||||||
|
<div class="dropdown contentbox handle">
|
||||||
|
<a href="#" data-toggle="dropdown" class="dropdown-toggle"><b><%= thema.title %></b></a> <%= link_to thema_path(thema),:remote=>true do %> <%= fa_icon('eye') %> <% end %><%= link_to edit_thema_path(thema),:remote=>true do %> <%= ff_icon('icon-pencil') %> <% end %>
|
||||||
|
|
||||||
<%= link_to thema_path(thema),:remote=>true do %> Show <% end %>
|
<ul class="dropdown-menu">
|
||||||
<%= link_to edit_thema_path(thema),:remote=>true do %> Edit <% end %>
|
<li><%= link_to thema_path(thema),:remote=>true do %> <%= fa_icon('eye') %> Show <% end %></li>
|
||||||
<%= link_to fragen_thema_path(thema),:remote=>true do %> Fragen <% end %>
|
<li><%= link_to edit_thema_path(thema),:remote=>true do %> <%= ff_icon('icon-pencil') %> Edit <% end %> </li>
|
||||||
<%= link_to attachments_thema_path(thema),:remote=>true do %> Attachments <% end %></li>
|
<li><%= link_to fragen_thema_path(thema),:remote=>true do %> Fragen <% end %></li>
|
||||||
|
<li><%= link_to attachments_thema_path(thema),:remote=>true do %> Attachments <% end %></li>
|
||||||
|
</ul>
|
||||||
|
</li>
|
||||||
<% end %>
|
<% end %>
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
<%= link_to themengruppe,{:class=>'linkbox color-1-dark'} do %>
|
<%= link_to themengruppe,{:class=>'linkbox color-1-dark'} do %>
|
||||||
|
<div class="container-fluid">
|
||||||
<div class="row-fluid">
|
<div class="row-fluid">
|
||||||
<div class="span12">
|
<div class="span12">
|
||||||
<div class="media">
|
<div class="media">
|
||||||
@@ -45,5 +46,5 @@
|
|||||||
|
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
|
</div>
|
||||||
<% end %>
|
<% end %>
|
||||||
|
|||||||
@@ -3,20 +3,20 @@
|
|||||||
<ul class="linklist">
|
<ul class="linklist">
|
||||||
<li>
|
<li>
|
||||||
<%= link_to fa_icon("question")+ I18n.t("themengruppe.faqs"), faqs_themengruppen_path,class: :linkbox %>
|
<%= link_to fa_icon("question")+ I18n.t("themengruppe.faqs"), faqs_themengruppen_path,class: :linkbox %>
|
||||||
</li>
|
|
||||||
</ul>
|
|
||||||
</p>
|
|
||||||
<ul class="unstyled linkbox-list">
|
|
||||||
<li>
|
|
||||||
<% @themengruppen.each do |themengruppe| %>
|
|
||||||
<div class="container-fluid">
|
|
||||||
<%= render themengruppe if can?(:show,themengruppe)%>
|
|
||||||
</div>
|
|
||||||
<% end %>
|
|
||||||
</li>
|
</li>
|
||||||
</ul>
|
</ul>
|
||||||
|
</p>
|
||||||
|
<ul class="unstyled linkbox-list">
|
||||||
|
<% @themengruppen.each do |themengruppe| %>
|
||||||
|
<li>
|
||||||
|
|
||||||
<br/>
|
<%= render themengruppe if can?(:show,themengruppe)%>
|
||||||
|
|
||||||
|
</li>
|
||||||
|
<% end %>
|
||||||
|
</ul>
|
||||||
|
|
||||||
|
<br/>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<script class="hidden-phone">
|
<script class="hidden-phone">
|
||||||
|
|||||||
Reference in New Issue
Block a user