-
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?
Changes from all commits
7721655
b5e5430
7da93e4
a6d8f46
10ce4fa
67cdc3a
e16b84e
644fc21
72d2a23
af22105
b884b99
ee42f43
18a7f37
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||||||
---|---|---|---|---|---|---|---|---|---|---|
|
@@ -21,8 +21,16 @@ protected override DriverResult Display(ContentPart part, string displayType, dy | |||||||||
protected override DriverResult Editor(ContentPart part, dynamic shapeHelper) { | ||||||||||
var results = new List<DriverResult> { ContentShape("Content_SaveButton", saveButton => saveButton) }; | ||||||||||
|
||||||||||
if (part.TypeDefinition.Settings.GetModel<ContentTypeSettings>().Draftable) | ||||||||||
if (part.TypeDefinition.Settings.GetModel<ContentTypeSettings>().Draftable) { | ||||||||||
results.Add(ContentShape("Content_PublishButton", publishButton => publishButton)); | ||||||||||
if (part.ContentItem.IsPublished()) { | ||||||||||
BenedekFarkas marked this conversation as resolved.
Show resolved
Hide resolved
|
||||||||||
results.Add(ContentShape("Content_UnpublishButton", unpublishButton => unpublishButton)); | ||||||||||
} | ||||||||||
Comment on lines
+26
to
+28
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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
Suggested change
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 commentThe reason will be displayed to describe this comment to others. Learn more. The |
||||||||||
} | ||||||||||
|
||||||||||
if (part.Id > 0) { | ||||||||||
results.Add(ContentShape("Content_DeleteButton", deleteButton => deleteButton)); | ||||||||||
} | ||||||||||
|
||||||||||
return Combined(results.ToArray()); | ||||||||||
} | ||||||||||
|
Original file line number | Diff line number | Diff line change | ||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
@@ -6,8 +6,10 @@ | |||||||||||||||||
Parts_Contents_Publish_SummaryAdmin | ||||||||||||||||||
--> | ||||||||||||||||||
<!-- edit "shape" --> | ||||||||||||||||||
<Place Content_UnpublishButton="Sidebar:25"/> | ||||||||||||||||||
<Place Content_PublishButton="Sidebar:24"/> | ||||||||||||||||||
<Place Content_SaveButton="Sidebar:23"/> | ||||||||||||||||||
<Place Content_DeleteButton="Sidebar:22"/> | ||||||||||||||||||
Comment on lines
+9
to
+12
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Reordered them according to placement. Also
Suggested change
|
||||||||||||||||||
<Match DisplayType="Detail"> | ||||||||||||||||||
<Place Parts_Contents_Publish="Content:5"/> | ||||||||||||||||||
</Match> | ||||||||||||||||||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 commentThe reason will be displayed to describe this comment to others. Learn more. Unused using. |
||
|
||
@if (Authorizer.Authorize(Permissions.DeleteContent, (IContent)Model.ContentItem)) { | ||
<fieldset class="delete-button"> | ||
<button type="submit" name="submit.Delete" value="submit.Delete" itemprop="RemoveUrl">@T("Delete")</button> | ||
</fieldset> | ||
} |
Original file line number | Diff line number | Diff line change | ||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
@@ -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 commentThe reason will be displayed to describe this comment to others. Learn more. Unused using. |
||||||||||||||||||
@{ | ||||||||||||||||||
var contentItem = Model.ContentItem as IContent; | ||||||||||||||||||
} | ||||||||||||||||||
Comment on lines
+4
to
+6
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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.
Suggested change
|
||||||||||||||||||
@if (Authorizer.Authorize(Permissions.PublishContent, contentItem) && contentItem.IsPublished()) { | ||||||||||||||||||
<fieldset class="unpublish-button"> | ||||||||||||||||||
<button type="submit" name="submit.Unpublish" value="submit.Unpublish">@T("Unpublish")</button> | ||||||||||||||||||
</fieldset> | ||||||||||||||||||
} |
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Please use remove and sort usings and auto-formatting. |
Original file line number | Diff line number | Diff line change | ||||||||
---|---|---|---|---|---|---|---|---|---|---|
|
@@ -2,6 +2,7 @@ | |||||||||
using System.Collections.Generic; | ||||||||||
using Orchard.ContentManagement; | ||||||||||
using Orchard.ContentManagement.Drivers; | ||||||||||
using Orchard.Core.Contents.Settings; | ||||||||||
using Orchard.Localization; | ||||||||||
using Orchard.Utility.Extensions; | ||||||||||
using Orchard.Widgets.Models; | ||||||||||
|
@@ -35,26 +36,27 @@ protected override DriverResult Editor(WidgetPart widgetPart, dynamic shapeHelpe | |||||||||
() => shapeHelper.EditorTemplate(TemplateName: "Parts.Widgets.WidgetPart", Model: widgetPart, Prefix: Prefix)) | ||||||||||
}; | ||||||||||
|
||||||||||
if (widgetPart.Id > 0) | ||||||||||
results.Add(ContentShape("Widget_DeleteButton", | ||||||||||
deleteButton => deleteButton)); | ||||||||||
if (widgetPart.Id > 0 && widgetPart.TypeDefinition.Settings.GetModel<ContentTypeSettings>().Draftable) { | ||||||||||
BenedekFarkas marked this conversation as resolved.
Show resolved
Hide resolved
|
||||||||||
results.Add(ContentShape("Content_UnpublishButton", | ||||||||||
unpublishButton => unpublishButton)); | ||||||||||
} | ||||||||||
Comment on lines
+39
to
+42
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is already rendered by ContentsDriver.
Suggested change
|
||||||||||
|
||||||||||
return Combined(results.ToArray()); | ||||||||||
} | ||||||||||
|
||||||||||
protected override DriverResult Editor(WidgetPart widgetPart, IUpdateModel updater, dynamic shapeHelper) { | ||||||||||
updater.TryUpdateModel(widgetPart, Prefix, null, null); | ||||||||||
|
||||||||||
if(string.IsNullOrWhiteSpace(widgetPart.Title)) { | ||||||||||
if (string.IsNullOrWhiteSpace(widgetPart.Title)) { | ||||||||||
updater.AddModelError("Title", T("Title can't be empty.")); | ||||||||||
} | ||||||||||
|
||||||||||
// if there is a name, ensure it's unique | ||||||||||
if(!string.IsNullOrWhiteSpace(widgetPart.Name)) { | ||||||||||
if (!string.IsNullOrWhiteSpace(widgetPart.Name)) { | ||||||||||
widgetPart.Name = widgetPart.Name.ToHtmlName(); | ||||||||||
|
||||||||||
var widgets = _contentManager.Query<WidgetPart, WidgetPartRecord>().Where(x => x.Name == widgetPart.Name && x.Id != widgetPart.Id).Count(); | ||||||||||
if(widgets > 0) { | ||||||||||
if (widgets > 0) { | ||||||||||
updater.AddModelError("Name", T("A Widget with the same Name already exists.")); | ||||||||||
} | ||||||||||
} | ||||||||||
|
This file was deleted.
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -1130,14 +1130,14 @@ html.dyn #submit-pager, html.dyn .apply-bulk-actions-auto { display:none; } | |
padding:0; | ||
} | ||
|
||
fieldset.publish-button, fieldset.delete-button, fieldset.save-button { | ||
fieldset.publish-button, fieldset.delete-button, fieldset.save-button, fieldset.unpublish-button { | ||
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 commentThe 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 commentThe 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;
} |
||
.dir-rtl fieldset.publish-button, fieldset.delete-button, .dir-rtl fieldset.save-button, .dir-rtl fieldset.unpublish-button { | ||
float:right; | ||
} | ||
.dir-rtl fieldset.save-button { | ||
clear:right; | ||
} | ||
.dir-rtl fieldset.publish-button { | ||
.dir-rtl fieldset.publish-button, .dir-rtl fieldset.unpublish-button { | ||
margin: 0 0 0 12px ; | ||
} | ||
.dir-rtl fieldset.delete-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.
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.