| | | 1 | | @* ArticleActionBar.razor - Action buttons and save status for article editing *@ |
| | | 2 | | |
| | | 3 | | <div class="chronicis-flex-between mt-4"> |
| | | 4 | | <SaveStatusIndicator IsSaving="IsSaving" |
| | | 5 | | HasUnsavedChanges="HasUnsavedChanges" |
| | | 6 | | LastSaveTime="@LastSaveTime" /> |
| | | 7 | | |
| | | 8 | | <div class="chronicis-flex" style="gap: 8px;"> |
| | | 9 | | <MudButton |
| | | 10 | | Variant="Variant.Outlined" |
| | | 11 | | Color="Color.Primary" |
| | | 12 | | OnClick="OnCreateChildClick" |
| | | 13 | | Disabled="IsSaving || IsCreatingChild" |
| | | 14 | | StartIcon="@Icons.Material.Filled.PostAdd"> |
| | 20 | 15 | | @if (IsCreatingChild) |
| | | 16 | | { |
| | | 17 | | <MudProgressCircular Size="Size.Small" Indeterminate="true" Class="mr-2" /> |
| | | 18 | | <span>Creating...</span> |
| | | 19 | | } |
| | | 20 | | else |
| | | 21 | | { |
| | | 22 | | <span>New Child</span> |
| | | 23 | | } |
| | | 24 | | </MudButton> |
| | | 25 | | |
| | | 26 | | <MudButton |
| | | 27 | | Variant="Variant.Outlined" |
| | | 28 | | Color="Color.Primary" |
| | | 29 | | OnClick="OnAutoLinkClick" |
| | | 30 | | Disabled="IsSaving || IsAutoLinking" |
| | | 31 | | StartIcon="@Icons.Material.Filled.AutoFixHigh"> |
| | 20 | 32 | | @if (IsAutoLinking) |
| | | 33 | | { |
| | | 34 | | <MudProgressCircular Size="Size.Small" Indeterminate="true" Class="mr-2" /> |
| | | 35 | | <span>Scanning...</span> |
| | | 36 | | } |
| | | 37 | | else |
| | | 38 | | { |
| | | 39 | | <span>Auto-AiLink</span> |
| | | 40 | | } |
| | | 41 | | </MudButton> |
| | | 42 | | |
| | | 43 | | <MudButton |
| | | 44 | | Variant="Variant.Filled" |
| | | 45 | | Color="Color.Success" |
| | | 46 | | OnClick="OnSaveClick" |
| | | 47 | | Disabled="IsSaving" |
| | | 48 | | StartIcon="@Icons.Material.Filled.Save"> |
| | | 49 | | Save |
| | | 50 | | </MudButton> |
| | | 51 | | |
| | | 52 | | <MudButton |
| | | 53 | | Variant="Variant.Filled" |
| | | 54 | | Color="Color.Error" |
| | | 55 | | OnClick="OnDeleteClick" |
| | | 56 | | StartIcon="@Icons.Material.Filled.Delete"> |
| | | 57 | | Delete |
| | | 58 | | </MudButton> |
| | | 59 | | </div> |
| | | 60 | | </div> |
| | | 61 | | |
| | | 62 | | @code { |
| | | 63 | | #region Status Parameters |
| | | 64 | | |
| | | 65 | | /// <summary> |
| | | 66 | | /// Whether a save operation is in progress. |
| | | 67 | | /// </summary> |
| | | 68 | | [Parameter] |
| | 83 | 69 | | public bool IsSaving { get; set; } |
| | | 70 | | |
| | | 71 | | /// <summary> |
| | | 72 | | /// Whether the auto-link operation is in progress. |
| | | 73 | | /// </summary> |
| | | 74 | | [Parameter] |
| | 39 | 75 | | public bool IsAutoLinking { get; set; } |
| | | 76 | | |
| | | 77 | | /// <summary> |
| | | 78 | | /// Whether a child article is being created. |
| | | 79 | | /// </summary> |
| | | 80 | | [Parameter] |
| | 39 | 81 | | public bool IsCreatingChild { get; set; } |
| | | 82 | | |
| | | 83 | | /// <summary> |
| | | 84 | | /// Whether there are unsaved changes. |
| | | 85 | | /// </summary> |
| | | 86 | | [Parameter] |
| | 21 | 87 | | public bool HasUnsavedChanges { get; set; } |
| | | 88 | | |
| | | 89 | | /// <summary> |
| | | 90 | | /// Display text for last save time (e.g., "just now"). |
| | | 91 | | /// </summary> |
| | | 92 | | [Parameter] |
| | 21 | 93 | | public string? LastSaveTime { get; set; } |
| | | 94 | | |
| | | 95 | | #endregion |
| | | 96 | | |
| | | 97 | | #region Event Callbacks |
| | | 98 | | |
| | | 99 | | /// <summary> |
| | | 100 | | /// Raised when the Save button is clicked. |
| | | 101 | | /// </summary> |
| | | 102 | | [Parameter] |
| | 2 | 103 | | public EventCallback OnSave { get; set; } |
| | | 104 | | |
| | | 105 | | /// <summary> |
| | | 106 | | /// Raised when the Delete button is clicked. |
| | | 107 | | /// </summary> |
| | | 108 | | [Parameter] |
| | 2 | 109 | | public EventCallback OnDelete { get; set; } |
| | | 110 | | |
| | | 111 | | /// <summary> |
| | | 112 | | /// Raised when the Auto-Link button is clicked. |
| | | 113 | | /// </summary> |
| | | 114 | | [Parameter] |
| | 2 | 115 | | public EventCallback OnAutoLink { get; set; } |
| | | 116 | | |
| | | 117 | | /// <summary> |
| | | 118 | | /// Raised when the New Child button is clicked. |
| | | 119 | | /// </summary> |
| | | 120 | | [Parameter] |
| | 2 | 121 | | public EventCallback OnCreateChild { get; set; } |
| | | 122 | | |
| | | 123 | | #endregion |
| | | 124 | | |
| | | 125 | | #region Event Handlers |
| | | 126 | | |
| | | 127 | | private async Task OnSaveClick() |
| | | 128 | | { |
| | 1 | 129 | | await OnSave.InvokeAsync(); |
| | 1 | 130 | | } |
| | | 131 | | |
| | | 132 | | private async Task OnDeleteClick() |
| | | 133 | | { |
| | 1 | 134 | | await OnDelete.InvokeAsync(); |
| | 1 | 135 | | } |
| | | 136 | | |
| | | 137 | | private async Task OnAutoLinkClick() |
| | | 138 | | { |
| | 1 | 139 | | await OnAutoLink.InvokeAsync(); |
| | 1 | 140 | | } |
| | | 141 | | |
| | | 142 | | private async Task OnCreateChildClick() |
| | | 143 | | { |
| | 1 | 144 | | await OnCreateChild.InvokeAsync(); |
| | 1 | 145 | | } |
| | | 146 | | |
| | | 147 | | #endregion |
| | | 148 | | } |