Source

main / Source / WebClient / Web.Client / Views / Document / _ParameterMetadata.cshtml

Full commit
@model DataUp.Web.Client.ViewModel.DocumentDetailViewModel
@{
    Layout = null;
    ViewContext.FormContext = new FormContext();
}
<script type="text/javascript">
    $(function () {
        $('.closeSquareGrayBtn').click(function () {
            var rowCount = $(".paramtrTableContainer tr").length;
            if (rowCount > 1) {
                var row = $(this).closest('tr').remove();
            }
            else {
                ClearParameterRow($(".paramtrTableContainer tr:last"), 0)
                $(this).closest('tr').hide();
                $(".paramtrTableContainer .noParameters").show();
            }
        });

        $('.typeSelectList').change(function () {
            var paramtrContType = $(this);
            var control = paramtrContType.closest('tr').find('.unitsText');
            var arrowControl = paramtrContType.closest('tr').find('.unitSelectList');
            var typeTextboxControl = $(this).closest('td').find('.typeText');
            $(typeTextboxControl).val($(this).find(":selected").val());


            if ($(typeTextboxControl)[0].value !== "Numeric") {
                $(control).attr('disabled', true);
                $(control).val('');
                $(arrowControl).attr('disabled', true);
            }
            else {
                $(control).attr('disabled', false);
                $(arrowControl).attr('disabled', false);
                //$(arrowControl).find("option:first").attr("disabled", true);
            }
        });

        $('.entityNameList').change(function () {
            var entityTextCtrl = $(this).closest('td').find('.entityText');
            $(entityTextCtrl).val($(this).find(":selected").val());
        });

        $('.unitSelectList').change(function () {
            var textboxControl = $(this).parent().parent().find('.visibleInputbox');
            $(textboxControl).val($(this).find(":selected").val());
        });

    });
</script>
<table width="100%" border="0" cellspacing="0" cellpadding="0" class="paramtrTableContainer">
@if (Model.ParameterMetadataList.Count > 0)
{
    string metaDataCount = (Model.ParameterMetadataList.Count == 1 && Model.ParameterMetadataList[0].IsBlankRow) ? "none" : "inline-block";
    string noRowsDisplay = (metaDataCount == "none") ? "inline-block" : "none";
    
    foreach (var parameterMetadata in Model.ParameterMetadataList)
    {
        int index = Model.ParameterMetadataList.IndexOf(parameterMetadata);
        string unitCell = (Model.ParameterMetadataList[index].Type != null && Model.ParameterMetadataList[index].Type.Contains("Numeric")) ? string.Empty : "disabled";
    <tr class="parameterRows" style="display: @metaDataCount">
        <td class="paramtrContType paddingTop8">
            <div class="dropdownCont" style="width: 140px !important;">
                <div class="dropdownElementsHolder">
                    @Html.TextBoxFor(m => m.ParameterMetadataList[index].EntityName, new { id = "ParameterMetadataList_" + @index + "__EntityName", @class = "visibleInputbox entityText", @readonly = "true" })
                </div>
                @Html.DropDownListFor(m => m.ParameterMetadataList[index].EntityName, Model.EntityNameList, new { id = "ParameterMetadataList_" + @index + "__EntityNames", @class = "paramtrHdrType entityNameList" })
            </div>
        </td>
        <td class="paramtrContDes">
            @Html.TextBoxFor(m => m.ParameterMetadataList[index].EntityDescription, new { @class = "paramtrContDes entityDescription", @style = "width:208px;" })
        </td>
        <td class="paramtrContName">@Html.TextBoxFor(m => m.ParameterMetadataList[index].Name, new { @class = "paramtrContName paramName" })
            @Html.ValidationMessageFor(m => m.ParameterMetadataList[index].Name, "", new { @class = "gridName" })
        </td>
        <td class="paramtrContDes">
            @Html.TextBoxFor(m => m.ParameterMetadataList[index].Description, new { @class = "paramtrContDes paramDescription" })
        </td>
        <td class="paramtrContType paddingTop8">
            <div class="dropdownCont">
                <div class="dropdownElementsHolder">
                    @Html.TextBoxFor(m => m.ParameterMetadataList[index].Type, new { id = "ParameterMetadataList_" + @index + "__Type", @class = "visibleInputbox typeText", @readonly = "true" })
                </div>
                @Html.DropDownListFor(m => m.ParameterMetadataList[index].Type, Model.ParameterTypeList, string.Empty, new { id = "ParameterMetadataList_" + @index + "__Types", @class = "paramtrContType typeSelectList" })
            </div>
        </td>
        <td class="paramtrHdrUnit">
            <div class="dropdownCont">
                <div class="dropdownElementsHolder">
                    @if (unitCell.Equals(string.Empty))
                    {
                        @Html.TextBoxFor(m => m.ParameterMetadataList[index].Units, new { id = "ParameterMetadataList_" + @index + "__Units", @class = "visibleInputbox unitsText" })
                    }
                    else
                    {
                        @Html.TextBoxFor(m => m.ParameterMetadataList[index].Units, new { id = "ParameterMetadataList_" + @index + "__Units", @class = "visibleInputbox unitsText", disabled = @unitCell })
                    }
                </div>
                @if (unitCell.Equals(string.Empty))
                {
                    @Html.DropDownListFor(m => m.ParameterMetadataList[index].Units, Model.ParameterUnitList, string.Empty, new { id = "ParameterMetadataList_" + @index + "__Unit", @class = "hiddenDropdown unitSelectList" })
                }
                else
                {
                    @Html.DropDownListFor(m => m.ParameterMetadataList[index].Units, Model.ParameterUnitList, string.Empty, new { id = "ParameterMetadataList_" + @index + "__Unit", @class = "hiddenDropdown unitSelectList", disabled = @unitCell })
                }
            </div>
        </td>
        <td class="paramtrContBtn">
            <input type="button" class="closeSquareGrayBtn rFloat" />
        </td>
    </tr>
    }
    <div style="display: @noRowsDisplay; font-size: 12px" class="noParameters" >
        Click on <b>+Add Item </b>button to provide Column Description
    </div>
}
</table>