mirror of https://github.com/abpframework/abp.git
14 changed files with 138 additions and 6 deletions
@ -0,0 +1,16 @@ |
|||||
|
@model Volo.Abp.AspNetCore.Mvc.UI.Alerts.AlertList |
||||
|
@if (Model.Any()) |
||||
|
{ |
||||
|
<div id="AbpPageAlerts"> |
||||
|
@foreach (var alertMessage in Model) |
||||
|
{ |
||||
|
<abp-alert alert-type="@alertMessage.Type" dismissible="@alertMessage.Dismissible"> |
||||
|
@if (alertMessage.Title != null) |
||||
|
{ |
||||
|
<h4>@alertMessage.Title</h4> |
||||
|
} |
||||
|
@alertMessage.Text |
||||
|
</abp-alert> |
||||
|
} |
||||
|
</div> |
||||
|
} |
||||
@ -0,0 +1,20 @@ |
|||||
|
using Microsoft.AspNetCore.Mvc; |
||||
|
using Volo.Abp.AspNetCore.Mvc.UI.Alerts; |
||||
|
|
||||
|
namespace Volo.Abp.AspNetCore.Mvc.UI.Theme.Basic.Themes.Basic.Components.PageAlerts |
||||
|
{ |
||||
|
public class PageAlertsViewComponent : AbpViewComponent |
||||
|
{ |
||||
|
private readonly IAlertManager _alertManager; |
||||
|
|
||||
|
public PageAlertsViewComponent(IAlertManager alertManager) |
||||
|
{ |
||||
|
_alertManager = alertManager; |
||||
|
} |
||||
|
|
||||
|
public IViewComponentResult Invoke(string name) |
||||
|
{ |
||||
|
return View("~/Themes/Basic/Components/PageAlerts/Default.cshtml", _alertManager.Alerts); |
||||
|
} |
||||
|
} |
||||
|
} |
||||
@ -0,0 +1,32 @@ |
|||||
|
using System.Collections.Generic; |
||||
|
|
||||
|
namespace Volo.Abp.AspNetCore.Mvc.UI.Alerts |
||||
|
{ |
||||
|
public class AlertList : List<AlertMessage> |
||||
|
{ |
||||
|
public void Add(AlertType type, string text, string title = null, bool dismissible = true) |
||||
|
{ |
||||
|
Add(new AlertMessage(type, text, title, dismissible)); |
||||
|
} |
||||
|
|
||||
|
public void Info(string text, string title = null, bool dismissible = true) |
||||
|
{ |
||||
|
Add(new AlertMessage(AlertType.Info, text, title, dismissible)); |
||||
|
} |
||||
|
|
||||
|
public void Warning(string text, string title = null, bool dismissible = true) |
||||
|
{ |
||||
|
Add(new AlertMessage(AlertType.Warning, text, title, dismissible)); |
||||
|
} |
||||
|
|
||||
|
public void Danger(string text, string title = null, bool dismissible = true) |
||||
|
{ |
||||
|
Add(new AlertMessage(AlertType.Danger, text, title, dismissible)); |
||||
|
} |
||||
|
|
||||
|
public void Success(string text, string title = null, bool dismissible = true) |
||||
|
{ |
||||
|
Add(new AlertMessage(AlertType.Success, text, title, dismissible)); |
||||
|
} |
||||
|
} |
||||
|
} |
||||
@ -0,0 +1,14 @@ |
|||||
|
using Volo.Abp.DependencyInjection; |
||||
|
|
||||
|
namespace Volo.Abp.AspNetCore.Mvc.UI.Alerts |
||||
|
{ |
||||
|
public class AlertManager : IAlertManager, IScopedDependency |
||||
|
{ |
||||
|
public AlertList Alerts { get; } |
||||
|
|
||||
|
public AlertManager() |
||||
|
{ |
||||
|
Alerts = new AlertList(); |
||||
|
} |
||||
|
} |
||||
|
} |
||||
@ -0,0 +1,30 @@ |
|||||
|
using JetBrains.Annotations; |
||||
|
|
||||
|
namespace Volo.Abp.AspNetCore.Mvc.UI.Alerts |
||||
|
{ |
||||
|
public class AlertMessage |
||||
|
{ |
||||
|
[NotNull] |
||||
|
public string Text |
||||
|
{ |
||||
|
get => _text; |
||||
|
set => _text = Check.NotNullOrWhiteSpace(value, nameof(value)); |
||||
|
} |
||||
|
private string _text; |
||||
|
|
||||
|
public AlertType Type { get; set; } |
||||
|
|
||||
|
[CanBeNull] |
||||
|
public string Title { get; set; } |
||||
|
|
||||
|
public bool Dismissible { get; set; } |
||||
|
|
||||
|
public AlertMessage(AlertType type, [NotNull] string text, string title = null, bool dismissible = true) |
||||
|
{ |
||||
|
Type = type; |
||||
|
Text = Check.NotNullOrWhiteSpace(text, nameof(text)); |
||||
|
Title = title; |
||||
|
Dismissible = dismissible; |
||||
|
} |
||||
|
} |
||||
|
} |
||||
@ -1,6 +1,6 @@ |
|||||
namespace Volo.Abp.AspNetCore.Mvc.UI.Bootstrap.TagHelpers.Alert |
namespace Volo.Abp.AspNetCore.Mvc.UI.Alerts |
||||
{ |
{ |
||||
public enum AbpAlertType |
public enum AlertType |
||||
{ |
{ |
||||
Default, |
Default, |
||||
Primary, |
Primary, |
||||
@ -0,0 +1,7 @@ |
|||||
|
namespace Volo.Abp.AspNetCore.Mvc.UI.Alerts |
||||
|
{ |
||||
|
public interface IAlertManager |
||||
|
{ |
||||
|
AlertList Alerts { get; } |
||||
|
} |
||||
|
} |
||||
Loading…
Reference in new issue