| | | 1 | | @model DataScopeEditVm |
| | | 2 | | @{ |
| | 0 | 3 | | var token = Xsrf.GetAndStoreTokens(ViewContext.HttpContext).RequestToken; |
| | | 4 | | } |
| | | 5 | | @inject Microsoft.AspNetCore.Antiforgery.IAntiforgery Xsrf |
| | | 6 | | |
| | | 7 | | <section class="admin-hero"> |
| | 0 | 8 | | <h1>@(Model.Id == 0 ? "Новый набор данных" : "Редактирование набора данных")</h1> |
| | | 9 | | <p class="subtitle">Настройка выражения Dynamic LINQ и параметров применения.</p> |
| | | 10 | | <p class="subtitle-help">Проверяйте выражение перед сохранением.</p> |
| | | 11 | | </section> |
| | | 12 | | |
| | | 13 | | <nav class="admin-quick-links"> |
| | | 14 | | <a asp-area="Admin" asp-controller="DataScopes" asp-action="Index"><i class="bi bi-funnel"></i>К реестру наборов</a> |
| | | 15 | | <a asp-area="Admin" asp-controller="DataScopes" asp-action="Templates"><i class="bi bi-magic"></i>Шаблоны</a> |
| | | 16 | | <a asp-area="Admin" asp-controller="Roles" asp-action="Index"><i class="bi bi-person-badge"></i>Роли</a> |
| | | 17 | | </nav> |
| | | 18 | | |
| | 0 | 19 | | <form asp-action="@(Model.Id == 0 ? "Create" : "Edit")" asp-route-id="@Model.Id" method="post"> |
| | 0 | 20 | | @Html.AntiForgeryToken() |
| | | 21 | | <input type="hidden" asp-for="Id"/> |
| | | 22 | | <div class="card"> |
| | | 23 | | <div class="card-body"> |
| | | 24 | | <div class="row g-3"> |
| | | 25 | | <div class="col-md-4"><label asp-for="Code" class="form-label"></label><input asp-for="Code" class="form |
| | | 26 | | <div class="col-md-4"><label asp-for="DisplayName" class="form-label"></label><input asp-for="DisplayNam |
| | | 27 | | <div class="col-md-4"><label asp-for="EntityName" class="form-label"></label><input asp-for="EntityName" |
| | | 28 | | <div class="col-12"> |
| | | 29 | | <label asp-for="FilterExpression" class="form-label"></label> |
| | | 30 | | <textarea asp-for="FilterExpression" rows="3" class="form-control font-monospace" placeholder='Creat |
| | 0 | 31 | | <div class="form-text">Доступные параметры: <code>@("@userId")</code>, <code>@("@userName")</code>. |
| | | 32 | | <button type="button" id="btnTest" class="btn btn-sm btn-outline-info mt-2"><i class="bi bi-check2-c |
| | | 33 | | <span id="testResult" class="ms-2 small"></span> |
| | | 34 | | </div> |
| | | 35 | | <div class="col-12"><label asp-for="Description" class="form-label"></label><textarea asp-for="Descripti |
| | | 36 | | <div class="col-md-3"><div class="form-check"><input asp-for="IsActive" class="form-check-input"/><label |
| | | 37 | | </div> |
| | | 38 | | </div> |
| | | 39 | | <div class="card-footer d-flex gap-2"> |
| | | 40 | | <button class="btn btn-primary"><i class="bi bi-save"></i> Сохранить</button> |
| | | 41 | | <a asp-action="Index" class="btn btn-outline-secondary">Отмена</a> |
| | | 42 | | </div> |
| | | 43 | | </div> |
| | | 44 | | </form> |
| | | 45 | | |
| | | 46 | | @section Scripts { |
| | | 47 | | <partial name="_ValidationScriptsPartial"/> |
| | | 48 | | <script> |
| | | 49 | | document.getElementById('btnTest').addEventListener('click', async () => { |
| | | 50 | | const expr = document.querySelector('[name="FilterExpression"]').value; |
| | | 51 | | const res = document.getElementById('testResult'); |
| | | 52 | | res.textContent = '...'; |
| | | 53 | | const fd = new FormData(); |
| | | 54 | | fd.append('expression', expr); |
| | 0 | 55 | | fd.append('__RequestVerificationToken', '@token'); |
| | 0 | 56 | | const r = await fetch('@Url.Action("TestExpression")', { method: 'POST', body: fd }); |
| | | 57 | | const json = await r.json(); |
| | | 58 | | res.className = 'ms-2 small ' + (json.ok ? 'text-success' : 'text-danger'); |
| | | 59 | | res.textContent = json.message; |
| | | 60 | | }); |
| | | 61 | | </script> |
| | | 62 | | } |