diff --git a/src/Orchard.Web/Modules/Orchard.Widgets/Drivers/WidgetPartDriver.cs b/src/Orchard.Web/Modules/Orchard.Widgets/Drivers/WidgetPartDriver.cs index a38e7018766..c20af20b8af 100644 --- a/src/Orchard.Web/Modules/Orchard.Widgets/Drivers/WidgetPartDriver.cs +++ b/src/Orchard.Web/Modules/Orchard.Widgets/Drivers/WidgetPartDriver.cs @@ -36,22 +36,27 @@ protected override DriverResult Editor(WidgetPart widgetPart, dynamic shapeHelpe () => shapeHelper.EditorTemplate(TemplateName: "Parts.Widgets.WidgetPart", Model: widgetPart, Prefix: Prefix)) }; + if (widgetPart.Id > 0 && widgetPart.TypeDefinition.Settings.GetModel().Draftable) { + results.Add(ContentShape("Content_UnpublishButton", + unpublishButton => unpublishButton)); + } + 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().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.")); } }