@inherits Dynamicweb.Rendering.ViewModelTemplate<Dynamicweb.Frontend.ParagraphViewModel>
@using Dynamicweb.Ecommerce.ProductCatalog
@using System.Collections.Generic

@{
	var groups = GetViewParameter("Groups") as List<FieldGroupViewModel>;
	bool hideGroupHeaders = GetViewParameterBoolean("HideGroupHeaders");
	bool hideTitle = GetViewParameterBoolean("HideTitle");
	string size = GetViewParameterString("Size");

	string title = Model.Item.GetString("Title");
	bool hideLabels = Model.Item.GetBoolean("HideFieldLabels");
	string titleFontSize = Model.Item.GetRawValueString("TitleFontSize", "display-4");
	string gapCss = size == "full" ? " gap-4" : " gap-2";

	if (!hideTitle)
	{
		<h2 class="g-col-12 @titleFontSize">@title</h2>
	}

	<div class="g-col-12">
		@foreach (var group in groups)
		{

			if (!hideGroupHeaders)
			{
				<h3>@group.Name</h3>
			}

			<dl class="grid @(gapCss)">
				@foreach (var field in group.Fields)
				{
					if (!hideLabels)
					{
						<dt class="g-col-4">@field.Name</dt>
						<dd class="g-col-8 mb-0 text-break">@RenderPartial("Components/Specifications/Shared/FieldValue.cshtml", field)</dd>
					}
					else 
					{
						<dd class="g-col-12 mb-0 text-break">@RenderPartial("Components/Specifications/Shared/FieldValue.cshtml", field)</dd>					
					}
				}
			</dl>
		}
	</div>
}
