From e38178eca560690f3edc39a8bd2dfa68070c2d38 Mon Sep 17 00:00:00 2001 From: Robert Brands Date: Sun, 14 Nov 2021 14:18:13 +0100 Subject: [PATCH] Users/rbrands/2021 11 11 (#99) * Routes synced with app * Using the name for comment * Comments for routes --- MeetUpFunctions/Constants.cs | 2 +- MeetUpPlanner/Client/AppState.cs | 16 +++++++++++++ MeetUpPlanner/Client/Pages/About.razor | 2 +- MeetUpPlanner/Client/Pages/NewMeetUp.razor | 4 ++-- MeetUpPlanner/Client/Pages/Routes.razor | 6 +++++ MeetUpPlanner/Client/Shared/EditComment.razor | 13 ++++++++-- MeetUpPlanner/Client/Shared/RouteCard.razor | 24 ++++++++++++++++--- .../Server/Controllers/UtilController.cs | 2 +- MeetUpPlanner/Shared/ExtendedInfoItem.cs | 1 + 9 files changed, 60 insertions(+), 10 deletions(-) diff --git a/MeetUpFunctions/Constants.cs b/MeetUpFunctions/Constants.cs index cc52cf2..08fac8c 100644 --- a/MeetUpFunctions/Constants.cs +++ b/MeetUpFunctions/Constants.cs @@ -22,7 +22,7 @@ public static class Constants public const string DEFAULT_DISCLAIMER = "Disclaimer"; public const string DEFAULT_GUEST_DISCLAIMER = "Guest Disclaimer"; - public const string VERSION = "2021-11-08"; + public const string VERSION = "2021-11-14"; public const int ADMINOVERBOOKFACTOR = 2; public const int LOG_TTL = 30 * 24 * 3600; // 30 days TTL for Log items diff --git a/MeetUpPlanner/Client/AppState.cs b/MeetUpPlanner/Client/AppState.cs index 507a9c1..1b59941 100644 --- a/MeetUpPlanner/Client/AppState.cs +++ b/MeetUpPlanner/Client/AppState.cs @@ -2,6 +2,7 @@ using System.Collections.Generic; using System.Linq; using System.Threading.Tasks; +using System.Text; using MeetUpPlanner.Shared; using System.ComponentModel.DataAnnotations; @@ -39,6 +40,21 @@ public ClientSettings ClientSettings [MaxLength(80, ErrorMessage = "Der Nachname ist zu lang."), MinLength(3, ErrorMessage = "Der Nachname ist zu kurz.")] [Required(ErrorMessage = "Der Nachname fehlt.")] public string LastName { get; set; } + public string DisplayName + { + get + { + int nameDisplayLength = _clientSettings != null ? _clientSettings.NameDisplayLength : 0; + int length = nameDisplayLength > 0 ? Math.Min(nameDisplayLength, LastName.Length) : LastName.Length; + StringBuilder sb = new StringBuilder(FirstName).Append(' '); + sb.Append(LastName.Substring(0, length)); + if (length < LastName.Length) + { + sb.Append('.'); + } + return sb.ToString(); + } + } [MaxLength(120, ErrorMessage = "Die Tel-Nr/Mail-Adresse ist zu lang"), MinLength(8, ErrorMessage = "Die Tel-Nr/Mail-Adresse ist zu kurz.")] [Required(ErrorMessage = "Tel-Nr/Mail-Adresse fehlen.")] public string PhoneMail { get; set; } diff --git a/MeetUpPlanner/Client/Pages/About.razor b/MeetUpPlanner/Client/Pages/About.razor index ce68b25..db1ad90 100644 --- a/MeetUpPlanner/Client/Pages/About.razor +++ b/MeetUpPlanner/Client/Pages/About.razor @@ -51,7 +51,7 @@ @code { - private const string clientVersion = "2021-11-08"; + private const string clientVersion = "2021-11-14"; private string serverVersion = "tbd"; private string functionsVersion = "tbd"; diff --git a/MeetUpPlanner/Client/Pages/NewMeetUp.razor b/MeetUpPlanner/Client/Pages/NewMeetUp.razor index c404cc8..cc0f7bc 100644 --- a/MeetUpPlanner/Client/Pages/NewMeetUp.razor +++ b/MeetUpPlanner/Client/Pages/NewMeetUp.razor @@ -7,6 +7,7 @@ @inject NavigationManager NavigationManager @inject NotificationService notificationService @using Newtonsoft.Json +@using System.Text @using Microsoft.AspNetCore.SignalR.Client @using MeetUpPlanner.Shared @using Blazored.TextEditor @@ -648,8 +649,7 @@ _routeComment = new MeetUpPlanner.Shared.Comment(); _routeComment.ReferenceId = route.Core.Id; _routeComment.CommentText = "Im MeetUpPlanner für eine Ausfahrt ausgewählt!"; - _routeComment.AuthorDisplayName = $"{AppStateStore.FirstName}"; - + _routeComment.AuthorDisplayName = AppStateStore.DisplayName; } } diff --git a/MeetUpPlanner/Client/Pages/Routes.razor b/MeetUpPlanner/Client/Pages/Routes.razor index 27f33de..00edea2 100644 --- a/MeetUpPlanner/Client/Pages/Routes.razor +++ b/MeetUpPlanner/Client/Pages/Routes.razor @@ -25,6 +25,7 @@ else

+

@@ -67,7 +68,12 @@ else { try { + _statusMessage.Hide(); _routes = await RoutesApi.GetRoutes(_filter); + if (_routes.Count() == 0) + { + _statusMessage.ShowWarning("Keine Route mit den Suchkriterien gefunden. Bitte ändere deinen Suchfilter."); + } } catch (Exception ex) { diff --git a/MeetUpPlanner/Client/Shared/EditComment.razor b/MeetUpPlanner/Client/Shared/EditComment.razor index e419394..9dd014d 100644 --- a/MeetUpPlanner/Client/Shared/EditComment.razor +++ b/MeetUpPlanner/Client/Shared/EditComment.razor @@ -17,7 +17,7 @@ } else { - +
@@ -60,6 +60,15 @@ else await OnCancel.InvokeAsync(); } - + private async Task SaveComment() + { + if (!String.IsNullOrEmpty(Comment.Core.CommentText) || !String.IsNullOrEmpty(Comment.Core.Link)) + { + Comment.Core.AuthorDisplayName = AppStateStore.DisplayName; + await Api.WriteComment(Comment.Core); + } + _editMode = false; + await OnSave.InvokeAsync(); + } } diff --git a/MeetUpPlanner/Client/Shared/RouteCard.razor b/MeetUpPlanner/Client/Shared/RouteCard.razor index d6fce0b..3a54bba 100644 --- a/MeetUpPlanner/Client/Shared/RouteCard.razor +++ b/MeetUpPlanner/Client/Shared/RouteCard.razor @@ -79,8 +79,10 @@ {
+ +
- } + }
@@ -88,6 +90,10 @@
+ @if (_enableCommentInput) + { + + }
@@ -96,6 +102,7 @@ public ExtendedRoute RouteItem { get; set; } = new ExtendedRoute(); [Parameter] public EventCallback OnReload { get; set; } + private Boolean _enableCommentInput = false; private string[] BadgeClasses = { @@ -119,8 +126,8 @@ { Comment comment = new Comment(); comment.ReferenceId = RouteItem.Core.Id; - comment.CommentText = "Die Route wurde im MeetUpPlanner verwendet!"; - comment.AuthorDisplayName = $"{AppStateStore.FirstName}"; + comment.CommentText = "Danke, ich bin die Route gefahren!"; + comment.AuthorDisplayName = AppStateStore.DisplayName; await RouteApi.WriteComment(comment); await OnReload.InvokeAsync(); } @@ -133,4 +140,15 @@ { await OnReload.InvokeAsync(); } + private void ToggleCommentInput() + { + _enableCommentInput = !_enableCommentInput; + } + private async Task OnSaveComment() + { + _enableCommentInput = !_enableCommentInput; + await OnReload.InvokeAsync(); + } + + } diff --git a/MeetUpPlanner/Server/Controllers/UtilController.cs b/MeetUpPlanner/Server/Controllers/UtilController.cs index aa54868..c5eb464 100644 --- a/MeetUpPlanner/Server/Controllers/UtilController.cs +++ b/MeetUpPlanner/Server/Controllers/UtilController.cs @@ -20,7 +20,7 @@ public class UtilController : ControllerBase { private readonly MeetUpFunctions _meetUpFunctions; private readonly ILogger logger; - const string serverVersion = "2021-11-08"; + const string serverVersion = "2021-11-14"; string functionsVersion = "tbd"; public UtilController(ILogger logger, MeetUpFunctions meetUpFunctions) diff --git a/MeetUpPlanner/Shared/ExtendedInfoItem.cs b/MeetUpPlanner/Shared/ExtendedInfoItem.cs index 5f4d0d6..d3ee4cb 100644 --- a/MeetUpPlanner/Shared/ExtendedInfoItem.cs +++ b/MeetUpPlanner/Shared/ExtendedInfoItem.cs @@ -36,6 +36,7 @@ public ExtendedInfoItem(InfoItem infoItem) this.OrderId = infoItem.OrderId; this.Tenant = infoItem.Tenant; this.Title = infoItem.Title; + this.SubTitle = infoItem.SubTitle; } } }