Skip to content

Commit

Permalink
Enable links to InfoCards
Browse files Browse the repository at this point in the history
  • Loading branch information
rbrands committed Oct 3, 2020
1 parent 3ce416f commit a342335
Show file tree
Hide file tree
Showing 4 changed files with 44 additions and 3 deletions.
2 changes: 1 addition & 1 deletion MeetUpPlanner/Client/Pages/InfoComment.razor
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
@using Microsoft.AspNetCore.SignalR.Client

<InfoSummary InfoItem="@infoItem" AdditionalText="@lifetimeHint" />
<AddComment OnSaveComment="SaveComment" OnCancel="OnCancel"></AddComment>
<AddComment OnSaveComment="SaveComment" OnCancel="OnCancel" EnableLink="true"></AddComment>
<hr />
<CommentsList Comments="@infoItem.CommentsList" OnRemoveComment="RemoveComment"></CommentsList>

Expand Down
19 changes: 19 additions & 0 deletions MeetUpPlanner/Client/Shared/AddComment.razor
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,23 @@
Über die Kommentarfunktion können wir uns weiter abstimmen.
</small>
</div>
@if (EnableLink)
{
<div class="form-group">
<label for="link">Link</label>
<InputText id="link" aria-describedby="linkHelp" class="form-control" @bind-Value="comment.Link" placeholder="URL" title="Link zu weiteren Infos" />
<small id="linkHelp" class="form-text text-muted">
Optional: Link zu weiteren Infos, z.B. Fotos, Artikel usw..
</small>
</div>
<div class="form-group">
<label for="linkTitle">Link-Bezeichnung</label>
<InputText id="linkTitle" aria-describedby="linkTitleHelp" class="form-control" @bind-Value="comment.LinkTitle" placeholder="Kurze Überschrift zum Link" title="Bezeichnung des Links" />
<small id="linkTitleHelp" class="form-text text-muted">
Optional: Kurze Bezeichnung zu dem Link oben, falls der Standardtext nicht passt.
</small>
</div>
}
<button type="submit" id="BtnSave" disabled="@saveDisabled" class="btn btn-primary">Kommentar speichern ...</button>
<button type="reset" id="BtnCancel" class="btn btn-secondary" @onclick="@(() => OnCancelBtn())">Zurück ...</button>
</EditForm>
Expand All @@ -19,6 +36,8 @@
public EventCallback<CalendarComment> OnSaveComment { get; set; }
[Parameter]
public EventCallback OnCancel { get; set; }
[Parameter]
public Boolean EnableLink { get; set; } = false;
CalendarComment comment = new CalendarComment() { AuthorFirstName = "NN", AuthorLastName = "NN" };
private Boolean saveDisabled = false;

Expand Down
10 changes: 9 additions & 1 deletion MeetUpPlanner/Client/Shared/InfoCard.razor
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,15 @@
<ul class="list-unstyled">
@foreach (CalendarComment c in InfoItem.CommentsList)
{
<li><small><em>@c.AuthorDisplayName (@c.DisplayDate): </em>@c.Comment</small></li>
<li>
<small>
<em>@c.AuthorDisplayName (@c.DisplayDate): </em>@c.Comment
@if (!String.IsNullOrEmpty(c.Link))
{
<text> </text><a title="@c.DisplayLinkTitle" target="_blank" href="@c.Link">@c.DisplayLinkTitle</a>
}
</small>
</li>
}
</ul>
<hr/>
Expand Down
16 changes: 15 additions & 1 deletion MeetUpPlanner/Shared/CalendarComment.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,12 @@ public class CalendarComment : CosmosDBEntity
public string AuthorLastName { get; set; }
[JsonProperty(PropertyName = "commentDate")]
public DateTime CommentDate { get; set; }
[JsonProperty(PropertyName = "comment"), MaxLength(200, ErrorMessage = "Kommentar zu lang.")]
[JsonProperty(PropertyName = "comment"), MaxLength(250, ErrorMessage = "Kommentar zu lang.")]
public string Comment { get; set; }
[JsonProperty(PropertyName = "link", NullValueHandling = NullValueHandling.Ignore), MaxLength(200, ErrorMessage = "Link zu lang.")]
public string Link { get; set; }
[JsonProperty(PropertyName = "linkTitle", NullValueHandling = NullValueHandling.Ignore), MaxLength(80, ErrorMessage = "Link-Titel zu lang.")]
public string LinkTitle { get; set; }
[JsonIgnore]
public string AuthorDisplayName
{
Expand All @@ -32,13 +36,23 @@ public string AuthorDisplayName
return AuthorFirstName + " " + AuthorLastName[0] + ".";
}
}
[JsonIgnore]
public string DisplayDate
{
get
{
return (null != CommentDate) ? CommentDate.ToString("dd.MM. HH:mm") : String.Empty;
}
}
[JsonIgnore]

public string DisplayLinkTitle
{
get
{
return String.IsNullOrEmpty(LinkTitle) ? "Link ..." : LinkTitle;
}
}

}
}

0 comments on commit a342335

Please sign in to comment.