这是松结对编程的第23篇(专栏目录)。
接上文,45分钟后……
public static MvcHtmlString DropdownListHtml(WebViewPage page, MvcHtmlString title, IEnumerable<MvcHtmlString> linksLeft, IEnumerable<MvcHtmlString> linksRight1, IEnumerable<MvcHtmlString> linksRight2, string width = "400px", string viewName = "~/Views/MFCControls/_HtmlDropdownList.cshtml", MvcHtmlString valueSpecial = null)还好,接口算是明白,原来有个LinksRight2来处理右边的第二排;还有个width可以设置宽度。
public static MvcHtmlString StatusFiltersDropdownList(WebViewPage page) { var allStatuses = Status.AllStatuses().ToList(); const string key = "statusIds"; var currentStatusIds = page.ParameterOf(key); //Status groups filters on the top. var linksLeft = new Dictionary<string, IEnumerable<Status>> { {"所有状态", allStatuses}, {"所有正常", allStatuses.Where(i => i.IsNormal)}, {"所有开放", allStatuses.Where(i => !i.IsClosed)}, {"所有故事板", allStatuses.Where(i => i.IsDisplayedOnKanban)}, }; var linksListLeft = AddToList(page, key, currentStatusIds, linksLeft); var linksRight1 = new Dictionary<string, IEnumerable<Status>> { {"0", null}, {"所有已放弃或推迟", allStatuses.Where(i => !i.IsNormal)}, {"所有关闭", allStatuses.Where(i => i.IsClosed)}, {"所有非故事板", allStatuses.Where(i => !i.IsDisplayedOnKanban)} }; var linksListRight1 = AddToList(page, key, currentStatusIds, linksRight1); //Single status filters on the bottom. linksListLeft.Add(new MvcHtmlString("<hr/>")); linksListLeft.AddRange(allStatuses.Where(i => i.IsNormal) .Select(status => status.Link(outerLink: page.MergeParameter(key, "_" + status.ID + "_"), title: status.Value.ToString(), displayAsBoldText: "_" + status.ID + "_" == currentStatusIds))); linksListLeft.Add(new MvcHtmlString("<hr/>")); linksListLeft.AddRange(allStatuses.Where(i => !i.IsNormal) .Select(status => status.Link(outerLink: page.MergeParameter(key, "_" + status.ID + "_"), title: status.Value.ToString(), displayAsBoldText: "_" + status.ID + "_" == currentStatusIds))); /*linksListRight1.Add(null); linksListRight1.Add(MFCUI.Link("及更早", "#", textColor: "#EEE")); inksListRight1.AddRange(allStatuses.Where(i => i.IsNormal).Skip(1) .Select(status => MFCUI.Link("及更早", page.MergeParameter(key, allStatuses.Where(s => s.IsNormal && s.Value <= status.Value).Aggregate<Status, string>(null, (current, s) => current + "_" + s.ID + "_")), title: status.Value.ToString(), displayAsBoldText: currentStatusIds == allStatuses.Where(i => i.IsNormal && i.Value <= status.Value).Aggregate<Status, string>(null, (current, i) => current + "_" + i.ID + "_")))); var linksListRight2 = new List<MvcHtmlString>(); linksListRight2.AddRange(new List<MvcHtmlString> { null, null, null, null, null}); linksListRight2.AddRange(allStatuses.Where(i => i.IsNormal).Take(allStatuses.Count(i => i.IsNormal) - 1) .Select(status => MFCUI.Link("及更晚", page.MergeParameter(key, allStatuses.Where(s => s.IsNormal && s.Value >= status.Value).Aggregate<Status, string>(null, (current, s) => current + "_" + s.ID + "_")), title: status.Value.ToString(), displayAsBoldText: currentStatusIds == allStatuses.Where(i => i.IsNormal && i.Value >= status.Value).Aggregate<Status, string>(null, (current, i) => current + "_" + i.ID + "_")))); linksListRight2.Add(MFCUI.Link("及更晚", "#", textColor: "#EEE"));*/ //Current value text var currentValueText = ""; MvcHtmlString currentValue = null; currentValueText = linksLeft.SingleOrDefault(i => i.Value != null && currentStatusIds == i.Value.Aggregate<Status, string>(null, (current, status) => current + "_" + status.ID + "_")) .Key ?? currentValueText; //Is a group filter in left column. currentValueText = linksRight1.SingleOrDefault(i => i.Value != null && currentStatusIds == i.Value.Aggregate<Status, string>(null, (current, status) => current + "_" + status.ID + "_")) .Key ?? currentValueText; //Is a group filter in right column. if (!string.IsNullOrEmpty(currentValueText)) { currentValue = new MvcHtmlString("<b>" + currentValueText + "</b>"); } else { var currentStatus = allStatuses.SingleOrDefault(i => currentStatusIds == "_" + i.ID + "_"); //Is a single status filter. if (currentStatus != null) currentValue = MFCUI.Image(currentStatus.Title, "/MFC/Items/STAT/STAT16.png", showText: true, cssClassOfText: "bold", textColor: currentStatus.Color); else {/* currentStatus = allStatuses.SingleOrDefault(status => currentStatusIds == allStatuses.Where(i => i.IsNormal && i.Value <= status.Value) .Aggregate<Status, string>(null, (current, i) => current + "_" + i.ID + "_")); //Is a equal-to or early-than filter. if (currentStatus != null) currentValue = new MvcHtmlString(MFCUI.Image(currentStatus.Title, "/MFC/Items/STAT/STAT16.png", showText: true, cssClassOfText: "bold", textColor: currentStatus.Color) + "<b> 及更早</b>"); else { currentStatus = allStatuses.SingleOrDefault(status => currentStatusIds == allStatuses.Where(i => i.IsNormal && i.Value >= status.Value) .Aggregate<Status, string>(null, (current, i) => current + "_" + i.ID + "_")); //Is a equal-to or later-than filter. if (currentStatus != null) currentValue = new MvcHtmlString(MFCUI.Image(currentStatus.Title, "/MFC/Items/STAT/STAT16.png", showText: true, cssClassOfText: "bold", textColor: currentStatus.Color) + "<b> 及更晚</b>");*/ else currentValue = new MvcHtmlString("<b style=\"color: #169; \">请选择</b>"); } } } var ddl = MFCUI.DropdownListHtml(page, currentValue, linksListLeft, linksListRight1, /*linksListRight2, "300px"*/); return new MvcHtmlString("状态:" + ddl); }
public ActionResult IndexTree(int rootID, string whats, string whattypes/*, string statusIds*/) { if (string.IsNullOrEmpty(whats) || string.IsNullOrEmpty(whattypes)) return RedirectToAction("IndexTree", new { rootID, whats = SystemItemWhat.Story, whattypes = ItemWhattype.AllItemWhattypeString(SystemItemWhat.Story), /*statusIds = Status.AllStatuses().Where(i => i.Value >= Status.FirstStatusOnboard.Value)*/ }); var root = _repository.ReadItemAt(rootID); return IndexTreeView("用例树[" + root.Title + "]", new ItemTreeRightPadViewModel(_repository, null, rootID, whats, whattypes, /*statusIds,*/ Product.ProductsAccessibleToUserIDs(WebSecurity.CurrentUserId), showOpenAsTreeRoot: true, subItemsTreeColumnWidth: 350), comments: root.WhatType == ItemWhattype.ProductProductline ? new MvcHtmlString("悬停并点击下面的产品名称后的" + MFCUI.Image("", "/MFC/ItemTrees/OpenAsTreeRoot16.png") + "以查看详细的产品树。") : new MvcHtmlString("下面是首级子目录水平放置的故事树;点击各级故事目录后的“打开子树”图标 " + MFCUI.Image("打开子树", "/MFC/ItemTrees/OpenAsTreeRoot16.png") + " 以展开详细故事树。" + "首级目录排序和跨产品拖拽只能在" + MFCUI.ImageLink("故事树首页", "/ProductManagement/StoryTrees/Index") + " 进行")); }下面是筛选“所有故事板上的用户故事的测试用例”: