private ActionComponentSetup getFavoriteAction() { var text = "{0} Article ({1})".FormatWith( AppTools.User == null || FavoritesTableRetrieval.GetRowMatchingPk(AppTools.User.UserId, ArticleId, returnNullIfNoMatch: true) == null ? "Favorite" : "Unfavorite", FavoritesTableRetrieval.GetRows(new FavoritesTableEqualityConditions.ArticleId(ArticleId)).Count()); var icon = new ActionComponentIcon(new FontAwesomeIcon("fa-heart")); return(AppTools.User == null ? (ActionComponentSetup) new HyperlinkSetup(User.GetInfo(), text, icon: icon) : new ButtonSetup( text, behavior: new PostBackBehavior( postBack: FavoritesTableRetrieval.GetRowMatchingPk(AppTools.User.UserId, ArticleId, returnNullIfNoMatch: true) == null ? PostBack.CreateFull( id: "favorite", modificationMethod: () => FavoritesModification.InsertRow(AppTools.User.UserId, ArticleId)) : PostBack.CreateFull( id: "unfavorite", modificationMethod: () => FavoritesModification.DeleteRows( new FavoritesTableEqualityConditions.UserId(AppTools.User.UserId), new FavoritesTableEqualityConditions.ArticleId(ArticleId)))), icon: icon)); }
public override List <ActionButtonSetup> GetGlobalNavActionControls() { var navButtonSetups = new List <ActionButtonSetup>(); if (CreateSystem.GetInfo().IsIdenticalToCurrent()) { return(navButtonSetups); } // This will hide itself because Contact Us requires a logged-in user, and the standard library test web site has no users. var contactPage = EnterpriseWebFramework.EnterpriseWebLibrary.WebSite.ContactSupport.GetInfo(EwfPage.Instance.InfoAsBaseType.GetUrl()); navButtonSetups.Add(new ActionButtonSetup(contactPage.ResourceName, new EwfLink(contactPage))); var menu = EwfTable.Create(); menu.AddItem( () => new EwfTableItem( new EwfTableItemSetup( clickScript: ClickScript.CreatePostBackScript( PostBack.CreateFull(id: "testMethod", firstModificationMethod: () => EwfPage.AddStatusMessage(StatusMessageType.Info, "Successful method execution.")))), "Test method")); navButtonSetups.Add(new ActionButtonSetup("Test", new ToolTipButton(menu))); return(navButtonSetups); }
protected override void loadData() { var pb = PostBack.CreateFull(actionGetter: () => new PostBackAction(new ExternalResourceInfo(es.info.ReturnAndDestinationUrl))); var fib = FormItemBlock.CreateFormItemTable(); newPassword = new DataValue <string>(); fib.AddFormItems( FormItem.Create( "New password", new EwfTextBox("", masksCharacters: true), validationGetter: control => new Validation((pbv, v) => newPassword.Value = control.GetPostBackValue(pbv), pb))); var newPasswordConfirm = new DataValue <string>(); fib.AddFormItems( FormItem.Create( "Re-type new password", new EwfTextBox("", masksCharacters: true), validationGetter: control => new Validation((pbv, v) => newPasswordConfirm.Value = control.GetPostBackValue(pbv), pb))); pb.AddTopValidationMethod((pbv, validator) => FormsAuthStatics.ValidatePassword(validator, newPassword, newPasswordConfirm)); ph.AddControlsReturnThis(fib); EwfUiStatics.SetContentFootActions(new ActionButtonSetup("Change Password", new PostBackButton(pb))); pb.AddModificationMethod(modifyData); }
protected override PageContent getContent() => new UiPageContent( pageActions: AppTools.User != null && articleRow.AuthorId == AppTools.User.UserId ? new HyperlinkSetup( Editor.GetInfo(ArticleId), "Edit Article", icon: new ActionComponentIcon(new FontAwesomeIcon("fa-pencil"))) .Append <ActionComponentSetup>( new ButtonSetup( "Delete Article", behavior: new PostBackBehavior( postBack: PostBack.CreateFull( id: "delete", modificationMethod: () => { ArticleTagsModification.DeleteRows(new ArticleTagsTableEqualityConditions.ArticleId(ArticleId)); ArticlesModification.DeleteRows(new ArticlesTableEqualityConditions.ArticleId(ArticleId)); }, actionGetter: () => new PostBackAction(Home.GetInfo()))), icon: new ActionComponentIcon(new FontAwesomeIcon("fa-trash")))) .Materialize() : AppStatics.GetFollowAction(articleRow.AuthorId).Append(getFavoriteAction()).Materialize()) .Add(AppStatics.GetAuthorDisplay(articleRow, UsersTableRetrieval.GetRowMatchingId(articleRow.AuthorId))) .Add(new HtmlBlockContainer(Markdown.ToHtml(articleRow.BodyMarkdown))) .Add(AppStatics.GetTagDisplay(ArticleId, ArticleTagsTableRetrieval.GetRowsLinkedToArticle(ArticleId))) .Add(getCommentComponents());
/// <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 <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() { 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))); }
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))); }
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()); }); }
public override List <ActionButtonSetup> GetGlobalNavActionControls() { var navButtonSetups = new List <ActionButtonSetup>(); // This will hide itself because Contact Us requires a logged-in user, and the standard library test web site has no users. navButtonSetups.Add( new ActionButtonSetup( "Contact us", new EwfLink( RedStapler.StandardLibrary.EnterpriseWebFramework.EnterpriseWebLibrary.WebSite.ContactUs.Page.GetInfo(EwfPage.Instance.InfoAsBaseType.GetUrl())))); var menu = EwfTable.Create(); menu.AddItem( () => new EwfTableItem( new EwfTableItemSetup( clickScript: ClickScript.CreatePostBackScript( PostBack.CreateFull(id: "testMethod", firstModificationMethod: () => EwfPage.AddStatusMessage(StatusMessageType.Info, "Successful method execution.")))), "Test method")); navButtonSetups.Add(new ActionButtonSetup("Test", new ToolTipButton(menu))); navButtonSetups.Add( new ActionButtonSetup( "Calendar", new EwfLink( CalendarDemo.GetInfo( new EntitySetup.OptionalParameterPackage(), new CalendarDemo.OptionalParameterPackage { ReturnUrl = EwfPage.Instance.InfoAsBaseType.GetUrl(), Date = DateTime.Now })))); return(navButtonSetups); }
/// <summary> /// Adds a new column on the left of the table containing a checkbox for each row. /// Adds an action link to the top of the table that acts on all rows that are checked. /// Each row must specify the UniqueIdentifier for its row setup. This will be passed back to the given action method. /// Adding multiple actions results in just one column of checkboxes. /// The checkbox column consumes 5% of the table width. /// The action method automatically executes in an EhModifyData method, so your implementation does not need to do this. /// </summary> public void AddSelectedRowsAction(string label, RowMethod action) { var postBack = PostBack.CreateFull(id: PostBack.GetCompositeId(PostBackIdBase, label)); selectedRowDataModificationsToMethods.Add(postBack, action); selectedRowActionButtonsToAdd.Add(new PostBackButton(postBack, new TextActionControlStyle(label), usesSubmitBehavior: false)); }
protected override void loadData() { ph.AddControlsReturnThis( getBox( new PostBackButton( PostBack.CreateFull(id: "tiny"), new ButtonActionControlStyle("Tiny Post Back Button", buttonSize: ButtonActionControlStyle.ButtonSize.ShrinkWrap), false))); ph.AddControlsReturnThis( getBox( EwfLink.Create(SubFolder.General.GetInfo(), new ButtonActionControlStyle("Tiny EWF Link", buttonSize: ButtonActionControlStyle.ButtonSize.ShrinkWrap)))); ph.AddControlsReturnThis( getBox( new ToggleButton(new WebControl[0], new ButtonActionControlStyle("Tiny Toggle Button", buttonSize: ButtonActionControlStyle.ButtonSize.ShrinkWrap)))); ph.AddControlsReturnThis( getBox( new PostBackButton(PostBack.CreateFull(id: "normal"), new ButtonActionControlStyle("Post Back Button"), usesSubmitBehavior: false) { Width = Unit.Pixel(200) })); ph.AddControlsReturnThis(getBox(EwfLink.Create(EwfTableDemo.GetInfo(), new ButtonActionControlStyle("EWF Link")))); ph.AddControlsReturnThis(getBox(new ToggleButton(new WebControl[0], new ButtonActionControlStyle("Toggle button")))); ph.AddControlsReturnThis( getBox( new PostBackButton( PostBack.CreateFull(id: "large"), new ButtonActionControlStyle("Large Post Back Button", buttonSize: ButtonActionControlStyle.ButtonSize.Large), usesSubmitBehavior: false))); ph.AddControlsReturnThis( getBox(EwfLink.Create(EwfTableDemo.GetInfo(), new ButtonActionControlStyle("Large EWF Link", ButtonActionControlStyle.ButtonSize.Large)))); ph.AddControlsReturnThis( getBox(new ToggleButton(new WebControl[0], new ButtonActionControlStyle("Large Toggle Button", ButtonActionControlStyle.ButtonSize.Large)))); }
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())));
public override IReadOnlyCollection <ActionComponentSetup> GetGlobalNavActions() { var navButtonSetups = new List <ActionComponentSetup>(); if (CreateSystem.GetInfo().IsIdenticalToCurrent()) { return(navButtonSetups); } // This will hide itself because Contact Us requires a logged-in user, and the standard library test web site has no users. var contactPage = EnterpriseWebFramework.EnterpriseWebLibrary.WebSite.ContactSupport.GetInfo(EwfPage.Instance.InfoAsBaseType.GetUrl()); navButtonSetups.Add(new HyperlinkSetup(contactPage, contactPage.ResourceName)); navButtonSetups.Add( new ButtonSetup( "Test", behavior: new MenuButtonBehavior( new EwfButton( new StandardButtonStyle("Test method"), behavior: new PostBackBehavior( postBack: PostBack.CreateFull( id: "testMethod", firstModificationMethod: () => EwfPage.AddStatusMessage(StatusMessageType.Info, "Successful method execution.")))).ToCollection()))); return(navButtonSetups); }
protected override void loadData() { var pb = PostBack.CreateFull(actionGetter: () => new PostBackAction(new ExternalResourceInfo(es.info.DestinationUrl))); EwfUiStatics.SetContentFootActions(new ActionButtonSetup("Reset Password", new PostBackButton(pb))); pb.AddModificationMethod(modifyData); }
/// <summary> /// Adds a new column on the left of the table containing a checkbox for each row. /// Adds an action link to the top of the table that acts on all rows that are checked. /// Each row must specify the UniqueIdentifier for its row setup. This will be passed back to the given action method. /// Adding multiple actions results in just one column of checkboxes. /// The checkbox column consumes 5% of the table width. /// The action method automatically executes in an EhModifyData method, so your implementation does not need to do this. /// </summary> public void AddSelectedRowsAction(string label, RowMethod action) { var postBack = PostBack.CreateFull(id: PostBack.GetCompositeId(PostBackIdBase, label)); selectedRowDataModificationsToMethods.Add(postBack, action); selectedRowActionButtonsToAdd.Add( new EwfButton(new StandardButtonStyle(label, buttonSize: ButtonSize.ShrinkWrap), behavior: new PostBackBehavior(postBack: postBack))); }
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()));
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() { pb = PostBack.CreateFull(); 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() { // NOTE: The attributes need to have a value... ph.AddControlsReturnThis(new FancyFileManager("first one!", "a")); var postBack = PostBack.CreateFull(firstTopValidationMethod: (pbv, v) => v.NoteErrorAndAddMessage("error")); ph.AddControlsReturnThis( FormItemBlock.CreateFormItemTable(heading: "woo", formItems: new FormItem[] { FormItem.Create("Files", new FancyFileManager("second one!", "")) })); ph.AddControlsReturnThis(new PostBackButton(postBack)); }
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 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); }
// NOTE: EVERYTHING should be done here. We shouldn't have LoadData. We should audit everyone using this control and see if we can improve things. // NOTE: This should also be full of delegates that run when events (such as deleting a file) are occurring. // NOTE: There should be a way to tell if a file was uploaded. void ControlTreeDataLoader.LoadData() { if (fileCollectionId != null) { file = BlobFileOps.GetFirstFileFromCollection(fileCollectionId.Value); } var controlStack = ControlStack.Create(true); if (file != null) { var download = new PostBackButton( PostBack.CreateFull( id: PostBack.GetCompositeId("ewfFile", file.FileId.ToString()), actionGetter: () => { // Refresh the file here in case a new one was uploaded on the same post-back. return (new PostBackAction( new SecondaryResponse(new BlobFileResponse(BlobFileOps.GetFirstFileFromCollection(fileCollectionId.Value).FileId, () => true), false))); }), new TextActionControlStyle(Translation.DownloadExisting + " (" + file.FileName + ")"), false); controlStack.AddControls(download); } else if (!HideNoExistingFileMessage) { controlStack.AddControls(new Label { Text = Translation.NoExistingFile }); } uploadedFile = new EwfFileUpload(); if (file != null) { uploadedFile.SetInitialDisplay(false); var replaceExistingFileLink = new ToggleButton( uploadedFile.ToSingleElementArray(), new TextActionControlStyle(Translation.ClickHereToReplaceExistingFile)) { AlternateText = "" }; controlStack.AddControls(replaceExistingFileLink); } controlStack.AddControls(uploadedFile); var thumbnailControl = BlobFileOps.GetThumbnailControl(file, ThumbnailResourceInfoCreator); if (thumbnailControl != null) { Controls.Add(thumbnailControl); } Controls.Add(controlStack); }
private Box test5(Action <string> setValue) { var pb = PostBack.CreateFull(id: "test5"); var box = FormItem.Create( "", new EwfTextBox("", postBack: pb), validationGetter: control => new EwfValidation((pbv, v) => setValue(control.GetPostBackValue(pbv)), pb)).Control; return(new Box("Post-back on enter.", box.ToSingleElementArray())); }
private IReadOnlyCollection <PhrasingComponent> getFavoriteTabComponents() { const string label = "Favorited Articles"; return(ShowFavorites ? label.ToComponents() : new EwfButton( new StandardButtonStyle(label), behavior: new PostBackBehavior( postBack: PostBack.CreateFull(id: "favorite", modificationMethod: () => parametersModification.ShowFavorites = true))).ToCollection()); }
private Section test4(Action <string> setValue) { var pb = PostBack.CreateFull(id: "test4"); var box = FormItem.Create( "", new EwfTextBox("", postBack: pb, autoPostBack: true), validationGetter: control => new EwfValidation((pbv, v) => setValue(control.GetPostBackValue(pbv)), pb)).Control; return(new Section("Post-back on change.", box.ToSingleElementArray(), style: SectionStyle.Box)); }
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()); }); }
protected override PageContent getContent() => new UiPageContent().Add( new StackList( new EwfButton( new StandardButtonStyle("Send Health Check"), behavior: new PostBackBehavior( postBack: PostBack.CreateFull(id: "sendHealthCheck", modificationMethod: () => EwfApp.Instance.SendHealthCheck()))).ToComponentListItem() .Append( new EwfButton( new StandardButtonStyle("Throw Unhandled Exception"), behavior: new PostBackBehavior(postBack: PostBack.CreateFull(id: "throwException", modificationMethod: throwException))) .ToComponentListItem())));
private void addFileRow(DynamicTable table, BlobFile file, ActionPostBack deletePb, List <Func <bool> > deleteModMethods) { var cells = new List <EwfTableCell>(); var thumbnailControl = BlobFileOps.GetThumbnailControl(file, ThumbnailResourceInfoCreator); if (thumbnailControl != null) { cells.Add(thumbnailControl); } var fileIsUnread = fileIdsMarkedAsRead != null && !fileIdsMarkedAsRead.Contains(file.FileId); cells.Add( new PostBackButton( PostBack.CreateFull( id: PostBack.GetCompositeId(postBackIdBase, file.FileId.ToString()), firstModificationMethod: () => { if (fileIsUnread && markFileAsReadMethod != null) { markFileAsReadMethod(file.FileId); } }, actionGetter: () => new PostBackAction(new SecondaryResponse(new BlobFileResponse(file.FileId, () => true), false))), new TextActionControlStyle(file.FileName), false) { ToolTip = file.FileName }); cells.Add(file.UploadedDate.ToDayMonthYearString(false)); cells.Add((fileIsUnread ? "New!" : "").ToCell(new TableCellSetup(classes: "ewfNewness".ToSingleElementArray()))); var delete = false; var deleteCheckBox = FormItem.Create( "", new EwfCheckBox(false, postBack: deletePb), validationGetter: control => new EwfValidation((pbv, v) => { delete = control.IsCheckedInPostBack(pbv); }, deletePb)).ToControl(); cells.Add(ReadOnly ? null : deleteCheckBox); deleteModMethods.Add( () => { if (!delete) { return(false); } BlobFileOps.SystemProvider.DeleteFile(file.FileId); return(true); }); table.AddRow(cells.ToArray()); }
public BlobFileManager(int?fileCollectionId) { this.fileCollectionId = fileCollectionId; if (fileCollectionId != null) { file = BlobFileOps.GetFirstFileFromCollection(fileCollectionId.Value); } var controlStack = ControlStack.Create(true); if (file != null) { var download = new PostBackButton( new TextActionControlStyle(Translation.DownloadExisting + " (" + file.FileName + ")"), usesSubmitBehavior: false, postBack: PostBack.CreateFull( id: PostBack.GetCompositeId("ewfFile", file.FileId.ToString()), actionGetter: () => { // Refresh the file here in case a new one was uploaded on the same post-back. return (new PostBackAction( new SecondaryResponse(new BlobFileResponse(BlobFileOps.GetFirstFileFromCollection(fileCollectionId.Value).FileId, () => true), false))); })); controlStack.AddControls(download); } else if (!HideNoExistingFileMessage) { controlStack.AddControls(new Label { Text = Translation.NoExistingFile }); } uploadedFile = new EwfFileUpload(); if (file != null) { uploadedFile.SetInitialDisplay(false); var replaceExistingFileLink = new ToggleButton( uploadedFile.ToCollection(), new TextActionControlStyle(Translation.ClickHereToReplaceExistingFile), false, (postBackValue, validator) => { }) { AlternateText = "" }; controlStack.AddControls(replaceExistingFileLink); } controlStack.AddControls(uploadedFile); this.AddControlsReturnThis(BlobFileOps.GetThumbnailControl(file, ThumbnailResourceInfoCreator)); Controls.Add(controlStack); }