예제 #1
0
        protected override void loadData()
        {
            ph.AddControlsReturnThis(new LegacyParagraph("You may report any problems, make suggestions, or ask for help here."));

            FormState.ExecuteWithDataModificationsAndDefaultAction(
                PostBack.CreateFull(firstModificationMethod: modifyData, actionGetter: () => new PostBackAction(new ExternalResourceInfo(info.ReturnUrl)))
                .ToCollection(),
                () => {
                var list = FormItemList.CreateStack();
                list.AddFormItems(
                    new EmailAddress(AppTools.User.Email, AppTools.User.FriendlyName).ToMailAddress()
                    .ToString()
                    .ToComponents()
                    .ToFormItem(label: "From".ToComponents()),
                    "{0} ({1} for this system)".FormatWith(
                        StringTools.GetEnglishListPhrase(EmailStatics.GetAdministratorEmailAddresses().Select(i => i.DisplayName), true),
                        "support contacts".ToQuantity(EmailStatics.GetAdministratorEmailAddresses().Count(), showQuantityAs: ShowQuantityAs.None))
                    .ToComponents()
                    .ToFormItem(label: "To".ToComponents()),
                    body.ToTextControl(false, setup: TextControlSetup.Create(numberOfRows: 10), value: "").ToFormItem(label: "Message".ToComponents()));
                ph.AddControlsReturnThis(list.ToCollection().GetControls());

                EwfUiStatics.SetContentFootActions(new ButtonSetup("Send Message").ToCollection());
            });
        }
        void ControlTreeDataLoader.LoadData()
        {
            FormState.ExecuteWithDataModificationsAndDefaultAction(
                dataModifications,
                () => {
                if (TagKey == HtmlTextWriterTag.Button)
                {
                    Attributes.Add("name", EwfPage.ButtonElementName);
                    Attributes.Add("value", "v");
                    Attributes.Add("type", usesSubmitBehavior ? "submit" : "button");
                }

                FormAction action = postBackAction;
                action.AddToPageIfNecessary();

                if (ConfirmationWindowContentControl != null)
                {
                    if (usesSubmitBehavior)
                    {
                        throw new ApplicationException("PostBackButton cannot be the submit button and also have a confirmation message.");
                    }
                    confirmationWindow = new ModalWindow(this, ConfirmationWindowContentControl, title: "Confirmation", postBack: postBackAction.PostBack);
                }
                else if (!usesSubmitBehavior)
                {
                    PreRender += delegate { this.AddJavaScriptEventScript(JsWritingMethods.onclick, action.GetJsStatements() + " return false"); }
                }
                ;

                CssClass = CssClass.ConcatenateWithSpace("ewfClickable");
                ActionControlStyle.SetUpControl(this, "");
            });
        }
예제 #3
0
        /// <summary>
        /// Builds this LookupBox and returns the panel.
        /// </summary>
        public WebControl BuildLookupBoxPanel()
        {
            var val      = new DataValue <string>();
            var postBack = PostBack.CreateFull(id: postBackId, actionGetter: () => new PostBackAction(handler(val.Value)));

            return(FormState.ExecuteWithDataModificationsAndDefaultAction(
                       postBack.ToCollection(),
                       () => {
                var textBox = FormItem.Create(
                    "",
                    new EwfTextBox("")
                {
                    Width = new Unit(pixelWidth)
                },
                    validationGetter: control => new EwfValidation((pbv, validator) => val.Value = control.GetPostBackValue(pbv)));
                textBox.Control.SetWatermarkText(defaultText);
                if (autoCompleteService != null)
                {
                    textBox.Control.SetupAutoComplete(autoCompleteService, AutoCompleteOption.PostBackOnItemSelect);
                }

                return new Block(textBox.ToControl())
                {
                    CssClass = "ewfLookupBox"
                };
            }));
        }
        private IReadOnlyCollection <FlowComponent> getNewCommentComponents(UpdateRegionSet createUpdateRegions)
        {
            if (AppTools.User == null)
            {
                return(new Paragraph(
                           new EwfHyperlink(
                               EnterpriseWebLibrary.EnterpriseWebFramework.UserManagement.Pages.LogIn.GetInfo(Home.GetInfo().GetUrl()),
                               new StandardHyperlinkStyle("Sign in")).Concat(" or ".ToComponents())
                           .Append(new EwfHyperlink(User.GetInfo(), new StandardHyperlinkStyle("sign up")))
                           .Concat(" to add comments on this article.".ToComponents())
                           .Materialize()).ToCollection());
            }

            commentMod = getCommentMod();
            return(FormState.ExecuteWithDataModificationsAndDefaultAction(
                       PostBack.CreateIntermediate(
                           createUpdateRegions.ToCollection(),
                           id: "comment",
                           modificationMethod: () => {
                commentMod.CommentId = MainSequence.GetNextValue();
                commentMod.Execute();
            })
                       .ToCollection(),
                       () => new FlowIdContainer(
                           commentMod.GetBodyTextTextControlFormItem(
                               false,
                               label: Enumerable.Empty <PhrasingComponent>().Materialize(),
                               controlSetup: TextControlSetup.Create(numberOfRows: 3, placeholder: "Write a comment..."),
                               value: "")
                           .ToComponentCollection()
                           .Append(new EwfButton(new StandardButtonStyle("Post Comment"))),
                           updateRegionSets: createUpdateRegions.ToCollection()).ToCollection()));
        }
예제 #5
0
 protected override PageContent getContent() =>
 FormState.ExecuteWithDataModificationsAndDefaultAction(
     PostBack.CreateFull().ToCollection(),
     () => new UiPageContent().Add(
         FormItemList.CreateStack(
             generalSetup: new FormItemListSetup(buttonSetup: new ButtonSetup("Submit")),
             items: getControls().Select((getter, i) => getter((i + 1).ToString())).Materialize())));
예제 #6
0
 private IReadOnlyCollection <Func <string, FormItem> > getIndependentControls() =>
 new Func <string, FormItem>[]
 {
     id => {
         var pb = PostBack.CreateFull(id: id);
         return(FormState.ExecuteWithDataModificationsAndDefaultAction(pb.ToCollection(), () => get("Standard", null)(id)));
     },
     id => {
         var pb = PostBack.CreateFull(id: id);
         return(FormState.ExecuteWithDataModificationsAndDefaultAction(
                    pb.ToCollection(),
                    () => get(
                        "Auto-complete, triggers action when item selected",
                        TextControlSetup.CreateAutoComplete(TestService.GetInfo(), triggersActionWhenItemSelected: true))(id)));
     },
     id => {
         var pb = PostBack.CreateFull(id: id);
         return(FormState.ExecuteWithDataModificationsAndDefaultAction(
                    pb.ToCollection(),
                    () => get(
                        "Auto-complete, triggers action when item selected or value changed",
                        TextControlSetup.CreateAutoComplete(
                            TestService.GetInfo(),
                            triggersActionWhenItemSelected: true,
                            valueChangedAction: new PostBackFormAction(pb)))(id)));
     }
 };
        protected override void loadData()
        {
            var pb = PostBack.CreateFull(
                firstModificationMethod: () => {
                IntermediateAuthenticationMethods.SetCookie();
                AppRequestState.Instance.IntermediateUserExists = true;
            },
                actionGetter: () => new PostBackAction(new ExternalResourceInfo(info.ReturnUrl)));

            FormState.ExecuteWithDataModificationsAndDefaultAction(
                pb.ToCollection(),
                () => {
                ph.AddControlsReturnThis(
                    FormItemBlock.CreateFormItemTable(
                        formItems:
                        FormItem.Create(
                            "Enter your password for this non-live installation",
                            new EwfTextBox("", masksCharacters: true),
                            validationGetter: control => new EwfValidation(
                                (pbv, validator) => {
                    // NOTE: Using a single password here is a hack. The real solution is being able to use RSIS credentials, which is a goal.
                    var passwordMatch = control.GetPostBackValue(pbv) ==
                                        ConfigurationStatics.SystemGeneralProvider.IntermediateLogInPassword;
                    if (!passwordMatch)
                    {
                        validator.NoteErrorAndAddMessage("Incorrect password.");
                    }
                })).ToCollection()));
            });

            EwfUiStatics.SetContentFootActions(new ActionButtonSetup("Log In", new PostBackButton(pb)));
        }
        private IEnumerable <Control> getBasicRegionBlocks()
        {
            var rs = new UpdateRegionSet();
            var pb = PostBack.CreateIntermediate(rs.ToCollection(), id: "basic");

            yield return
                (new LegacyParagraph(new PostBackButton(new ButtonActionControlStyle("Toggle Basic Region Below"), usesSubmitBehavior: false, postBack: pb)));

            var regionControls    = new List <Control>();
            var dynamicFieldValue = new DataValue <string>();

            FormState.ExecuteWithDataModificationsAndDefaultAction(
                pb.ToCollection(),
                () => {
                if (info.Toggled)
                {
                    regionControls.Add(
                        FormItem.Create(
                            "Dynamic Field",
                            new EwfTextBox("This was just added!"),
                            validationGetter: control => new EwfValidation((pbv, validator) => dynamicFieldValue.Value = control.GetPostBackValue(pbv))).ToControl());
                }
                else
                {
                    regionControls.Add(new LegacyParagraph("Nothing here yet."));
                }
            });
            yield return
                (new NamingPlaceholder(new Section("Basic Update Region", regionControls, style: SectionStyle.Box).ToCollection(), updateRegionSets: rs.ToCollection()));

            pb.AddModificationMethod(() => parametersModification.Toggled = !parametersModification.Toggled);
            pb.AddModificationMethod(
                () =>
                AddStatusMessage(StatusMessageType.Info, info.Toggled ? "Dynamic field value was '{0}'.".FormatWith(dynamicFieldValue.Value) : "Dynamic field added."));
        }
        protected override void loadData()
        {
            ph.AddControlsReturnThis(new LegacyParagraph("You may report any problems, make suggestions, or ask for help here."));

            var pb = PostBack.CreateFull(firstModificationMethod: modifyData, actionGetter: () => new PostBackAction(new ExternalResourceInfo(info.ReturnUrl)));

            FormState.ExecuteWithDataModificationsAndDefaultAction(
                pb.ToCollection(),
                () => {
                var table = FormItemBlock.CreateFormItemTable();
                table.AddFormItems(
                    FormItem.Create(
                        "From",
                        new PlaceHolder().AddControlsReturnThis(
                            new EmailAddress(AppTools.User.Email, AppTools.User.FriendlyName).ToMailAddress().ToString().ToComponents().GetControls())),
                    FormItem.Create(
                        "To",
                        new PlaceHolder().AddControlsReturnThis(
                            "{0} ({1} for this system)".FormatWith(
                                StringTools.GetEnglishListPhrase(EmailStatics.GetAdministratorEmailAddresses().Select(i => i.DisplayName), true),
                                "support contacts".ToQuantity(EmailStatics.GetAdministratorEmailAddresses().Count(), showQuantityAs: ShowQuantityAs.None))
                            .ToComponents()
                            .GetControls())),
                    FormItem.Create(
                        "Message",
                        new EwfTextBox("", rows: 10),
                        validationGetter:
                        control =>
                        new EwfValidation(
                            (pbv, validator) => body.Value = validator.GetString(new ValidationErrorHandler("message"), control.GetPostBackValue(pbv), false))));
                ph.AddControlsReturnThis(table);
            });

            EwfUiStatics.SetContentFootActions(new ActionButtonSetup("Send Message", new PostBackButton(pb)));
        }
        void ControlTreeDataLoader.LoadData()
        {
            FormState.ExecuteWithDataModificationsAndDefaultAction(
                dataModifications,
                () => {
                CssClass = CssClass.ConcatenateWithSpace(CssElementCreator.CssClass);

                textBox = new EwfTextBox(
                    value.HasValue ? value.Value.ToMonthDayYearString() + " " + value.Value.ToHourAndMinuteString() : "",
                    disableBrowserAutoComplete: true,
                    autoPostBack: autoPostBack);
                Controls.Add(new ControlLine(textBox, getIconButton()));

                min = DateTime.MinValue;
                max = DateTime.MaxValue;
                if (constrainToSqlSmallDateTimeRange)
                {
                    min = Validator.SqlSmallDateTimeMinValue;
                    max = Validator.SqlSmallDateTimeMaxValue;
                }
                if (minDate.HasValue && minDate.Value > min)
                {
                    min = minDate.Value;
                }
                if (maxDate.HasValue && maxDate.Value < max)
                {
                    max = maxDate.Value;
                }

                if (ToolTip != null || ToolTipControl != null)
                {
                    new ToolTip(ToolTipControl ?? EnterpriseWebFramework.Controls.ToolTip.GetToolTipTextControl(ToolTip), this);
                }
            });
        }
 protected override PageContent getContent() =>
 FormState.ExecuteWithDataModificationsAndDefaultAction(
     PostBack.CreateFull().ToCollection(),
     () => new UiPageContent(contentFootActions: new ButtonSetup("Submit").ToCollection()).Add(
         new Section("Radio Button List, Vertical", FormItemList.CreateStack(items: getRadioItems(false).Materialize()).ToCollection())
         .Append(new Section("Radio Button List, Horizontal", FormItemList.CreateStack(items: getRadioItems(true).Materialize()).ToCollection()))
         .Append(getChosenUpgradeTestingInfo())
         .Append(new Section("Drop-Down List", FormItemList.CreateStack(items: getDropDownItems().Materialize()).ToCollection()))
         .Materialize()));
예제 #12
0
        protected override void loadData()
        {
            var pb =
                PostBack.CreateFull(
                    actionGetter:
                    () =>
                    new PostBackAction(
                        new SecondaryResponse(
                            () =>
                            EwfResponse.Create(
                                ContentTypes.ApplicationZip,
                                new EwfResponseBodyCreator(createAndZipSystem),
                                fileNameCreator: () => "{0}.zip".FormatWith(systemShortName.Value)))));

            FormState.ExecuteWithDataModificationsAndDefaultAction(
                pb.ToCollection(),
                () => {
                ph.AddControlsReturnThis(
                    FormItemBlock.CreateFormItemTable(
                        formItems: new[]
                {
                    FormItem.Create(
                        "System name",
                        new EwfTextBox(""),
                        validationGetter: control => new EwfValidation(
                            (pbv, validator) => {
                        systemName.Value = validator.GetString(
                            new ValidationErrorHandler("system name"),
                            control.GetPostBackValue(pbv),
                            false,
                            50);
                        if (systemName.Value != systemName.Value.RemoveNonAlphanumericCharacters(preserveWhiteSpace: true))
                        {
                            validator.NoteErrorAndAddMessage("The system name must consist of only alphanumeric characters and white space.");
                        }
                        systemShortName.Value = systemName.Value.EnglishToPascal();
                    })),
                    FormItem.Create(
                        "Base namespace",
                        new EwfTextBox(""),
                        validationGetter: control => new EwfValidation(
                            (pbv, validator) => {
                        baseNamespace.Value = validator.GetString(
                            new ValidationErrorHandler("base namespace"),
                            control.GetPostBackValue(pbv),
                            false,
                            50);
                        if (baseNamespace.Value != EwlStatics.GetCSharpIdentifier(baseNamespace.Value))
                        {
                            validator.NoteErrorAndAddMessage("The base namespace must be a valid C# identifier.");
                        }
                    }))
                }));
            });

            EwfUiStatics.SetContentFootActions(new ActionButtonSetup("Create System", new PostBackButton(pb)));
        }
        protected override void loadData()
        {
            HtmlBlockEditorModification mod;

            FormState.ExecuteWithDataModificationsAndDefaultAction(
                PostBack.CreateFull().ToCollection(),
                () => {
                ph.AddControlsReturnThis(new HtmlBlockEditor(null, id => { }, out mod).ToFormItem("").ToControl());
                EwfUiStatics.SetContentFootActions(new ActionButtonSetup("Post Back", new PostBackButton()));
            });
        }
 protected override void loadData()
 {
     FormState.ExecuteWithDataModificationsAndDefaultAction(
         PostBack.CreateFull().ToCollection(),
         () => {
         ph.AddControlsReturnThis(
             new HtmlBlockEditor(null, id => {}, out var mod).ToFormItem(label: Enumerable.Empty <PhrasingComponent>().Materialize())
             .ToComponentCollection()
             .GetControls());
         EwfUiStatics.SetContentFootActions(new ButtonSetup("Post Back").ToCollection());
     });
 }
예제 #15
0
        protected override PageContent getContent()
        {
            var mod    = getMod();
            var tagIds = ComponentStateItem.Create(
                "tags",
                ArticleId.HasValue
                                        ? ArticleTagsTableRetrieval.GetRowsLinkedToArticle(ArticleId.Value).Select(i => i.TagId).Materialize()
                                        : Enumerable.Empty <int>().Materialize(),
                v => v.All(id => TagsTableRetrieval.GetRowMatchingId(id, returnNullIfNoMatch: true) != null),
                true);

            return(FormState.ExecuteWithDataModificationsAndDefaultAction(
                       PostBack.CreateFull(
                           modificationMethod: () => {
                if (!ArticleId.HasValue)
                {
                    mod.ArticleId = MainSequence.GetNextValue();
                    mod.Slug = getSuffixedSlug(mod.Title.ToUrlSlug());
                    mod.CreationDateAndTime = DateTime.UtcNow;
                }
                mod.Execute();

                if (ArticleId.HasValue)
                {
                    ArticleTagsModification.DeleteRows(new ArticleTagsTableEqualityConditions.ArticleId(ArticleId.Value));
                }
                foreach (var i in tagIds.Value.Value)
                {
                    ArticleTagsModification.InsertRow(mod.ArticleId, i);
                }
            },
                           actionGetter: () => new PostBackAction(Article.GetInfo(mod.ArticleId)))
                       .ToCollection(),
                       () => {
                var stack = FormItemList.CreateStack(generalSetup: new FormItemListSetup(etherealContent: tagIds.ToCollection()));

                stack.AddItems(
                    mod.GetTitleTextControlFormItem(false, label: "Article title".ToComponents(), value: ArticleId.HasValue ? null : "")
                    .Append(
                        mod.GetDescriptionTextControlFormItem(false, label: "What's this article about?".ToComponents(), value: ArticleId.HasValue ? null : ""))
                    .Append(
                        mod.GetBodyMarkdownTextControlFormItem(
                            false,
                            label: "Write your article (in markdown)".ToComponents(),
                            controlSetup: TextControlSetup.Create(numberOfRows: 8),
                            value: ArticleId.HasValue ? null : ""))
                    .Append(getTagFormItem(tagIds.Value))
                    .Materialize());

                return new UiPageContent(contentFootActions: new ButtonSetup("Publish Article").ToCollection()).Add(stack);
            }));
        }
        private Section test5(Action <string> setValue)
        {
            var pb = PostBack.CreateFull(id: "test5");

            return(FormState.ExecuteWithDataModificationsAndDefaultAction(
                       pb.ToCollection(),
                       () => {
                var box =
                    FormItem.Create("", new EwfTextBox(""), validationGetter: control => new EwfValidation((pbv, v) => setValue(control.GetPostBackValue(pbv))))
                    .Control;
                return new Section("Post-back on enter.", box.ToCollection(), style: SectionStyle.Box);
            }));
        }
예제 #17
0
        protected override void loadData()
        {
            BasicPage.Instance.Body.Attributes["class"] = CssElementCreator.SelectUserPageBodyCssClass;

            ph.AddControlsReturnThis(new PageName());

            if (ConfigurationStatics.IsLiveInstallation)
            {
                ph.AddControlsReturnThis(
                    new Paragraph(
                        new ImportantContent("Warning:".ToComponents()).ToCollection()
                        .Concat(" Do not impersonate a user without permission. Your actions will be attributed to the user you are impersonating, not to you.".ToComponents()))
                    .ToCollection().GetControls());
            }

            DataValue <User> user = new DataValue <User>();
            var pb = PostBack.CreateFull(
                firstModificationMethod: () => UserImpersonationStatics.BeginImpersonation(user.Value),
                actionGetter: () => new PostBackAction(new ExternalResourceInfo(info.ReturnUrl.Any() ? info.ReturnUrl : NetTools.HomeUrl)));

            FormState.ExecuteWithDataModificationsAndDefaultAction(
                pb.ToCollection(),
                () => {
                ph.AddControlsReturnThis(
                    FormItem.Create(
                        "User's email address (leave blank for anonymous)",
                        new EwfTextBox(""),
                        validationGetter: control => new EwfValidation(
                            (pbv, validator) => {
                    var errorHandler = new ValidationErrorHandler("user");
                    var emailAddress = validator.GetEmailAddress(errorHandler, control.GetPostBackValue(pbv), true);
                    if (errorHandler.LastResult != ErrorCondition.NoError)
                    {
                        return;
                    }
                    if (!emailAddress.Any())
                    {
                        user.Value = null;
                        return;
                    }
                    user.Value = UserManagementStatics.GetUser(emailAddress);
                    if (user.Value == null)
                    {
                        validator.NoteErrorAndAddMessage("The email address you entered does not match a user.");
                    }
                })).ToControl(),
                    new LegacyParagraph(
                        new PostBackButton(
                            new ButtonActionControlStyle(AppRequestState.Instance.ImpersonatorExists ? "Change User" : "Begin Impersonation", buttonSize: ButtonSize.Large))));
            });
        }
예제 #18
0
        protected override PageContent getContent()
        {
            var mod      = getMod();
            var password = new DataValue <string> {
                Value = ""
            };
            Tuple <IReadOnlyCollection <EtherealComponent>, Action <int> > logInHiddenFieldsAndMethod = null;

            return(FormState.ExecuteWithDataModificationsAndDefaultAction(
                       PostBack.CreateFull(
                           modificationMethod: () => {
                if (AppTools.User == null)
                {
                    mod.UserId = MainSequence.GetNextValue();
                }
                if (password.Value.Any())
                {
                    var passwordSalter = new Password(password.Value);
                    mod.Salt = passwordSalter.Salt;
                    mod.SaltedPassword = passwordSalter.ComputeSaltedHash();
                }
                mod.Execute();

                logInHiddenFieldsAndMethod?.Item2(mod.UserId);
            },
                           actionGetter: () => new PostBackAction(logInHiddenFieldsAndMethod != null ? (PageBase)Home.GetInfo() : Profile.GetInfo(AppTools.User.UserId)))
                       .ToCollection(),
                       () => {
                var content = new UiPageContent(contentFootActions: new ButtonSetup(AppTools.User != null ? "Update Settings" : "Sign up").ToCollection());

                if (AppTools.User == null)
                {
                    content.Add(
                        new EwfHyperlink(
                            EnterpriseWebLibrary.EnterpriseWebFramework.UserManagement.Pages.LogIn.GetInfo(Home.GetInfo().GetUrl()),
                            new StandardHyperlinkStyle("Have an account?")));
                }

                content.Add(getFormItemStack(mod, password));

                if (AppTools.User == null)
                {
                    logInHiddenFieldsAndMethod = FormsAuthStatics.GetLogInHiddenFieldsAndSpecifiedUserLogInMethod();
                    content.Add(logInHiddenFieldsAndMethod.Item1);
                }

                return content;
            }));
        }
        protected override void loadData()
        {
            var pb = PostBack.CreateFull();

            FormState.ExecuteWithDataModificationsAndDefaultAction(
                pb.ToCollection(),
                () => {
                ph.AddControlsReturnThis(
                    FormItemBlock.CreateFormItemTable(heading: "Radio Button List, Vertical", formItems: getRadioItems(false)),
                    FormItemBlock.CreateFormItemTable(heading: "Radio Button List, Horizontal", formItems: getRadioItems(true)),
                    getSelect2UpgradeTestingInfo(),
                    FormItemBlock.CreateFormItemTable(heading: "Drop-Down List", formItems: getDropDownItems()));
            });
            EwfUiStatics.SetContentFootActions(new ActionButtonSetup("Submit", new PostBackButton(pb)));
        }
        protected override void loadData()
        {
            var pb = PostBack.CreateFull();

            FormState.ExecuteWithDataModificationsAndDefaultAction(
                pb.ToCollection(),
                () => {
                addMessageIfNotNull(ph, getTest1(null));
                ph.AddControlsReturnThis(test1(setTest1));

                addMessageIfNotNull(ph, getTest2(null));
                ph.AddControlsReturnThis(test2(setTest2));

                addMessageIfNotNull(ph, getTest3(null));
                ph.AddControlsReturnThis(test3(setTest3));

                addMessageIfNotNull(ph, getTest4(null));
                ph.AddControlsReturnThis(test4(setTest4));

                addMessageIfNotNull(ph, getTest5(null));
                ph.AddControlsReturnThis(test5(setTest5));

                addMessageIfNotNull(ph, getTest6(null));
                ph.AddControlsReturnThis(test6(setTest6));

                var table = FormItemBlock.CreateFormItemTable();
                table.AddFormItems(
                    FormItem.Create("Textarea", new EwfTextBox("This is a paragraph.", rows: 4)),
                    FormItem.Create("Masked Input", new EwfTextBox("This should not appear in the markup!", masksCharacters: true)));
                ph.AddControlsReturnThis(table);

                EwfUiStatics.SetContentFootActions(
                    new ActionButtonSetup("OK", new PostBackButton()),
                    new ActionButtonSetup(
                        "Reset Values",
                        new PostBackButton(
                            PostBack.CreateFull(
                                id: "reset",
                                firstModificationMethod: () => {
                    setTest1(null);
                    setTest2(null);
                    setTest3(null);
                    setTest4(null);
                    setTest5(null);
                    setTest6(null);
                }))));
            });
        }
예제 #21
0
 protected override void loadData()
 {
     ph.AddControlsReturnThis(
         FormState.ExecuteWithDataModificationsAndDefaultAction(
             PostBack.CreateFull().ToCollection(),
             () => FormItemList.CreateStack(
                 generalSetup: new FormItemListSetup(buttonSetup: new ButtonSetup("Submit")),
                 items: getControls().Select((getter, i) => getter((i + 1).ToString())).Materialize()))
         .ToCollection <FlowComponent>()
         .Append(
             new Section(
                 "Independent Controls",
                 FormItemList.CreateStack(items: getIndependentControls().Select((getter, i) => getter("I-" + (i + 1).ToString())).Materialize())
                 .ToCollection()))
         .GetControls());
 }
        protected override void loadData()
        {
            FormState.ExecuteWithDataModificationsAndDefaultAction(
                PostBack.CreateFull().ToCollection(),
                () => {
                ph.AddControlsReturnThis(
                    new Section("Radio Button List, Vertical", FormItemList.CreateStack(items: getRadioItems(false).Materialize()).ToCollection())
                    .ToCollection <FlowComponent>()
                    .Append(new Section("Radio Button List, Horizontal", FormItemList.CreateStack(items: getRadioItems(true).Materialize()).ToCollection()))
                    .Append(getChosenUpgradeTestingInfo())
                    .Append(new Section("Drop-Down List", FormItemList.CreateStack(items: getDropDownItems().Materialize()).ToCollection()))
                    .GetControls());

                EwfUiStatics.SetContentFootActions(new ButtonSetup("Submit").ToCollection());
            });
        }
        protected override void loadData()
        {
            var pb = PostBack.CreateFull(
                firstModificationMethod: modifyData,
                actionGetter: () => new PostBackAction(new ExternalResourceInfo(es.info.ReturnAndDestinationUrl)));

            FormState.ExecuteWithDataModificationsAndDefaultAction(
                pb.ToCollection(),
                () => {
                newPassword = new DataValue <string>();
                ph.AddControlsReturnThis(
                    FormItemBlock.CreateFormItemTable(
                        formItems: newPassword.GetPasswordModificationFormItems(firstLabel: "New password", secondLabel: "Re-type new password")));
                EwfUiStatics.SetContentFootActions(new ActionButtonSetup("Change Password", new PostBackButton()));
            });
        }
예제 #24
0
        protected override void loadData()
        {
            FormState.ExecuteWithDataModificationsAndDefaultAction(
                PostBack.CreateFull(
                    actionGetter: () => new PostBackAction(
                        new PageReloadBehavior(
                            secondaryResponse: new SecondaryResponse(
                                () => EwfResponse.Create(
                                    ContentTypes.ApplicationZip,
                                    new EwfResponseBodyCreator(createAndZipSystem),
                                    fileNameCreator: () => "{0}.zip".FormatWith(systemShortName.Value))))))
                .ToCollection(),
                () => {
                ph.AddControlsReturnThis(
                    FormItemList.CreateStack(
                        items: new[]
                {
                    systemName.ToTextControl(
                        false,
                        value: "",
                        maxLength: 50,
                        additionalValidationMethod: validator => {
                        if (systemName.Value != systemName.Value.RemoveNonAlphanumericCharacters(preserveWhiteSpace: true))
                        {
                            validator.NoteErrorAndAddMessage("The system name must consist of only alphanumeric characters and white space.");
                        }
                        systemShortName.Value = systemName.Value.EnglishToPascal();
                    })
                    .ToFormItem(label: "System name".ToComponents()),
                    baseNamespace.ToTextControl(
                        false,
                        value: "",
                        maxLength: 50,
                        additionalValidationMethod: validator => {
                        if (baseNamespace.Value != EwlStatics.GetCSharpIdentifier(baseNamespace.Value))
                        {
                            validator.NoteErrorAndAddMessage("The base namespace must be a valid C# identifier.");
                        }
                    })
                    .ToFormItem(label: "Base namespace".ToComponents())
                })
                    .ToCollection()
                    .GetControls());

                EwfUiStatics.SetContentFootActions(new ButtonSetup("Create System").ToCollection());
            });
        }
예제 #25
0
        private ControlList getUploadControlList()
        {
            RsFile file = null;
            var    dm   = PostBack.CreateFull(
                id: PostBack.GetCompositeId(postBackIdBase, "add"),
                firstModificationMethod: () => {
                if (file == null)
                {
                    return;
                }

                var existingFile = files.SingleOrDefault(i => i.FileName == file.FileName);
                int newFileId;
                if (existingFile != null)
                {
                    BlobFileOps.SystemProvider.UpdateFile(existingFile.FileId, file.FileName, file.Contents, BlobFileOps.GetContentTypeForPostedFile(file));
                    newFileId = existingFile.FileId;
                }
                else
                {
                    newFileId = BlobFileOps.SystemProvider.InsertFile(fileCollectionId, file.FileName, file.Contents, BlobFileOps.GetContentTypeForPostedFile(file));
                }

                NewFileNotificationMethod?.Invoke(newFileId);
                EwfPage.AddStatusMessage(StatusMessageType.Info, "File uploaded successfully.");
            });

            return(FormState.ExecuteWithDataModificationsAndDefaultAction(
                       dm.ToCollection(),
                       () => {
                var fi = FormItem.Create(
                    "",
                    new EwfFileUpload(),
                    validationGetter: control => new EwfValidation(
                        (pbv, validator) => {
                    BlobFileOps.ValidateUploadedFile(validator, control, acceptableFileExtensions, ValidateImage, AcceptOnlyImages);
                    file = control.GetPostBackValue(pbv);
                }));

                return ControlList.CreateWithControls(
                    true,
                    "Select and upload a new file:",
                    fi.ToControl(),
                    new PostBackButton(new ButtonActionControlStyle("Upload new file"), usesSubmitBehavior: false));
            }));
        }
        private Section test6(Action <string> setValue)
        {
            var pb = PostBack.CreateFull(id: "test6");

            return(FormState.ExecuteWithDataModificationsAndDefaultAction(
                       pb.ToCollection(),
                       () => {
                var box =
                    FormItem.Create("", new EwfTextBox(""), validationGetter: control => new EwfValidation((pbv, v) => setValue(control.GetPostBackValue(pbv))))
                    .Control;
                var button = new PostBackButton(new ButtonActionControlStyle("OK"), usesSubmitBehavior: false);
                return new Section(
                    "Post-back with non-default submit button. This post-back-value shouldn't show up when the page's submit button is submitted.",
                    new WebControl[] { box, button },
                    style: SectionStyle.Box);
            }));
        }
        private Section test2(Action <string> setValue)
        {
            var pb = PostBack.CreateFull(id: "test2");

            return(FormState.ExecuteWithDataModificationsAndDefaultAction(
                       pb.ToCollection(),
                       () => {
                var box =
                    FormItem.Create("", new EwfTextBox(""), validationGetter: control => new EwfValidation((pbv, v) => setValue(control.GetPostBackValue(pbv))))
                    .Control;
                box.SetupAutoComplete(TestService.GetInfo(), AutoCompleteOption.PostBackOnItemSelect);
                return
                new Section(
                    "Autofill behavior. Typing more than 3 characters should bring up autofill options from a web service. " + "Selecting an item will cause a post-back.",
                    box.ToCollection(),
                    style: SectionStyle.Box);
            }));
        }
예제 #28
0
        protected override PageContent getContent()
        {
            Action userModMethod = null;

            return(FormState.ExecuteWithDataModificationsAndDefaultAction(
                       PostBack.CreateFull(modificationMethod: () => userModMethod(), actionGetter: () => new PostBackAction(ParentResource)).ToCollection(),
                       () => new UiPageContent(
                           pageActions: UserId.HasValue
                                                             ? new ButtonSetup(
                               "Delete User",
                               behavior: new PostBackBehavior(
                                   postBack: PostBack.CreateFull(
                                       id: "delete",
                                       modificationMethod: deleteUser,
                                       actionGetter: () => new PostBackAction(ParentResource)))).ToCollection()
                                                             : null,
                           contentFootActions: new ButtonSetup("OK").ToCollection()).Add(new UserEditor(UserId, out userModMethod))));
        }
예제 #29
0
 private IReadOnlyCollection <Func <string, FormItem> > getControls() =>
 new[]
 {
     getCheckbox("Standard", null), id => {
         var pb = PostBack.CreateIntermediate(null, id: id);
         return(FormState.ExecuteWithDataModificationsAndDefaultAction(
                    FormState.Current.DataModifications.Append(pb),
                    () => getCheckbox("Separate value-changed action", CheckboxSetup.Create(valueChangedAction: new PostBackFormAction(pb)))(id)));
     },
     new Func <Func <string, FormItem> >(
         () => {
         var pmv = new PageModificationValue <bool>();
         return(getCheckbox("Page modification", CheckboxSetup.Create(pageModificationValue: pmv), pageModificationValue: pmv));
     })(),
     getCheckbox("Read-only", CheckboxSetup.CreateReadOnly()), getFlowCheckbox("Flow", null),
     getFlowCheckbox("Flow with highlighting", FlowCheckboxSetup.Create(highlightedWhenChecked: true)),
     getFlowCheckbox(
         "Flow with nested content",
         FlowCheckboxSetup.Create(
             nestedContentGetter: () => new Paragraph(
                 "Lorem ipsum dolor sit amet, consectetur adipiscing elit. Proin id vestibulum neque. Suspendisse vel sem ac nunc condimentum tempus eget quis nunc. Morbi mattis elementum cursus. Integer eros mi, porttitor vitae orci eget, facilisis pretium diam. Aenean et nisi leo. Aenean nibh ligula, suscipit sit amet nulla ac, faucibus suscipit ipsum. Nunc quis faucibus ex."
                 .ToComponents()).ToCollection())),
     getFlowCheckbox(
         "Flow with nested content always displayed",
         FlowCheckboxSetup.Create(
             nestedContentGetter: () => new Paragraph(
                 "Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nunc vel diam quis felis accumsan tempus. Nunc hendrerit mi in hendrerit finibus. Nullam aliquet pharetra mauris ac vehicula. Quisque vehicula imperdiet pulvinar. Morbi ullamcorper est non arcu suscipit, quis interdum ex egestas. Sed vel risus vitae nisl scelerisque pretium. Aliquam vel pretium orci, eu scelerisque felis. Morbi ac auctor lacus, sit amet congue nunc."
                 .ToComponents()).ToCollection(),
             nestedContentAlwaysDisplayed: true)),
     getRadioGroup("Radio group", null),
     getRadioGroup("Radio group with no selection", null, noSelection: true),
     getRadioGroup("Radio group with single button", null, singleButton: true), id => {
         var pb = PostBack.CreateIntermediate(null, id: id);
         return(FormState.ExecuteWithDataModificationsAndDefaultAction(
                    FormState.Current.DataModifications.Append(pb),
                    () => getRadioGroup("Radio group with separate selection-changed action", null, selectionChangedAction: new PostBackFormAction(pb))(id)));
     },
     new Func <Func <string, FormItem> >(
         () => {
         var pmv = new PageModificationValue <bool>();
         return(getRadioGroup("Radio group with page modification", RadioButtonSetup.Create(pageModificationValue: pmv), pageModificationValue: pmv));
     })(),
     getRadioGroup("Radio group with read-only button", RadioButtonSetup.CreateReadOnly())
 };
        void ControlTreeDataLoader.LoadData()
        {
            FormState.ExecuteWithDataModificationsAndDefaultAction(
                dataModifications,
                () => {
                CssClass = CssClass.ConcatenateWithSpace(CssElementCreator.CssClass);

                if (minuteInterval < 30)
                {
                    textBox = new EwfTextBox(
                        value.HasValue ? value.Value.ToTimeOfDayHourAndMinuteString() : "",
                        disableBrowserAutoComplete: true,
                        action: action,
                        autoPostBack: autoPostBack);
                    Controls.Add(new ControlLine(textBox, getIconButton()));
                }
                else
                {
                    var minuteValues = new List <int>();
                    for (var i = 0; i < 60; i += minuteInterval)
                    {
                        minuteValues.Add(i);
                    }
                    selectList = SelectList.CreateDropDown(
                        from hour in Enumerable.Range(0, 24)
                        from minute in minuteValues
                        let timeSpan = new TimeSpan(hour, minute, 0)
                                       select SelectListItem.Create <TimeSpan?>(timeSpan, timeSpan.ToTimeOfDayHourAndMinuteString()),
                        value,
                        width: Unit.Percentage(100),
                        placeholderIsValid: true,
                        placeholderText: "",
                        action: action,
                        autoPostBack: autoPostBack);
                    Controls.Add(selectList);
                }

                if (ToolTip != null || ToolTipControl != null)
                {
                    new ToolTip(ToolTipControl ?? EnterpriseWebFramework.Controls.ToolTip.GetToolTipTextControl(ToolTip), this);
                }
            });
        }