ModalContainer.razor 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  1. @if (WebReport.EnableModalDialog)
  2. {
  3. @*CONTENT*@
  4. <div class="fr-webreport-popup" @onclick="CancelClick">
  5. <div class="fr-webreport-popup-content" @onclick="() => { }" @onclick:stopPropagation="true" @onclick:preventDefault="true">
  6. <ModalContainerContent WebReport="WebReport" ExportParameters="ExportParameters" />
  7. @*BUTTONS*@
  8. <div class="fr-webreport-popup-content-buttons">
  9. <button class="fr-webreport-popup-content-btn-submit fr-webreport-popup-content-btn-cancel" @onclick="CancelClick">@LocalizedCancel</button>
  10. <button class="fr-webreport-popup-content-btn-submit @OkButtonErrorClass" @onclick="async () => await OkClick()">OK</button>
  11. </div>
  12. </div>
  13. </div>
  14. }
  15. @if (NeedPopup)
  16. {
  17. <PopupNotification @ref="_popup" CssClass="@PopupCssClass"/>
  18. }
  19. @code {
  20. private string LocalizedCancel;
  21. private PopupNotification _popup;
  22. private const string PopupCssClass = "hide";
  23. #if !WASM
  24. private const bool NeedPopup = true;
  25. private string LocalizedFailure;
  26. private string LocalizedSuccess;
  27. private async Task ShowPopup(string message, string cssClass)
  28. {
  29. await _popup.ShowPopup(message, cssClass);
  30. }
  31. private async Task ShowPositivePopup()
  32. {
  33. await ShowPopup(LocalizedSuccess, "positive");
  34. }
  35. private async Task ShowNegativePopup()
  36. {
  37. await ShowPopup(LocalizedFailure, "negative");
  38. }
  39. #else
  40. private const bool NeedPopup = false;
  41. #endif
  42. [Parameter]
  43. public WebReport WebReport { get; set; }
  44. internal void Update()
  45. {
  46. StateHasChanged();
  47. }
  48. protected override void OnParametersSet()
  49. {
  50. var res = WebReport.Res;
  51. res.Root("Buttons");
  52. LocalizedCancel = res.Get("Cancel");
  53. #if !WASM
  54. res.Root("Export,Email");
  55. LocalizedFailure = res.Get("ErrorEmailSending");
  56. LocalizedSuccess = res.Get("SuccessfulEmailSending");
  57. #endif
  58. }
  59. }