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

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

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


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

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

			if (!hideGroupHeaders)
			{
				<h4 class="g-col-12 h4 mb-0">@group.Name</h4>
			}

			<table class="table @(tableSizeCss)">
				<tbody>
					@foreach (var field in group.Fields)
					{
						<tr>
							@if (!hideLabels) 
							{ 
							<td style="width: 35%;">@(field.Name)</td>
							}

							<td class="text-break">@RenderPartial("Components/Specifications/Shared/FieldValue.cshtml", field)</td>
						</tr>
					}
				</tbody>
			</table>
		}
	</div>

}

