public override async Task <IDisplayResult> EditAsync(SubscriptionGroupAccessPart part, BuildPartEditorContext context)
        {
            var subscriptions = await _subscriptionGroupsService.GetAllAsync();

            return(Initialize <SubscriptionGroupAccessPartViewModel>("SubscriptionGroupAccessPart_Edit", model => {
                model.SubscriptionGroupSelection = _subscriptionGroupPartService.SelectedSubscriptionGroupParts(subscriptions, part);
            })
                   .Location("Parts#Subscription:5"));
        }
Exemplo n.º 2
0
 public override IDisplayResult Edit(ProjectionPart part, BuildPartEditorContext context)
 {
     return(Initialize <ProjectionEditPartViewModel>("ProjectionPart_Edit", async m => await BuildViewModelAsync(m, part, context.Updater))
            .Location("Detail", "Content:5")
            );
 }
 public virtual Task <IDisplayResult> UpdateAsync(TPart part, BuildPartEditorContext context)
 {
     return(UpdateAsync(part, context.Updater));
 }
        public async override Task <IDisplayResult> EditAsync(LocalizedTextPart part, BuildPartEditorContext context)
        {
            var cultures = await _localizationService.GetSupportedCulturesAsync();

            return(Initialize <EditLocalizedTextFieldViewModel>(GetEditorShapeType(context), model =>
            {
                model.Part = part;
                model.SupportedCultures = JsonConvert.SerializeObject(cultures);
                model.Data = JsonConvert.SerializeObject(part.Data ?? new List <LocalizedTextEntry>(), Formatting.None);
            }));
        }
Exemplo n.º 5
0
 public override IDisplayResult Edit(AliasPart aliasPart, BuildPartEditorContext context)
 {
     return(Initialize <AliasPartViewModel>(GetEditorShapeType(context), m => BuildViewModel(m, aliasPart, context.TypePartDefinition.GetSettings <AliasPartSettings>())));
 }
Exemplo n.º 6
0
 public override IDisplayResult Edit(WorkDocumentPart part, BuildPartEditorContext context)
 {
     return(Initialize <WorkDocumentPartEditViewModel>("WorkDocumentPart_Edit", m => BuildEditViewModel(m, part, context.TypePartDefinition.GetSettings <WorkDocumentPartSettings>()))
            .Location("Detail", "Content:5")
            );
 }
//        public override IDisplayResult Display(TabPanelPart part)
//        {
//            return Combine(
//                Initialize<TabPanelPartViewModel>("TabPanelPartPart", m => BuildViewModel(m, part))
//                    .Location("Detail", "Content:20")
////                Initialize<DisqusPartViewModel>("DisqusPart_Summary", m => BuildViewModel(m, disqusPart))
////                    .Location("Summary", "Meta:5")
//            );
//        }

        public override IDisplayResult Edit(TabPanelPart part, BuildPartEditorContext context)
        {
            return(Initialize <TabPanelPartViewModel>("TabPanelPart_Edit", m => BuildViewModel(m, part)));
        }
 public override IDisplayResult Edit(GraphLookupPart part, BuildPartEditorContext context)
 {
     return(Initialize <GraphLookupPartViewModel>("GraphLookupPart_Edit", m => BuildViewModel(m, part, context)));
 }
//todo: why does warning not appear on save, but later when view content items?
#pragma warning disable S1172 // Unused method parameters should be removed
        private void BuildViewModel(GraphLookupPartViewModel model, GraphLookupPart part, BuildPartEditorContext context)
#pragma warning restore S1172 // Unused method parameters should be removed
        {
            var settings = GetGraphLookupPartSettings(part);

            //todo: rename
            model.ItemIds = string.Join(",", part.Nodes.Select(n => n.Id));
            //todo: store id's also, so no need to go back to graph

            model.GraphLookupPart = part;
            //todo: view needs partname & field name, not whole PartFieldDefinition.
            //todo: check if really needs them, and if so, find them without this...
            //model.PartFieldDefinition = context.TypePartDefinition.PartDefinition.Fields.First(f => f.Name == "todo");
            model.PartName = context.TypePartDefinition.PartDefinition.Name;
            model.Settings = settings;

            model.SelectedItems = part.Nodes;
        }
Exemplo n.º 10
0
 public override IDisplayResult Edit(OrderPart orderPart, BuildPartEditorContext context)
 => Initialize <OrderPartViewModel>(GetEditorShapeType(context), m => BuildViewModel(m, orderPart));
Exemplo n.º 11
0
 public override IDisplayResult Edit(AddressPart part, BuildPartEditorContext context)
 {
     return(Initialize <AddressPartViewModel>("AddressPart_Edit", m => BuildViewModel(m, part))
            .Location("Detail", "Content:5")
            );
 }
        public override async Task <IDisplayResult> EditAsync(SubscriptionGroupSelectPart part, BuildPartEditorContext context)
        {
            var subscriptionGroups = await _subscriptionGroupsService.GetAllAsync();

            return(Initialize <SubscriptionGroupSelectPartViewModel>("SubscriptionGroupSelectPart_Edit", model => {
                model.SubscriptionGroups = subscriptionGroups;
                model.SubscriptionGroup = part.SubscriptionGroup;
                return;
            }));
        }
Exemplo n.º 13
0
        public override async Task <IDisplayResult> EditAsync(SubscriptionLevelPart part, BuildPartEditorContext context)
        {
            var subscriptions = await _subscriptionsService.GetAllAsync();

            return(Initialize <SubscriptionLevelPartViewModel>("SubscriptionLevelPart_Edit", model => {
                model.Subscription = part.Subscription;
                model.Subscriptions = subscriptions;
                model.SubscriptionSelection = _subscriptionPartService.SelectedSubscriptionParts(model.Subscriptions, part);

                model.Settings = _subscriptionLevelService.GetSettings(part);

                return;
            })
                   .Location("Parts#Subscription:5"));
        }
Exemplo n.º 14
0
 public override IDisplayResult Edit(DisqusPart disqusPart, BuildPartEditorContext context)
 {
     return(Initialize <DisqusPartViewModel>("DisqusPart_Edit", m => BuildViewModel(m, disqusPart, context.TypePartDefinition.GetSettings <DisqusPartSettings>())));
 }
        public override async Task <IDisplayResult> EditAsync(UserGroupListPart part, BuildPartEditorContext context)
        {
            var allUsers = await _session.Query <User, UserIndex>().ListAsync();//User Service should have a function to get all users

            return(Initialize <UserGroupListPartEditViewModel>("UserGroupListPart_Edit", model =>
            {
                foreach (var user in allUsers)
                {
                    var isUserInList = part.UserGroupMembers.FirstOrDefault(x => x.Email == user.Email);
                    model.SelectedUsers.Add(
                        new GroupUserEditViewModel()
                    {
                        GroupUser = new GroupUser()
                        {
                            Username = user.UserName, Email = user.Email
                        },
                        IsInGroup = isUserInList != null
                    }
                        );
                }
            }));
        }
Exemplo n.º 16
0
 public override IDisplayResult Edit(PartyPart part, BuildPartEditorContext context)
 {
     return(Initialize <PartyPartViewModel>("PartyPart_Edit", async m => await BuildViewModel(m, part))
            .Location("Detail", "Content:5")
            );
 }
 public override IDisplayResult Edit(PersonPart part, BuildPartEditorContext context)
 {
     return(Initialize <PersonPartViewModel>(GetEditorShapeType(context), viewModel => PopulateViewModel(part, viewModel))
            .Location("Content:5"));
 }
        Task <IDisplayResult> IContentPartDisplayDriver.BuildEditorAsync(ContentPart contentPart, ContentTypePartDefinition typePartDefinition, BuildEditorContext context)
        {
            var buildEditorContext = new BuildPartEditorContext(typePartDefinition, context);

            return(EditAsync(contentPart, buildEditorContext));
        }
//        public override IDisplayResult Display(TabPanelPart part)
//        {
//            return Combine(
//                Initialize<TabPanelPartViewModel>("TabPanelPartPart", m => BuildViewModel(m, part))
//                    .Location("Detail", "Content:20")
////                Initialize<DisqusPartViewModel>("DisqusPart_Summary", m => BuildViewModel(m, disqusPart))
////                    .Location("Summary", "Meta:5")
//            );
//        }

        public override IDisplayResult Edit(WizardConfigPart configPart, BuildPartEditorContext context)
        {
            return(Initialize <WizardConfigPartViewModel>("WizardConfigPart_Edit", m => BuildViewModel(m, configPart)));
        }
Exemplo n.º 20
0
 public override IDisplayResult Edit(MarkdownBodyPart MarkdownBodyPart, BuildPartEditorContext context)
 {
     return(Initialize <MarkdownBodyPartViewModel>(GetEditorShapeType(context), m => BuildViewModel(m, MarkdownBodyPart, context.TypePartDefinition)));
 }
 public override IDisplayResult Edit(DashboardPart dashboardPart, BuildPartEditorContext context)
 {
     return(Initialize <DashboardPartViewModel>(GetEditorShapeType(context), m => BuildViewModel(m, dashboardPart)));
 }
Exemplo n.º 22
0
 public override IDisplayResult Edit(HtmlMenuItemPart part, BuildPartEditorContext context)
 {
     return(Initialize <HtmlMenuItemPartEditViewModel>("HtmlMenuItemPart_Edit", m => BuildViewModel(m, part, context.TypePartDefinition)));
 }
Exemplo n.º 23
0
        public override async Task <IDisplayResult> EditAsync(ContentPermissionsPart part, BuildPartEditorContext context)
        {
            var roles = await _roleService.GetRoleNamesAsync();

            return(Initialize <ContentPermissionsPartEditViewModel>("ContentPermissionsPart_Edit", model =>
            {
                model.ContentPermissionsPart = part;
                model.Enabled = part.Enabled;
                model.PossibleRoles = roles.ToArray();
                model.Roles = part.Roles;
            }));
        }
Exemplo n.º 24
0
 protected string GetEditorShapeType(BuildPartEditorContext context)
 {
     return(GetEditorShapeType(context.TypePartDefinition));
 }
        public override async Task <IDisplayResult> UpdateAsync(WidgetsListPart part, BuildPartEditorContext context)
        {
            var contentItemDisplayManager = _serviceProvider.GetRequiredService <IContentItemDisplayManager>();

            var model = new WidgetsListPartEditViewModel {
                WidgetsListPart = part
            };

            await context.Updater.TryUpdateModelAsync(model, Prefix);

            part.Widgets.Clear();

            // Remove any content or the zones would be merged and not be cleared
            part.Content.Widgets.RemoveAll();

            for (var i = 0; i < model.Prefixes.Length; i++)
            {
                var contentType = model.ContentTypes[i];
                var zone        = model.Zones[i];
                var prefix      = model.Prefixes[i];

                var contentItem = await _contentManager.NewAsync(contentType);

                contentItem.Weld(new WidgetMetadata());

                var widgetModel = await contentItemDisplayManager.UpdateEditorAsync(contentItem, context.Updater, context.IsNew, htmlFieldPrefix : prefix);

                if (!part.Widgets.ContainsKey(zone))
                {
                    part.Widgets.Add(zone, new List <ContentItem>());
                }

                part.Widgets[zone].Add(contentItem);
            }

            return(Edit(part, context));
        }
Exemplo n.º 26
0
        public override async Task <IDisplayResult> EditAsync(ContentApprovalPart part, BuildPartEditorContext context)
        {
            var httpContext   = _httpContextAccessor.HttpContext;
            var baseShapeName = GetEditorShapeType(context);

            // Have to do Publish Content permissions first
            if (await _authorizationService.AuthorizeAsync(httpContext?.User, OrchardCore.Contents.Permissions.PublishContent, part.ContentItem))
            {
                var shapeName = $"{ baseShapeName }_ApprovalResponse";
                return(Initialize <ApprovalResponseViewModel>(shapeName,
                                                              model => PopulateApprovalResponseViewModel(part, model))
                       .Location("Actions:First"));
            }
            else if (await _authorizationService.AuthorizeAsync(httpContext?.User, Permissions.RequestApproval, part.ContentItem))
            {
                var shapeName = $"{ baseShapeName }_ApprovalRequest";
                return(Initialize <ApprovalRequestViewModel>(shapeName,
                                                             model => PopulateApprovalRequestViewModel(part, model))
                       .Location("Actions:Last"));
            }

            return(null);
        }
Exemplo n.º 27
0
 public virtual IDisplayResult Edit(TPart part, BuildPartEditorContext context)
 {
     return(Edit(part));
 }
 public override IDisplayResult Edit(PublishLaterPart part, BuildPartEditorContext context)
 {
     return(Initialize <PublishLaterPartViewModel>(GetEditorShapeType(context),
                                                   model => PopulateViewModel(part, model))
            .Location("Actions:10"));
 }
 public virtual Task <IDisplayResult> EditAsync(TPart part, BuildPartEditorContext context)
 {
     return(Task.FromResult(Edit(part, context)));
 }
 public override IDisplayResult Edit(ProductPart productPart, BuildPartEditorContext context)
 {
     return(Initialize <ProductPartViewModel>(GetEditorShapeType(context), m => BuildViewModel(m, productPart)));
 }