123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135 |
- <div class="modal" tabindex="-1" role="dialog" style="display:none" id="@elementid">
- <div class="modal-container">
- <div class="modal__body">
- <div class="modal__body__header">
- <div class="modal__body__header__info">
- <img src="img/user.svg" alt="">
- <p>@Title</p>
- </div>
- </div>
- <div class="modal__body__container modal__body__container_noflex" style="vertical-align:top">
- <div class="modal__404__text__box">
- @Body
- <button class="btn_orange" style="margin-bottom: 20px" @onclick="SendTestNotification">Отправить тестовое сообщение этому юзеру</button>
- <table border="1">
- <tr>
- <th>Тип</th>
- <th>Заголовок</th>
- <th>Сообщение</th>
- <th>Прочитано</th>
- <th>Утверждено</th>
- <th>Отклонено</th>
- </tr>
- @foreach (var n in _notifications)
- {
- <tr>
- <td>@n.Value.NotifiType</td>
- <td>@n.Value.Header</td>
- <td><div style="width:100%; padding:5px">@n.Value.Body</div></td>
- <td>
- <input type="checkbox" @bind="n.Value.IsRead" disabled>
- <button @onclick="(() => ReadOnClick(n.Value.ID))">read</button>
- </td>
- <td>
- <input type="checkbox" @bind="n.Value.IsApproved" disabled>
- <button @onclick="(() => ApproveOnClick(n.Value.ID))">approve</button>
- </td>
- <td>
- <input type="checkbox" @bind="n.Value.IsRejected" disabled>
- <button @onclick="(() => RejectOnClick(n.Value.ID))">reject</button>
- </td>
- </tr>
- }
- </table>
- </div>
- </div>
- </div>
- <a class="modal_close" style="cursor:pointer" @onclick="@Close">✖</a>
- </div>
- </div>
- @code {
- @using HyperCube.Models;
- [Inject]
- public IJSRuntime JsRuntime { get; set; }
- [Parameter]
- public RenderFragment Title { get; set; }
- [Parameter]
- public RenderFragment Body { get; set; }
- string message = "";
- string elementid = "modal_notifications";
- Dictionary<int, Models.Notification> _notifications = new();
- AccountModel _currentAcc = new();
- public async Task SendTestNotification()
- {
- await _currentAcc.SendTestNotification(_currentAcc, "Test text");
- }
- public void Open(Dictionary<int, Notification> notifications, AccountModel acc)
- {
- _notifications = acc.notifications;
- _currentAcc = acc;
- JsRuntime.InvokeVoidAsync("OpenModal", elementid);
- }
- public void Close()
- {
- JsRuntime.InvokeVoidAsync("CloseModal", elementid);
- }
- async Task ReadOnClick(int id)
- {
- if (!_notifications[id].IsRead)
- {
- _notifications[id].IsRead = true;
- _notifications[id].DateRead = DateTime.Now;
- }
- else
- {
- _notifications[id].IsRead = false;
- _notifications[id].DateRead = null;
- }
- await _notifications[id].Update();
- }
- async Task ApproveOnClick(int id)
- {
- if (!_notifications[id].IsApproved)
- {
- _notifications[id].IsApproved = true;
- _notifications[id].DateApprove = DateTime.Now;
- }
- else
- {
- _notifications[id].IsApproved = false;
- _notifications[id].DateApprove = null;
- }
- await _notifications[id].Update();
- }
- async Task RejectOnClick(int id)
- {
- if (!_notifications[id].IsRejected)
- {
- _notifications[id].IsRejected = true;
- _notifications[id].DateReject = DateTime.Now;
- }
- else
- {
- _notifications[id].IsRejected = false;
- _notifications[id].DateReject = null;
- }
- await _notifications[id].Update();
- }
- }
|