File tree Expand file tree Collapse file tree 2 files changed +11
-1
lines changed
src/LinkDotNet.Blog.Web/Features/Admin/BlogPostEditor/Components
tests/LinkDotNet.Blog.UnitTests/Web/Features/Admin/BlogPostEditor/Components Expand file tree Collapse file tree 2 files changed +11
-1
lines changed Original file line number Diff line number Diff line change 1
1
@using LinkDotNet .Blog .Domain
2
+ @inject IToastService ToastService
2
3
3
4
<h3 >@Title </h3 >
4
5
93
94
94
95
private CreateNewModel model = new ();
95
96
97
+ private bool ignoreIsDirty ;
98
+
96
99
protected override void OnParametersSet ()
97
100
{
98
101
if (BlogPost == null )
124
127
125
128
private void PreventNavigationWhenDirty (LocationChangingContext context )
126
129
{
127
- if (model .IsDirty )
130
+ if (model .IsDirty && ! ignoreIsDirty )
131
+ {
128
132
context .PreventNavigation ();
133
+ ToastService .ShowWarning (
134
+ " You have unsaved changes. Click on this message to ignore this warning the next time" ,
135
+ onClick : () => ignoreIsDirty = true );
136
+ }
129
137
}
130
138
}
Original file line number Diff line number Diff line change 1
1
using System ;
2
2
using System . Linq ;
3
+ using Blazored . Toast . Services ;
3
4
using Bunit ;
4
5
using LinkDotNet . Blog . Domain ;
5
6
using LinkDotNet . Blog . TestUtilities ;
@@ -14,6 +15,7 @@ public class CreateNewBlogPostTests : TestContext
14
15
public CreateNewBlogPostTests ( )
15
16
{
16
17
ComponentFactories . AddStub < UploadFile > ( ) ;
18
+ Services . AddScoped ( _ => Mock . Of < IToastService > ( ) ) ;
17
19
}
18
20
19
21
[ Fact ]
You can’t perform that action at this time.
0 commit comments