themen verwalten add
This commit is contained in:
@@ -3,8 +3,9 @@ class ThemengruppenController < ApplicationController
|
||||
# GET /themengruppen.json
|
||||
load_and_authorize_resource
|
||||
def index
|
||||
@themengruppen = Themengruppe.order(:title)
|
||||
@themengruppen = Themengruppe.order(:priority).reverse
|
||||
@toolbar_elements = [{:icon=>:plus, :hicon=>'icon-plus-sign', :text=>I18n.t('themengruppe.new'), :path=>new_themengruppe_path()}]
|
||||
@toolbar_elements = [{:icon=>:plus, :hicon=>'icon-plus-sign', :text=>I18n.t('common.verwalten'), :path=>verwalten_all_themengruppen_path()}]
|
||||
|
||||
respond_to do |format|
|
||||
format.html # index.html.erb
|
||||
@@ -16,10 +17,13 @@ class ThemengruppenController < ApplicationController
|
||||
# GET /themengruppen/1.json
|
||||
def show
|
||||
@themengruppe = Themengruppe.find(params[:id])
|
||||
@themen = @themengruppe.themen.order(:priority).reverse
|
||||
|
||||
@toolbar_elements = []
|
||||
@toolbar_elements << {:icon=>:plus, :hicon=>'icon-plus-sign', :text=>I18n.t('thema.add'), :path=>new_themengruppe_thema_path(@themengruppe)} if can? :new, Themengruppe
|
||||
@toolbar_elements << {:icon=>:pencil, :hicon=>'icon-pencil', :text=>I18n.t('themengruppe.edit'), :path=>edit_themengruppe_path(@themengruppe)} if can? :edit, @themengruppe
|
||||
@toolbar_elements << {:hicon=>'icon-remove-circle',:text=>I18n.t('themengruppe.remove'), :path=>themengruppe_path(@themengruppe), :method=>:delete,:confirm=>I18n.t('themengruppe.sure')} if can? :delete, @themengruppe
|
||||
@toolbar_elements << {:icon=>:pencil, :hicon=>'icon-pencil', :text=>I18n.t("themengruppe.verwalten"), :path=>themengruppe_verwalten_path(@themengruppe)} if can? :edit, @themengruppe
|
||||
@toolbar_elements << {:hicon=>'icon-remove-circle',:text=>I18n.t('themengruppe.remove'), :path=>themengruppe_path(@themengruppe), :method=>:delete,:confirm=>I18n.t('themengruppe.sure')} if can? :delete, @themengruppe
|
||||
|
||||
|
||||
respond_to do |format|
|
||||
@@ -43,6 +47,42 @@ class ThemengruppenController < ApplicationController
|
||||
def edit
|
||||
@themengruppe = Themengruppe.find(params[:id])
|
||||
end
|
||||
def verwalten_all
|
||||
@themengruppen =Themengruppe.order(:priority).reverse
|
||||
end
|
||||
def verwalten
|
||||
@themengruppe = Themengruppe.find(params[:themengruppe_id])
|
||||
@themen = @themengruppe.themen.order(:priority).reverse
|
||||
end
|
||||
|
||||
def sort_themengruppen
|
||||
@params=params
|
||||
i=1
|
||||
params['themengruppen'].reverse.each do |themengruppeid|
|
||||
themengruppe=Themengruppe.find(themengruppeid)
|
||||
themengruppe.priority=i
|
||||
themengruppe.save
|
||||
i=i+1
|
||||
end
|
||||
respond_to do |format|
|
||||
format.js
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
def sort_themen
|
||||
@params=params
|
||||
i=1
|
||||
params['themen'].reverse.each do |themaid|
|
||||
thema=Thema.find(themaid)
|
||||
thema.priority=i
|
||||
thema.save
|
||||
i=i+1
|
||||
end
|
||||
respond_to do |format|
|
||||
format.js
|
||||
end
|
||||
end
|
||||
|
||||
# POST /themengruppen
|
||||
# POST /themengruppen.json
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
</p>
|
||||
|
||||
<div class="accordion" id="accordion1">
|
||||
<% @themengruppe.themen.each do |thema| %>
|
||||
<% @themen.each do |thema| %>
|
||||
<div class="accordion-group">
|
||||
<div class="accordion-heading">
|
||||
<a class="accordion-toggle" data-toggle="collapse" data-parent="#accordion1" href="#collapse<%=thema.id%>">
|
||||
|
||||
1
app/views/themengruppen/sort_themen.js.erb
Normal file
1
app/views/themengruppen/sort_themen.js.erb
Normal file
@@ -0,0 +1 @@
|
||||
alert('sd<%= escape_javascript(@params['themen'].to_s) %>');
|
||||
1
app/views/themengruppen/sort_themengruppen.js.erb
Normal file
1
app/views/themengruppen/sort_themengruppen.js.erb
Normal file
@@ -0,0 +1 @@
|
||||
alert("tt")
|
||||
56
app/views/themengruppen/verwalten.html.erb
Normal file
56
app/views/themengruppen/verwalten.html.erb
Normal file
@@ -0,0 +1,56 @@
|
||||
<style>
|
||||
#themen { list-style-type: none; margin: 0; padding: 0; margin-bottom: 15px;zoom: 1; }
|
||||
#themen li { margin: 0 5px 5px 5px; padding: 5px; font-size: 1.2em; width: 95%; }
|
||||
</style>
|
||||
<ul id="themen" class="sort" >
|
||||
<% @themen.each do |thema| %>
|
||||
<li id="themen_<%= thema.id %>" class="sort" style="background:white;display:block;" ><%= thema.title %>-<%= thema.priority %></li>
|
||||
<% end %>
|
||||
</ul>
|
||||
|
||||
<script>
|
||||
|
||||
$( document ).ready(function(){
|
||||
$("#themen").sortable({
|
||||
cursor: 'crosshair',
|
||||
drag:true,
|
||||
update: function(){
|
||||
$.ajax({
|
||||
url: '<%= themengruppe_sort_themen_path(@themengruppe) %>',
|
||||
type: 'post',
|
||||
data: $('#themen').sortable('serialize'),
|
||||
dataType: 'script',
|
||||
complete: function(request){
|
||||
alert("complete");
|
||||
}
|
||||
})
|
||||
}
|
||||
});
|
||||
});
|
||||
</script>
|
||||
|
||||
<!--
|
||||
$( document ).ready(function(){
|
||||
$("#themen").sortable({
|
||||
axis: 'y',
|
||||
drag:true,
|
||||
dropOnEmpty: false,
|
||||
handle: '.handle',
|
||||
cursor: 'crosshair',
|
||||
items: 'li',
|
||||
opacity: 0.4,
|
||||
scroll: true,
|
||||
update: function(){
|
||||
$.ajax({
|
||||
url: '/books/sort',
|
||||
type: 'post',
|
||||
data: $('#themen').sortable('serialize'),
|
||||
dataType: 'script',
|
||||
complete: function(request){
|
||||
$('#themen').effect('highlight');
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
});
|
||||
-->
|
||||
@@ -4,7 +4,7 @@
|
||||
<%= @themengruppe.text %>
|
||||
</p>
|
||||
<ul class="unstyled linkbox-list" >
|
||||
<% @themengruppe.themen.each do |thema| %>
|
||||
<% @themen.each do |thema| %>
|
||||
<li>
|
||||
<div class="contentbox">
|
||||
<a href="#<%=thema.id%>">
|
||||
|
||||
27
app/views/themes/2003/themengruppen/verwalten_all.html.erb
Normal file
27
app/views/themes/2003/themengruppen/verwalten_all.html.erb
Normal file
@@ -0,0 +1,27 @@
|
||||
|
||||
<ul id="themengruppen" class="sort" >
|
||||
<% @themengruppen.each do |themengruppe| %>
|
||||
<li id="themengruppen_<%= themengruppe.id %>" class="sort" style="background:white;display:block;" ><%= themengruppe.title %>-<%= themengruppe.priority %></li>
|
||||
<% end %>
|
||||
</ul>
|
||||
|
||||
<script>
|
||||
|
||||
$( document ).ready(function(){
|
||||
$("#themengruppen").sortable({
|
||||
cursor: 'crosshair',
|
||||
drag:true,
|
||||
update: function(){
|
||||
$.ajax({
|
||||
url: '<%= sort_themengruppen_themengruppen_path() %>',
|
||||
type: 'post',
|
||||
data: $('#themengruppen').sortable('serialize'),
|
||||
dataType: 'script',
|
||||
complete: function(request){
|
||||
alert("complete");
|
||||
}
|
||||
})
|
||||
}
|
||||
});
|
||||
});
|
||||
</script>
|
||||
Reference in New Issue
Block a user