diff --git a/app/controllers/themengruppen_controller.rb b/app/controllers/themengruppen_controller.rb index 29ada1f..aba10ca 100644 --- a/app/controllers/themengruppen_controller.rb +++ b/app/controllers/themengruppen_controller.rb @@ -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 diff --git a/app/views/themengruppen/show.html.erb b/app/views/themengruppen/show.html.erb index 4df5827..6da95cd 100644 --- a/app/views/themengruppen/show.html.erb +++ b/app/views/themengruppen/show.html.erb @@ -5,7 +5,7 @@

- <% @themengruppe.themen.each do |thema| %> + <% @themen.each do |thema| %>
diff --git a/app/views/themengruppen/sort_themen.js.erb b/app/views/themengruppen/sort_themen.js.erb new file mode 100644 index 0000000..319928a --- /dev/null +++ b/app/views/themengruppen/sort_themen.js.erb @@ -0,0 +1 @@ +alert('sd<%= escape_javascript(@params['themen'].to_s) %>'); \ No newline at end of file diff --git a/app/views/themengruppen/sort_themengruppen.js.erb b/app/views/themengruppen/sort_themengruppen.js.erb new file mode 100644 index 0000000..b6aee38 --- /dev/null +++ b/app/views/themengruppen/sort_themengruppen.js.erb @@ -0,0 +1 @@ +alert("tt") \ No newline at end of file diff --git a/app/views/themengruppen/verwalten.html.erb b/app/views/themengruppen/verwalten.html.erb new file mode 100644 index 0000000..911a87f --- /dev/null +++ b/app/views/themengruppen/verwalten.html.erb @@ -0,0 +1,56 @@ + +
    +<% @themen.each do |thema| %> +
  • <%= thema.title %>-<%= thema.priority %>
  • +<% end %> +
+ + + + diff --git a/app/views/themes/2003/themengruppen/show.html.erb b/app/views/themes/2003/themengruppen/show.html.erb index 9fc9187..ca514a6 100644 --- a/app/views/themes/2003/themengruppen/show.html.erb +++ b/app/views/themes/2003/themengruppen/show.html.erb @@ -4,7 +4,7 @@ <%= @themengruppe.text %>