From cae5b4accca2f880bbd4a5ffae265f78c689075c Mon Sep 17 00:00:00 2001 From: hukl Date: Tue, 1 Sep 2009 23:13:45 +0200 Subject: Added javascript goodness to add and sort and drag and drop images on pages --- app/controllers/pages_controller.rb | 14 ++++++++++++++ app/views/nodes/edit.html.erb | 23 +++++++++++++++++++---- app/views/nodes/show.html.erb | 2 +- 3 files changed, 34 insertions(+), 5 deletions(-) (limited to 'app') diff --git a/app/controllers/pages_controller.rb b/app/controllers/pages_controller.rb index e298265..4b3b541 100644 --- a/app/controllers/pages_controller.rb +++ b/app/controllers/pages_controller.rb @@ -12,4 +12,18 @@ class PagesController < ApplicationController end end + + + def sort_images + page = Page.find(params[:id]) + + page.related_assets.destroy_all + + params[:images].each_with_index do |id, index| + asset = Asset.find(id) + page.related_assets.create(:asset_id => asset.id, :position => index+1) + end + + render :nothing => true, :status => 200 + end end diff --git a/app/views/nodes/edit.html.erb b/app/views/nodes/edit.html.erb index 00815b7..a8138c2 100644 --- a/app/views/nodes/edit.html.erb +++ b/app/views/nodes/edit.html.erb @@ -36,10 +36,15 @@ Images - - <% @draft.assets.images.each do |image| %> - <%= image_tag(image.upload.url(:thumb)) %> - <% end %> + + + add image @@ -69,4 +74,14 @@ <% end %> <% end %> + + + + +
+
\ No newline at end of file diff --git a/app/views/nodes/show.html.erb b/app/views/nodes/show.html.erb index 8aaedc5..15547f9 100644 --- a/app/views/nodes/show.html.erb +++ b/app/views/nodes/show.html.erb @@ -1,5 +1,5 @@ <% content_for :subnavigation do %> - <%= link_to 'Edit', edit_node_path(@node), :id => 'button', :class => "unselected" %> + <%= link_to 'Edit', edit_node_path(@node), :class => "unselected" %> <%= link_to 'Preview', preview_page_path(@page) %> <%= link_to 'Revisions', revision_path(params[:id]) %> <% end %> -- cgit v1.3