< Summary

Information
Class: Chronicis.Client.Services.WikiLinkAutocompleteItem
Assembly: Chronicis.Client
File(s): /home/runner/work/chronicis/chronicis/src/Chronicis.Client/Services/IWikiLinkAutocompleteService.cs
Line coverage
0%
Covered lines: 0
Uncovered lines: 22
Coverable lines: 22
Total lines: 131
Line coverage: 0%
Branch coverage
N/A
Covered branches: 0
Total branches: 0
Branch coverage: N/A
Method coverage

Feature is only available for sponsors

Upgrade to PRO version

Metrics

MethodBranch coverage Crap Score Cyclomatic complexity Line coverage
get_DisplayText()100%210%
get_ArticleId()100%210%
get_ExternalKey()100%210%
get_Tooltip()100%210%
get_IsExternal()100%210%
get_IsCategory()100%210%
FromInternal(...)100%210%
FromExternal(...)100%210%

File(s)

/home/runner/work/chronicis/chronicis/src/Chronicis.Client/Services/IWikiLinkAutocompleteService.cs

#LineLine coverage
 1using Chronicis.Shared.DTOs;
 2
 3namespace Chronicis.Client.Services;
 4
 5/// <summary>
 6/// Service for managing wiki link autocomplete state and operations
 7/// </summary>
 8public interface IWikiLinkAutocompleteService
 9{
 10    /// <summary>
 11    /// Event raised when autocomplete should be shown
 12    /// </summary>
 13    event Action? OnShow;
 14
 15    /// <summary>
 16    /// Event raised when autocomplete should be hidden
 17    /// </summary>
 18    event Action? OnHide;
 19
 20    /// <summary>
 21    /// Event raised when suggestions have been updated
 22    /// </summary>
 23    event Action? OnSuggestionsUpdated;
 24
 25    /// <summary>
 26    /// Current autocomplete position (x, y)
 27    /// </summary>
 28    (double X, double Y) Position { get; }
 29
 30    /// <summary>
 31    /// Whether autocomplete is currently visible
 32    /// </summary>
 33    bool IsVisible { get; }
 34
 35    /// <summary>
 36    /// Current search query
 37    /// </summary>
 38    string Query { get; }
 39
 40    /// <summary>
 41    /// Whether this is an external resource query (e.g., srd/...)
 42    /// </summary>
 43    bool IsExternalQuery { get; }
 44
 45    /// <summary>
 46    /// External source key (e.g., "srd")
 47    /// </summary>
 48    string? ExternalSourceKey { get; }
 49
 50    /// <summary>
 51    /// Current autocomplete suggestions
 52    /// </summary>
 53    List<WikiLinkAutocompleteItem> Suggestions { get; }
 54
 55    /// <summary>
 56    /// Currently selected suggestion index
 57    /// </summary>
 58    int SelectedIndex { get; }
 59
 60    /// <summary>
 61    /// Whether suggestions are currently loading
 62    /// </summary>
 63    bool IsLoading { get; }
 64
 65    /// <summary>
 66    /// Show autocomplete at the specified position with the given query
 67    /// </summary>
 68    Task ShowAsync(string query, double x, double y, Guid? worldId);
 69
 70    /// <summary>
 71    /// Hide the autocomplete
 72    /// </summary>
 73    void Hide();
 74
 75    /// <summary>
 76    /// Move selection down
 77    /// </summary>
 78    void SelectNext();
 79
 80    /// <summary>
 81    /// Move selection up
 82    /// </summary>
 83    void SelectPrevious();
 84
 85    /// <summary>
 86    /// Set the selected index directly
 87    /// </summary>
 88    void SetSelectedIndex(int index);
 89
 90    /// <summary>
 91    /// Get the currently selected suggestion
 92    /// </summary>
 93    WikiLinkAutocompleteItem? GetSelectedSuggestion();
 94}
 95
 96/// <summary>
 97/// Autocomplete item representing either an internal article or external resource
 98/// </summary>
 99public class WikiLinkAutocompleteItem
 100{
 0101    public string DisplayText { get; set; } = string.Empty;
 0102    public string? ArticleId { get; set; }
 0103    public string? ExternalKey { get; set; }
 0104    public string? Tooltip { get; set; }
 0105    public bool IsExternal { get; set; }
 0106    public bool IsCategory { get; set; }
 107
 108    public static WikiLinkAutocompleteItem FromInternal(LinkSuggestionDto suggestion)
 109    {
 0110        return new WikiLinkAutocompleteItem
 0111        {
 0112            DisplayText = suggestion.Title,
 0113            ArticleId = suggestion.ArticleId.ToString(),
 0114            Tooltip = suggestion.DisplayPath,
 0115            IsExternal = false,
 0116            IsCategory = false
 0117        };
 118    }
 119
 120    public static WikiLinkAutocompleteItem FromExternal(ExternalLinkSuggestionDto suggestion)
 121    {
 0122        return new WikiLinkAutocompleteItem
 0123        {
 0124            DisplayText = suggestion.Title,
 0125            ExternalKey = suggestion.Id,
 0126            Tooltip = suggestion.Source,
 0127            IsExternal = true,
 0128            IsCategory = !string.IsNullOrEmpty(suggestion.Category)
 0129        };
 130    }
 131}