private Func <string, FormItem> getFlowCheckbox(string label, FlowCheckboxSetup setup) => id => new FlowCheckbox( false, "Lorem ipsum dolor sit amet".ToComponents(), setup: setup, validationMethod: (postBackValue, validator) => AddStatusMessage( StatusMessageType.Info, "{0}: {1}".FormatWith(id, postBackValue.Value.ToString()))).ToFormItem(label: "{0}. {1}".FormatWith(id, label).ToComponents());
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()) };
private FlowComponent getFormItemStack(UsersModification mod, DataValue <string> password) { var stack = FormItemList.CreateStack(); if (AppTools.User != null) { stack.AddItem(mod.GetProfilePictureUrlUrlControlFormItem(true, label: "URL of profile picture".ToComponents())); } stack.AddItem(mod.GetUsernameTextControlFormItem(false, label: "Username".ToComponents(), value: AppTools.User == null ? "" : null)); if (AppTools.User != null) { stack.AddItem( mod.GetShortBioTextControlFormItem(true, label: "Short bio about you".ToComponents(), controlSetup: TextControlSetup.Create(numberOfRows: 8))); } stack.AddItem(mod.GetEmailAddressEmailAddressControlFormItem(false, label: "Email".ToComponents(), value: AppTools.User == null ? "" : null)); if (AppTools.User == null) { stack.AddItems(password.GetPasswordModificationFormItems()); } else { var changePasswordChecked = new DataValue <bool>(); stack.AddItem( changePasswordChecked.ToFlowCheckbox( "Change password".ToComponents(), setup: FlowCheckboxSetup.Create( nestedContentGetter: () => FormState.ExecuteWithValidationPredicate( () => changePasswordChecked.Value, () => FormItemList.CreateGrid(1, items: password.GetPasswordModificationFormItems()).ToCollection())), value: false) .ToFormItem()); } return(stack); }