mirror of
https://github.com/OrchardCMS/Orchard.git
synced 2025-10-15 19:54:57 +08:00
Prevent unnecessary db calls for containers
This commit is contained in:
@@ -52,7 +52,7 @@ namespace Orchard.Core.Containers.Drivers {
|
||||
if (updater != null) {
|
||||
var oldContainerId = model.ContainerId;
|
||||
updater.TryUpdateModel(model, "Containable", null, new[] { "ShowContainerPicker", "ShowPositionEditor" });
|
||||
if (oldContainerId != model.ContainerId) {
|
||||
if (oldContainerId != model.ContainerId && settings.ShowContainerPicker) {
|
||||
if (commonPart != null) {
|
||||
var containerItem = _contentManager.Get(model.ContainerId, VersionOptions.Latest);
|
||||
commonPart.Container = containerItem;
|
||||
@@ -61,6 +61,7 @@ namespace Orchard.Core.Containers.Drivers {
|
||||
part.Position = model.Position;
|
||||
}
|
||||
|
||||
if (settings.ShowContainerPicker) {
|
||||
var containers = _contentManager
|
||||
.Query<ContainerPart, ContainerPartRecord>(VersionOptions.Latest)
|
||||
.List()
|
||||
@@ -75,6 +76,8 @@ namespace Orchard.Core.Containers.Drivers {
|
||||
.ToList();
|
||||
|
||||
model.AvailableContainers = new SelectList(listItems, "Value", "Text", model.ContainerId);
|
||||
}
|
||||
|
||||
model.Position = part.Position;
|
||||
|
||||
return shapeHelper.EditorTemplate(TemplateName: "Containable", Model: model, Prefix: "Containable");
|
||||
|
Reference in New Issue
Block a user