private static MvcHtmlString ClassifierField(this HtmlHelper source, string name, string value, Field field, Article article, bool forceReadOnly) { Article aggregatedArticle = null; var classifierValue = Converter.ToInt32(value, 0); if (article.ViewType != ArticleViewType.Virtual) { aggregatedArticle = article.GetAggregatedArticleByClassifier(classifierValue); } var sb = new StringBuilder(source.BeginClassifierFieldComponent(name, value, field, article, aggregatedArticle, out var _)); if (forceReadOnly) { var classifierContent = ArticleViewModel.GetContentById(Converter.ToNullableInt32(value)); var classifierContentName = classifierContent?.Name; var htmlAttributes = new Dictionary <string, object> { { "class", HtmlHelpersExtensions.ArticleTextboxClassName }, { "disabled", "disabled" }, { HtmlHelpersExtensions.DataContentFieldName, field.Name } }; sb.Append(source.QpTextBox(name, classifierContentName, htmlAttributes)); } else { var contentListHtmlAttrs = new Dictionary <string, object> { { "class", "dropDownList classifierContentList" }, { HtmlHelpersExtensions.DataContentFieldName, field.Name } }; sb.Append(source.DropDownList(name, source.List(ArticleViewModel.GetAggregatableContentsForClassifier(field, value)), FieldStrings.SelectContent, contentListHtmlAttrs).ToHtmlString()); } sb.Append(EndClassifierFieldComponent()); return(MvcHtmlString.Create(sb.ToString())); }
private static IHtmlContent ClassifierField( this IHtmlHelper source, string name, string value, Field field, Article article, bool forceReadOnly) { Article aggregatedArticle = null; var classifierValue = Converter.ToInt32(value, 0); if (article.ViewType != ArticleViewType.Virtual) { aggregatedArticle = article.GetAggregatedArticleByClassifier(classifierValue); } var classifierTag = source.ClassifierFieldComponent(name, value, field, article, aggregatedArticle); if (forceReadOnly) { var classifierContent = ArticleViewModel.GetContentById(Converter.ToNullableInt32(value)); var classifierContentName = classifierContent?.Name; var htmlAttributes = new Dictionary <string, object> { { "class", HtmlHelpersExtensions.ArticleTextboxClassName }, { "disabled", "disabled" }, { HtmlHelpersExtensions.DataContentFieldName, field.Name } }; classifierTag.InnerHtml.AppendHtml(source.QpTextBox(name, classifierContentName, htmlAttributes)); } else { var contentListHtmlAttrs = new Dictionary <string, object> { { "class", "dropDownList classifierContentList" }, { HtmlHelpersExtensions.DataContentFieldName, field.Name } }; var dropDownList = source.DropDownList( name, source.List(ArticleViewModel.GetAggregatableContentsForClassifier(field, value)), FieldStrings.SelectContent, contentListHtmlAttrs); classifierTag.InnerHtml.AppendHtml(dropDownList); } return(classifierTag); }