|
21 | 21 | <FluentTab Label=" Edit Summary" Icon="@(new Icons.Regular.Size20.FormSparkle())" Id="tabEdit"> |
22 | 22 | <EditForm Model="@readingNotes" OnValidSubmit="@HandleValidSubmit" FormName="new_readingNotes"> |
23 | 23 | <FluentStack Orientation="Orientation.Vertical" Width="100%"> |
24 | | - <FluentButton Type="ButtonType.Submit" Appearance="Appearance.Accent">Save</FluentButton> |
| 24 | + |
| 25 | + <FluentButton Type="ButtonType.Submit" Appearance="Appearance.Accent">Save as Draft</FluentButton> |
| 26 | + |
25 | 27 | <DataAnnotationsValidator /> |
| 28 | + |
26 | 29 | <div style="width: 80%;"> |
27 | 30 | <FluentTextField Label="Title" @bind-Value="readingNotes!.Title"/> |
28 | 31 | </div> |
|
32 | 35 | <div style="width: 80%;"> |
33 | 36 | <FluentTextField Label="Published Url" @bind-Value="@readingNotes!.PublishedUrl" style="width: 80%;"/> |
34 | 37 | </div> |
| 38 | + <div style="width: 80%;"> |
| 39 | + <FluentTextArea Placeholder="Introduction" @bind-Value=@readingNotes.Intro Cols="100" Rows="5"></FluentTextArea> |
| 40 | + </div> |
35 | 41 |
|
36 | 42 | <div> |
37 | 43 | @foreach (var note in readingNotes!.Notes) |
@@ -74,19 +80,17 @@ else{ |
74 | 80 | <FluentValidationSummary /> |
75 | 81 | </div> |
76 | 82 | <FluentButton OnClick="@(async () => await Publish())" Type="ButtonType.Button" Appearance="Appearance.Lightweight">Publish</FluentButton> | |
77 | | - <FluentButton Type="ButtonType.Submit" Appearance="Appearance.Accent">Save</FluentButton> |
| 83 | + <FluentButton Type="ButtonType.Submit" Appearance="Appearance.Accent">Save as Draft</FluentButton> |
78 | 84 | </EditForm> |
79 | 85 |
|
80 | 86 | </FluentTab> |
81 | 87 |
|
82 | 88 | <FluentTab Label=" Markdown" Icon="@(new Icons.Regular.Size20.Markdown())" Id="tabMD"> |
83 | | - <FluentLabel Typo="Typography.Body" Color="@Color.Disabled"> Read Only: This Markdown is generated from the form.</FluentLabel> |
84 | | - <FluentTextArea Value="@readingNotesMD" ReadOnly="true" Cols="100" Rows="30"/> |
| 89 | + <FluentTextArea @bind-Value="@readingNotesMD" Cols="100" Rows="30"/> |
85 | 90 | </FluentTab> |
86 | 91 |
|
87 | 92 | <FluentTab Label=" Html" Icon="@(new Icons.Regular.Size20.Code())" Id="tabHTML"> |
88 | | - <FluentLabel Typo="Typography.Body" Color="@Color.Disabled"> Read Only: This HTML is generated from the Markdown.</FluentLabel> |
89 | | - <FluentTextArea Value="@readingNotesHTML" ReadOnly="true" Cols="100" Rows="30"/> |
| 93 | + <FluentTextArea Value="@readingNotesHTML" Cols="100" Rows="30"/> |
90 | 94 | </FluentTab> |
91 | 95 |
|
92 | 96 | </FluentTabs> |
@@ -196,25 +200,44 @@ else{ |
196 | 200 | private void DeleteReadingNote(string category, string RowKey) |
197 | 201 | { |
198 | 202 | readingNotes!.Notes[category].RemoveAll(x => x.RowKey == RowKey); |
199 | | - } |
200 | | - |
| 203 | + } |
| 204 | + |
201 | 205 | private async Task Publish() |
202 | 206 | { |
203 | | - if(readingNotes is not null) |
| 207 | + if (readingNotes is not null) |
204 | 208 | { |
| 209 | + if (string.IsNullOrWhiteSpace(readingNotes.PublishedUrl)) |
| 210 | + { |
| 211 | + toastService.ShowError("Published Url is required to publish."); |
| 212 | + return; |
| 213 | + } |
| 214 | + |
| 215 | + // Save markdown to blob storage only if readingNotesMD is not null or empty |
| 216 | + if (!string.IsNullOrWhiteSpace(readingNotesMD)) |
| 217 | + { |
| 218 | + var markdownSaved = await client.SaveReadingNotesMarkdown(readingNotesMD, readingNotes.Number); |
| 219 | + if (!markdownSaved) |
| 220 | + { |
| 221 | + toastService.ShowError("Failed to save markdown file."); |
| 222 | + return; |
| 223 | + } |
| 224 | + } |
| 225 | + |
205 | 226 | await HandleValidSubmit(); |
206 | 227 | var settings = await client.GetSettings(); |
207 | | - if(settings is not null) |
| 228 | + if (settings is not null) |
208 | 229 | { |
209 | 230 | var cnt = Convert.ToInt32(settings!.ReadingNotesCounter); |
210 | 231 | // Only increment if the current Summary is the most recent one. |
211 | | - if(cnt == Convert.ToInt32(readingNotes!.Number)) |
| 232 | + if (cnt == Convert.ToInt32(readingNotes!.Number)) |
212 | 233 | { |
213 | 234 | cnt++; |
214 | 235 | settings.ReadingNotesCounter = (cnt).ToString(); |
215 | 236 | await client.SaveSettings(settings); |
216 | 237 | } |
217 | 238 | } |
| 239 | + |
| 240 | + toastService.ShowSuccess("Reading notes published successfully!"); |
218 | 241 | } |
219 | 242 | } |
220 | 243 | } |
|
0 commit comments