Browse Source

Renamed StyleSrcs to StyleFiles and ScriptSrcs to ScriptFiles

pull/1520/head
Halil İbrahim Kalkan 7 years ago
parent
commit
f186648270
  1. 4
      framework/src/Volo.Abp.AspNetCore.Mvc.UI.Widgets/Volo/Abp/AspNetCore/Mvc/UI/Widgets/WidgetAttribute.cs
  2. 8
      framework/src/Volo.Abp.AspNetCore.Mvc.UI.Widgets/Volo/Abp/AspNetCore/Mvc/UI/Widgets/WidgetDefinition.cs
  3. 5
      samples/DashboardDemo/src/DashboardDemo.Web/Pages/Components/MySimpleWidget/Default.cshtml
  4. 28
      samples/DashboardDemo/src/DashboardDemo.Web/Pages/Components/MySimpleWidget/MySimpleWidgetViewComponent.cs
  5. 7
      samples/DashboardDemo/src/DashboardDemo.Web/Pages/Components/MySimpleWidget/MySimpleWidgetViewModel.cs
  6. 11
      samples/DashboardDemo/src/DashboardDemo.Web/Pages/MyWidgets.cshtml

4
framework/src/Volo.Abp.AspNetCore.Mvc.UI.Widgets/Volo/Abp/AspNetCore/Mvc/UI/Widgets/WidgetAttribute.cs

@ -9,13 +9,13 @@ namespace Volo.Abp.AspNetCore.Mvc.UI.Widgets
public class WidgetAttribute : Attribute
{
[CanBeNull]
public string[] StyleSrcs { get; set; }
public string[] StyleFiles { get; set; }
[CanBeNull]
public Type[] StyleTypes { get; set; }
[CanBeNull]
public string[] ScriptSrcs { get; set; }
public string[] ScriptFiles { get; set; }
[CanBeNull]
public Type[] ScriptTypes { get; set; }

8
framework/src/Volo.Abp.AspNetCore.Mvc.UI.Widgets/Volo/Abp/AspNetCore/Mvc/UI/Widgets/WidgetDefinition.cs

@ -68,9 +68,9 @@ namespace Volo.Abp.AspNetCore.Mvc.UI.Widgets
{
var styles = new List<WidgetResourceItem>();
if (!widgetAttribute.StyleSrcs.IsNullOrEmpty())
if (!widgetAttribute.StyleFiles.IsNullOrEmpty())
{
styles.AddRange(widgetAttribute.StyleSrcs.Select(src => new WidgetResourceItem(src)));
styles.AddRange(widgetAttribute.StyleFiles.Select(src => new WidgetResourceItem(src)));
}
if (!widgetAttribute.StyleTypes.IsNullOrEmpty())
@ -85,9 +85,9 @@ namespace Volo.Abp.AspNetCore.Mvc.UI.Widgets
{
var scripts = new List<WidgetResourceItem>();
if (!widgetAttribute.ScriptSrcs.IsNullOrEmpty())
if (!widgetAttribute.ScriptFiles.IsNullOrEmpty())
{
scripts.AddRange(widgetAttribute.ScriptSrcs.Select(src => new WidgetResourceItem(src)));
scripts.AddRange(widgetAttribute.ScriptFiles.Select(src => new WidgetResourceItem(src)));
}
if (!widgetAttribute.ScriptTypes.IsNullOrEmpty())

5
samples/DashboardDemo/src/DashboardDemo.Web/Pages/Components/MySimpleWidget/Default.cshtml

@ -1,4 +1,5 @@
<div class="my-simple-widget">
@model DashboardDemo.Web.Pages.Components.MySimpleWidget.MySimpleWidgetViewModel
<div class="my-simple-widget">
<h2>My Simple Widget</h2>
<p>This is a simple widget!</p>
<p>Hello <strong>@Model.Name</strong>! This is a simple widget!</p>
</div>

28
samples/DashboardDemo/src/DashboardDemo.Web/Pages/Components/MySimpleWidget/MySimpleWidgetViewComponent.cs

@ -1,36 +1,18 @@
using System.Collections.Generic;
using Microsoft.AspNetCore.Mvc;
using Microsoft.AspNetCore.Mvc;
using Volo.Abp.AspNetCore.Mvc;
using Volo.Abp.AspNetCore.Mvc.UI.Bundling;
using Volo.Abp.AspNetCore.Mvc.UI.Widgets;
namespace DashboardDemo.Web.Pages.Components.MySimpleWidget
{
[Widget(
StyleTypes = new[] { typeof(MySimpleWidgetStyleBundleContributor) },
ScriptTypes = new[] { typeof(MySimpleWidgetScriptBundleContributor) }
StyleFiles = new[] { "/Pages/Components/MySimpleWidget/Default.css" },
ScriptFiles = new[] { "/Pages/Components/MySimpleWidget/Default.js" }
)]
public class MySimpleWidgetViewComponent : AbpViewComponent
{
public IViewComponentResult Invoke()
public IViewComponentResult Invoke(string name)
{
return View("~/Pages/Components/MySimpleWidget/Default.cshtml");
}
}
public class MySimpleWidgetStyleBundleContributor : BundleContributor
{
public override void ConfigureBundle(BundleConfigurationContext context)
{
context.Files.AddIfNotContains("/Pages/Components/MySimpleWidget/Default.css");
}
}
public class MySimpleWidgetScriptBundleContributor : BundleContributor
{
public override void ConfigureBundle(BundleConfigurationContext context)
{
context.Files.AddIfNotContains("/Pages/Components/MySimpleWidget/Default.js");
return View(new MySimpleWidgetViewModel { Name = name });
}
}
}

7
samples/DashboardDemo/src/DashboardDemo.Web/Pages/Components/MySimpleWidget/MySimpleWidgetViewModel.cs

@ -0,0 +1,7 @@
namespace DashboardDemo.Web.Pages.Components.MySimpleWidget
{
public class MySimpleWidgetViewModel
{
public string Name { get; set; }
}
}

11
samples/DashboardDemo/src/DashboardDemo.Web/Pages/MyWidgets.cshtml

@ -1,9 +1,10 @@
@page
@using DashboardDemo.Web.Pages.Components.MySimpleWidget
@model DashboardDemo.Web.Pages.MyWidgetsModel
@await Component.InvokeAsync(typeof(MySimpleWidgetViewComponent))
<hr />
@await Component.InvokeAsync("MySimpleWidget")
@* Example usage by widget name *@
@await Component.InvokeAsync("MySimpleWidget", new { name = "John" })
<hr />
<vc:my-custom-name-widget></vc:my-custom-name-widget>
@* Example usage by widget type *@
@await Component.InvokeAsync("MySimpleWidget", new { name = "Mete" })
Loading…
Cancel
Save