forked from refinery/refinerycms-portfolio
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Adds items, fixes child creation, adds sorting to items.
- Loading branch information
Rob Yurkowski
committed
Feb 27, 2012
1 parent
17d3c18
commit c560b3c
Showing
20 changed files
with
298 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
25 changes: 25 additions & 0 deletions
25
app/controllers/refinery/portfolio/admin/items_controller.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
module Refinery | ||
module Portfolio | ||
module Admin | ||
class ItemsController < ::Refinery::AdminController | ||
crudify :'refinery/portfolio/item', | ||
:order => 'lft ASC' | ||
|
||
def index | ||
if params[:orphaned] | ||
@items = Item.orphaned | ||
elsif params[:gallery_id] | ||
@items = Item.child_of(params[:gallery_id]) | ||
else | ||
@items = Item.all | ||
end | ||
end | ||
|
||
def new | ||
@item = ::Refinery::Portfolio::Item.new(params.except(:controller, :action, :switch_locale)) | ||
end | ||
|
||
end | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
module Refinery | ||
module Portfolio | ||
module Admin | ||
module ItemsHelper | ||
|
||
def gallery_path_for(item) | ||
(gallery = item.gallery).present? ? refinery.portfolio_gallery_path(gallery) : refinery.portfolio_galleries_path | ||
end | ||
|
||
def gallery_url_for(item) | ||
(gallery = item.gallery).present? ? refinery.portfolio_gallery_url(gallery) : refinery.portfolio_galleries_url | ||
end | ||
end | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
<%= form_for [refinery, :portfolio_admin, @gallery, @item] do |f| -%> | ||
<%= render :partial => "/refinery/admin/error_messages", :locals => { | ||
:object => @item, | ||
:include_object_name => true } %> | ||
|
||
<div class='field'> | ||
<%= f.label :title -%> | ||
<%= f.text_field :title, :class => 'larger widest' -%> | ||
</div> | ||
|
||
<div class='field'> | ||
<div id='page-tabs' class='clearfix ui-tabs ui-widget ui-widget-content ui-corner-all'> | ||
<ul id='page_parts'> | ||
<% [:caption].each_with_index do |part, part_index| %> | ||
<li class='ui-state-default<%= ' ui-state-active' if part_index == 0 %>'> | ||
<%= link_to t("#{part}", :scope => "activerecord.attributes.refinery/portfolio/item", :default => part.to_s.titleize), "##{part}" %> | ||
</li> | ||
<% end %> | ||
</ul> | ||
<div id='page_part_editors'> | ||
<% [:caption].each do |part| %> | ||
<div class='page_part' id='<%= part %>'> | ||
<%= f.text_area part, :rows => 20, :class => 'wymeditor widest' -%> | ||
</div> | ||
<% end %> | ||
</div> | ||
</div> | ||
</div> | ||
|
||
<%= render :partial => '/refinery/admin/image_picker', | ||
:locals => { | ||
:f => f, | ||
:field => :image_id, | ||
:image => @item.image, | ||
:toggle_image_display => false | ||
} %> | ||
|
||
<div class='field'> | ||
<span class='label_with_help'> | ||
<%= f.label :gallery_id, t('.gallery') -%> | ||
<%= refinery_help_tag t('.gallery_help') -%> | ||
</span> | ||
<%= f.select :gallery_id, nested_set_options(::Refinery::Portfolio::Gallery, @gallery) { |i| "#{'-' * i.level} #{i.title}" }, :include_blank => true %> | ||
</div> | ||
|
||
<%= render :partial => "/refinery/admin/form_actions", | ||
:locals => { | ||
:f => f, | ||
:continue_editing => false, | ||
:delete_title => t('delete', :scope => 'refinery.portfolio.admin.items.item'), | ||
:delete_confirmation => t('message', :scope => 'refinery.admin.delete', :title => @item.title) | ||
} %> | ||
|
||
<% end -%> | ||
|
||
<% content_for :javascripts do %> | ||
<script> | ||
$(document).ready(function(){ | ||
page_options.init(false, '', ''); | ||
}); | ||
</script> | ||
<% end %> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
<li class='clearfix record <%= cycle("on", "on-hover") %>' id="<%= dom_id(item) -%>"> | ||
<span class='title'> | ||
<%= item.title %> | ||
<span class="preview"> </span> | ||
</span> | ||
<span class='actions'> | ||
<%= link_to refinery_icon_tag("application_go.png"), gallery_path_for(item), | ||
:title => t('.view_live_html'), | ||
:target => "_blank" %> | ||
<%= link_to refinery_icon_tag("application_edit.png"), refinery.edit_portfolio_admin_item_path(item), | ||
:title => t('.edit') %> | ||
<%= link_to refinery_icon_tag("delete.png"), refinery.portfolio_admin_item_path(item), | ||
:class => "cancel confirm-delete", | ||
:title => t('.delete'), | ||
:confirm => t('message', :scope => 'refinery.admin.delete', :title => item.title), | ||
:method => :delete %> | ||
</span> | ||
</li> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
<%= render :partial => "sortable_list" %> |
16 changes: 16 additions & 0 deletions
16
app/views/refinery/portfolio/admin/items/_records.html.erb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
<% if searching? %> | ||
<h2><%= t('results_for', :scope => 'refinery.admin.search', :query => params[:search]) %></h2> | ||
<% end %> | ||
<% if @items.any? %> | ||
<%= render :partial => 'items' %> | ||
<% else %> | ||
<p> | ||
<% unless searching? %> | ||
<strong> | ||
<%= t('.no_items_yet') %> | ||
</strong> | ||
<% else %> | ||
<%= t('no_results', :scope => 'refinery.admin.search') %> | ||
<% end %> | ||
</p> | ||
<% end %> |
9 changes: 9 additions & 0 deletions
9
app/views/refinery/portfolio/admin/items/_sortable_list.html.erb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
<ul class='sortable_list'> | ||
<%= render :partial => 'item', | ||
:collection => @items, | ||
:locals => { | ||
:collection => @items | ||
} %> | ||
</ul> | ||
<%= render :partial => "/refinery/admin/sortable_list", :locals => { :continue_reordering => !!local_assigns[:continue_reordering] } %> | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
<section id='records' class='tree'> | ||
<%= render 'records' %> | ||
</section> | ||
|
||
<section id='actions' | ||
<%= render :partial => 'actions' %> | ||
</section> | ||
|
||
<%= render '/refinery/admin/make_sortable', :tree => false if @items.many? %> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
<%= render :partial => "form" %> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
class AddPositionToPortfolioItems < ActiveRecord::Migration | ||
def change | ||
add_column :refinery_portfolio_items, :position, :integer | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,87 @@ | ||
require "spec_helper" | ||
include ActionController::RecordIdentifier | ||
|
||
describe Refinery do | ||
describe "Portfolio" do | ||
describe "Admin" do | ||
describe "Items" do | ||
login_refinery_user | ||
|
||
let(:image) { mock_model(Refinery::Image, :id => 23, :url => 'http://gifs.gifbin.com/1236681924_snail_transformers.gif') } | ||
let(:item) { FactoryGirl.create(:item, :gallery_id => nil, :image_id => 23) } | ||
let(:gallery) { FactoryGirl.create(:gallery) } | ||
|
||
describe "items list" do | ||
before(:each) do | ||
item.stub(:image).and_return(image) | ||
::Refinery::Portfolio::Item.stub(:root_items).and_return([item]) | ||
end | ||
|
||
context "no parent gallery" do | ||
it "shows items" do | ||
visit refinery.portfolio_admin_galleries_path | ||
within "#actions" do | ||
click_link "View top-level images" | ||
end | ||
|
||
page.should have_content item.title | ||
end | ||
end | ||
|
||
context "parent gallery" do | ||
before(:each) do | ||
gallery.stub(:items).and_return([item]) | ||
end | ||
|
||
it "shows items" do | ||
pending "Needs implementation" | ||
visit refinery.portfolio_admin_galleries_path | ||
within("##{dom_id(gallery)}") do | ||
click_link 'Edit' | ||
end | ||
|
||
page.should have_content(item.title) | ||
end | ||
end | ||
end | ||
|
||
describe "create" do | ||
context "valid data" do | ||
it "succeeds" do | ||
pending "Needs implementation" | ||
visit refinery.portfolio_admin_galleries_path | ||
within("#actions") do | ||
click_link 'Add an image' | ||
end | ||
|
||
fill_in :title, :with => "My Image" | ||
click_link "There is currently no image selected, please click here to add one." | ||
save_and_open_page | ||
end | ||
end | ||
|
||
context "invalid data" do | ||
it "fails" do | ||
end | ||
end | ||
|
||
context "duplicate" do | ||
it "fails" do | ||
end | ||
end | ||
end | ||
|
||
describe "edit" do | ||
it "succeeds" do | ||
end | ||
end | ||
|
||
describe "destroy" do | ||
it "succeeds" do | ||
end | ||
end | ||
|
||
end | ||
end | ||
end | ||
end |
Oops, something went wrong.