示例#1
0
文件: CardView.cs 项目: upta/Coalesce
        public override void BuildOutput(HtmlCodeBuilder b)
        {
            b.Line("@{ ViewBag.Fluid = true; }");

            b.Line();
            using (b.TagBlock("style"))
            {
                b.Lines(
                    ".card-view-header {",
                    "    padding: 10px 15px;",
                    "}"
                    );
            }

            b.Line();
            using (b.TagBlock("div", $"card-view obj-{Model.ClientTypeName.ToCamelCase()}"))
            {
                WriteAdminTableControls(b, "card");

                b.Line();
                b.EmptyTag("hr");

                b.Line();
                using (b.TagBlock("div",
                                  @class: "flex-card-container card-view-body",
                                  dataBind: "foreach: items, visible: isLoaded",
                                  style: "display: none"))
                {
                    var titleProp = Model.ListTextProperty;

                    // The card for each object.
                    using (b.TagBlock("div", "flex-card"))
                    {
                        if (titleProp != null)
                        {
                            using (b.TagBlock("div", "card-heading").TagBlock("h3", "card-title"))
                            {
                                b.Line($"<span data-bind=\"text: {titleProp.JsVariableForBinding()}\"></span>");
                            }
                        }

                        using (b.TagBlock("div", "card-body flex"))
                        {
                            // List of all data properties on the object
                            using (b.TagBlock("dl"))
                            {
                                var properties = Model.ClientProperties
                                                 .Where(f => !f.IsHidden(HiddenAttribute.Areas.List))
                                                 .OrderBy(f => f.EditorOrder)
                                                 .ToList();
                                foreach (var prop in properties)
                                {
                                    b.Line($"<dt>{prop.DisplayName}</dt>");
                                    b.Line("<dd>");
                                    b.Indented($"{Display.PropertyHelper(prop, false)}");
                                    b.Line("</dd>");
                                }
                            }

                            // Edit/Delete buttons, and instance method dropdown.
                            b.Line();
                            using (b.TagBlock("div", style: "margin-top: auto"))
                            {
                                b.Line("<!-- Editor buttons -->");
                                using (b.TagBlock("div", new { @class = "pull-right", role = "group" }))
                                {
                                    WriteListViewObjectButtons(b);
                                }
                                b.Line("<span class=\"form-control-static\" data-bind=\"text: errorMessage\"></span>");
                            }
                        }
                    }
                }
            }

            b.Line();
            WriteMethodsCard(b, Model.ClientMethods.Where(f => f.IsStatic));

            b.Line();
            foreach (var method in Model.ClientMethods.Where(f => f.IsStatic && f.ClientParameters.Any()))
            {
                b.Line(IntelliTect.Coalesce.Knockout.Helpers.Knockout.ModalFor(method).ToString());
            }

            WriteListViewScript(b);
        }