mirror of
https://github.com/OrchardCMS/Orchard.git
synced 2026-02-09 09:16:41 +08:00
Display the default location settings next to the actual values
For a part, we have settings coming from the part definition and settings coming from the part in the type definition, which take precedence. Display the former next to the later in the settings partial views. --HG-- branch : dev
This commit is contained in:
@@ -19,10 +19,6 @@ namespace Orchard.Core.ContentsLocation.Models {
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (this.TryGetValue("Default", out result)) {
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
return new ContentLocation { Zone = defaultZone, Position = defaultPosition };
|
return new ContentLocation { Zone = defaultZone, Position = defaultPosition };
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -32,14 +28,42 @@ namespace Orchard.Core.ContentsLocation.Models {
|
|||||||
return part.GetLocation(locationName, null, null);
|
return part.GetLocation(locationName, null, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static ContentLocation GetLocation<TContent>(this TContent part, string locationName, string defaultZone, string defaultPosition) where TContent : ContentPart {
|
public static ContentLocation GetLocation(this ContentPart part, string locationName, string defaultZone, string defaultPosition) {
|
||||||
// Get the specific location from the part in the type context
|
// Get the specific location from the part in the type context
|
||||||
var location = part.TypePartDefinition.Settings.GetModel<LocationSettings>().Get(locationName);
|
var location = part.TypePartDefinition.Settings.GetModel<LocationSettings>().Get(locationName);
|
||||||
if (location.Position != null || location.Zone != null)
|
if (location.Position != null || location.Zone != null)
|
||||||
return location;
|
return location;
|
||||||
|
|
||||||
|
// Get the "Default" location from the part in the type context
|
||||||
|
location = part.TypePartDefinition.Settings.GetModel<LocationSettings>().Get("Default");
|
||||||
|
if (location.Position != null || location.Zone != null)
|
||||||
|
return location;
|
||||||
|
|
||||||
// Get the specific location from the part definition
|
// Get the specific location from the part definition
|
||||||
return part.PartDefinition.Settings.GetModel<LocationSettings>().Get(locationName, defaultZone, defaultPosition);
|
location = part.PartDefinition.Settings.GetModel<LocationSettings>().Get(locationName);
|
||||||
|
if (location.Position != null || location.Zone != null)
|
||||||
|
return location;
|
||||||
|
|
||||||
|
// Get the "Default" location from the part definition
|
||||||
|
location = part.PartDefinition.Settings.GetModel<LocationSettings>().Get("Default");
|
||||||
|
if (location.Position != null || location.Zone != null)
|
||||||
|
return location;
|
||||||
|
|
||||||
|
return new ContentLocation { Zone = defaultZone, Position = defaultPosition };
|
||||||
|
}
|
||||||
|
|
||||||
|
public static ContentLocation GetLocation(this ContentField field, string locationName, string defaultZone, string defaultPosition) {
|
||||||
|
// Get the specific location from the part in the type context
|
||||||
|
var location = field.PartFieldDefinition.Settings.GetModel<LocationSettings>().Get(locationName);
|
||||||
|
if (location.Position != null || location.Zone != null)
|
||||||
|
return location;
|
||||||
|
|
||||||
|
// Get the "Default" location from the part in the type context
|
||||||
|
location = field.PartFieldDefinition.Settings.GetModel<LocationSettings>().Get("Default");
|
||||||
|
if (location.Position != null || location.Zone != null)
|
||||||
|
return location;
|
||||||
|
|
||||||
|
return new ContentLocation { Zone = defaultZone, Position = defaultPosition };
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1,5 +1,6 @@
|
|||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using Orchard.ContentManagement;
|
using Orchard.ContentManagement;
|
||||||
|
using Orchard.ContentManagement.Drivers;
|
||||||
using Orchard.ContentManagement.MetaData;
|
using Orchard.ContentManagement.MetaData;
|
||||||
using Orchard.ContentManagement.MetaData.Builders;
|
using Orchard.ContentManagement.MetaData.Builders;
|
||||||
using Orchard.ContentManagement.MetaData.Models;
|
using Orchard.ContentManagement.MetaData.Models;
|
||||||
@@ -26,12 +27,13 @@ namespace Orchard.Core.ContentsLocation.Settings {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private LocationSettings MergeSettings(LocationSettings partSettings, LocationSettings partDefinitionSettings) {
|
private LocationSettings MergeSettings(LocationSettings partSettings, LocationSettings partDefinitionSettings) {
|
||||||
var result = new LocationSettings(partSettings);
|
return partSettings;
|
||||||
foreach (var entry in partDefinitionSettings) {
|
//var result = new LocationSettings(partSettings);
|
||||||
if (!partSettings.ContainsKey(entry.Key))
|
//foreach (var entry in partDefinitionSettings) {
|
||||||
partSettings[entry.Key] = entry.Value;
|
// if (!partSettings.ContainsKey(entry.Key))
|
||||||
}
|
// partSettings[entry.Key] = entry.Value;
|
||||||
return result;
|
//}
|
||||||
|
//return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
#region Standalone part definition
|
#region Standalone part definition
|
||||||
@@ -41,7 +43,8 @@ namespace Orchard.Core.ContentsLocation.Settings {
|
|||||||
foreach (var location in GetPredefinedLocations()) {
|
foreach (var location in GetPredefinedLocations()) {
|
||||||
var viewModel = new LocationSettingsViewModel {
|
var viewModel = new LocationSettingsViewModel {
|
||||||
Definition = location,
|
Definition = location,
|
||||||
Location = settings.Get(location.Name)
|
Location = settings.Get(location.Name),
|
||||||
|
DefaultLocation = new ContentLocation()
|
||||||
};
|
};
|
||||||
yield return DefinitionTemplate(viewModel, templateName: "LocationSettings", prefix: location.Name);
|
yield return DefinitionTemplate(viewModel, templateName: "LocationSettings", prefix: location.Name);
|
||||||
}
|
}
|
||||||
@@ -70,7 +73,8 @@ namespace Orchard.Core.ContentsLocation.Settings {
|
|||||||
foreach (var location in GetPredefinedLocations()) {
|
foreach (var location in GetPredefinedLocations()) {
|
||||||
var viewModel = new LocationSettingsViewModel {
|
var viewModel = new LocationSettingsViewModel {
|
||||||
Definition = location,
|
Definition = location,
|
||||||
Location = settings.Get(location.Name)
|
Location = settings.Get(location.Name),
|
||||||
|
DefaultLocation = partDefinitionSettings.Get(location.Name)
|
||||||
};
|
};
|
||||||
yield return DefinitionTemplate(viewModel, templateName: "LocationSettings", prefix: location.Name);
|
yield return DefinitionTemplate(viewModel, templateName: "LocationSettings", prefix: location.Name);
|
||||||
}
|
}
|
||||||
@@ -94,7 +98,8 @@ namespace Orchard.Core.ContentsLocation.Settings {
|
|||||||
foreach (var location in GetPredefinedLocations()) {
|
foreach (var location in GetPredefinedLocations()) {
|
||||||
var viewModel = new LocationSettingsViewModel {
|
var viewModel = new LocationSettingsViewModel {
|
||||||
Definition = location,
|
Definition = location,
|
||||||
Location = settings.Get(location.Name)
|
Location = settings.Get(location.Name),
|
||||||
|
DefaultLocation = new ContentLocation { Zone = "body", Position = "" }
|
||||||
};
|
};
|
||||||
yield return DefinitionTemplate(viewModel, templateName: "LocationSettings", prefix: location.Name);
|
yield return DefinitionTemplate(viewModel, templateName: "LocationSettings", prefix: location.Name);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -5,5 +5,6 @@ namespace Orchard.Core.ContentsLocation.ViewModels {
|
|||||||
public class LocationSettingsViewModel {
|
public class LocationSettingsViewModel {
|
||||||
public LocationDefinition Definition { get; set; }
|
public LocationDefinition Definition { get; set; }
|
||||||
public ContentLocation Location { get; set; }
|
public ContentLocation Location { get; set; }
|
||||||
|
public ContentLocation DefaultLocation { get; set; }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -4,9 +4,11 @@
|
|||||||
|
|
||||||
<label for="<%:Html.FieldIdFor(m => m.Location.Zone) %>"><%:T("Zone name (e.g. body, primary)") %></label>
|
<label for="<%:Html.FieldIdFor(m => m.Location.Zone) %>"><%:T("Zone name (e.g. body, primary)") %></label>
|
||||||
<%:Html.EditorFor(m => m.Location.Zone)%>
|
<%:Html.EditorFor(m => m.Location.Zone)%>
|
||||||
|
<%: string.IsNullOrEmpty(Model.DefaultLocation.Zone) ? T("") : T("({0})", Model.DefaultLocation.Zone) %>
|
||||||
<%:Html.ValidationMessageFor(m => m.Location.Zone)%>
|
<%:Html.ValidationMessageFor(m => m.Location.Zone)%>
|
||||||
|
|
||||||
<label for="<%:Html.FieldIdFor(m => m.Location.Position) %>"><%:T("Position in zone (e.g. 1, 1.0, 2.5.1)") %></label>
|
<label for="<%:Html.FieldIdFor(m => m.Location.Position) %>"><%:T("Position in zone (e.g. 1, 1.0, 2.5.1)") %></label>
|
||||||
<%:Html.EditorFor(m => m.Location.Position)%>
|
<%:Html.EditorFor(m => m.Location.Position)%>
|
||||||
|
<%: string.IsNullOrEmpty(Model.DefaultLocation.Position) ? T("") : T("({0})", Model.DefaultLocation.Position) %>
|
||||||
<%:Html.ValidationMessageFor(m => m.Location.Position)%>
|
<%:Html.ValidationMessageFor(m => m.Location.Position)%>
|
||||||
</fieldset>
|
</fieldset>
|
||||||
|
|||||||
Reference in New Issue
Block a user