#5467: Fixes the issue where the "Set as homepage" setting is not retained when saving,

The issue was that when you save a content item (without publishing it) while checking the "Set as homepage" checkbox, it would lose its checked status after save.
With this change, the checkbox is again rendered but in a checked status, so that when you do publish, it will become the homepage.

Fixes #5467
This commit is contained in:
Sipke Schoorstra
2015-07-02 13:01:49 +03:00
parent dbba4e2787
commit eebe29fec3
3 changed files with 8 additions and 8 deletions
@@ -67,9 +67,8 @@ namespace Orchard.Autoroute.Drivers {
var homepage = _aliasService.Get(string.Empty); var homepage = _aliasService.Get(string.Empty);
var displayRouteValues = _contentManager.GetItemMetadata(part).DisplayRouteValues; var displayRouteValues = _contentManager.GetItemMetadata(part).DisplayRouteValues;
if(homepage.Match(displayRouteValues)) { viewModel.IsHomePage = homepage.Match(displayRouteValues);
viewModel.PromoteToHomePage = true; viewModel.PromoteToHomePage = viewModel.IsHomePage || part.DisplayAlias == "/";
}
if (settings.PerItemConfiguration) { if (settings.PerItemConfiguration) {
// if enabled, the list of all available patterns is displayed, and the user can // if enabled, the list of all available patterns is displayed, and the user can
@@ -4,6 +4,7 @@ namespace Orchard.Autoroute.ViewModels {
public class AutoroutePartEditViewModel { public class AutoroutePartEditViewModel {
public AutorouteSettings Settings { get; set; } public AutorouteSettings Settings { get; set; }
public bool IsHomePage { get; set; }
public bool PromoteToHomePage { get; set; } public bool PromoteToHomePage { get; set; }
public string CurrentUrl { get; set; } public string CurrentUrl { get; set; }
public string CustomPattern { get; set; } public string CustomPattern { get; set; }
@@ -16,7 +16,7 @@
} }
} }
@if (!Model.PromoteToHomePage) { @if (!Model.IsHomePage) {
<fieldset class="permalink"> <fieldset class="permalink">
<label>@T("Permalink")</label> <label>@T("Permalink")</label>
@if (Model.Settings.AllowCustomPattern) { @if (Model.Settings.AllowCustomPattern) {
@@ -24,7 +24,7 @@
<span>@Url.MakeAbsolute("/")@urlPrefix</span> <span>@Url.MakeAbsolute("/")@urlPrefix</span>
<span>@Html.TextBoxFor(m => m.CurrentUrl, new { @class = "text is-url" })</span> <span>@Html.TextBoxFor(m => m.CurrentUrl, new { @class = "text is-url" })</span>
</span> </span>
<span class="hint">@T("Save the current item and leave the input empty to have it automatically generated using the pattern {0} e.g., {1}", defaultPattern.Name, defaultPattern.Description)</span> <span class="hint">@T("Save the current item and leave the input empty to have it automatically generated using the pattern {0} e.g., {1}.", defaultPattern.Name, defaultPattern.Description)</span>
} }
else { else {
var hintClass = string.Empty; var hintClass = string.Empty;
@@ -35,7 +35,7 @@
if (string.IsNullOrEmpty(Model.CurrentUrl) if (string.IsNullOrEmpty(Model.CurrentUrl)
|| (!string.IsNullOrEmpty(Model.CurrentUrl) && Model.Settings.AutomaticAdjustmentOnEdit)) { || (!string.IsNullOrEmpty(Model.CurrentUrl) && Model.Settings.AutomaticAdjustmentOnEdit)) {
<span class="@hintClass">@T("Save the current item and the url will be generated using the pattern {0} e.g., {1}", defaultPattern.Name, defaultPattern.Description)</span> <span class="@hintClass">@T("Save the current item and the url will be generated using the pattern {0} e.g., {1}.", defaultPattern.Name, defaultPattern.Description)</span>
} }
} }
@if (!String.IsNullOrEmpty(Model.CurrentUrl)) { @if (!String.IsNullOrEmpty(Model.CurrentUrl)) {
@@ -54,10 +54,10 @@
@Html.EditorFor(m => m.PromoteToHomePage) @Html.EditorFor(m => m.PromoteToHomePage)
<label for="@Html.FieldIdFor(m => m.PromoteToHomePage)" class="forcheckbox">@T("Set as home page")</label> <label for="@Html.FieldIdFor(m => m.PromoteToHomePage)" class="forcheckbox">@T("Set as home page")</label>
</span> </span>
<span class="hint">@T("Check to promote this content as the home page")</span> <span class="hint">@T("Check to promote this content as the home page.")</span>
</fieldset> </fieldset>
} }
} }
else { else {
<span>@T("This content is the current home page")</span> <span>@T("This content is the current home page.")</span>
} }