public override IEnumerable<TemplateViewModel> TypePartEditor(ContentTypePartDefinition definition) { if (definition.PartDefinition.Name != "ContainerPart") yield break; var model = definition.Settings.GetModel<ContainerTypePartSettings>(); var partModel = definition.PartDefinition.Settings.GetModel<ContainerPartSettings>(); if (model.PageSizeDefault == null) model.PageSizeDefault = partModel.PageSizeDefault; if (model.PaginatedDefault == null) model.PaginatedDefault = partModel.PaginatedDefault; var viewModel = new ContainerTypePartSettingsViewModel { PageSizeDefault = model.PageSizeDefault, PaginatedDefault = model.PaginatedDefault, RestrictedItemContentTypes = _contentDefinitionManager.ParseContentTypeDefinitions(model.RestrictedItemContentTypes).Select(x => x.Name).ToList(), RestrictItemContentTypes = model.RestrictItemContentTypes, EnablePositioning = model.EnablePositioning, AdminListViewName = model.AdminListViewName, AvailableItemContentTypes = _containerService.GetContainableTypes().ToList(), ListViewProviders = _listViewService.Providers.ToList() }; yield return DefinitionTemplate(viewModel); }
public override IEnumerable<TemplateViewModel> TypePartEditorUpdate(ContentTypePartDefinitionBuilder builder, IUpdateModel updateModel) { if (builder.Name != "ContainerPart") yield break; var viewModel = new ContainerTypePartSettingsViewModel { AvailableItemContentTypes = _containerService.GetContainableTypes().ToList() }; updateModel.TryUpdateModel(viewModel, "ContainerTypePartSettingsViewModel", null, new[] { "AvailableItemContentTypes" }); builder.WithSetting("ContainerTypePartSettings.ItemsShownDefault", viewModel.ItemsShownDefault.ToString()); builder.WithSetting("ContainerTypePartSettings.PageSizeDefault", viewModel.PageSizeDefault.ToString()); builder.WithSetting("ContainerTypePartSettings.PaginatedDefault", viewModel.PaginatedDefault.ToString()); builder.WithSetting("ContainerTypePartSettings.RestrictedItemContentTypes", viewModel.RestrictedItemContentTypes != null ? string.Join(",", viewModel.RestrictedItemContentTypes) : ""); builder.WithSetting("ContainerTypePartSettings.RestrictItemContentTypes", viewModel.RestrictItemContentTypes.ToString()); builder.WithSetting("ContainerTypePartSettings.EnablePositioning", viewModel.EnablePositioning.ToString()); builder.WithSetting("ContainerTypePartSettings.AdminListViewName", viewModel.AdminListViewName); yield return DefinitionTemplate(viewModel); }