public string Generate(Repository repository, Models.DataRuleSetting dataRule) { if (dataRule.DataRule is DataRuleBase) { var dataRuleBase = (DataRuleBase)dataRule.DataRule; var schema = dataRuleBase.GetSchema(repository).AsActual(); string html = @" <h2><%: ViewBag.{0}.{1} ?? """" %></h2> <ul class=""detail {2}-detail""> {3} </ul>"; string columnTp = @" <li> {0}: <p> <%: ViewBag.{1}.{0} ?? """" %> </p> </li> "; var titleField = schema.GetSummarizeColumn().Name; schema = schema.AsActual(); StringBuilder sb = new StringBuilder(); foreach (var column in schema.Columns) { if (!column.Name.EqualsOrNullEmpty(titleField, StringComparison.CurrentCultureIgnoreCase)) { sb.AppendFormat(columnTp, column.Name, dataRule.DataName); } } return(string.Format(html, dataRule.DataName, schema.GetSummarizeColumn().Name, schema.Name, sb.ToString())); } return(string.Empty); }
public string Generate(Repository repository, Models.DataRuleSetting dataRule) { if (dataRule.DataRule is DataRuleBase) { var dataRuleBase = (DataRuleBase)dataRule.DataRule; var schema = dataRuleBase.GetSchema(repository).AsActual(); string html = @" <ul> <%foreach (var item in ViewBag.{0}) {{%> <li> <%: Html.FrontHtml().PageLink(item.{1}, ""{2}/detail"", new {{ UserKey = item.UserKey}}) %> </li> <%}}%> </ul>"; var snippet = string.Format(html, dataRule.DataName, schema.GetSummarizeColumn().Name, schema.Name); if (dataRule.DataRule.EnablePaging()) { snippet += Environment.NewLine + string.Format("<%: Html.FrontHtml().Pager(ViewBag.{0}) %>", dataRule.DataName); } return(snippet); } return(string.Empty); }
public string Generate(Bzway.Data.Models.Repository repository, Models.DataRuleSetting dataRule, bool inlineEdit) { if (dataRule.DataRule is DataRuleBase) { var dataRuleBase = (DataRuleBase)dataRule.DataRule; var schema = (dataRuleBase.GetSchema(repository)).AsActual(); string html = @" #foreach($item in $ViewBag.{0}) #each <li{2}>{1}</li> #before #after #between #odd #even #nodata #beforeall <ul class=""list""> #afterall </ul> #end"; var titleField = schema.GetSummarizeColumn(); var editItem = ""; var linkHtml = string.Format("<a class='title' href='$Url.FrontUrl().PageUrl(\"{1}/detail\",\"%{{UserKey = $item.UserKey}}\")'>$item.{0}</a>", titleField.Name, schema.Name); if (inlineEdit) { editItem = " $ViewHelper.Edit($item)"; linkHtml = string.Format("<a class='title' href='$Url.FrontUrl().PageUrl(\"{1}/detail\",\"%{{UserKey = $item.UserKey}}\")' $ViewHelper.Edit($item,\"{0}\")>$item.{0}</a>", titleField.Name, schema.Name); } var snippet = string.Format(html, dataRule.DataName, linkHtml, editItem); if (dataRule.DataRule.EnablePaging.Value) { snippet += Environment.NewLine + string.Format(@" <div class=""pager""> $Html.FrontHtml().Pager($ViewBag.{0}) </div>", dataRule.DataName); } return(snippet); } return(string.Empty); }
public string Generate(Repository repository, Models.DataRuleSetting dataRule, bool inlineEdit) { if (dataRule.DataRule is DataRuleBase) { var dataRuleBase = (DataRuleBase)dataRule.DataRule; var schema = dataRuleBase.GetSchema(repository).AsActual(); string html = @" <ul class=""list""> <% foreach(dynamic item in ViewBag.{0}) {{%> <li{2}> {1} </li> <%}}%> </ul>"; var titleField = schema.GetSummarizeColumn(); var editItem = ""; var linkHtml = string.Format("<a class='title' href='<%:@Url.FrontUrl().PageUrl(\"{1}/detail\",new {{ UserKey = item.UserKey}})%>'><%:item.{0}%></a>", titleField.Name, schema.Name); if (inlineEdit) { editItem = " <%:ViewHelper.Edit(item)%>"; linkHtml = string.Format("<a class='title' href='<%:@Url.FrontUrl().PageUrl(\"{1}/detail\",new {{ UserKey = item.UserKey}})%>' <%:ViewHelper.Edit(item,\"{0}\")%>><%:item.{0}%></a>", titleField.Name, schema.Name); } var snippet = string.Format(html, dataRule.DataName, linkHtml, editItem); if (dataRule.DataRule.EnablePaging.Value) { snippet += Environment.NewLine + string.Format(@" <div class=""pager""> <%: Html.FrontHtml().Pager(ViewBag.{0}) %> </div>", dataRule.DataName); } return(snippet); } return(string.Empty); }
public string Generate(Repository repository, Models.DataRuleSetting dataRule, bool inlineEdit) { if (dataRule.DataRule is DataRuleBase) { var dataRuleBase = (DataRuleBase)dataRule.DataRule; var schema = dataRuleBase.GetSchema(repository).AsActual(); string html = @" <div> <h3 class=""title""{3}>@Html.Raw(ViewBag.{0}.{1} ?? """")</h3> <div class=""content""> {2} </div> </div>"; string columnTp = @" <div{2}> @Html.Raw(ViewBag.{1}.{0} ?? """") </div> "; var titleField = schema.GetSummarizeColumn().Name; var editField = " @ViewHelper.Edit(ViewBag.{0},\"{1}\")"; schema = schema.AsActual(); StringBuilder sb = new StringBuilder(); foreach (var column in schema.Columns) { if (!column.Name.EqualsOrNullEmpty(titleField, StringComparison.CurrentCultureIgnoreCase)) { sb.AppendFormat(columnTp, column.Name, dataRule.DataName, inlineEdit ? string.Format(editField, dataRule.DataName, column.Name) : ""); } } return(string.Format(html, dataRule.DataName, schema.GetSummarizeColumn().Name, sb.ToString() , inlineEdit ? string.Format(editField, dataRule.DataName, titleField) : "")); } return(string.Empty); }