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