Permalink
Browse files

[#566] [BUG FIX] Can't move or remove portlets

Since portlets don't support inline editing, we need to display buttons to remove/move them.

We made this conditional on content not supporting inline editing, so that it doesn't clutter up pages.
  • Loading branch information...
1 parent e8b9205 commit 79d94724bfa25636c4cec2aba4b9f40ff5039ba5 @peakpg peakpg committed Mar 19, 2013
@@ -35,6 +35,20 @@
opacity:1;
}
+.cms-move-up-content-link {
+ @extend .cms-edit-content-link;
+ right: 32px;
+}
+.cms-move-down-content-link {
+ @extend .cms-edit-content-link;
+ right: 16px;
+}
+
+.cms-remove-content-link{
+ @extend .cms-edit-content-link;
+ right:50px;
+}
+
// *****************************************************************
// Deprecated (pre 4.0)
// The rest of these are the pre 4.0 UI controls and can be safely deleted after the UI revamp is complete.
@@ -81,6 +81,11 @@ def render_connectable(content_block)
"ERROR: #{e.message}"
end
+ # Some content doesn't have inline editing, so we need to conditionally show move up/down/remove buttons on the page
+ def content_supports_inline_editing?(connector)
+ content = connector.connectable
+ content.supports_inline_editing?
+ end
##
# Renders the toolbar for the CMS. All page templates need to include this or they won't be editable.
# Typically rendered as an iframe to avoid CSS/JS conflicts.
@@ -45,6 +45,11 @@ def self.helper_path
def self.helper_class
"#{name}Helper".constantize
end
+
+ # Portlets don't generally support inline editing. Subclasses can override this if they do though.
+ def supports_inline_editing?
+ false
+ end
end
end
@@ -4,6 +4,21 @@
remove: cms.connector_path(connector, format: :json),
edit_path: edit_cms_connectable_path(connectable, :_redirect_to => @page.path)
} do %>
+ <% if (!content_supports_inline_editing?(connector)) %>
+ <%= link_to(image_tag('cms/arrow-up.png', class: 'cms-move-up-content-link'),
+ move_up_connector_path(connector),
+ method: :put,
+ title: "Move this content up.") %>
+ <%= link_to(image_tag('cms/arrow-down.png', class: 'cms-move-down-content-link'),
+ move_down_connector_path(connector),
+ method: :put,
+ title: "Move this content down.") %>
+ <%= link_to image_tag("ckeditor/plugins/delete_content/icons/deletecontent.png", class: 'cms-remove-content-link', alt: "Remove content"),
+ cms.connector_path(connector, _redirect_to: @page.path),
+ method: :delete,
+ confirm:"Are you sure you want to remove this content from the page? (It will remain available in the Content Library.)",
+ title: "Remove this content from page (#{connectable.name})." %>
+ <% end %>
<%= link_to(image_tag('cms/pencil.png', class: 'cms-edit-content-link'),
edit_cms_connectable_path(connectable, :_redirect_to => @page.path),
title: "Edit this content.") %>
@@ -81,6 +81,10 @@ def connect_to_page
true
end
+ # By default, all content types will support inline editing. Subclasses can override this.
+ def supports_inline_editing?
+ true
+ end
#
# After blocks are updated, all pages they are connected to should also be updated,
# connecting the page to the new version of the block, as well as putting the pages into
View
@@ -20,7 +20,6 @@
### ToDo
-* [BUG] Can't move portlets up/down.
* [BUG][Minor] Inline (i.e. product.name) fields display have a <p> tag added by ckeditor, so they display as block elements. This might go away if we don't embed content blocks.
* [Improvement][Minor] Block Orders - Disable button based on position (i.e. Can't move first block up, last block down)
* [BUG][Trivial] If the same block appears twice on the same page, inline editing one will not cause the other to immediately show the update. (This is probably so rare as to be a non-issue anyway.)
@@ -27,6 +27,12 @@ def teardown
assert_equal expected.object_id, @block.connected_pages.object_id
end
+ test ".supports_inline_editing?" do
+ assert @block.supports_inline_editing?
+ end
+ test ".supports_inline_editing? shouldn't be true for portlet subclasses'" do
+ refute LoginPortlet.new.supports_inline_editing?
+ end
end
end

0 comments on commit 79d9472

Please sign in to comment.