/
SettingViewComponent.cs
46 lines (43 loc) · 1.7 KB
/
SettingViewComponent.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
using System.Collections.Generic;
using System.Linq;
using EasyAbp.Abp.SettingUi.Dto;
using EasyAbp.Abp.SettingUi.Extensions;
using Microsoft.AspNetCore.Mvc;
using Volo.Abp.AspNetCore.Mvc;
using Volo.Abp.AspNetCore.Mvc.UI.Widgets;
namespace EasyAbp.Abp.SettingUi.Web.Pages.Components.SettingUi
{
[Widget(StyleFiles = new[] { "/Pages/Components/SettingUi/Default.css" })]
public class SettingViewComponent : AbpViewComponent
{
public IViewComponentResult Invoke(SettingGroup parameter)
{
var settingInfos = parameter.SettingInfos.Select(si => new SettingHtmlInfo(si));
return View("~/Pages/Components/SettingUi/Default.cshtml", settingInfos);
}
}
public class SettingHtmlInfo
{
public string Name { get; }
public string DisplayName { get; }
public string Description { get; }
public string Value { get; }
public string Group1 { get; }
public string Group2 { get; }
public string FormName { get; }
public string Type { get; }
public Dictionary<string, object> Properties { get; }
public SettingHtmlInfo(SettingInfo settingInfo)
{
Name = settingInfo.Name;
DisplayName = settingInfo.DisplayName;
Description = settingInfo.Description;
Value = settingInfo.Value;
Group1 = (string)settingInfo.Properties[SettingUiConst.Group1];
Group2 = (string)settingInfo.Properties[SettingUiConst.Group2];
FormName = SettingUiConst.FormNamePrefix + Name.DotToUnderscore();
Type = (string)settingInfo.Properties[SettingUiConst.Type];
Properties = settingInfo.Properties;
}
}
}