-
Notifications
You must be signed in to change notification settings - Fork 1.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
#8565: Delete and Unpublish buttons in backoffice content edit #8566
base: 1.10.x
Are you sure you want to change the base?
#8565: Delete and Unpublish buttons in backoffice content edit #8566
Conversation
@@ -352,6 +352,18 @@ public class AdminController : ContentControllerBase, IUpdateModel { | |||
return EditPOST(id, returnUrl, contentItem => _contentManager.Publish(contentItem)); | |||
} | |||
|
|||
[HttpPost, ActionName("Edit")] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why is this different that the other unpublish/delete actions?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I added delete and unpublish actions referencing specific submits to the controller. There already were unpublish and delete actions (the ones called from the lists), so I called those inside the new actions, specific to the edit form.
@sebastienros fixed as requested. |
Modified the code following Sebastien's remarks. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I really like the consolidation for the delete button! Please merge from 1.10.x.
However I'm unsure about adding the Unpublish button in the editor - is that really necessary UX-wise? I feel like it get can get a bit too crowded in the action button row.
Some of the editors I checked have minor styling issues under different circumstances, but some of those might be independent of this PR:
- BlogPost, Page, etc., when Draftable is enabled (default configuration) - too much space
- BlogPost, when Draftable is disabled - spacing missing:
EDIT: These spacing problems are addressed by my suggestions below.
src/Orchard.Web/Modules/Orchard.Blogs/Controllers/BlogPostAdminController.cs
Outdated
Show resolved
Hide resolved
src/Orchard.Web/Core/Contents/Views/Content.DeleteButton.cshtml
Outdated
Show resolved
Hide resolved
src/Orchard.Web/Core/Contents/Views/Content.UnpublishButton.cshtml
Outdated
Show resolved
Hide resolved
src/Orchard.Web/Core/Contents/Views/Content.UnpublishButton.cshtml
Outdated
Show resolved
Hide resolved
if (part.ContentItem.IsPublished()) { | ||
results.Add(ContentShape("Content_UnpublishButton", unpublishButton => unpublishButton)); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Re: the previous comment - shouldn't be just this then, since the template already checks IsPublished
?
if (part.ContentItem.IsPublished()) { | |
results.Add(ContentShape("Content_UnpublishButton", unpublishButton => unpublishButton)); | |
} | |
results.Add(ContentShape("Content_UnpublishButton", unpublishButton => unpublishButton)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't remember right now. I'll check asap.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The Content.UnpublishButton
template does check if the item is published.
Managed unpublish and delete button for blogs and widgets.
Condition for delete button visibility now checks for contentItem.Id > 0 instead of IsNew() function
…hape and avoid its duplication or confusing management via Placement.info.
Added comments to clarify how new Unpublish and Delete actions work.
…d checked the content is published before showing the unpublish button.
e2d564e
to
18a7f37
Compare
rebased on 1.10.x and applied some of @BenedekFarkas suggestions |
Sorry for replying just now, I'll be able to review later towards the end of September (after Harvest). |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please use remove and sort usings and auto-formatting.
@@ -0,0 +1,9 @@ | |||
@using Orchard.ContentManagement; | |||
@using Orchard.Core.Contents; | |||
@using Orchard.Utility.Extensions |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Unused using.
@@ -0,0 +1,11 @@ | |||
@using Orchard.ContentManagement; | |||
@using Orchard.Core.Contents; | |||
@using Orchard.Utility.Extensions; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Unused using.
@{ | ||
var contentItem = Model.ContentItem as IContent; | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Add empty lines around this block. I pointed this out earlier too and it would be easier if you just accepted my change suggestions in bulk, so that I don't have to go through all of them again to figure out what's fixed and what isn't.
@{ | |
var contentItem = Model.ContentItem as IContent; | |
} | |
@{ | |
var contentItem = Model.ContentItem as IContent; | |
} | |
if (part.ContentItem.IsPublished()) { | ||
results.Add(ContentShape("Content_UnpublishButton", unpublishButton => unpublishButton)); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The Content.UnpublishButton
template does check if the item is published.
<Place Content_UnpublishButton="Sidebar:25"/> | ||
<Place Content_PublishButton="Sidebar:24"/> | ||
<Place Content_SaveButton="Sidebar:23"/> | ||
<Place Content_DeleteButton="Sidebar:22"/> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reordered them according to placement. Also Content_DeleteButton
shouldn't be the first one, because it will be become the default action (e.g., when you hit enter while editing the title) just by virtue of being the first in the rendered HTML.
SaveButton should come first, then PublishButton (because SaveButton is not rendered if the type is not Draftable).
<Place Content_UnpublishButton="Sidebar:25"/> | |
<Place Content_PublishButton="Sidebar:24"/> | |
<Place Content_SaveButton="Sidebar:23"/> | |
<Place Content_DeleteButton="Sidebar:22"/> | |
<Place Content_SaveButton="Sidebar:23"/> | |
<Place Content_PublishButton="Sidebar:24"/> | |
<Place Content_UnpublishButton="Sidebar:25"/> | |
<Place Content_DeleteButton="Sidebar:26"/> |
clear:none; | ||
float:left; | ||
} | ||
fieldset.save-button { | ||
clear:left; | ||
} | ||
fieldset.publish-button { | ||
fieldset.publish-button, fieldset.unpublish-button { | ||
margin: 0 12px 0 0; | ||
padding: 0 12px; | ||
border-right:1px solid #ccc; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This styling was overcomplicated to begin with, but we don't need to complicate it further. You can apply this to the whole section between lines 1128 and 1147, so we don't need to care about how many items are rendered and in what order:
.edit-item-sidebar fieldset {
margin: 0;
padding: 0;
clear: none;
float: left;
}
.edit-item-sidebar fieldset:not(:first-child) {
margin-left: 12px;
}
.edit-item-sidebar fieldset:first-child {
clear: left;
}
fieldset.publish-button, fieldset.unpublish-button {
padding-right: 12px;
border-right: 1px solid #ccc;
}
fieldset.delete-button {
float: right;
}
@@ -1495,13 +1495,13 @@ html.dir-rtl { | |||
margin-left:inherit; | |||
margin-right:10px; | |||
} | |||
.dir-rtl fieldset.publish-button, fieldset.delete-button, .dir-rtl fieldset.save-button { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same as above, RTL version for lines 1498-1509:
.dir-rtl .edit-item-sidebar fieldset {
float: right;
}
.dir-rtl .edit-item-sidebar fieldset:first-child {
clear: right;
}
.dir-rtl .edit-item-sidebar fieldset:not(:first-child) {
margin-left: 0;
margin-right: 12px;
}
.dir-rtl fieldset.publish-button, fieldset.unpublish-button {
padding-right: 0;
border-right: none;
padding-left: 12px;
border-left: 1px solid #ccc;
}
.dir-rtl fieldset.delete-button {
float: left;
}
if (widgetPart.Id > 0 && widgetPart.TypeDefinition.Settings.GetModel<ContentTypeSettings>().Draftable) { | ||
results.Add(ContentShape("Content_UnpublishButton", | ||
unpublishButton => unpublishButton)); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is already rendered by ContentsDriver.
if (widgetPart.Id > 0 && widgetPart.TypeDefinition.Settings.GetModel<ContentTypeSettings>().Draftable) { | |
results.Add(ContentShape("Content_UnpublishButton", | |
unpublishButton => unpublishButton)); | |
} |
Fixes #8565
Added unpublish and delete buttons to backoffice content edit view.
Adapted Orchard.Blogs and Orchard.Widgets to be in line with the patch, adding a "unpublish-button" css class too (it is identical to "publish-button".
Regarding Orchard.Widgets, I removed previous delete button (Widget_DeleteButton shape, Widget.DeleteButton.cshtml) because it was now redundant and conflicted with the Core/Contents... button (not a terrible conflict, but both were displayed and editing the Placement.info turned to be a unreliable solution).
Modified / added actions to controllers when needed.