<commit_before>﻿@model PompeiiSquare.Server.Areas.VenueAdministrator.Models.VenueCreateBindingModel
@{
    ViewBag.Title = "Create new venue";
}

<h2>Create new venue</h2>
@using (Html.BeginForm())
{
    @Html.AntiForgeryToken()

    <div class="form-horizontal">
        @Html.ValidationSummary(true, "", new { @class = "text-danger" })
        <div class="form-group">
            @Html.LabelFor(model => model.Name, htmlAttributes: new { @class = "control-label col-md-2" })
            <div class="col-md-10">
                @Html.EditorFor(model => model.Name, new { htmlAttributes = new { @class = "form-control" } })
                @Html.ValidationMessageFor(model => model.Name, "", new { @class = "text-danger" })
            </div>
        </div>

        <div class="form-group">
            @Html.LabelFor(model => model.Address, htmlAttributes: new { @class = "control-label col-md-2" })
            <div class="col-md-10">
                @Html.EditorFor(model => model.Address, new { htmlAttributes = new { @class = "form-control" } })
                @Html.ValidationMessageFor(model => model.Address, "", new { @class = "text-danger" })
            </div>
        </div>

        <div class="form-group">
            @Html.LabelFor(model => model.Contact, htmlAttributes: new { @class = "control-label col-md-2" })
            <div class="col-md-10">
                @Html.EditorFor(model => model.Contact, new { htmlAttributes = new { @class = "form-control" } })
                @Html.ValidationMessageFor(model => model.Contact, "", new { @class = "text-danger" })
            </div>
        </div>

        <div class="form-group">
            @Html.LabelFor(model => model.Location, htmlAttributes: new { @class = "control-label col-md-2" })
            <div class="col-md-10">
                @Html.EditorFor(model => model.Location, new { htmlAttributes = new { @class = "form-control" } })
                @Html.ValidationMessageFor(model => model.Location, "", new { @class = "text-danger" })
            </div>
        </div>

        <div class="form-group">
            @Html.LabelFor(model => model.PriceTier, htmlAttributes: new { @class = "control-label col-md-2" })
            <div class="col-md-10">
                @Html.EditorFor(model => model.PriceTier, new { htmlAttributes = new { @class = "form-control" } })
                @Html.ValidationMessageFor(model => model.PriceTier, "", new { @class = "text-danger" })
            </div>
        </div>

        <div class="form-group">
            @Html.LabelFor(model => model.Description, htmlAttributes: new { @class = "control-label col-md-2" })
            <div class="col-md-10">
                @Html.EditorFor(model => model.Description, new { htmlAttributes = new { @class = "form-control" } })
                @Html.ValidationMessageFor(model => model.Description, "", new { @class = "text-danger" })
            </div>
        </div>

        <div class="form-group">
            @Html.LabelFor(model => model.Groups, htmlAttributes: new { @class = "control-label col-md-2" })
            <div class="col-md-10">
                @Html.EditorFor(model => model.Groups, new { htmlAttributes = new { @class = "form-control" } })
                @Html.ValidationMessageFor(model => model.Groups, "", new { @class = "text-danger" })
            </div>
        </div>

        <div class="form-group">
            @Html.LabelFor(model => model.OpenHours, htmlAttributes: new { @class = "control-label col-md-2" })
            <div class="col-md-10">
                @Html.EditorFor(model => model.OpenHours, new { htmlAttributes = new { @class = "form-control" } })
                @Html.ValidationMessageFor(model => model.OpenHours, "", new { @class = "text-danger" })
                @Ajax.ActionLink(
                    "Add new",
                    "AddNewOpenHours",
                    new AjaxOptions() { InsertionMode = InsertionMode.InsertAfter, UpdateTargetId = "open-hours-items", OnSuccess = "changeNextOpenHoursId" })
            </div>
        </div>
        <div class="form-group">
            @Html.LabelFor(model => model.Tags, htmlAttributes: new { @class = "control-label col-md-2" })
            <div class="col-md-10">
                @Html.EditorFor(model => model.Tags, new { htmlAttributes = new { @class = "form-control" } })
                @Html.ValidationMessageFor(model => model.Tags, "", new { @class = "text-danger" })
            </div>
        </div>

        <div class="form-group">
            <div class="col-md-offset-2 col-md-10">
                <input type="submit" value="Create" class="btn btn-default" />
            </div>
        </div>
    </div>
}

@section Scripts {
    <script src="@Url.Content("~/Scripts/jquery.unobtrusive-ajax.js")" type="text/javascript"></script>
    @Scripts.Render("~/bundles/jquery")
    @Scripts.Render("~/bundles/jqueryval")
    <script>
        var nextOpenHoursId = 1;
        function changeNextOpenHoursId() {
            var fieldsToChange = $(this).siblings().first().children().last();
            var weekdayField = fieldsToChange.find("input[name='Weekday']");
            var hoursField = fieldsToChange.find("input[name='Hours']");
            weekdayField.attr("name", "OpenHours[" + (nextOpenHoursId) + "]." + weekdayField.attr("name"));
            hoursField.attr("name", "OpenHours[" + (nextOpenHoursId) + "]." + hoursField.attr("name"));
            nextOpenHoursId++;
        }
    </script>
}
<commit_msg>Adding multiple working hours is now working<commit_after>﻿@model PompeiiSquare.Server.Areas.VenueAdministrator.Models.VenueCreateBindingModel
@{
    ViewBag.Title = "Create new venue";
}

<h2>Create new venue</h2>
@using (Html.BeginForm())
{
    @Html.AntiForgeryToken()

    <div class="form-horizontal">
        @Html.ValidationSummary(true, "", new { @class = "text-danger" })
        <div class="form-group">
            @Html.LabelFor(model => model.Name, htmlAttributes: new { @class = "control-label col-md-2" })
            <div class="col-md-10">
                @Html.EditorFor(model => model.Name, new { htmlAttributes = new { @class = "form-control" } })
                @Html.ValidationMessageFor(model => model.Name, "", new { @class = "text-danger" })
            </div>
        </div>

        <div class="form-group">
            @Html.LabelFor(model => model.Address, htmlAttributes: new { @class = "control-label col-md-2" })
            <div class="col-md-10">
                @Html.EditorFor(model => model.Address, new { htmlAttributes = new { @class = "form-control" } })
                @Html.ValidationMessageFor(model => model.Address, "", new { @class = "text-danger" })
            </div>
        </div>

        <div class="form-group">
            @Html.LabelFor(model => model.Contact, htmlAttributes: new { @class = "control-label col-md-2" })
            <div class="col-md-10">
                @Html.EditorFor(model => model.Contact, new { htmlAttributes = new { @class = "form-control" } })
                @Html.ValidationMessageFor(model => model.Contact, "", new { @class = "text-danger" })
            </div>
        </div>

        <div class="form-group">
            @Html.LabelFor(model => model.Location, htmlAttributes: new { @class = "control-label col-md-2" })
            <div class="col-md-10">
                @Html.EditorFor(model => model.Location, new { htmlAttributes = new { @class = "form-control" } })
                @Html.ValidationMessageFor(model => model.Location, "", new { @class = "text-danger" })
            </div>
        </div>

        <div class="form-group">
            @Html.LabelFor(model => model.PriceTier, htmlAttributes: new { @class = "control-label col-md-2" })
            <div class="col-md-10">
                @Html.EditorFor(model => model.PriceTier, new { htmlAttributes = new { @class = "form-control" } })
                @Html.ValidationMessageFor(model => model.PriceTier, "", new { @class = "text-danger" })
            </div>
        </div>

        <div class="form-group">
            @Html.LabelFor(model => model.Description, htmlAttributes: new { @class = "control-label col-md-2" })
            <div class="col-md-10">
                @Html.EditorFor(model => model.Description, new { htmlAttributes = new { @class = "form-control" } })
                @Html.ValidationMessageFor(model => model.Description, "", new { @class = "text-danger" })
            </div>
        </div>

        <div class="form-group">
            @Html.LabelFor(model => model.Groups, htmlAttributes: new { @class = "control-label col-md-2" })
            <div class="col-md-10">
                @Html.EditorFor(model => model.Groups, new { htmlAttributes = new { @class = "form-control" } })
                @Html.ValidationMessageFor(model => model.Groups, "", new { @class = "text-danger" })
            </div>
        </div>

        <div class="form-group">
            @Html.LabelFor(model => model.OpenHours, htmlAttributes: new { @class = "control-label col-md-2" })
            <div class="col-md-10">
                @Html.EditorFor(model => model.OpenHours, new { htmlAttributes = new { @class = "form-control" } })
                @Html.ValidationMessageFor(model => model.OpenHours, "", new { @class = "text-danger" })
                @Ajax.ActionLink(
                    "Add new",
                    "AddNewOpenHours",
                    new AjaxOptions() { InsertionMode = InsertionMode.InsertAfter, UpdateTargetId = "open-hours-items" })
            </div>
        </div>
        <div class="form-group">
            @Html.LabelFor(model => model.Tags, htmlAttributes: new { @class = "control-label col-md-2" })
            <div class="col-md-10">
                @Html.EditorFor(model => model.Tags, new { htmlAttributes = new { @class = "form-control" } })
                @Html.ValidationMessageFor(model => model.Tags, "", new { @class = "text-danger" })
            </div>
        </div>
        <div class="form-group">
            <div class="col-md-offset-2 col-md-10">
                <input type="submit" value="Create" class="btn btn-default" onclick="updateIds()" />
            </div>
        </div>
    </div>
}

@section Scripts {
    <script src="@Url.Content("~/Scripts/jquery.unobtrusive-ajax.js")" type="text/javascript"></script>
    @Scripts.Render("~/bundles/jquery")
    @Scripts.Render("~/bundles/jqueryval")
    <script>
        //var nextOpenHoursId = 1;
        //function changeNextOpenHoursId() {
        //    var fieldsToChange = $(this).siblings().first().children().last();
        //    var weekdayField = fieldsToChange.find("input[name='Weekday']");
        //    var hoursField = fieldsToChange.find("input[name='Hours']");
        //    weekdayField.attr("name", "OpenHours[" + (nextOpenHoursId) + "]." + weekdayField.attr("name"));
        //    hoursField.attr("name", "OpenHours[" + (nextOpenHoursId) + "]." + hoursField.attr("name"));
        //    nextOpenHoursId++;
        //}

        function updateIds() {
            updateWorkingHoursIds();
        }

        function updateWorkingHoursIds() {
            var nextOpenHoursId = 1;
            $("input[name='Weekday']")
                .each(function (index, element) {
                    $(element).attr("name", "OpenHours[" + (nextOpenHoursId++) + "]." + $(element).attr("name"));
                });
            nextOpenHoursId = 1;
            $("input[name='Hours']")
                .each(function (index, element) {
                    $(element).attr("name", "OpenHours[" + (nextOpenHoursId++) + "]." + $(element).attr("name"));
                });
        }
    </script>
}

{'fraction_non_alphanumeric': 0.16997603560424512, 'fraction_numerical': 0.005819924683327628, 'mean_word_length': 2.1615259740259742, 'pattern_counts': {'":': 0, '<': 101, '<?xml version=': 0, '>': 155, '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': '6024317', 'n_tokens_mistral': 3551, 'n_tokens_neox': 3407, 'n_words': 631}