File tree Expand file tree Collapse file tree
src/Eurofurence.App.Backoffice/Components Expand file tree Collapse file tree Original file line number Diff line number Diff line change 5454 <MudTooltip >
5555 <ChildContent >
5656 <div style =" width : 500px ;" >
57- <ImageField ImageResponse =" @_bannerImage" ImageChanged =" OnBannerImageUploaded" ImageUploadError =" OnImageUploadError" />
57+ <ImageField ImageResponse =" @_bannerImage" UploadStarted = " OnImageUploadStarted " ImageChanged =" OnBannerImageUploaded" ImageUploadError =" OnImageUploadError" Disabled = " _busy " />
5858 </div >
5959 </ChildContent >
6060 <TooltipContent >
6969 <MudTooltip >
7070 <ChildContent >
7171 <div style =" width : 500px ;" >
72- <ImageField ImageResponse =" @_posterImage" ImageChanged =" OnPosterImageUploaded" ImageUploadError =" OnImageUploadError" />
72+ <ImageField ImageResponse =" @_posterImage" UploadStarted = " OnImageUploadStarted " ImageChanged =" OnPosterImageUploaded" ImageUploadError =" OnImageUploadError" Disabled = " _busy " />
7373 </div >
7474 </ChildContent >
7575 <TooltipContent >
176176 return null ;
177177 }
178178
179+ /// <summary >
180+ /// Called when an image uploaded is started.
181+ /// </summary >
182+ private void OnImageUploadStarted ()
183+ {
184+ _busy = true ;
185+ }
186+
179187 /// <summary >
180188 /// Called when an error occurs while uploading an image.
181189 /// </summary >
182190 private void OnImageUploadError ()
183191 {
192+ _busy = false ;
184193 Snackbar .Add (" Error uploading image." , Severity .Error );
185194 }
186195
187196 /// <summary >
188- /// Called when a banner image is uploaded.
197+ /// Called when a banner image has been uploaded.
189198 /// </summary >
190199 /// <param name =" image" >The uploaded image.</param >
191200 private void OnBannerImageUploaded (ImageResponse ? image )
192201 {
202+ _busy = false ;
193203 _bannerImage = image ;
194204 Snackbar .Add (" Banner image successfully uploaded." , Severity .Success );
195205 }
196206
197207 /// <summary >
198- /// Called when a poster image is uploaded.
208+ /// Called when a poster image has been uploaded.
199209 /// </summary >
200210 /// <param name =" image" >The uploaded image.</param >
201211 private void OnPosterImageUploaded (ImageResponse ? image )
202212 {
213+ _busy = false ;
203214 _posterImage = image ;
204215 Snackbar .Add (" Poster image successfully uploaded." , Severity .Success );
205216 }
Original file line number Diff line number Diff line change 2727 {
2828 <MudGrid >
2929 <MudItem xl =" 6" md =" 6" >
30- <MudFileUpload T =" IBrowserFile" FilesChanged =" UploadImage" Style =" margin-top: 10px;" />
30+ <MudFileUpload T =" IBrowserFile" Disabled = " IsUploading || Disabled " FilesChanged =" UploadImage" Style =" margin-top: 10px;" />
3131 </MudItem >
3232 <MudItem xl =" 6" md =" 6" >
33- <MudButton Variant =" Variant.Outlined" Color =" Color.Error" OnClick =" ClearImage" FullWidth =" true" Style =" margin-top: 10px;" >
33+ <MudButton Variant =" Variant.Outlined" Color =" Color.Error" Disabled = " IsUploading || Disabled " OnClick =" ClearImage" FullWidth =" true" Style =" margin-top: 10px;" >
3434 Remove
3535 </MudButton >
3636 </MudItem >
3737 </MudGrid >
3838 }
3939 else
4040 {
41- <MudFileUpload T =" IBrowserFile" FilesChanged =" UploadImage" Style =" margin-top: 10px;" />
41+ <MudFileUpload T =" IBrowserFile" Disabled = " IsUploading || Disabled " FilesChanged =" UploadImage" Style =" margin-top: 10px;" />
4242 }
4343</div >
4444
5050 [Parameter ]
5151 public ImageResponse ? ImageResponse { get ; set ; }
5252
53+ /// <summary >
54+ /// Event raised when the image upload is started.
55+ /// </summary >
56+ [Parameter ]
57+ public EventCallback UploadStarted { get ; set ; }
58+
5359 /// <summary >
5460 /// Event raised when the image is changed.
5561 /// </summary >
6369 [Parameter ]
6470 public EventCallback ImageUploadError { get ; set ; }
6571
72+ /// <summary >
73+ /// Disables upload and remove buttons.
74+ /// </summary >
75+ [Parameter ]
76+ public bool Disabled { get ; set ; }
77+
6678 /// <summary >
6779 /// Determines whether the remove button should be hidden.
6880 /// </summary >
8395 }
8496
8597 IsUploading = true ;
98+ await UploadStarted .InvokeAsync ();
99+
86100 StateHasChanged ();
87101
88102 try
You can’t perform that action at this time.
0 commit comments