Ejemplo n.º 1
0
        protected override void loadData()
        {
            var staticFil = FormItemList.CreateStack(generalSetup: new FormItemListSetup(buttonSetup: new ButtonSetup("Submit")));

            staticFil.AddFormItems(
                new TextControl("Values here will be retained across post-backs", true).ToFormItem(label: "Static Field".ToComponents()),
                new TextControl("", true).ToFormItem(label: "Static Field".ToComponents()),
                new TextControl(
                    "Edit this one to get a validation error",
                    true,
                    setup: TextControlSetup.Create(validationPredicate: valueChangedOnPostBack => valueChangedOnPostBack),
                    validationMethod: (postBackValue, validator) => validator.NoteErrorAndAddMessage("You can't change the value in this box!")).ToFormItem(
                    label: "Static Field".ToComponents()));
            ph.AddControlsReturnThis(staticFil.ToCollection().GetControls());

            ph.AddControlsReturnThis(getBasicRegionComponents().GetControls());

            var listTable = EwfTable.Create(
                style: EwfTableStyle.StandardLayoutOnly,
                fields: new[] { 10, 1, 10 }.Select(i => new EwfTableField(size: i.ToPercentage())).Materialize());

            listTable.AddItem(
                EwfTableItem.Create(
                    EwfTableItemSetup.Create(verticalAlignment: TableCellVerticalAlignment.Top),
                    getNonIdListRegionComponents().ToCell(),
                    "".ToCell(),
                    getIdListRegionComponents().ToCell()));
            ph.AddControlsReturnThis(listTable.ToCollection().GetControls());
        }
Ejemplo n.º 2
0
 private IEnumerable <Func <EwfTableItem> > getItems(int count, bool includeId)
 {
     return(from i in Enumerable.Range(1, count)
            select new Func <EwfTableItem>(
                () => EwfTableItem.Create(
                    EwfTableItemSetup.Create(
                        activationBehavior: ElementActivationBehavior.CreateHyperlink(ActionControls.GetInfo()),
                        id: includeId ? new SpecifiedValue <int>(i) : null),
                    i.ToString().ToCell(),
                    ((i * 2) + Environment.NewLine + "extra stuff").ToCell())));
 }
        protected override PageContent getContent()
        {
            var content = new UiPageContent(omitContentBox: true);

            if (UserManagementStatics.IdentityProviders.OfType <SamlIdentityProvider>().Any())
            {
                var certificate = UserManagementStatics.GetCertificate();
                content.Add(
                    new Section(
                        "Identity providers",
                        FormItemList.CreateStack(
                            items:
                            (certificate.Any()
                                                                          ? "Certificate valid until {0}.".FormatWith(
                                 new X509Certificate2(Convert.FromBase64String(certificate), UserManagementStatics.CertificatePassword).NotAfter
                                 .ToDayMonthYearString(
                                     false))
                             .ToComponents()
                                                                          : "No certificate.".ToComponents()).Concat(" ".ToComponents())
                            .Append(
                                new EwfButton(
                                    new StandardButtonStyle("Regenerate", buttonSize: ButtonSize.ShrinkWrap),
                                    behavior: new ConfirmationButtonBehavior(
                                        "Are you sure?".ToComponents(),
                                        postBack: PostBack.CreateFull(
                                            "certificate",
                                            modificationMethod: () => UserManagementStatics.UpdateCertificate(generateCertificate(DateTimeOffset.UtcNow))))))
                            .Materialize()
                            .ToFormItem(label: "System self-signed certificate".ToComponents())
                            .Concat(
                                AuthenticationStatics.SamlIdentityProviders.Any()
                                                                                ? new EwfHyperlink(EnterpriseWebFramework.UserManagement.SamlResources.Metadata.GetInfo(), new StandardHyperlinkStyle(""))
                                .ToFormItem(label: "Application SAML metadata".ToComponents())
                                .ToCollection()
                                                                                : Enumerable.Empty <FormItem>())
                            .Materialize())
                        .ToCollection(),
                        style: SectionStyle.Box));
            }
            content.Add(
                new Section(
                    "System users",
                    EwfTable.Create(
                        tableActions: new HyperlinkSetup(new SystemUser(Es, null), "Create User").ToCollection(),
                        headItems: EwfTableItem.Create("Email".ToCell().Append("Role".ToCell()).Materialize()).ToCollection())
                    .AddData(
                        UserManagementStatics.SystemProvider.GetUsers(),
                        user => EwfTableItem.Create(
                            user.Email.ToCell().Append(user.Role.Name.ToCell()).Materialize(),
                            setup: EwfTableItemSetup.Create(activationBehavior: ElementActivationBehavior.CreateHyperlink(new SystemUser(Es, user.UserId)))))
                    .ToCollection(),
                    style: SectionStyle.Box));
            return(content);
        }
 protected override void loadData()
 {
     ph.AddControlsReturnThis(
         EwfTable
         .Create(
             tableActions: new HyperlinkSetup(new EditUser.Info(es.info, null), "Create User").ToCollection(),
             headItems: EwfTableItem.Create("Email".ToCell().Append("Role".ToCell()).Materialize()).ToCollection())
         .AddData(
             UserManagementStatics.GetUsers(),
             user => EwfTableItem.Create(
                 user.Email.ToCell().Append(user.Role.Name.ToCell()).Materialize(),
                 setup: EwfTableItemSetup.Create(
                     activationBehavior: ElementActivationBehavior.CreateRedirectScript(new EditUser.Info(es.info, user.UserId)))))
         .ToCollection()
         .GetControls());
 }
        protected override void loadData()
        {
            var itemGroups = Enumerable.Range(1, 2)
                             .Select(
                group => ColumnPrimaryItemGroup.Create(
                    "Group {0}".FormatWith(group).ToComponents(),
                    groupActions:
                    new ButtonSetup(
                        "Action 1",
                        behavior: new PostBackBehavior(
                            postBack: PostBack.CreateIntermediate(
                                null,
                                id: PostBack.GetCompositeId(group.ToString(), "action1"),
                                firstModificationMethod: () => AddStatusMessage(StatusMessageType.Info, "Action 1")))).Append(
                        new ButtonSetup(
                            "Action 2",
                            behavior: new PostBackBehavior(
                                postBack: PostBack.CreateIntermediate(
                                    null,
                                    id: PostBack.GetCompositeId(group.ToString(), "action2"),
                                    firstModificationMethod: () => AddStatusMessage(StatusMessageType.Info, "Action 2")))))
                    .Materialize(),
                    selectedItemActions: group == 1
                                                                             ? SelectedItemAction.CreateWithIntermediatePostBackBehavior <int>(
                        "Echo group IDs",
                        null,
                        ids => AddStatusMessage(
                            StatusMessageType.Info,
                            StringTools.GetEnglishListPhrase(ids.Select(i => i.ToString()), true)))
                    .ToCollection()
                                                                             : Enumerable.Empty <SelectedItemAction <int> >().Materialize(),
                    items: Enumerable.Range(1, 5)
                    .Select(
                        i => EwfTableItem.Create(
                            EwfTableItemSetup.Create(
                                activationBehavior: ElementActivationBehavior.CreateRedirectScript(ActionControls.GetInfo()),
                                id: new SpecifiedValue <int>(group * 10 + i)),
                            i.ToString().ToCell(),
                            ((i * 2) + Environment.NewLine + "extra stuff").ToCell()))))
                             .Materialize();

            place.AddControlsReturnThis(
                ColumnPrimaryTable.Create(
                    caption: "My table",
                    subCaption: "A new table implementation",
                    allowExportToExcel: true,
                    tableActions: new ButtonSetup(
                        "Action",
                        behavior: new PostBackBehavior(
                            postBack: PostBack.CreateIntermediate(
                                null,
                                id: "action",
                                firstModificationMethod: () => AddStatusMessage(StatusMessageType.Info, "You clicked action.")))).ToCollection(),
                    selectedItemActions: SelectedItemAction
                    .CreateWithIntermediatePostBackBehavior <int>(
                        "Echo IDs",
                        null,
                        ids => AddStatusMessage(StatusMessageType.Info, StringTools.GetEnglishListPhrase(ids.Select(i => i.ToString()), true)))
                    .Append(
                        SelectedItemAction.CreateWithIntermediatePostBackBehavior <int>(
                            "With confirmation",
                            null,
                            ids => AddStatusMessage(StatusMessageType.Info, StringTools.GetEnglishListPhrase(ids.Select(i => i.ToString()), true)),
                            confirmationDialogContent: "Are you sure?".ToComponents()))
                    .Materialize(),
                    fields: new[] { new EwfTableField(size: 1.ToPercentage()), new EwfTableField(size: 2.ToPercentage()) })
                .AddItemGroups(itemGroups)
                .ToCollection()
                .GetControls());
        }