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()); }
protected override PageContent getContent() => new UiPageContent().Add( EwfTable.Create() .AddData( getStatusTests(), tests => EwfTableItem.Create( tests.Item1.ToCell(), new EwfButton(new StandardButtonStyle("Test"), behavior: new PostBackBehavior(postBack: tests.Item2)).ToCell())));
private EwfTableItemGroup getItemGroup(int groupNumber) { var updateRegionSet = new UpdateRegionSet(); return(EwfTableItemGroup.Create( () => new EwfTableItemGroupRemainingData( "Group {0}".FormatWith(groupNumber).ToComponents(), groupActions: groupNumber == 2 ? new ButtonSetup( "Action 1", behavior: new PostBackBehavior( postBack: PostBack.CreateIntermediate( null, id: PostBack.GetCompositeId(groupNumber.ToString(), "action1"), modificationMethod: () => AddStatusMessage(StatusMessageType.Info, "Action 1")))).Append( new ButtonSetup( "Action 2", behavior: new PostBackBehavior( postBack: PostBack.CreateIntermediate( null, id: PostBack.GetCompositeId(groupNumber.ToString(), "action2"), modificationMethod: () => AddStatusMessage(StatusMessageType.Info, "Action 2"))))) .Materialize() : null, groupHeadActivationBehavior: ElementActivationBehavior.CreateButton( new PostBackBehavior( postBack: PostBack.CreateIntermediate( null, id: "group{0}".FormatWith(groupNumber), modificationMethod: () => AddStatusMessage(StatusMessageType.Info, "You clicked group {0}.".FormatWith(groupNumber))))), tailUpdateRegions: groupNumber == 1 ? new TailUpdateRegion(updateRegionSet.ToCollection(), 1).ToCollection() : null), groupNumber == 1 ? getItems(FirstGroupItemCount, true) .Concat( new Func <EwfTableItem>( () => EwfTableItem.Create( new EwfButton( new StandardButtonStyle("Add Row"), behavior: new PostBackBehavior( postBack: PostBack.CreateIntermediate( updateRegionSet.ToCollection(), id: "addRow", modificationMethod: () => parametersModification.FirstGroupItemCount += 1))).ToCollection() .ToCell(), "".ToCell())).ToCollection()) : getItems(250, false), selectedItemActions: groupNumber == 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())); }
private void testUrl(EwfTable <int> table, string url) { var validator = new Validator(); validator.GetUrl(new ValidationErrorHandler(""), url, false); table.AddItem( EwfTableItem.Create( url.ToCell(), (!validator.ErrorsOccurred).ToYesOrEmpty() .ToCell(new TableCellSetup(classes: (validator.ErrorsOccurred ? CssClasses.Red : CssClasses.Green).ToCollection())))); }
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); }
private FlowComponent getResultTable() { var results = ShowFavorites ? ArticlesRetrieval.GetRowsLinkedToUser(UserId) : ArticlesRetrieval.GetRowsLinkedToAuthor(UserId); var usersById = UsersTableRetrieval.GetRows().ToIdDictionary(); var tagsByArticleId = ArticleTagsTableRetrieval.GetRows().ToArticleIdLookup(); var favoritesByArticleId = FavoritesTableRetrieval.GetRows().ToArticleIdLookup(); var table = EwfTable.Create(defaultItemLimit: DataRowLimit.Fifty); table.AddData(results, i => EwfTableItem.Create(AppStatics.GetArticleDisplay(i, usersById, tagsByArticleId, favoritesByArticleId).ToCell())); return(table); }
protected override void loadData() { ph.AddControlsReturnThis( EwfTable.Create() .AddData( getStatusTests(), tests => EwfTableItem.Create( tests.Item1.ToCell(), new EwfButton(new StandardButtonStyle("Test"), behavior: new PostBackBehavior(postBack: tests.Item2)).ToCell())) .ToCollection() .GetControls()); }
private FlowComponent getResultTable(string filter) { var results = filter == "user" && AppTools.User != null?ArticlesRetrieval.GetRowsLinkedToFollower(AppTools.User.UserId) : filter.StartsWith("tag") ? ArticlesRetrieval.GetRowsLinkedToTag(int.Parse(filter.Substring(3))) : ArticlesRetrieval.GetRowsOrderedByCreation(); var usersById = UsersTableRetrieval.GetRows().ToIdDictionary(); var tagsByArticleId = ArticleTagsTableRetrieval.GetRows().ToArticleIdLookup(); var favoritesByArticleId = FavoritesTableRetrieval.GetRows().ToArticleIdLookup(); var table = EwfTable.Create(defaultItemLimit: DataRowLimit.Fifty); table.AddData(results, i => EwfTableItem.Create(AppStatics.GetArticleDisplay(i, usersById, tagsByArticleId, favoritesByArticleId).ToCell())); return(table); }
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 PageContent getContent() { var content = new UiPageContent(); var updateRegionSet = new UpdateRegionSet(); content.Add( EwfTable.Create( caption: "Caption", subCaption: "Sub caption", allowExportToExcel: true, tableActions: new ButtonSetup( "Remove Last Group", behavior: new PostBackBehavior( postBack: PostBack.CreateIntermediate( updateRegionSet.ToCollection(), id: "removeLastGroup", modificationMethod: () => { if (GroupCount <= 0) { throw new DataModificationException("No groups to remove."); } parametersModification.GroupCount -= 1; }))).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()) }, headItems: EwfTableItem.Create("First Column".ToCell(), "Second Column".ToCell()).ToCollection(), defaultItemLimit: DataRowLimit.Fifty, tailUpdateRegions: new TailUpdateRegion(updateRegionSet.ToCollection(), 1).ToCollection()) .AddItemGroups(Enumerable.Range(1, GroupCount).Select(getItemGroup).Materialize())); return(content); }
protected override void loadData() { var fil = FormItemList.CreateStack(); fil.AddFormItems(parametersModification.GetField1TextControlFormItem(true), parametersModification.GetField2TextControlFormItem(true)); ph.AddControlsReturnThis(fil.ToCollection().GetControls()); ph.AddControlsReturnThis( new EwfButton( new StandardButtonStyle("Navigate and change Field 2"), behavior: new PostBackBehavior( postBack: PostBack.CreateFull( actionGetter: () => new PostBackAction(new Info(es.info, new OptionalParameterPackage { Field2 = "bob" }))))) .ToCollection() .GetControls()); var table = EwfTable.Create(headItems: new[] { EwfTableItem.Create("Url".ToCell(), "Valid?".ToCell()) }); ph.AddControlsReturnThis(table.ToCollection().GetControls()); foreach (var scheme in new[] { "http://", "ftp://", "file://" }) { foreach (var userinfo in new[] { "", "user:pass@" }) { foreach (var subdomain in new[] { "", "subdomain." }) { foreach (var domain in new[] { "domain", "localhost" }) { foreach (var tld in new[] { "", ".com" }) { foreach (var port in new[] { "", ":80" }) { foreach (var folder in new[] { "", "/", "/folder/" }) { foreach (var file in new[] { "", "file.asp" }) { foreach (var query in new[] { "", "?here=go&there=yup" }) { foreach (var frag in new[] { "", "#fragment" }) { testUrl(table, scheme + userinfo + subdomain + domain + tld + port + folder + file + query + frag); } } } } } } } } } foreach (var additionalUrl in new[] { "//example.org/scheme-relative/URI/with/absolute/path/to/resource.txt", "/relative/URI/with/absolute/path/to/resource.txt", "relative/path/to/resource.txt", "../../../resource.txt", "./resource.txt#frag01", "resource.txt", "#frag01", "www.world.com" }) { testUrl(table, additionalUrl); } } }
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()); }
protected override PageContent getContent() { var content = new UiPageContent(isAutoDataUpdater: true); var fil = FormItemList.CreateStack(); fil.AddFormItems(parametersModification.GetField1TextControlFormItem(true), parametersModification.GetField2TextControlFormItem(true)); content.Add(fil); content.Add( new EwfButton( new StandardButtonStyle("Navigate and change Field 2"), behavior: new PostBackBehavior( postBack: PostBack.CreateFull( actionGetter: () => new PostBackAction( new OptionalParametersDemo(Es, optionalParameterSetter: (specifier, entitySetup, parameters) => { specifier.Field2 = "bob"; })))))); var table = EwfTable.Create(headItems: new[] { EwfTableItem.Create("Url".ToCell(), "Valid?".ToCell()) }); content.Add(table); foreach (var scheme in new[] { "http://", "ftp://", "file://" }) { foreach (var userinfo in new[] { "", "user:pass@" }) { foreach (var subdomain in new[] { "", "subdomain." }) { foreach (var domain in new[] { "domain", "localhost" }) { foreach (var tld in new[] { "", ".com" }) { foreach (var port in new[] { "", ":80" }) { foreach (var folder in new[] { "", "/", "/folder/" }) { foreach (var file in new[] { "", "file.asp" }) { foreach (var query in new[] { "", "?here=go&there=yup" }) { foreach (var frag in new[] { "", "#fragment" }) { testUrl(table, scheme + userinfo + subdomain + domain + tld + port + folder + file + query + frag); } } } } } } } } } foreach (var additionalUrl in new[] { "//example.org/scheme-relative/URI/with/absolute/path/to/resource.txt", "/relative/URI/with/absolute/path/to/resource.txt", "relative/path/to/resource.txt", "../../../resource.txt", "./resource.txt#frag01", "resource.txt", "#frag01", "www.world.com" }) { testUrl(table, additionalUrl); } } return(content); }