Gestita pagina notifiche
This commit is contained in:
@@ -6,11 +6,11 @@ using salesbook.Shared.Core.Interface.IntegryApi;
|
||||
|
||||
namespace salesbook.Maui.Core.RestClient.IntegryApi;
|
||||
|
||||
public class IntegryNotificationRestClient(
|
||||
ILogger<IntegryNotificationRestClient> logger,
|
||||
public class IntegryRegisterNotificationRestClient(
|
||||
ILogger<IntegryRegisterNotificationRestClient> logger,
|
||||
IUserSession userSession,
|
||||
IIntegryApiRestClient integryApiRestClient
|
||||
) : IIntegryNotificationRestClient
|
||||
) : IIntegryRegisterNotificationRestClient
|
||||
{
|
||||
public async Task Register(string fcmToken, ILogger? logger1 = null)
|
||||
{
|
||||
@@ -1,14 +1,15 @@
|
||||
using AutoMapper;
|
||||
using MudBlazor.Extensions;
|
||||
using salesbook.Shared.Core.Dto;
|
||||
using salesbook.Shared.Core.Dto.Activity;
|
||||
using salesbook.Shared.Core.Dto.Contact;
|
||||
using salesbook.Shared.Core.Entity;
|
||||
using salesbook.Shared.Core.Helpers.Enum;
|
||||
using salesbook.Shared.Core.Interface;
|
||||
using Sentry.Protocol;
|
||||
using System.Linq.Expressions;
|
||||
using salesbook.Shared.Core.Interface.IntegryApi;
|
||||
using salesbook.Shared.Core.Interface.System.Network;
|
||||
using Sentry.Protocol;
|
||||
using System.Linq.Expressions;
|
||||
|
||||
namespace salesbook.Maui.Core.Services;
|
||||
|
||||
@@ -211,6 +212,15 @@ public class ManageDataService(
|
||||
{
|
||||
var dto = mapper.Map<ActivityDTO>(activity);
|
||||
|
||||
if (activity is { AlarmTime: not null, EstimatedTime: not null })
|
||||
{
|
||||
var minuteBefore = activity.EstimatedTime.Value - activity.AlarmTime.Value;
|
||||
dto.MinuteBefore = (int)Math.Abs(minuteBefore.TotalMinutes);
|
||||
|
||||
dto.NotificationDate = dto.MinuteBefore == 0 ?
|
||||
activity.EstimatedTime : activity.AlarmTime;
|
||||
}
|
||||
|
||||
if (activity.CodJcom != null)
|
||||
{
|
||||
dto.Category = ActivityCategoryEnum.Commessa;
|
||||
|
||||
@@ -8,7 +8,7 @@ namespace salesbook.Maui.Core.System.Notification;
|
||||
|
||||
public class FirebaseNotificationService(
|
||||
IPushManager pushManager,
|
||||
IIntegryNotificationRestClient integryNotificationRestClient,
|
||||
IIntegryRegisterNotificationRestClient integryRegisterNotificationRestClient,
|
||||
INotificationManager notificationManager
|
||||
) : IFirebaseNotificationService
|
||||
{
|
||||
@@ -19,7 +19,7 @@ public class FirebaseNotificationService(
|
||||
var (accessState, token) = await pushManager.RequestAccess();
|
||||
|
||||
if (accessState == AccessState.Denied || token is null) return;
|
||||
await integryNotificationRestClient.Register(token);
|
||||
await integryRegisterNotificationRestClient.Register(token);
|
||||
}
|
||||
|
||||
private void CreateNotificationChannel()
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
using CommunityToolkit.Mvvm.Messaging;
|
||||
using salesbook.Shared.Core.Dto.Notification;
|
||||
using salesbook.Shared.Core.Entity;
|
||||
using salesbook.Shared.Core.Interface.IntegryApi;
|
||||
using salesbook.Shared.Core.Messages.Notification;
|
||||
using Shiny.Push;
|
||||
@@ -7,7 +7,7 @@ using Shiny.Push;
|
||||
namespace salesbook.Maui.Core.System.Notification.Push;
|
||||
|
||||
public class PushNotificationDelegate(
|
||||
IIntegryNotificationRestClient integryNotificationRestClient,
|
||||
IIntegryRegisterNotificationRestClient integryRegisterNotificationRestClient,
|
||||
IMessenger messenger
|
||||
) : IPushDelegate
|
||||
{
|
||||
@@ -20,10 +20,10 @@ public class PushNotificationDelegate(
|
||||
public Task OnReceived(PushNotification notification)
|
||||
{
|
||||
if (notification.Notification is null) return Task.CompletedTask;
|
||||
var pushNotification = new PushNotificationDTO
|
||||
var pushNotification = new WtbNotification
|
||||
{
|
||||
Title = notification.Notification.Title,
|
||||
Message = notification.Notification.Message
|
||||
Body = notification.Notification.Message
|
||||
};
|
||||
|
||||
messenger.Send(new NewPushNotificationMessage(pushNotification));
|
||||
@@ -33,7 +33,7 @@ public class PushNotificationDelegate(
|
||||
|
||||
public Task OnNewToken(string token)
|
||||
{
|
||||
integryNotificationRestClient.Register(token);
|
||||
integryRegisterNotificationRestClient.Register(token);
|
||||
return Task.CompletedTask;
|
||||
}
|
||||
|
||||
|
||||
@@ -86,6 +86,7 @@ namespace salesbook.Maui
|
||||
//Notification
|
||||
builder.Services.AddNotifications();
|
||||
builder.Services.AddPush<PushNotificationDelegate>();
|
||||
builder.Services.AddSingleton<IIntegryRegisterNotificationRestClient, IntegryRegisterNotificationRestClient>();
|
||||
builder.Services.AddSingleton<IIntegryNotificationRestClient, IntegryNotificationRestClient>();
|
||||
builder.Services.AddSingleton<IFirebaseNotificationService, FirebaseNotificationService>();
|
||||
builder.Services.AddSingleton<IShinyNotificationManager, ShinyNotificationManager>();
|
||||
|
||||
@@ -133,7 +133,7 @@
|
||||
<ItemGroup>
|
||||
<PackageReference Include="CommunityToolkit.Maui" Version="12.0.0" />
|
||||
<PackageReference Include="CommunityToolkit.Mvvm" Version="8.4.0" />
|
||||
<PackageReference Include="IntegryApiClient.MAUI" Version="1.1.6" />
|
||||
<PackageReference Include="IntegryApiClient.MAUI" Version="1.2.1" />
|
||||
<PackageReference Include="Microsoft.Extensions.Logging" Version="9.0.6" />
|
||||
<PackageReference Include="Microsoft.Maui.Controls" Version="9.0.81" />
|
||||
<PackageReference Include="Microsoft.Maui.Controls.Compatibility" Version="9.0.81" />
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
@using CommunityToolkit.Mvvm.Messaging
|
||||
@using salesbook.Shared.Core.Dto
|
||||
@using salesbook.Shared.Core.Dto.Activity
|
||||
@using salesbook.Shared.Core.Dto.Notification
|
||||
@using salesbook.Shared.Core.Dto.PageState
|
||||
@using salesbook.Shared.Core.Entity
|
||||
@using salesbook.Shared.Core.Messages.Activity.Copy
|
||||
@@ -35,7 +34,7 @@
|
||||
</NavLink>
|
||||
</li>
|
||||
<li class="nav-item">
|
||||
<MudBadge Content="Notification.UnreadNotifications.Count" Visible="!Notification.UnreadNotifications.IsNullOrEmpty()" Color="Color.Error" Overlap="true">
|
||||
<MudBadge Content="Notification.Count" Visible="Notification.Count > 0" Color="Color.Error" Overlap="true">
|
||||
<NavLink class="nav-link" href="Notifications" Match="NavLinkMatch.All">
|
||||
<div class="d-flex flex-column">
|
||||
<i class="ri-notification-4-line"></i>
|
||||
@@ -113,9 +112,9 @@
|
||||
}
|
||||
}
|
||||
|
||||
private void NewNotificationReceived(PushNotificationDTO notification)
|
||||
private void NewNotificationReceived(WtbNotification notification)
|
||||
{
|
||||
Notification.UnreadNotifications.Add(notification);
|
||||
Notification.ReceivedNotifications.Add(notification);
|
||||
InvokeAsync(StateHasChanged);
|
||||
}
|
||||
}
|
||||
@@ -24,6 +24,7 @@
|
||||
padding-bottom: 1rem;
|
||||
overflow-x: hidden;
|
||||
overflow-y: visible;
|
||||
min-height: 7rem;
|
||||
}
|
||||
|
||||
.week-slider.expanded {
|
||||
@@ -31,7 +32,7 @@
|
||||
grid-template-columns: repeat(7, 1fr);
|
||||
gap: 0.4rem;
|
||||
padding: 1rem;
|
||||
overflow-y: auto;
|
||||
overflow-y: hidden;
|
||||
}
|
||||
|
||||
.week-slider.expand-animation { animation: expandFromCenter 0.3s ease forwards; }
|
||||
@@ -122,8 +123,7 @@
|
||||
flex-direction: column;
|
||||
-ms-overflow-style: none;
|
||||
scrollbar-width: none;
|
||||
padding-bottom: 16vh;
|
||||
height: calc(100% - 130px);
|
||||
padding-bottom: 9vh;
|
||||
}
|
||||
|
||||
.appointments.ah-calendar-m { height: calc(100% - 315px) !important; }
|
||||
|
||||
@@ -1,46 +1,179 @@
|
||||
@page "/Notifications"
|
||||
@attribute [Authorize]
|
||||
@using salesbook.Shared.Components.Layout
|
||||
@using salesbook.Shared.Components.Layout.Spinner
|
||||
@using salesbook.Shared.Components.SingleElements
|
||||
@using salesbook.Shared.Core.Dto.Notification
|
||||
@using salesbook.Shared.Core.Dto.PageState
|
||||
@using salesbook.Shared.Core.Entity
|
||||
@using salesbook.Shared.Core.Interface.IntegryApi
|
||||
@using salesbook.Shared.Core.Messages.Notification
|
||||
@inject NotificationState Notification
|
||||
@inject NewPushNotificationService NewPushNotificationService
|
||||
@inject IJSRuntime JS
|
||||
@inject IIntegryNotificationRestClient IntegryNotificationRestClient
|
||||
|
||||
<HeaderLayout Title="Notifiche" />
|
||||
|
||||
<div class="container">
|
||||
@if (Notification.UnreadNotifications.IsNullOrEmpty())
|
||||
@if (Loading)
|
||||
{
|
||||
<SpinnerLayout FullScreen="true" />
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
if (Notification.ReceivedNotifications.IsNullOrEmpty() && Notification.UnreadNotifications.IsNullOrEmpty() && Notification.NotificationsRead.IsNullOrEmpty())
|
||||
{
|
||||
<NoDataAvailable Text="Nessuna notifica meno recente" />
|
||||
}
|
||||
else
|
||||
{
|
||||
<div class="list" id="list">
|
||||
@foreach(var notification in Notification.ReceivedNotifications)
|
||||
{
|
||||
<NotificationCard Unread="true" Notification="notification" />
|
||||
}
|
||||
|
||||
@foreach(var notification in Notification.UnreadNotifications)
|
||||
{
|
||||
<NotificationCard Unread="true" Notification="notification" />
|
||||
}
|
||||
|
||||
@foreach (var notification in Notification.NotificationsRead)
|
||||
{
|
||||
<NotificationCard Notification="notification" />
|
||||
}
|
||||
</div>
|
||||
}
|
||||
}
|
||||
</div>
|
||||
|
||||
@code {
|
||||
private DotNetObjectReference<Notifications>? _objectReference;
|
||||
private bool Loading { get; set; } = true;
|
||||
|
||||
protected override Task OnInitializedAsync()
|
||||
{
|
||||
_objectReference = DotNetObjectReference.Create(this);
|
||||
NewPushNotificationService.OnNotificationReceived += NewNotificationReceived;
|
||||
return Task.CompletedTask;
|
||||
}
|
||||
|
||||
protected override async Task OnAfterRenderAsync(bool firstRender)
|
||||
{
|
||||
await JS.InvokeVoidAsync("initNotifications");
|
||||
await JS.InvokeVoidAsync("initNotifications", _objectReference);
|
||||
|
||||
if (firstRender)
|
||||
{
|
||||
await LoadData();
|
||||
Loading = false;
|
||||
StateHasChanged();
|
||||
}
|
||||
}
|
||||
|
||||
private void NewNotificationReceived(PushNotificationDTO notification)
|
||||
private async Task LoadData()
|
||||
{
|
||||
var allNotifications = await IntegryNotificationRestClient.Get();
|
||||
var allIds = allNotifications.Select(n => n.Id).ToHashSet();
|
||||
|
||||
Notification.ReceivedNotifications = Notification.ReceivedNotifications
|
||||
.Where(r => !allIds.Contains(r.Id))
|
||||
.ToList();
|
||||
|
||||
Notification.UnreadNotifications = allNotifications
|
||||
.Where(x =>
|
||||
x.WtbDeviceNotifications == null ||
|
||||
x.WtbDeviceNotifications.Any(y => y.ReadDate == null))
|
||||
.ToList();
|
||||
|
||||
Notification.NotificationsRead = allNotifications
|
||||
.Where(x =>
|
||||
x.WtbDeviceNotifications != null &&
|
||||
x.WtbDeviceNotifications.All(y => y.ReadDate != null))
|
||||
.ToList();
|
||||
|
||||
OrderNotificationList();
|
||||
}
|
||||
|
||||
private void NewNotificationReceived(WtbNotification notification)
|
||||
{
|
||||
InvokeAsync(StateHasChanged);
|
||||
}
|
||||
|
||||
[JSInvokable]
|
||||
public async Task Delete(string id)
|
||||
{
|
||||
Loading = true;
|
||||
_ = InvokeAsync(StateHasChanged);
|
||||
|
||||
if (!long.TryParse(id, out var notificationId)) return;
|
||||
|
||||
var removed = false;
|
||||
|
||||
if (Notification.ReceivedNotifications.RemoveAll(x => x.Id == notificationId) > 0)
|
||||
removed = true;
|
||||
else if (Notification.UnreadNotifications.RemoveAll(x => x.Id == notificationId) > 0)
|
||||
removed = true;
|
||||
else if (Notification.NotificationsRead.RemoveAll(x => x.Id == notificationId) > 0)
|
||||
removed = true;
|
||||
|
||||
if (!removed) return;
|
||||
|
||||
OrderNotificationList();
|
||||
Loading = false;
|
||||
_ = InvokeAsync(StateHasChanged);
|
||||
|
||||
_ = Task.Run(() =>
|
||||
{
|
||||
_ = IntegryNotificationRestClient.Delete(notificationId);
|
||||
});
|
||||
}
|
||||
|
||||
[JSInvokable]
|
||||
public async Task MarkAsRead(string id)
|
||||
{
|
||||
Loading = true;
|
||||
_ = InvokeAsync(StateHasChanged);
|
||||
|
||||
var notificationId = long.Parse(id);
|
||||
|
||||
var wtbNotification = Notification.ReceivedNotifications
|
||||
.FindLast(x => x.Id == notificationId);
|
||||
|
||||
if (wtbNotification == null)
|
||||
{
|
||||
wtbNotification = Notification.UnreadNotifications
|
||||
.FindLast(x => x.Id == notificationId);
|
||||
|
||||
Notification.UnreadNotifications.Remove(wtbNotification!);
|
||||
}
|
||||
else
|
||||
{
|
||||
Notification.ReceivedNotifications.Remove(wtbNotification);
|
||||
}
|
||||
|
||||
wtbNotification = await IntegryNotificationRestClient.MarkAsRead(notificationId);
|
||||
Notification.NotificationsRead.Add(wtbNotification);
|
||||
|
||||
OrderNotificationList();
|
||||
Loading = false;
|
||||
StateHasChanged();
|
||||
}
|
||||
|
||||
private void OrderNotificationList()
|
||||
{
|
||||
Notification.ReceivedNotifications = Notification.ReceivedNotifications
|
||||
.OrderByDescending(x => x.StartDate).ToList();
|
||||
|
||||
Notification.UnreadNotifications = Notification.UnreadNotifications
|
||||
.OrderByDescending(x => x.StartDate).ToList();
|
||||
|
||||
Notification.NotificationsRead = Notification.NotificationsRead
|
||||
.OrderByDescending(x => x.StartDate).ToList();
|
||||
}
|
||||
|
||||
public void Dispose()
|
||||
{
|
||||
_objectReference?.Dispose();
|
||||
}
|
||||
}
|
||||
@@ -143,6 +143,7 @@
|
||||
max-height: 32vh;
|
||||
overflow: auto;
|
||||
scrollbar-width: none;
|
||||
padding: 1rem 0;
|
||||
}
|
||||
|
||||
.container-pers-rif::-webkit-scrollbar { display: none; }
|
||||
|
||||
@@ -5,8 +5,7 @@
|
||||
flex-direction: column;
|
||||
-ms-overflow-style: none;
|
||||
scrollbar-width: none;
|
||||
padding-bottom: 70px;
|
||||
height: 100%;
|
||||
padding-bottom: 9vh;
|
||||
}
|
||||
|
||||
.users .divider {
|
||||
|
||||
@@ -1,15 +1,86 @@
|
||||
@using salesbook.Shared.Core.Dto.Notification
|
||||
@using salesbook.Shared.Core.Entity
|
||||
|
||||
<div class="row">
|
||||
<div class="behind"><button class="trash-btn"><MudIcon Icon="@Icons.Material.Filled.Delete" /></button></div>
|
||||
<div class="row" id="@Notification.Id">
|
||||
<div class="behind-left">
|
||||
<button class="read-btn">
|
||||
<MudIcon Icon="@Icons.Material.Rounded.Check" />
|
||||
</button>
|
||||
</div>
|
||||
<div class="behind-right">
|
||||
<button class="trash-btn">
|
||||
<MudIcon Icon="@Icons.Material.Rounded.Delete" />
|
||||
</button>
|
||||
</div>
|
||||
<div class="notification-card">
|
||||
<div>
|
||||
@if (Notification.NotificationData is { Type: not null })
|
||||
{
|
||||
@switch (Notification.NotificationData.Type)
|
||||
{
|
||||
case "memo":
|
||||
<div class="avatar"><MudIcon Icon="@Icons.Material.Rounded.ContentPaste" /></div>
|
||||
break;
|
||||
case "newPlanned":
|
||||
<div class="avatar"><MudIcon Icon="@Icons.Material.Rounded.CalendarMonth" /></div>
|
||||
break;
|
||||
}
|
||||
}
|
||||
<div class="notification-body">
|
||||
<div class="title-row">
|
||||
<div class="title">@Notification.Title</div>
|
||||
<div class="subtitle">@Notification.Message</div>
|
||||
|
||||
<div class="section-time">
|
||||
<div class="notification-time">@GetTimeAgo(Notification.StartDate)</div>
|
||||
@if (Unread)
|
||||
{
|
||||
<span class="unread-dot"></span>
|
||||
}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@if (
|
||||
Notification.StartDate < DateTime.Today && Notification.Body != null && Notification.Body.Contains("Oggi")
|
||||
)
|
||||
{
|
||||
<MudText Typo="Typo.caption" Class="subtitle">@Notification.Body.Replace("Oggi", $"{Notification.StartDate:d}")</MudText>
|
||||
}
|
||||
else
|
||||
{
|
||||
<MudText Typo="Typo.caption" Class="subtitle">@Notification.Body</MudText>
|
||||
}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@code {
|
||||
[Parameter] public PushNotificationDTO Notification { get; set; } = new();
|
||||
[Parameter] public bool Unread { get; set; }
|
||||
[Parameter] public WtbNotification Notification { get; set; } = new();
|
||||
|
||||
private static string GetTimeAgo(DateTime? timestamp)
|
||||
{
|
||||
if (timestamp is null) return "";
|
||||
|
||||
var difference = DateTime.Now - timestamp.Value;
|
||||
|
||||
switch (difference.TotalMinutes)
|
||||
{
|
||||
case < 1:
|
||||
return "Adesso";
|
||||
case < 60:
|
||||
return $"{(int)difference.TotalMinutes} minuti fa";
|
||||
default:
|
||||
{
|
||||
switch (difference.TotalHours)
|
||||
{
|
||||
case < 2:
|
||||
return $"{(int)difference.TotalHours} ora fa";
|
||||
case < 24:
|
||||
return $"{timestamp.Value:t}";
|
||||
default:
|
||||
{
|
||||
return difference.TotalDays < 7 ? $"{(int)difference.TotalDays}g fa" : timestamp.Value.ToString("dd/MM/yyyy");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -6,18 +6,27 @@
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
.behind {
|
||||
.behind-left, .behind-right {
|
||||
position: absolute;
|
||||
inset: 0;
|
||||
display: flex;
|
||||
justify-content: flex-end;
|
||||
align-items: center;
|
||||
padding-right: 14px;
|
||||
background: var(--mud-palette-error);
|
||||
z-index: 0;
|
||||
}
|
||||
|
||||
.trash-btn {
|
||||
.behind-right {
|
||||
justify-content: flex-end;
|
||||
padding-right: 14px;
|
||||
background: var(--mud-palette-error);
|
||||
}
|
||||
|
||||
.behind-left {
|
||||
justify-content: flex-start;
|
||||
padding-left: 14px;
|
||||
background: var(--mud-palette-info);
|
||||
}
|
||||
|
||||
.read-btn, .trash-btn {
|
||||
color: white;
|
||||
padding: 10px 15px;
|
||||
cursor: pointer;
|
||||
@@ -29,6 +38,7 @@
|
||||
display: flex;
|
||||
align-items: center;
|
||||
padding: 12px;
|
||||
gap: 12px;
|
||||
background: var(--mud-palette-background);
|
||||
transition: transform .2s ease;
|
||||
touch-action: pan-y;
|
||||
@@ -37,15 +47,34 @@
|
||||
}
|
||||
|
||||
.avatar {
|
||||
width: 42px;
|
||||
min-width: 42px;
|
||||
height: 42px;
|
||||
border-radius: 12px;
|
||||
display: grid;
|
||||
place-items: center;
|
||||
background: #0b1220;
|
||||
border: 1px solid #1f2937;
|
||||
background: var(--mud-palette-background);
|
||||
border: 1px solid var(--mud-palette-divider);
|
||||
font-weight: bold;
|
||||
color: #22d3ee;
|
||||
color: var(--mud-palette-primary);
|
||||
}
|
||||
|
||||
.notification-body {
|
||||
width: 100%
|
||||
}
|
||||
|
||||
.title-row {
|
||||
display: flex;
|
||||
gap: 8px;
|
||||
justify-items: center;
|
||||
align-items: flex-start;
|
||||
justify-content: space-between;
|
||||
}
|
||||
|
||||
.unread-dot {
|
||||
width: 10px;
|
||||
height: 10px;
|
||||
background-color: var(--mud-palette-error);
|
||||
border-radius: 50%;
|
||||
}
|
||||
|
||||
.title {
|
||||
@@ -53,12 +82,24 @@
|
||||
margin-bottom: unset !important;
|
||||
}
|
||||
|
||||
.subtitle {
|
||||
.section-time {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: .5rem;
|
||||
}
|
||||
|
||||
.notification-time {
|
||||
font-size: 13px;
|
||||
color: #94a3b8;
|
||||
line-height: normal;
|
||||
}
|
||||
|
||||
.collapsing {
|
||||
transition: height .22s ease, margin .22s ease, opacity .22s ease;
|
||||
overflow: hidden;
|
||||
}
|
||||
|
||||
.subtitle {
|
||||
font-size: 12px;
|
||||
color: var(--mud-palette-drawer-text);
|
||||
}
|
||||
@@ -74,9 +74,18 @@
|
||||
<div class="divider"></div>
|
||||
|
||||
<div class="form-container">
|
||||
<span>Avviso</span>
|
||||
<span class="disable-full-width">Avviso</span>
|
||||
|
||||
<MudSwitch ReadOnly="IsView" T="bool" Disabled="true" Color="Color.Primary"/>
|
||||
<MudSelectExtended FullWidth="true" ReadOnly="@(IsView || ActivityModel.EstimatedTime == null)" T="int" Variant="Variant.Text" @bind-Value="ActivityModel.MinuteBefore" @bind-Value:after="OnAfterChangeTimeBefore" Class="customIcon-select" AdornmentIcon="@Icons.Material.Filled.Code">
|
||||
<MudSelectItemExtended Class="custom-item-select" Text="Nessuno" Value="-1">Nessuno</MudSelectItemExtended>
|
||||
<MudSelectItemExtended Class="custom-item-select" Text="All'ora pianificata" Value="0">All'ora pianificata</MudSelectItemExtended>
|
||||
<MudSelectItemExtended Class="custom-item-select" Text="15 minuti prima" Value="15">15 minuti prima</MudSelectItemExtended>
|
||||
<MudSelectItemExtended Class="custom-item-select" Text="30 minuti prima" Value="30">30 minuti prima</MudSelectItemExtended>
|
||||
<MudSelectItemExtended Class="custom-item-select" Text="1 ora prima" Value="60">1 ora prima</MudSelectItemExtended>
|
||||
<MudSelectItemExtended Class="custom-item-select" Text="2 ore prima" Value="120">2 ore prima</MudSelectItemExtended>
|
||||
<MudSelectItemExtended Class="custom-item-select" Text="1 giorno prima" Value="1440">1 giorno prima</MudSelectItemExtended>
|
||||
<MudSelectItemExtended Class="custom-item-select" Text="1 settimana prima" Value="10080">1 settimana prima</MudSelectItemExtended>
|
||||
</MudSelectExtended>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -84,7 +93,7 @@
|
||||
<div class="form-container">
|
||||
<span class="disable-full-width">Assegnata a</span>
|
||||
|
||||
<MudSelectExtended FullWidth="true" ReadOnly="IsView" T="string?" Variant="Variant.Text" @bind-Value="ActivityModel.UserName" @bind-Value:after="OnAfterChangeValue" Class="customIcon-select" AdornmentIcon="@Icons.Material.Filled.Code">
|
||||
<MudSelectExtended FullWidth="true" ReadOnly="IsView" T="string?" Variant="Variant.Text" @bind-Value="ActivityModel.UserName" @bind-Value:after="OnUserChanged" Class="customIcon-select" AdornmentIcon="@Icons.Material.Filled.Code">
|
||||
@foreach (var user in Users)
|
||||
{
|
||||
<MudSelectItemExtended Class="custom-item-select" Value="@user.UserName">@user.FullName</MudSelectItemExtended>
|
||||
@@ -376,7 +385,9 @@
|
||||
return false;
|
||||
}
|
||||
|
||||
private async Task LoadData()
|
||||
private Task LoadData()
|
||||
{
|
||||
return Task.Run(async () =>
|
||||
{
|
||||
if (!IsNew && Id != null)
|
||||
{
|
||||
@@ -387,6 +398,9 @@
|
||||
ActivityResult = await ManageData.GetTable<StbActivityResult>();
|
||||
Clienti = await ManageData.GetClienti(new WhereCondContact {FlagStato = "A"});
|
||||
Pros = await ManageData.GetProspect();
|
||||
|
||||
await InvokeAsync(StateHasChanged);
|
||||
});
|
||||
}
|
||||
|
||||
private async Task LoadActivityType()
|
||||
@@ -448,6 +462,24 @@
|
||||
OnAfterChangeValue();
|
||||
}
|
||||
|
||||
private void OnAfterChangeTimeBefore()
|
||||
{
|
||||
if (ActivityModel.EstimatedTime != null)
|
||||
{
|
||||
if (ActivityModel.MinuteBefore != -1)
|
||||
{
|
||||
ActivityModel.NotificationDate = ActivityModel.MinuteBefore == 0 ?
|
||||
ActivityModel.EstimatedTime : ActivityModel.EstimatedTime.Value.AddMinutes(ActivityModel.MinuteBefore * -1);
|
||||
}
|
||||
else
|
||||
{
|
||||
ActivityModel.NotificationDate = null;
|
||||
}
|
||||
}
|
||||
|
||||
OnAfterChangeValue();
|
||||
}
|
||||
|
||||
private void OnAfterChangeValue()
|
||||
{
|
||||
if (!IsNew)
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
using salesbook.Shared.Core.Entity;
|
||||
using System.Text.Json.Serialization;
|
||||
using salesbook.Shared.Core.Entity;
|
||||
using salesbook.Shared.Core.Helpers.Enum;
|
||||
|
||||
namespace salesbook.Shared.Core.Dto.Activity;
|
||||
@@ -10,6 +11,11 @@ public class ActivityDTO : StbActivity
|
||||
public ActivityCategoryEnum Category { get; set; }
|
||||
public bool Complete { get; set; }
|
||||
|
||||
//Notification
|
||||
public int MinuteBefore { get; set; } = -1;
|
||||
[JsonPropertyName("notificationDate")]
|
||||
public DateTime? NotificationDate { get; set; }
|
||||
|
||||
public bool Deleted { get; set; }
|
||||
|
||||
public PositionDTO? Position { get; set; }
|
||||
@@ -23,6 +29,9 @@ public class ActivityDTO : StbActivity
|
||||
{
|
||||
return Commessa == other.Commessa &&
|
||||
Cliente == other.Cliente &&
|
||||
Position == other.Position &&
|
||||
MinuteBefore == other.MinuteBefore &&
|
||||
NotificationDate == other.NotificationDate &&
|
||||
Category == other.Category &&
|
||||
Complete == other.Complete && ActivityId == other.ActivityId && ActivityResultId == other.ActivityResultId && ActivityTypeId == other.ActivityTypeId && DataInsAct.Equals(other.DataInsAct) && ActivityDescription == other.ActivityDescription && ParentActivityId == other.ParentActivityId && TipoAnag == other.TipoAnag && CodAnag == other.CodAnag && CodJcom == other.CodJcom && CodJfas == other.CodJfas && Nullable.Equals(EstimatedDate, other.EstimatedDate) && Nullable.Equals(EstimatedTime, other.EstimatedTime) && Nullable.Equals(AlarmDate, other.AlarmDate) && Nullable.Equals(AlarmTime, other.AlarmTime) && Nullable.Equals(EffectiveDate, other.EffectiveDate) && Nullable.Equals(EffectiveTime, other.EffectiveTime) && ResultDescription == other.ResultDescription && Nullable.Equals(EstimatedEnddate, other.EstimatedEnddate) && Nullable.Equals(EstimatedEndtime, other.EstimatedEndtime) && Nullable.Equals(EffectiveEnddate, other.EffectiveEnddate) && Nullable.Equals(EffectiveEndtime, other.EffectiveEndtime) && UserCreator == other.UserCreator && UserName == other.UserName && Nullable.Equals(PercComp, other.PercComp) && Nullable.Equals(EstimatedHours, other.EstimatedHours) && CodMart == other.CodMart && PartitaMag == other.PartitaMag && Matricola == other.Matricola && Priorita == other.Priorita && Nullable.Equals(ActivityPlayCounter, other.ActivityPlayCounter) && ActivityEvent == other.ActivityEvent && Guarantee == other.Guarantee && Note == other.Note && Rfid == other.Rfid && IdLotto == other.IdLotto && PersonaRif == other.PersonaRif && HrNum == other.HrNum && Gestione == other.Gestione && Nullable.Equals(DataOrd, other.DataOrd) && NumOrd == other.NumOrd && IdStep == other.IdStep && IdRiga == other.IdRiga && Nullable.Equals(OraInsAct, other.OraInsAct) && IndiceGradimento == other.IndiceGradimento && NoteGradimento == other.NoteGradimento && FlagRisolto == other.FlagRisolto && FlagTipologia == other.FlagTipologia && OreRapportino == other.OreRapportino && UserModifier == other.UserModifier && Nullable.Equals(OraModAct, other.OraModAct) && Nullable.Equals(OraViewAct, other.OraViewAct) && CodVdes == other.CodVdes && CodCmac == other.CodCmac && WrikeId == other.WrikeId && CodMgrp == other.CodMgrp && PlanId == other.PlanId;
|
||||
}
|
||||
@@ -97,6 +106,9 @@ public class ActivityDTO : StbActivity
|
||||
hashCode.Add(Cliente);
|
||||
hashCode.Add(Category);
|
||||
hashCode.Add(Complete);
|
||||
hashCode.Add(Position);
|
||||
hashCode.Add(MinuteBefore);
|
||||
hashCode.Add(NotificationDate);
|
||||
return hashCode.ToHashCode();
|
||||
}
|
||||
}
|
||||
@@ -1,9 +0,0 @@
|
||||
namespace salesbook.Shared.Core.Dto.Notification;
|
||||
|
||||
public class PushNotificationDTO
|
||||
{
|
||||
public string? Title { get; set; }
|
||||
public string? Message { get; set; }
|
||||
|
||||
public DateTime Hours => DateTime.Now;
|
||||
}
|
||||
12
salesbook.Shared/Core/Dto/NotificationDataDTO.cs
Normal file
12
salesbook.Shared/Core/Dto/NotificationDataDTO.cs
Normal file
@@ -0,0 +1,12 @@
|
||||
using System.Text.Json.Serialization;
|
||||
|
||||
namespace salesbook.Shared.Core.Dto;
|
||||
|
||||
public class NotificationDataDTO
|
||||
{
|
||||
[JsonPropertyName("activityId")]
|
||||
public string? ActivityId { get; set; }
|
||||
|
||||
[JsonPropertyName("type")]
|
||||
public string? Type { get; set; }
|
||||
}
|
||||
@@ -1,8 +1,12 @@
|
||||
using salesbook.Shared.Core.Dto.Notification;
|
||||
using salesbook.Shared.Core.Entity;
|
||||
|
||||
namespace salesbook.Shared.Core.Dto.PageState;
|
||||
|
||||
public class NotificationState
|
||||
{
|
||||
public List<PushNotificationDTO> UnreadNotifications { get; set; } = [];
|
||||
public List<WtbNotification> ReceivedNotifications { get; set; } = [];
|
||||
public List<WtbNotification> UnreadNotifications { get; set; } = [];
|
||||
public List<WtbNotification> NotificationsRead { get; set; } = [];
|
||||
|
||||
public int Count => ReceivedNotifications.Count() + UnreadNotifications.Count();
|
||||
}
|
||||
15
salesbook.Shared/Core/Dto/ReadNotificationRequestDTO.cs
Normal file
15
salesbook.Shared/Core/Dto/ReadNotificationRequestDTO.cs
Normal file
@@ -0,0 +1,15 @@
|
||||
using System.Text.Json.Serialization;
|
||||
|
||||
namespace salesbook.Shared.Core.Dto;
|
||||
|
||||
public class ReadNotificationRequestDTO
|
||||
{
|
||||
[JsonPropertyName("deviceToken")]
|
||||
public string DeviceToken { get; set; }
|
||||
|
||||
[JsonPropertyName("username")]
|
||||
public string Username { get; set; }
|
||||
|
||||
[JsonPropertyName("notificationId")]
|
||||
public long NotificationId { get; set; }
|
||||
}
|
||||
15
salesbook.Shared/Core/Entity/WtbDeviceNotification.cs
Normal file
15
salesbook.Shared/Core/Entity/WtbDeviceNotification.cs
Normal file
@@ -0,0 +1,15 @@
|
||||
using System.Text.Json.Serialization;
|
||||
|
||||
namespace salesbook.Shared.Core.Entity;
|
||||
|
||||
public class WtbDeviceNotification
|
||||
{
|
||||
[JsonPropertyName("userDeviceId")]
|
||||
public long? UserDeviceId { get; set; }
|
||||
|
||||
[JsonPropertyName("notificationId")]
|
||||
public long? NotificationId { get; set; }
|
||||
|
||||
[JsonPropertyName("readDate")]
|
||||
public DateTime? ReadDate { get; set; }
|
||||
}
|
||||
37
salesbook.Shared/Core/Entity/WtbNotification.cs
Normal file
37
salesbook.Shared/Core/Entity/WtbNotification.cs
Normal file
@@ -0,0 +1,37 @@
|
||||
using System.Text.Json.Serialization;
|
||||
using salesbook.Shared.Core.Dto;
|
||||
|
||||
namespace salesbook.Shared.Core.Entity;
|
||||
|
||||
public class WtbNotification
|
||||
{
|
||||
[JsonPropertyName("id")]
|
||||
public long Id { get; set; }
|
||||
|
||||
[JsonPropertyName("title")]
|
||||
public string? Title { get; set; }
|
||||
|
||||
[JsonPropertyName("body")]
|
||||
public string? Body { get; set; }
|
||||
|
||||
[JsonPropertyName("imageUrl")]
|
||||
public string? ImageUrl { get; set; }
|
||||
|
||||
[JsonPropertyName("notificationData")]
|
||||
public NotificationDataDTO? NotificationData { get; set; }
|
||||
|
||||
[JsonPropertyName("startDate")]
|
||||
public DateTime? StartDate { get; set; }
|
||||
|
||||
[JsonPropertyName("endDate")]
|
||||
public DateTime? EndDate { get; set; }
|
||||
|
||||
[JsonPropertyName("persistent")]
|
||||
public bool? Persistent { get; set; }
|
||||
|
||||
[JsonPropertyName("topics")]
|
||||
public List<string>? Topics { get; set; }
|
||||
|
||||
[JsonPropertyName("wtbDeviceNotifications")]
|
||||
public List<WtbDeviceNotification>? WtbDeviceNotifications { get; set; }
|
||||
}
|
||||
@@ -1,8 +1,11 @@
|
||||
using Microsoft.Extensions.Logging;
|
||||
using salesbook.Shared.Core.Entity;
|
||||
|
||||
namespace salesbook.Shared.Core.Interface.IntegryApi;
|
||||
|
||||
public interface IIntegryNotificationRestClient
|
||||
{
|
||||
Task Register(string fcmToken, ILogger? logger1 = null);
|
||||
Task<List<WtbNotification>> Get();
|
||||
Task<WtbNotification> MarkAsRead(long id);
|
||||
Task Delete(long id);
|
||||
Task DeleteAll();
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
using Microsoft.Extensions.Logging;
|
||||
|
||||
namespace salesbook.Shared.Core.Interface.IntegryApi;
|
||||
|
||||
public interface IIntegryRegisterNotificationRestClient
|
||||
{
|
||||
Task Register(string fcmToken, ILogger? logger1 = null);
|
||||
}
|
||||
@@ -1,6 +1,6 @@
|
||||
using CommunityToolkit.Mvvm.Messaging.Messages;
|
||||
using salesbook.Shared.Core.Dto.Notification;
|
||||
using salesbook.Shared.Core.Entity;
|
||||
|
||||
namespace salesbook.Shared.Core.Messages.Notification;
|
||||
|
||||
public class NewPushNotificationMessage(PushNotificationDTO value) : ValueChangedMessage<PushNotificationDTO>(value);
|
||||
public class NewPushNotificationMessage(WtbNotification value) : ValueChangedMessage<WtbNotification>(value);
|
||||
@@ -1,11 +1,11 @@
|
||||
using CommunityToolkit.Mvvm.Messaging;
|
||||
using salesbook.Shared.Core.Dto.Notification;
|
||||
using salesbook.Shared.Core.Entity;
|
||||
|
||||
namespace salesbook.Shared.Core.Messages.Notification;
|
||||
|
||||
public class NewPushNotificationService
|
||||
{
|
||||
public event Action<PushNotificationDTO>? OnNotificationReceived;
|
||||
public event Action<WtbNotification>? OnNotificationReceived;
|
||||
|
||||
public NewPushNotificationService(IMessenger messenger)
|
||||
{
|
||||
|
||||
@@ -0,0 +1,33 @@
|
||||
using IntegryApiClient.Core.Domain.Abstraction.Contracts.Account;
|
||||
using IntegryApiClient.Core.Domain.RestClient.Contacts;
|
||||
using salesbook.Shared.Core.Dto;
|
||||
using salesbook.Shared.Core.Entity;
|
||||
using salesbook.Shared.Core.Interface.IntegryApi;
|
||||
|
||||
namespace salesbook.Shared.Core.Services;
|
||||
|
||||
public class IntegryNotificationRestClient(
|
||||
IUserSession userSession,
|
||||
IIntegryApiRestClient integryApiRestClient) : IIntegryNotificationRestClient
|
||||
{
|
||||
public Task<List<WtbNotification>> Get()
|
||||
{
|
||||
var queryParams = new Dictionary<string, object>
|
||||
{
|
||||
{ "mode", "ENABLED" },
|
||||
{ "forUser", userSession.User.Username }
|
||||
};
|
||||
|
||||
return integryApiRestClient.Get<List<WtbNotification>>("notification", queryParams)!;
|
||||
}
|
||||
|
||||
public Task<WtbNotification> MarkAsRead(long id) =>
|
||||
integryApiRestClient.Post<WtbNotification>("notification/read",
|
||||
new ReadNotificationRequestDTO { NotificationId = id, Username = userSession.User.Username })!;
|
||||
|
||||
public Task Delete(long id) =>
|
||||
integryApiRestClient.Delete<object>($"notification/{id}", null);
|
||||
|
||||
public Task DeleteAll() =>
|
||||
integryApiRestClient.Delete<object>($"notification/all/{userSession.User.Username}", null);
|
||||
}
|
||||
@@ -24,7 +24,7 @@
|
||||
<PackageReference Include="AutoMapper" Version="14.0.0" />
|
||||
<PackageReference Include="CodeBeam.MudBlazor.Extensions" Version="8.2.2" />
|
||||
<PackageReference Include="CommunityToolkit.Mvvm" Version="8.4.0" />
|
||||
<PackageReference Include="IntegryApiClient.Core" Version="1.1.6" />
|
||||
<PackageReference Include="IntegryApiClient.Core" Version="1.2.1" />
|
||||
<PackageReference Include="Microsoft.AspNetCore.Components.Authorization" Version="9.0.6" />
|
||||
<PackageReference Include="Microsoft.Maui.Essentials" Version="9.0.81" />
|
||||
<PackageReference Include="sqlite-net-pcl" Version="1.9.172" />
|
||||
|
||||
@@ -22,8 +22,12 @@ a, .btn-link {
|
||||
color: inherit;
|
||||
}
|
||||
|
||||
/*ServicesIsDown" : "SystemOk" : "NetworkKo*/
|
||||
article {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
}
|
||||
|
||||
/*ServicesIsDown" : "SystemOk" : "NetworkKo*/
|
||||
.Connection {
|
||||
padding: 0 .75rem;
|
||||
font-weight: 700;
|
||||
@@ -58,6 +62,8 @@ a, .btn-link {
|
||||
transform: translateY(-35px);
|
||||
}
|
||||
|
||||
.page > .Connection.Hide ~ main .bottom-sheet-container.show { bottom: -35px; }
|
||||
|
||||
.btn-primary {
|
||||
color: #fff;
|
||||
background-color: var(--primary-color);
|
||||
|
||||
@@ -1,17 +1,34 @@
|
||||
const FIRST_THRESHOLD = 80; // rivela pulsante
|
||||
const SECOND_THRESHOLD = 160; // elimina diretta
|
||||
const CLOSE_THRESHOLD = 40; // swipe a destra per richiudere
|
||||
const FIRST_THRESHOLD = 80;
|
||||
const SECOND_THRESHOLD = 160;
|
||||
const CLOSE_THRESHOLD = 40;
|
||||
const MAX_SWIPE = 200;
|
||||
|
||||
window.initNotifications = () => {
|
||||
let dotnetHelper;
|
||||
|
||||
window.initNotifications = (dotnetRef) => {
|
||||
dotnetHelper = dotnetRef;
|
||||
document.querySelectorAll('.row').forEach(initRow);
|
||||
};
|
||||
|
||||
function initRow(row) {
|
||||
const card = row.querySelector('.notification-card');
|
||||
const btn = row.querySelector('.trash-btn');
|
||||
const btnTrash = row.querySelector('.trash-btn');
|
||||
const btnRead = row.querySelector('.read-btn');
|
||||
|
||||
const behindRight = row.querySelector('.behind-right'); // cestino
|
||||
const behindLeft = row.querySelector('.behind-left'); // mark as read
|
||||
|
||||
let startX = 0, currentX = 0, dragging = false;
|
||||
let open = false;
|
||||
let open = null; // "left", "right" oppure null
|
||||
|
||||
// inizializza nascosti
|
||||
behindRight.style.visibility = "hidden";
|
||||
behindLeft.style.visibility = "hidden";
|
||||
|
||||
// funzione di utilità → controlla se c'è unread-dot
|
||||
function canMarkAsRead() {
|
||||
return row.querySelector('.unread-dot') !== null;
|
||||
}
|
||||
|
||||
card.addEventListener('pointerdown', (e) => {
|
||||
if (e.pointerType === 'mouse' && e.button !== 0) return;
|
||||
@@ -23,18 +40,38 @@ function initRow(row) {
|
||||
|
||||
card.addEventListener('pointermove', (e) => {
|
||||
if (!dragging) return;
|
||||
|
||||
const dx = e.clientX - startX;
|
||||
|
||||
if (dx > 0 && !canMarkAsRead() && !open) {
|
||||
currentX = 0;
|
||||
return; // niente movimento
|
||||
}
|
||||
|
||||
let translate = dx;
|
||||
|
||||
if (!open) {
|
||||
// swiping left to open/delete
|
||||
translate = Math.max(-MAX_SWIPE, Math.min(0, dx));
|
||||
} else {
|
||||
// if already open, allow swipe right to close
|
||||
translate = Math.min(0, -FIRST_THRESHOLD + dx);
|
||||
translate = Math.max(-MAX_SWIPE, Math.min(MAX_SWIPE, dx));
|
||||
} else if (open === "left") {
|
||||
translate = Math.min(MAX_SWIPE, FIRST_THRESHOLD + dx);
|
||||
} else if (open === "right") {
|
||||
translate = Math.max(-MAX_SWIPE, -FIRST_THRESHOLD + dx);
|
||||
}
|
||||
|
||||
currentX = translate;
|
||||
card.style.transform = `translateX(${translate}px)`;
|
||||
|
||||
// mostra/nascondi i behind in tempo reale
|
||||
if (currentX < 0) {
|
||||
behindRight.style.visibility = "visible"; // cestino
|
||||
behindLeft.style.visibility = "hidden";
|
||||
} else if (currentX > 0) {
|
||||
behindLeft.style.visibility = "visible"; // mark as read
|
||||
behindRight.style.visibility = "hidden";
|
||||
} else {
|
||||
behindLeft.style.visibility = "hidden";
|
||||
behindRight.style.visibility = "hidden";
|
||||
}
|
||||
});
|
||||
|
||||
function endDrag() {
|
||||
@@ -42,25 +79,60 @@ function initRow(row) {
|
||||
dragging = false;
|
||||
card.style.transition = 'transform .2s ease';
|
||||
|
||||
if (!open) {
|
||||
// blocca swipe destro se non consentito
|
||||
if (currentX > 0 && !canMarkAsRead() && !open) {
|
||||
card.style.transform = 'translateX(0)';
|
||||
currentX = 0;
|
||||
open = null;
|
||||
behindRight.style.visibility = "hidden";
|
||||
behindLeft.style.visibility = "hidden";
|
||||
return;
|
||||
}
|
||||
|
||||
// Swipe a sinistra → elimina
|
||||
if (!open && currentX < 0) {
|
||||
if (currentX < -SECOND_THRESHOLD) {
|
||||
card.style.transform = `translateX(-${MAX_SWIPE}px)`;
|
||||
setTimeout(() => removeRow(row), 200);
|
||||
} else if (currentX < -FIRST_THRESHOLD) {
|
||||
card.style.transform = `translateX(-${FIRST_THRESHOLD}px)`;
|
||||
open = true;
|
||||
open = "right";
|
||||
} else {
|
||||
card.style.transform = 'translateX(0)';
|
||||
open = false;
|
||||
open = null;
|
||||
behindRight.style.visibility = "hidden";
|
||||
behindLeft.style.visibility = "hidden";
|
||||
}
|
||||
}
|
||||
// Swipe a destra → mark as read SOLO se consentito
|
||||
else if (!open && currentX > 0) {
|
||||
if (currentX > SECOND_THRESHOLD) {
|
||||
card.style.transform = `translateX(${MAX_SWIPE}px)`;
|
||||
setTimeout(() => markAsRead(row), 200);
|
||||
} else if (currentX > FIRST_THRESHOLD) {
|
||||
card.style.transform = `translateX(${FIRST_THRESHOLD}px)`;
|
||||
open = "left";
|
||||
} else {
|
||||
// se è già aperto e vado a destra abbastanza → chiudo
|
||||
if (currentX > -FIRST_THRESHOLD + CLOSE_THRESHOLD) {
|
||||
card.style.transform = 'translateX(0)';
|
||||
open = false;
|
||||
} else {
|
||||
card.style.transform = `translateX(-${FIRST_THRESHOLD}px)`;
|
||||
open = true;
|
||||
open = null;
|
||||
behindRight.style.visibility = "hidden";
|
||||
behindLeft.style.visibility = "hidden";
|
||||
}
|
||||
}
|
||||
// Se già aperta, gestisci chiusura
|
||||
else {
|
||||
if (open === "right" && currentX > -FIRST_THRESHOLD + CLOSE_THRESHOLD) {
|
||||
card.style.transform = 'translateX(0)';
|
||||
open = null;
|
||||
behindRight.style.visibility = "hidden";
|
||||
behindLeft.style.visibility = "hidden";
|
||||
} else if (open === "left" && currentX < FIRST_THRESHOLD - CLOSE_THRESHOLD) {
|
||||
card.style.transform = 'translateX(0)';
|
||||
open = null;
|
||||
behindRight.style.visibility = "hidden";
|
||||
behindLeft.style.visibility = "hidden";
|
||||
} else if (open) {
|
||||
card.style.transform = `translateX(${open === "right" ? -FIRST_THRESHOLD : FIRST_THRESHOLD}px)`;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -68,10 +140,21 @@ function initRow(row) {
|
||||
card.addEventListener('pointerup', endDrag);
|
||||
card.addEventListener('pointercancel', endDrag);
|
||||
|
||||
btn.addEventListener('click', () => removeRow(row));
|
||||
btnTrash.addEventListener('click', () => removeRow(row));
|
||||
btnRead.addEventListener('click', () => markAsRead(row));
|
||||
}
|
||||
|
||||
function removeRow(row) {
|
||||
//collapseAndRemove(row);
|
||||
dotnetHelper.invokeMethodAsync('Delete', row.id);
|
||||
}
|
||||
|
||||
function markAsRead(row) {
|
||||
//collapseAndRemove(row);
|
||||
dotnetHelper.invokeMethodAsync('MarkAsRead', row.id);
|
||||
}
|
||||
|
||||
function collapseAndRemove(row) {
|
||||
const h = row.getBoundingClientRect().height;
|
||||
row.style.height = h + 'px';
|
||||
row.classList.add('collapsing');
|
||||
|
||||
@@ -16,7 +16,7 @@
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="IntegryApiClient.Blazor" Version="1.1.6" />
|
||||
<PackageReference Include="IntegryApiClient.Blazor" Version="1.2.1" />
|
||||
<PackageReference Include="Microsoft.AspNetCore.Components.Authorization" Version="9.0.6" />
|
||||
<PackageReference Include="Microsoft.AspNetCore.Components.WebAssembly" Version="9.0.6" />
|
||||
<PackageReference Include="Microsoft.AspNetCore.Components.WebAssembly.DevServer" Version="9.0.6" />
|
||||
|
||||
Reference in New Issue
Block a user