This repository has been archived by the owner on Apr 17, 2023. It is now read-only.
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Filters and initial string list are properly initialized on first page load based on the supplied query string - Modifying the filters loads the new data via Ajax and pushes the newly generated query string in browser history, same for the quick filter links - Reviewers see "Ignore" buttons in the list, but the buttons do nothing yet - A spinner is displayed in the center of the screen while loading Ajax data Ohter improvements: - Html.DropDownListFor is now used for rendering the dropdown filters - Bundling+minification of css and js configured for production environment - ASP.NET client validation disabled on startup (no more validation attributes in the generated HTML)
- Loading branch information
Showing
19 changed files
with
592 additions
and
108 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
site.min.* |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
22 changes: 22 additions & 0 deletions
22
Traducir.Web.Net/ViewModels/Home/FilterResultsViewModel.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using Traducir.Core.Models; | ||
using Traducir.Core.Models.Enums; | ||
|
||
namespace Traducir.Web.Net.ViewModels.Home | ||
{ | ||
public class FilterResultsViewModel | ||
{ | ||
public UserType UserType { get; set; } | ||
|
||
public IEnumerable<SOString> Strings { get; set; } | ||
|
||
public int Count => Strings.Count(); | ||
|
||
public int ApprovedSuggestionsCountFor(SOString str) => str.Suggestions?.Count(s => s.State == StringSuggestionState.ApprovedByTrustedUser) ?? 0; | ||
|
||
public int PendingSuggestionsCountFor(SOString str) => str.Suggestions?.Count(s => s.State == StringSuggestionState.Created) ?? 0; | ||
|
||
public bool UserCanManageIgnoring => UserType >= UserType.TrustedUser; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
@model Traducir.Web.Net.ViewModels.Home.FilterResultsViewModel | ||
|
||
<div class="m-2 text-center"> | ||
<h2> | ||
Results @(Model.Count > 0 ? $"({Model.Count})" : null) | ||
</h2> | ||
</div> | ||
<table class="table"> | ||
<thead class="thead-light"> | ||
<tr> | ||
<th>String</th> | ||
<th>Translation</th> | ||
<th>Suggestions</th> | ||
</tr> | ||
</thead> | ||
<tbody> | ||
@if(Model.Count == 0) | ||
{ | ||
<tr> | ||
<td colSpan="3" class="text-center">No results (sad trombone)</td> | ||
</tr> | ||
} | ||
else | ||
{ | ||
foreach (var str in Model.Strings) | ||
{ | ||
var approvedCount = Model.ApprovedSuggestionsCountFor(str); | ||
var pendingCount = Model.PendingSuggestionsCountFor(str); | ||
|
||
<tr> | ||
<td>@str.OriginalString</td> | ||
<td> | ||
@if(str.Translation != null) | ||
{ | ||
<text>@str.Translation</text> | ||
} | ||
else if(Model.UserCanManageIgnoring) | ||
{ | ||
if (str.IsIgnored) | ||
{ | ||
<button type="button" class="btn btn-warning btn-sm">Stop ignoring</button> | ||
} | ||
else | ||
{ | ||
<button type="button" class="btn btn-warning btn-sm">Ignore!</button> | ||
} | ||
} | ||
</td> | ||
<td> | ||
@if (approvedCount > 0) | ||
{ | ||
<span class="text-success">@approvedCount</span> | ||
} | ||
@if (approvedCount > 0 && pendingCount > 0) | ||
{ | ||
<span> - </span> | ||
} | ||
@if(pendingCount > 0) | ||
{ | ||
<span class="text-danger">@pendingCount</span> | ||
} | ||
</td> | ||
</tr> | ||
} | ||
} | ||
</tbody> | ||
</table> |
Oops, something went wrong.