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());
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 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 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); }
private FlowComponent getTagSection(DataValue <string> filter, UpdateRegionSet resultUpdateRegions) { var tags = ArticleTagsTableRetrieval.GetRows() .Select(i => i.TagId) .GroupBy(i => i) .OrderByDescending(i => i.Count()) .Take(20) .Select(i => TagsTableRetrieval.GetRowMatchingId(i.Key)); return(new Section( "Popular Tags", new WrappingList( tags.Select( i => (WrappingListItem) new EwfButton( new StandardButtonStyle(i.TagName, buttonSize: ButtonSize.ShrinkWrap), behavior: new PostBackBehavior( postBack: PostBack.CreateIntermediate( resultUpdateRegions.ToCollection(), id: PostBack.GetCompositeId("tag", i.TagId.ToString()), modificationMethod: () => filter.Value = "tag{0}".FormatWith(i.TagId)))).ToComponentListItem()), generalSetup: new ComponentListSetup(classes: ElementClasses.Tag)).ToCollection(), style: SectionStyle.Box)); }