Пример #1
0
        protected override DriverResult Display(ContentPart part, OptionSetField field, string displayType, dynamic shapeHelper)
        {
            return(ContentShape("Fields_OptionSetField", GetDifferentiator(field, part),
                                () => {
                var settings = field.PartFieldDefinition.Settings.GetModel <OptionSetFieldSettings>();
                var optionItems = _optionSetService.GetOptionItemsForContentItem(part.ContentItem.Id, field.Name).ToList();
                var optionSet = _optionSetService.GetOptionSet(settings.OptionSetId);

                return shapeHelper.Fields_OptionSetField(
                    ContentField: field,
                    OptionItems: optionItems,
                    Settings: settings,
                    OptionSet: optionSet);
            }));
        }
Пример #2
0
        public override void CustomDeleteAction(string fieldType, string fieldName, SettingsDictionary settingsDictionary)
        {
            if (fieldType != "OptionSetField")
            {
                return;
            }
            var optionSet = _optionSetService.GetOptionSet(int.Parse(settingsDictionary["ReferenceFieldSettings.OptionSetId"]));

            if (optionSet == null)
            {
                return;
            }
            _optionSetService.DeleteOptionSet(optionSet);
        }
Пример #3
0
        protected override DriverResult Display(OptionItemPart part, string displayType, dynamic shapeHelper)
        {
            return(Combined(
                       ContentShape("Parts_OptionItemPart_Feed", () => {
                // generates a link to the RSS feed for this term
                _feedManager.Register(part.Name, "rss", new RouteValueDictionary {
                    { "optionItem", part.Id }
                });
                return null;
            }),
                       ContentShape("Parts_OptionItemPart", () => {
                var pagerParameters = new PagerParameters();
                var httpContext = _httpContextAccessor.Current();
                if (httpContext != null)
                {
                    pagerParameters.Page = Convert.ToInt32(httpContext.Request.QueryString["page"]);
                }

                var pager = new Pager(_siteService.GetSiteSettings(), pagerParameters);
                var optionSet = _optionSetService.GetOptionSet(part.OptionSetId);
                var totalItemCount = 100;

                // asign Taxonomy and Term to the content item shape (Content) in order to provide
                // alternates when those content items are displayed when they are listed on a term
                var termContentItems = _optionSetService.GetContentItems(part, pager.GetStartIndex(), pager.PageSize)
                                       .Select(c => _contentManager.BuildDisplay(c, "Summary").Taxonomy(optionSet).Term(part));

                var list = shapeHelper.List();

                list.AddRange(termContentItems);

                var pagerShape = shapeHelper.Pager(pager)
                                 .TotalItemCount(totalItemCount)
                                 .Taxonomy(optionSet)
                                 .Term(part);

                return shapeHelper.Parts_TermPart(ContentItems: list, Taxonomy: optionSet, Pager: pagerShape);
            })));
        }