protected static void PropertySetHandlers(ActivatedContentContext context, ExtendedMenuItemPart part) { part.MenuVersionField.Setter(version => { // Adding consistency checks. Menu version set must be a version of the current menu var menu = part.As<MenuPart>().Menu; if (version == null || version.ContentItem == null || menu == null || menu.ContentItem.Id != version.ContentItem.Id) { part.Record.MenuVersionRecord = null; } else { part.Record.MenuVersionRecord = version.ContentItem.VersionRecord; } return version; }); if (part.MenuVersionField.Value != null) { part.MenuVersionField.Value = part.MenuVersionField.Value; } }
private static void UpdateUnderlyingMenuPart(PublishContentContext context, ExtendedMenuItemPart part) { if (!part.Is<MenuPart>()) return; part.As<MenuPart>().MenuPosition = part.Position; part.As<MenuPart>().MenuText = part.Text; }
protected void LazyLoadHandlers(LoadContentContext context, ExtendedMenuItemPart part) { part.MenuVersionField.Loader(() => { if (part.Record != null && part.Record.MenuVersionRecord != null) { // Adding consistency check - the version loaded must be a version of the currently set menu var menu = part.As<MenuPart>().Menu; if (menu != null && menu.Id == part.Record.MenuVersionRecord.ContentItemRecord.Id) { return context.ContentManager.Get(-1, VersionOptions.VersionRecord(part.Record.MenuVersionRecord.Id)); } // if the version is not consistent with the menu item - must be nullified part.MenuVersion = null; } return null; }); part.IsChangedField.Loader(() => _versions.HasDraftVersion(part.Id)); part.IsCurrentField.Loader(() => !part.IsDraft && part.HasPosition); part.IsDraftField.Loader(() => part.As<IVersionAspect>().Draft && !part.HasPosition && !part.HasPublished); part.IsNewField.Loader(() => !part.HasPublished); part.IsPublishedField.Loader(() => part.ContentItem.VersionRecord != null && part.As<IVersionAspect>().Published); part.PublishedVersionField.Loader(() => _versions.GetCurrent(part.ContentItem)); part.IsRemovedField.Loader(() => part.As<IVersionAspect>().Removed); part.HasPublishedField.Loader(() => _versions.HasPublishedVersion(part.Id)); part.HasLatestField.Loader(() => _versions.HasLatestVersion(part.Id)); // Forcing parent position to update if it hasn't been updated yet var parent = part.ParentPosition; }
protected void SetNewVersionValues(VersionContentContext context, ExtendedMenuItemPart part, ExtendedMenuItemPart newVersionPart) { if (newVersionPart.Is<CommonPart>()) { newVersionPart.As<CommonPart>().VersionModifiedUtc = part.As<CommonPart>().VersionModifiedUtc; } }
private void SetUpItemForVersion(ExtendedMenuItemPart item, IContent menuVersion) { item.MenuVersion = menuVersion; item.As<VersionInfoPart>().Draft = false; }