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.

4.2 KB
Raw Blame
@model CountryModel
<vc:admin-widget widget-zone="country_details_states_top" additional-data="Model"/>
@{
    if (!string.IsNullOrEmpty(Model.Id))
    {
        <admin-card flush>
            <card-actions>
                <a id="btnAddNewState" href="@(Url.Action("StateCreatePopup", "Country", new { countryId = Model.Id, area = Constants.AreaAdmin }))" class="btn btn-outline-secondary btn-sm"><i class="bi bi-plus-lg"></i> @Loc["Admin.Configuration.Countries.States.AddNew"]</a>
                <input type="submit" id="btnRefresh" style="display: none"/>
            </card-actions>
            <admin-grid id="states-grid"
                        read-url="@Url.Action("States", "Country", new { countryId = Model.Id, area = Constants.AreaAdmin })"
                        destroy-url="@Url.Action("StateDelete", "Country", new { countryId = Model.Id, area = Constants.AreaAdmin })"
                        pager="Compact"
                        confirm-destroy="true"
                        on-data-bound="onStatesGridDataBound">
                <grid-column field="Name" title="@Loc["Admin.Configuration.Countries.States.Fields.Name"]" width="300">
                    <cell-template>
                        <a class="text-decoration-none editstate" href="@Url.Action("StateEditPopup", "Country", new { area = Constants.AreaAdmin })/{{ Id }}?countryId=@(Model.Id)">{{ Name }}</a>
                    </cell-template>
                </grid-column>
                <grid-column field="Abbreviation" title="@Loc["Admin.Configuration.Countries.States.Fields.Abbreviation"]" width="150"/>
                <grid-column field="Published" title="@Loc["Admin.Configuration.Countries.States.Fields.Published"]" width="100" align="Center">
                    <cell-template>
                        <i data-if="Published" class="bi bi-check-lg text-success" aria-hidden="true"></i>
                        <i data-else class="bi bi-x-lg text-danger" aria-hidden="true"></i>
                    </cell-template>
                </grid-column>
                <grid-column field="DisplayOrder" title="@Loc["Admin.Configuration.Countries.States.Fields.DisplayOrder"]" width="100"/>
                <grid-commands destroy="true" title="@Loc["Admin.Common.Delete"]" width="100"/>
            </admin-grid>
        </admin-card>

        <script>
            $(document).ready(function () {
                $('#btnAddNewState').magnificPopup({
                    type: 'ajax',
                    settings: { cache: false, async: false },
                    midClick: true,
                    callbacks: {
                        parseAjax: function (mfpResponse) {
                            mfpResponse.data = $('<div></div>').html(mfpResponse.data);
                        },
                        ajaxContentAdded: function () {
                            $('.mfp-wrap').removeAttr('tabindex');
                        }
                    }
                });
            });
            function onStatesGridDataBound() {
                $('.editstate').magnificPopup({
                    type: 'ajax',
                    settings: { cache: false, async: false },
                    midClick: true,
                    callbacks: {
                        parseAjax: function (mfpResponse) {
                            mfpResponse.data = $('<div></div>').html(mfpResponse.data);
                        },
                        ajaxContentAdded: function () {
                            $('.mfp-wrap').removeAttr('tabindex');
                        }
                    }
                });
            }
        </script>
        <script>
            $(document).ready(function () {
                $('#btnRefresh').click(function () {
                    //refresh grid
                    var grid = GrandAdmin.grids.get("#states-grid");
                    grid.dataSource.read();

                    //return false to don't reload a page
                    return false;
                });
            });
        </script>
    }
    else
    {
        <div class="note note-info">
            @Loc["Admin.Configuration.Countries.States.SaveBeforeEdit"]
        </div>
    }
}
<vc:admin-widget widget-zone="country_details_states_bottom" additional-data="Model"/>