| | | 1 | | @page "/arc/{ArcId:guid}" |
| | | 2 | | @attribute [Authorize] |
| | | 3 | | @implements IDisposable |
| | | 4 | | @using Chronicis.Shared.DTOs |
| | | 5 | | @using Chronicis.Shared.DTOs.Quests |
| | | 6 | | @using Chronicis.Shared.DTOs.Sessions |
| | | 7 | | @using Chronicis.Client.Components.Dialogs |
| | | 8 | | @using Chronicis.Client.Components.Shared |
| | | 9 | | @using Chronicis.Client.Components.Quests |
| | | 10 | | @inject ArcDetailViewModel ViewModel |
| | | 11 | | @inject IAppContextService AppContext |
| | | 12 | | |
| | 3 | 13 | | @if (ViewModel.IsLoading) |
| | | 14 | | { |
| | | 15 | | <LoadingSkeleton /> |
| | | 16 | | } |
| | 2 | 17 | | else if (ViewModel.Arc != null) |
| | | 18 | | { |
| | | 19 | | <MudPaper Elevation="2" Class="chronicis-article-card chronicis-fade-in"> |
| | | 20 | | <DetailPageHeader Breadcrumbs="ViewModel.Breadcrumbs" |
| | | 21 | | Icon="@Icons.Material.Filled.Bookmark" |
| | | 22 | | Title="@ViewModel.EditName" |
| | | 23 | | TitleChanged="@(v => ViewModel.EditName = v)" |
| | | 24 | | Placeholder="Arc Name" |
| | | 25 | | OnTitleEdited="@(() => {})" |
| | | 26 | | OnEnterPressed="@(() => ViewModel.SaveAsync())" |
| | | 27 | | ReadOnly="@(!ViewModel.CanManageArcDetails)" /> |
| | | 28 | | |
| | | 29 | | <MudTabs Elevation="0" |
| | | 30 | | Rounded="true" |
| | | 31 | | ApplyEffectsToContainer="true" |
| | | 32 | | PanelClass="pa-4"> |
| | | 33 | | <MudTabPanel Text="Overview" Icon="@Icons.Material.Filled.Bookmark"> |
| | | 34 | | <MudTextField Value="@ViewModel.EditDescription" |
| | | 35 | | ValueChanged="@((string v) => ViewModel.EditDescription = v)" |
| | | 36 | | Label="Description" |
| | | 37 | | Variant="Variant.Outlined" |
| | | 38 | | Lines="3" |
| | | 39 | | Placeholder="Describe this arc..." |
| | | 40 | | Class="mb-4" |
| | | 41 | | Immediate="true" |
| | | 42 | | ReadOnly="@(!ViewModel.CanManageArcDetails)" /> |
| | | 43 | | |
| | | 44 | | <MudNumericField Value="@ViewModel.EditSortOrder" |
| | | 45 | | ValueChanged="@((int v) => ViewModel.EditSortOrder = v)" |
| | | 46 | | Label="Sort Order" |
| | | 47 | | Variant="Variant.Outlined" |
| | | 48 | | Min="0" |
| | | 49 | | Class="mb-4" |
| | | 50 | | Style="max-width: 150px;" |
| | | 51 | | Immediate="true" |
| | | 52 | | Disabled="@(!ViewModel.CanManageArcDetails)" /> |
| | | 53 | | |
| | | 54 | | <div class="d-flex align-center justify-space-between mb-3"> |
| | | 55 | | <MudText Typo="Typo.h6" Style="color: var(--chronicis-beige-gold);"> |
| | | 56 | | <MudIcon Icon="@Icons.Material.Filled.EventNote" Size="Size.Small" Class="mr-2" /> |
| | | 57 | | Sessions |
| | | 58 | | </MudText> |
| | | 59 | | @if (ViewModel.IsCurrentUserGM) |
| | | 60 | | { |
| | | 61 | | <MudButton Variant="Variant.Filled" |
| | | 62 | | Color="Color.Primary" |
| | | 63 | | Size="Size.Small" |
| | | 64 | | StartIcon="@Icons.Material.Filled.Add" |
| | | 65 | | OnClick="@(() => ViewModel.CreateSessionAsync())"> |
| | | 66 | | New Session |
| | | 67 | | </MudButton> |
| | | 68 | | } |
| | | 69 | | </div> |
| | | 70 | | |
| | | 71 | | @if (ViewModel.Sessions.Any()) |
| | | 72 | | { |
| | | 73 | | <MudList T="SessionTreeDto" Dense="true" Class="mb-4"> |
| | | 74 | | @foreach (var session in ViewModel.Sessions.OrderBy(s => s.Name)) |
| | | 75 | | { |
| | | 76 | | <EntityListItem Icon="@Icons.Material.Filled.EventNote" |
| | | 77 | | Title="@(string.IsNullOrEmpty(session.Name) ? "Untitled Session" : session.N |
| | | 78 | | OnClick="@(() => ViewModel.NavigateToSessionAsync(session))" /> |
| | | 79 | | } |
| | | 80 | | </MudList> |
| | | 81 | | } |
| | | 82 | | else |
| | | 83 | | { |
| | | 84 | | <MudAlert Severity="Severity.Info" Class="mb-4"> |
| | | 85 | | No sessions yet. Create your first session to start documenting your adventures! |
| | | 86 | | </MudAlert> |
| | | 87 | | } |
| | | 88 | | |
| | | 89 | | <ArcQuestList ArcId="@ArcId" IsGm="ViewModel.IsCurrentUserGM" OnEditQuest="ViewModel.OnEditQuest" /> |
| | | 90 | | |
| | | 91 | | @if (ViewModel.SelectedQuest != null) |
| | | 92 | | { |
| | | 93 | | <MudDivider Class="my-4" /> |
| | | 94 | | <ArcQuestEditor Quest="ViewModel.SelectedQuest" |
| | | 95 | | OnQuestUpdated="ViewModel.OnQuestUpdated" /> |
| | | 96 | | <ArcQuestTimeline Quest="ViewModel.SelectedQuest" |
| | | 97 | | IsGm="ViewModel.IsCurrentUserGM" |
| | | 98 | | CurrentUserId="ViewModel.CurrentUserId" /> |
| | | 99 | | } |
| | | 100 | | |
| | | 101 | | <MudText Typo="Typo.h6" Class="mb-3" Style="color: var(--chronicis-beige-gold);"> |
| | | 102 | | Arc Info |
| | | 103 | | </MudText> |
| | | 104 | | |
| | | 105 | | <MudSimpleTable Dense="true" Hover="true" Class="mb-4"> |
| | | 106 | | <tbody> |
| | | 107 | | <tr> |
| | | 108 | | <td><MudIcon Icon="@Icons.Material.Filled.PlayCircle" Size="Size.Small" Class="mr-2" />Activ |
| | | 109 | | <td> |
| | | 110 | | <MudSwitch T="bool" |
| | | 111 | | Value="ViewModel.Arc.IsActive" |
| | | 112 | | ValueChanged="@((bool v) => ViewModel.OnActiveToggleAsync(v))" |
| | | 113 | | Color="Color.Success" |
| | | 114 | | Size="Size.Small" |
| | | 115 | | Disabled="@(ViewModel.IsTogglingActive || !ViewModel.CanManageArcDetails)" /> |
| | | 116 | | </td> |
| | | 117 | | </tr> |
| | | 118 | | <tr> |
| | | 119 | | <td><MudIcon Icon="@Icons.Material.Filled.EventNote" Size="Size.Small" Class="mr-2" />Sessio |
| | | 120 | | <td>@ViewModel.Arc.SessionCount</td> |
| | | 121 | | </tr> |
| | | 122 | | <tr> |
| | | 123 | | <td><MudIcon Icon="@Icons.Material.Filled.Sort" Size="Size.Small" Class="mr-2" />Sort Order< |
| | | 124 | | <td>@ViewModel.Arc.SortOrder</td> |
| | | 125 | | </tr> |
| | | 126 | | <tr> |
| | | 127 | | <td><MudIcon Icon="@Icons.Material.Filled.CalendarToday" Size="Size.Small" Class="mr-2" />Cr |
| | | 128 | | <td>@ViewModel.Arc.CreatedAt.ToString("MMMM d, yyyy")</td> |
| | | 129 | | </tr> |
| | | 130 | | </tbody> |
| | | 131 | | </MudSimpleTable> |
| | | 132 | | |
| | | 133 | | <AISummarySection EntityId="ArcId" |
| | | 134 | | EntityType="Arc" |
| | | 135 | | IsExpanded="ViewModel.SummaryExpanded" |
| | | 136 | | IsExpandedChanged="@((bool v) => ViewModel.SummaryExpanded = v)" /> |
| | | 137 | | </MudTabPanel> |
| | | 138 | | |
| | | 139 | | @if (ViewModel.CanViewPrivateNotes) |
| | | 140 | | { |
| | | 141 | | <MudTabPanel Text="Private Notes" Icon="@Icons.Material.Filled.Lock"> |
| | | 142 | | <MudText Typo="Typo.body2" Class="mud-text-secondary mb-3"> |
| | | 143 | | Visible only to the world owner and GMs. |
| | | 144 | | </MudText> |
| | | 145 | | <PrivateNotesTipTapEditor WorldId="@ViewModel.Campaign!.WorldId" |
| | | 146 | | Value="@ViewModel.EditPrivateNotes" |
| | | 147 | | ValueChanged="@((string v) => ViewModel.EditPrivateNotes = v)" |
| | | 148 | | ReadOnly="@(!ViewModel.CanManageArcDetails)" |
| | | 149 | | UploadContextLabel="arc private notes" /> |
| | | 150 | | </MudTabPanel> |
| | | 151 | | } |
| | | 152 | | </MudTabs> |
| | | 153 | | |
| | | 154 | | <div class="chronicis-flex-between mt-4"> |
| | | 155 | | <SaveStatusIndicator IsSaving="ViewModel.IsSaving" HasUnsavedChanges="ViewModel.HasUnsavedChanges" /> |
| | | 156 | | |
| | | 157 | | <div class="d-flex gap-2"> |
| | | 158 | | <MudButton Variant="Variant.Filled" |
| | | 159 | | Color="Color.Primary" |
| | | 160 | | OnClick="@(() => ViewModel.SaveAsync())" |
| | | 161 | | Disabled="@(ViewModel.IsSaving || !ViewModel.CanManageArcDetails)" |
| | | 162 | | StartIcon="@Icons.Material.Filled.Save"> |
| | | 163 | | Save |
| | | 164 | | </MudButton> |
| | | 165 | | |
| | | 166 | | <MudButton Variant="Variant.Outlined" |
| | | 167 | | Color="Color.Error" |
| | | 168 | | OnClick="@(() => ViewModel.DeleteAsync())" |
| | | 169 | | Disabled="@(ViewModel.IsSaving || ViewModel.Sessions.Any() || !ViewModel.IsCurrentUserGM)" |
| | | 170 | | StartIcon="@Icons.Material.Filled.Delete"> |
| | | 171 | | Delete |
| | | 172 | | </MudButton> |
| | | 173 | | </div> |
| | | 174 | | </div> |
| | | 175 | | |
| | | 176 | | @if (ViewModel.Sessions.Any()) |
| | | 177 | | { |
| | | 178 | | <MudText Typo="Typo.caption" Class="mt-2" Style="color: var(--mud-palette-text-secondary);"> |
| | | 179 | | Delete all sessions before deleting this arc. |
| | | 180 | | </MudText> |
| | | 181 | | } |
| | | 182 | | </MudPaper> |
| | | 183 | | } |
| | | 184 | | |
| | | 185 | | @code { |
| | | 186 | | [Parameter] |
| | | 187 | | public Guid ArcId { get; set; } |
| | | 188 | | |
| | | 189 | | protected override async Task OnParametersSetAsync() |
| | | 190 | | { |
| | | 191 | | ViewModel.PropertyChanged += OnViewModelChanged; |
| | | 192 | | await ViewModel.LoadAsync(ArcId); |
| | | 193 | | |
| | | 194 | | if (ViewModel.Campaign != null && |
| | | 195 | | (AppContext.CurrentWorldId != ViewModel.Campaign.WorldId || AppContext.CurrentCampaignId != ViewModel.Campai |
| | | 196 | | { |
| | | 197 | | await AppContext.SelectWorldAsync(ViewModel.Campaign.WorldId, ViewModel.Campaign.Id); |
| | | 198 | | } |
| | | 199 | | } |
| | | 200 | | |
| | | 201 | | private void OnViewModelChanged(object? sender, System.ComponentModel.PropertyChangedEventArgs e) |
| | 17 | 202 | | => InvokeAsync(StateHasChanged); |
| | | 203 | | |
| | | 204 | | public void Dispose() |
| | | 205 | | { |
| | 3 | 206 | | ViewModel.PropertyChanged -= OnViewModelChanged; |
| | 3 | 207 | | } |
| | | 208 | | } |