@inherits Dynamicweb.Rendering.ViewModelTemplate<Dynamicweb.Ecommerce.ProductCatalog.FieldValueViewModel>
@using Dynamicweb.Frontend
@using Dynamicweb.Ecommerce.ProductCatalog

@{
	var hideUnitsOfMeasure = false;

	if (Model.Value is List<FieldOptionValueViewModel> listValues)
	{
		foreach (var field in listValues)
		{
			if (field.IsColor() && field.GetColor() is ColorViewModel colorModel)
			{
				string hexColor = colorModel.Hex;

				<span class="colorbox-sm" style="background-color: @hexColor" title="@hexColor"></span>
			}
			else
			{
				<span>@field.Name</span>
			}
		}
	}
	else
	{
		if (Model.IsLink() && Model.GetLink() is LinkViewModel linkModel)
		{
			<span>
				<a href="@linkModel.Url">@linkModel.Url</a>
			</span>
		}
		else if (Model.IsColor() && Model.GetColor() is ColorViewModel colorModel)
		{
			string hexColor = colorModel.Hex;

			<span class="colorbox-sm" style="background-color: @hexColor" title="@hexColor"></span>
		}
		else if (Model.IsFile() && Model.GetFile() is FileViewModel fileModel)
		{
			var file = fileModel;

			<a href="@file.Path" download>@file.Name</a>
		}
		else
		{
			var value = hideUnitsOfMeasure ? Model.Value : Model.GetValueWithUnits();
			value = value.ToString().ToLower() == "true" ? Translate("Yes") : value;
			value = value.ToString().ToLower() == "false" ? Translate("No") : value;

			<span>@value</span>
		}
	}
}
