<commit_before>﻿@using Purchasing.Web.Models
@model WorkgroupVendorViewModel

@using (Html.BeginForm())
{
	@Html.AntiForgeryToken()
	@Html.ValidationSummary(true)
    @Html.Hidden("newVendor", false)
    @Html.Hidden("WorkgroupVendor.Workgroup", Model.WorkgroupVendor.Workgroup.Id)
    
    <section class="ui-corner-all">
	    <header class="ui-corner-top">Kfs Vendor</header>

	    <div class="section-contents">

		    <div class="section-text">
			    <p>Selecting from the below drop downs will associate this vendor with KFS records and will automatically associate orders with KFS vendors when submitted to KFS.</p>
		    </div>

		    <ul>
				<li>
				    <div class="editor-label">@Html.LabelFor(a => a.WorkgroupVendor.VendorId)</div>
				    <div class="editor-field">
                        @this.Select("WorkgroupVendor.VendorId").Options(Model.Vendors, x => x.Id, x => x.Name).FirstOption("--Select Vendor--").Selected(Model.WorkgroupVendor.VendorId)
                        @Html.ValidationMessageFor(a => a.WorkgroupVendor.VendorId)
				    </div>
			    </li>

                <li>
                    <div class="editor-label">@Html.LabelFor(a => a.WorkgroupVendor.VendorAddressTypeCode)</div>
                    <div class="editor-field">
                        @this.Select("WorkgroupVendor.VendorAddressTypeCode").FirstOption("--Select Address--").Options(Model.VendorAddresses).Selected(Model.WorkgroupVendor.VendorAddressTypeCode)
                        @Html.ValidationMessageFor(a => a.WorkgroupVendor.VendorAddressTypeCode)
                    </div>
                </li>

		    </ul>

	    </div>

	    <footer class="ui-corner-bottom"></footer>

    </section>
       
    <section class="ui-corner-all">
    
        <div class="section-contents">
            <ul>
                <li>
                    <div class="editor-label">&nbsp;</div>
                    <div class="editor-field"><input class="button" type="submit" value="Save" /> | @Html.ActionLink("Cancel", "VendorList", new { id = Model.WorkgroupVendor.Workgroup.Id })</div>
                </li>
            </ul>
        </div>

    </section>
}<commit_msg>changed the search for vendors<commit_after>﻿@using Purchasing.Web.Models
@model WorkgroupVendorViewModel

@using (Html.BeginForm())
{
	@Html.AntiForgeryToken()
	@Html.ValidationSummary(true)
    @Html.Hidden("newVendor", false)
    @Html.Hidden("WorkgroupVendor.Workgroup", Model.WorkgroupVendor.Workgroup.Id)
    
    <section class="ui-corner-all">
	    <header class="ui-corner-top">Kfs Vendor</header>

	    <div class="section-contents">

		    <div class="section-text">
			    <p>Selecting from the below drop downs will associate this vendor with KFS records and will automatically associate orders with KFS vendors when submitted to KFS.</p>
		    </div>

		    <ul>
				<li>
				    <div class="editor-label">@Html.LabelFor(a => a.WorkgroupVendor.VendorId)</div>
				    <div class="editor-field">
                        @*@this.Select("WorkgroupVendor.VendorId").Options(Model.Vendors, x => x.Id, x => x.Name).FirstOption("--Select Vendor--").Selected(Model.WorkgroupVendor.VendorId)*@

                        <input type="text" id="VendorSearch"/>
                        @Html.Hidden("WorkgroupVendor.VendorId")

                        @Html.ValidationMessageFor(a => a.WorkgroupVendor.VendorId)
				    </div>
			    </li>

                <li>
                    <div class="editor-label">@Html.LabelFor(a => a.WorkgroupVendor.VendorAddressTypeCode)</div>
                    <div class="editor-field">
                        @this.Select("WorkgroupVendor.VendorAddressTypeCode").FirstOption("--Select Address--").Options(Model.VendorAddresses).Selected(Model.WorkgroupVendor.VendorAddressTypeCode).Disabled(true)
                        @Html.ValidationMessageFor(a => a.WorkgroupVendor.VendorAddressTypeCode)
                    </div>
                </li>

		    </ul>

	    </div>

	    <footer class="ui-corner-bottom"></footer>

    </section>
       
    <section class="ui-corner-all">
    
        <div class="section-contents">
            <ul>
                <li>
                    <div class="editor-label">&nbsp;</div>
                    <div class="editor-field"><input class="button" type="submit" value="Save" /> | @Html.ActionLink("Cancel", "VendorList", new { id = Model.WorkgroupVendor.Workgroup.Id })</div>
                </li>
            </ul>
        </div>

    </section>
}

<script type="text/javascript">
    $(function () {

        $("#VendorSearch").autocomplete({
            source: function (request, response) {
                var searchUrl = '@Url.Action("SearchVendor", "WorkgroupVendor")';

                $.getJSON(searchUrl, { searchTerm: request.term }, function (results) {

                    response($.map(results, function (item) {
                        return {
                            label: item.Name,
                            value: item.Id
                        };
                    }));

                });
            },
            minLength: 3,
            select: function (event, ui) {

                // set the selected vendor
                $("#WorkgroupVendor_VendorId").val(ui.item.value);

                // display the vendor's name
                $(this).val(ui.item.label);

                // search for an address
                searchVendorAddress(ui.item.value);

                return false;

            }
        });

    });

    function searchVendorAddress(vendorId) {

        var vendorAddressUrl = '@Url.Action("SearchVendorAddress", "WorkgroupVendor")';

        $.getJSON(vendorAddressUrl, { vendorId: vendorId }, function (results) {

            // clear the current options
            $("#WorkgroupVendor_VendorAddressTypeCode option:not(:first)").remove();

            var select = $("#WorkgroupVendor_VendorAddressTypeCode");

            if (results.length > 0) {

                var data = $.map(results, function (n, i) { return { id: n.Id, name: n.Name }; });

                $.tmpl($("#select-option-template"), data).appendTo("#WorkgroupVendor_VendorAddressTypeCode");

                // activate control
                select.removeAttr("disabled");
            }
            else {
                // deactivate select
                select.attr("disabled", "disabled");
            }

        });
    }
    
</script>

<script id="select-option-template" type="text/x-jquery-tmpl">
<option value="${id}">${name}</option>
</script>
{'fraction_non_alphanumeric': 0.14235474006116208, 'fraction_numerical': 0.0003058103975535168, 'mean_word_length': 2.0128972823583604, 'pattern_counts': {'":': 0, '<': 88, '<?xml version=': 0, '>': 101, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2651670', 'n_tokens_mistral': 1959, 'n_tokens_neox': 1789, 'n_words': 315}