Skip to content

Open-source eCommerce platform for C# and ASP.NET Core 10 with MongoDB. Build multi-store shops and multi-vendor marketplaces with B2B/B2C, REST API, plugins, Vue 3 and Docker.

3.1 KB
Raw Blame
@using Grand.Domain.Localization
@model LanguageModel
<vc:admin-widget widget-zone="language_details_resources_top" additional-data="Model"/>
@if (string.IsNullOrEmpty(Model.Id))
{
    <div class="note note-info">
        @Loc["Admin.Configuration.Languages.Resources.SaveBeforeEdit"]
    </div>
}
else
{
    @* the screen's Save is its primary action, so Search is a secondary one; the grid's Add new
       moves into the card header (grid.js) *@
    <admin-filters id="resources-filters" submit-id="search-resources" expanded="true" secondary-submit="true">
        <filters-search>
            <admin-input asp-for="Search.ResourceName"/>
        </filters-search>
        <admin-field asp-for="Search.ResourceValue"/>
    </admin-filters>
    <admin-card flush>
        <admin-grid id="resources-grid"
                    read-url="@Url.Action("Resources", "Language", new { languageId = Model.Id, area = Constants.AreaAdmin })"
                    create-url="@Url.Action("ResourceAdd", "Language", new { languageId = Model.Id, area = Constants.AreaAdmin })"
                    update-url="@Url.Action("ResourceUpdate", "Language", new { area = Constants.AreaAdmin })"
                    destroy-url="@Url.Action("ResourceDelete", "Language", new { area = Constants.AreaAdmin })"
                    additional-data="additionalData"
                    edit-mode="Inline">
            <grid-toolbar-create/>
            <grid-column field="Name" title="@Loc["Admin.Configuration.Languages.Resources.Fields.Name"]" width="300" editor="Text"/>
            <grid-column field="Value" title="@Loc["Admin.Configuration.Languages.Resources.Fields.Value"]" width="300" editor="Text"/>
            <grid-column field="Area" title="@Loc["Admin.Configuration.Languages.Resources.Fields.Area"]" width="100"
                         editor="Select" options="EnumTranslationService.ToSelectList(TranslationResourceArea.Common)" default-value="0"/>
            <grid-commands edit="true" destroy="true" width="200"/>
        </admin-grid>
    </admin-card>
}
<vc:admin-widget widget-zone="language_details_resources_bottom" additional-data="Model"/>
@if (!string.IsNullOrEmpty(Model.Id))
{
    <script>
            $(document).ready(function() {
                $('#search-resources').click(function() {
                    var grid = GrandAdmin.grids.get('#resources-grid');
                    grid.dataSource.page(1);
                    return false;
                });
            });

            function additionalData() {
                var data = {
                    ResourceName: $('#@Html.IdFor(model => model.Search.ResourceName)').val(),
                    ResourceValue: $('#@Html.IdFor(model => model.Search.ResourceValue)').val()
                };
                addAntiForgeryToken(data);
                return data;
            }

            $("".concat("#@Html.IdFor(model => model.Search.ResourceName),",
                "#@Html.IdFor(model => model.Search.ResourceValue)")).keydown(function(event) {
                if (event.keyCode === 13) {
                    $("#search-resources").click();
                    return false;
                }
            });
    </script>
}