Commit 93dcbd93 authored by Martin Markech's avatar Martin Markech
Browse files

make items sortable

parent a54d3840
......@@ -3,7 +3,7 @@ module Refinery
module Admin
class ItemsController < ::Refinery::AdminController
crudify :'refinery/news/item', :order => "publish_date DESC"
crudify :'refinery/news/item', :xhr_paging => true
end
end
......
......@@ -7,7 +7,7 @@ module Refinery
attr_accessor :locale # to hold temporarily
attr_accessible :title, :body, :content, :source, :publish_date, :expiration_date
attr_accessible :title, :body, :content, :source, :publish_date, :expiration_date, :position
class Translation
attr_accessible :locale
end
......@@ -19,7 +19,6 @@ module Refinery
acts_as_indexed :fields => [:title, :body]
default_scope :order => "publish_date DESC"
def not_published? # has the published date not yet arrived?
publish_date > Time.now
......
<ul>
<% if ::Refinery::News::Admin::ItemsController.searchable? %>
<li>
<%= render '/refinery/admin/search', :url => refinery.news_admin_items_path %>
</li>
<% end %>
<li>
<%= link_to t('.create_new'), refinery.new_news_admin_item_path,
:class => "add_icon" %>
</li>
<% if !searching? && ::Refinery::News::Admin::ItemsController.sortable? && ::Refinery::News::Item.any? %>
<li>
<%= link_to t('.reorder', :what => "Items"),
refinery.news_admin_items_path,
:id => "reorder_action",
:class => "reorder_icon" %>
<%= link_to t('.reorder_done', :what => "Items"),
refinery.news_admin_items_path,
:id => "reorder_action_done",
:style => "display: none;",
:class => "reorder_icon" %>
</li>
<% end %>
</ul>
<li class='clearfix record <%= cycle("on", "on-hover") %>'>
<li class='clearfix record <%= cycle("on", "on-hover") %>' id="<%= dom_id(item) -%>">
<span class='title'>
<%= item.title %>
<span class="preview">
<%= t('.published') %> <%= l(item.publish_date, :format => :short) %>
</span>
<% if defined?(::Refinery::I18n) and ::Refinery::I18n.frontend_locales.many? and
(locales = item.translations.collect{|t| t.locale}).present? %>
(locales = item.translations.collect{|t| t.locale}).present? %>
<span class='preview'>
<% locales.each do |locale| %>
<%= refinery_icon_tag "flags/#{locale}.png", :size => '16x11' %>
......@@ -15,8 +15,8 @@
</span>
<span class='actions'>
<%= link_to refinery_icon_tag('application_go.png'), refinery.news_item_path(item),
:title => t('.view_live_html'),
:target => "_blank" %>
:title => t('.view_live_html'),
:target => "_blank" %>
<%= link_to refinery_icon_tag('application_edit.png'), refinery.edit_news_admin_item_path(item),
:title => t('.edit') %>
<%= link_to refinery_icon_tag('delete.png'), refinery.news_admin_item_path(item),
......@@ -24,7 +24,8 @@
:title => t('.delete'),
:method => :delete,
:data => {
:confirm => t('refinery.admin.delete.message', :title => item.title)
:confirm => t('refinery.admin.delete.message', :title => item.title)
} %>
</span>
</li>
<%= will_paginate @items if Refinery::News::Admin::ItemsController.pageable? %>
<%= render 'sortable_list' %>
<% if searching? %>
<h2><%= t('results_for', :scope => 'refinery.admin.search', :query => params[:search]) %></h2>
<% end %>
<div class='pagination_container'>
<% if @items.any? %>
<%= render 'items' %>
<% else %>
<p>
<% unless searching? %>
<strong>
<%= t('.no_items_yet') %>
</strong>
<% else %>
<%= t('no_results', :scope => 'refinery.admin.search') %>
<% end %>
</p>
<% end %>
</div>
<ul id='sortable_list'>
<%= render :partial => 'item', :collection => @items %>
</ul>
<%= render '/refinery/admin/sortable_list',
:continue_reordering => (local_assigns.keys.include?(:continue_reordering)) ? continue_reordering : true %>
<div id='actions'>
<ul>
<li>
<%= render "/refinery/admin/search", :url => refinery.news_admin_items_path %>
</li>
<li>
<%= link_to t('.create'), refinery.new_news_admin_item_path, :class => "add_icon" %>
</li>
</ul>
</div>
<div id='records'>
<% if searching? %>
<h2><%= t('refinery.admin.search.results_for', :query => params[:search]) %></h2>
<% end %>
<% if @items.any? %>
<%= will_paginate @items %>
<ul>
<%= render :partial => "item", :collection => @items %>
</ul>
<%= will_paginate @items %>
<% else %>
<p>
<% unless searching? %>
<strong><%= t('.no_items_yet') %></strong>
<% else %>
<%= t('refinery.admin.search.no_results') %>
<% end %>
</p>
<% end %>
</div>
<section id='records'>
<%= render 'records' %>
</section>
<aside id='actions'>
<%= render 'actions' %>
</aside>
<%= render '/refinery/admin/make_sortable', :tree => false if !searching? and ::Refinery::News::Admin::ItemsController.sortable? and ::Refinery::News::Item.count > 1 %>
\ No newline at end of file
......@@ -7,6 +7,10 @@ sk:
news:
admin:
items:
actions:
create_new: Pridať novinku
reorder: Preusporiadať novinky
reorder_done: Uložiť usporiadanie noviniek
item:
view_live_html: "Zobraziť novinku v novom okne"
edit: "Editovať novinku"
......
......@@ -9,7 +9,11 @@ Refinery::Core::Engine.routes.draw do
namespace :admin, :path => 'refinery' do
scope :path => 'news' do
root :to => "items#index"
resources :items, :except => :show
resources :items, :except => :show do
collection do
post :update_positions
end
end
end
end
end
......
class AddPositionToNewsItems < ActiveRecord::Migration
def change
add_column Refinery::News::Item.table_name, :position, :integer
end
end
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment