Exemplo n.º 1
0
        protected override DriverResult Editor(ContentPart part, ContentPickerField field, IUpdateModel updater, dynamic shapeHelper)
        {
            var model = new ContentPickerFieldViewModel {
                SelectedIds = ContentItemElement.Serialize(field.Ids)
            };

            updater.TryUpdateModel(model, GetPrefix(field, part), null, null);

            var settings = field.PartFieldDefinition.Settings.GetModel <ContentPickerFieldSettings>();
            var ids      = ContentItemElement.Deserialize(model.SelectedIds).ToArray();

            if (!settings.Required || ids.Length > 0)
            {
                mRelationshipService.SetRelationships(part.Id, field.Name, ids);
            }

            return(null);
        }
        protected override EditorResult OnBuildEditor(BootstrapContentItem element, ElementEditorContext context)
        {
            var layoutPart = context.Content;
            var viewModel  = new BootstrapContentItemViewModel();
            var editor     = context.ShapeFactory.EditorTemplate(TemplateName: "Elements.BootstrapContentItem", Model: viewModel);

            if (context.Updater != null)
            {
                context.Updater.TryUpdateModel(viewModel, context.Prefix, null, null);
                element.ContentItemIds = ContentItem.Deserialize(viewModel.ContentItemIds);
                element.DisplayType    = viewModel.DisplayType;
            }

            var contentItemIds  = element.ContentItemIds;
            var displayType     = element.DisplayType;
            var layoutContentId = layoutPart != null ? layoutPart.Id : 0;

            viewModel.ContentItems = GetContentItems(RemoveCurrentContentItemId(contentItemIds, layoutContentId)).ToArray();
            viewModel.DisplayType  = displayType;

            return(Editor(context, editor));
        }
        protected override EditorResult OnBuildEditor(SlickSlider element, ElementEditorContext context)
        {
            var viewModel = new SlickSliderEditorViewModel();
            var editor    = context.ShapeFactory.EditorTemplate(TemplateName: "Elements.SlickSlider", Model: viewModel);

            if (context.Updater != null)
            {
                context.Updater.TryUpdateModel(viewModel, context.Prefix, null, null);
                element.MediaItemIds = ContentItem.Deserialize(viewModel.ContentItemIds);
                element.SliderId     = viewModel.SliderId;
                element.Config       = XmlHelper.Serialize(viewModel.Config);
            }

            var contentItemIds = element.MediaItemIds;
            var layoutPart     = context.Content;
            var layoutId       = layoutPart != null ? layoutPart.Id : 0;

            viewModel.ContentItems = GetContentItems(RemoveCurrentContentItemId(contentItemIds, layoutId)).ToArray();
            viewModel.SliderId     = element.SliderId;
            viewModel.Config       = GetConfigObjectFromString(element.Config);

            return(Editor(context, editor));
        }
Exemplo n.º 4
0
 private static int?ParseImageId(string imageId)
 {
     return(ContentItem.Deserialize(imageId).FirstOrDefault());
 }