@using System.Globalization
@model Griffin.MvcContrib.Areas.Griffin.Models.LocalizeViews.IndexModel
@{
    ViewBag.Title = "Index";
}
<div class="griffin">
    @Html.Partial("_menu")
    <h2>@CultureInfo.CurrentUICulture.DisplayName</h2>
    @using (Html.BeginForm("CreateLanguage", "LocalizeViews"))
    {
        @Html.ValidationSummary(true)
        <div style="float: right">
            Change language:
            @Html.DropDownList("changeLanguage", Model.CultureItems, "", CultureInfo.CurrentUICulture.Name)
            <div style="background-color: aliceblue; margin-top: 10px;">
                Create language (should be a lang code like "sv-se")
                <br />
                <input type="text" name="lang" />
                <input type="submit" value="Create" />
            </div>
        </div>
    }
    @using (Html.BeginForm("Index"))
    {
        <div style="float: left">
            Path: @Html.TextBoxFor(model => model.TableFilter)
            <br />
            Show only untranslated @Html.CheckBoxFor(model => Model.OnlyNotTranslated)
        </div>
        <input type="submit" value="show" />
        <div style="clear: both"></div>
    }
    <table>
        <tr>
            <th>
                ViewPath
            </th>
            <th>
                TextName
            </th>
            <th>
                TranslatedText
            </th>
            <th>
            </th>
        </tr>
        @foreach (var item in Model.Prompts)
        {
            <tr>
                <td>
                    @Html.DisplayFor(modelItem => item.ViewPath)
                </td>
                <td>
                    @Html.DisplayFor(modelItem => item.TextName)
                </td>
                <td>
                    @Html.DisplayFor(modelItem => item.TranslatedText)
                </td>
                <td style="width: 64px">
                    <a href="@Url.Action("Edit", new { id = item.TextKey })" title="Edit text" style="text-decoration: none">
                        <img src="@Url.Content("~/Areas/Griffin/Content/GriffinImg/edit.png")"/>
                    </a><a href="@Url.Action("Delete", new { id = item.TextKey })" title="Delete text" style="text-decoration: none">
                        <img src="@Url.Content("~/Areas/Griffin/Content/GriffinImg/delete.png")"/>
                    </a>
                    @if (item.ViewPath != "CommonPrompts")
                    {
                        <a href="@Url.Action("MakeCommon", new { id = item.TextKey })" title="Share text between views" style="text-decoration: none">
                            <img src="@Url.Content("~/Areas/Griffin/Content/GriffinImg/generic.png")"/>
                        </a>
                    }
                </td>
            </tr>
        }
    </table>
    <script type="text/javascript">
        $(function () {
            $('#changeLanguage').change(function () {
                window.location = '@Url.Action("Index")?lang=' + $('#changeLanguage').val();
            });
            $('#TableFilter').keypress(function () {

            });
        })
    </script>
</div>
