Introduction of the template FilesWithEditor

This commit is contained in:
2020-04-16 00:49:34 +02:00
parent 0af8f20db1
commit c584733ab1
23 changed files with 31565 additions and 48 deletions
+3
View File
@@ -0,0 +1,3 @@
@inherits FileItemBase
+16
View File
@@ -0,0 +1,16 @@
using Microsoft.AspNetCore.Components;
using Seenginx.Models;
using System;
using System.Collections.Generic;
using System.Text;
namespace Seenginx.Components
{
public class FileItemBase : ComponentBase
{
[Parameter]
public ConfigFile File { get; set; }
}
}
+65
View File
@@ -0,0 +1,65 @@
@typeparam CFile
<div class="tile is-ancestor">
<div class="tile is-parent is-vertical is-3">
<div class="content">
<p>
@foreach (var filter in Filters)
{
<span class="tag is-light">@filter</span>
}
</p>
</div>
<div class="content">
<div class="field">
<div class="control">
<InputText Value="SearchInput" ValueChanged="OnSearchChanged" class="input is-primary" type="text" placeholder="Search..." />
</div>
</div>
</div>
<div class="content">
<aside class="menu">
<ul class="menu-list">
@foreach (var file in Files)
{
<li>
<FileItem File="file" @onclick="OnFileClick(file)"></FileItem>
</li>
}
<li><a>Dashboard</a></li>
<li><a>Customers</a></li>
</ul>
</aside>
</div>
<div class="content">
<div class="buttons has-addons">
<button class="button is-primary">
<span class="icon is-small">
<i class="mdi mdi-plus-box-outline"></i>
</span>
Add
</button>
<button class="button is-warning">
<span class="icon is-small">
<i class="mdi mdi-pencil-box-outline"></i>
</span>
Update
</button>
<button class="button is-danger">
<span class="icon is-small">
<i class="mdi mdi-minus-box-outline"></i>
</span>
Delete
</button>
</div>
</div>
</div>
<div class="tile is-parent is-vertical is-9">
@Editor
</div>
</div>
@@ -0,0 +1,87 @@
using Microsoft.AspNetCore.Components;
using Seenginx.Models;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Seenginx.Components
{
public partial class FilesWithEditor<CFile> : ComponentBase
where CFile : ConfigFile
{
[Parameter]
public List<CFile> Files { get; set; } = new List<CFile>();
[Parameter]
public List<string> Filters { get; set; } = new List<string>();
[Parameter]
public List<int> FilteredOutFiles { get; set; } = new List<int>();
[Parameter]
public EventCallback<string> ApplyFilter { get; set; }
[Parameter]
public RenderFragment<CFile> Editor { get; set; }
[Parameter]
public RenderFragment<CFile> CreateDialog { get; set; }
[Parameter]
public RenderFragment<CFile> UpdateDialog { get; set; }
[Parameter]
public RenderFragment<CFile> DeleteDialog { get; set; }
protected bool IsAnyFileSelected => SelectedFile != default;
private CFile SelectedFile { get; set; }
protected string SearchInput { get; set; }
protected async Task OnDeselectClick()
{
SelectedFile = null;
//Clean on the right
}
protected async Task OnFilterClick(EventArgs e, string filter)
{
await ApplyFilter.InvokeAsync(filter);
for (int index = 0; index < Files.Count; index++)
if (FilteredOutFiles.Contains(index))
Files[index].Hide();
else
Files[index].Unhide();
}
protected async Task OnSearchChanged()
{
if (string.IsNullOrEmpty(SearchInput))
Files.ForEach(f => f.Hide());
else
Files.ForEach(f =>
{
if (f.Name.ToLower().Contains(SearchInput.ToLower()))
f.Unhide();
else
f.Hide();
});
}
protected async Task OnFileClick(CFile file)
{
SelectedFile = file;
}
protected async Task OnCreateFile()
{
}
protected async Task OnUpdateDialog(CFile file)
{
}
protected async Task OnDeleteDialog(CFile file)
{
}
}
}
@@ -14,7 +14,7 @@
<ItemGroup>
<Folder Include="wwwroot\" />
<ProjectReference Include="..\Seenginx.Models\Seenginx.Models.csproj" />
</ItemGroup>
</Project>
+1 -2
View File
@@ -1,3 +1,2 @@
@using Microsoft.AspNetCore.Components.Web
@*@using Radzen*@
@*@using Radzen.Blazor*@
@using Microsoft.AspNetCore.Components.Forms
File diff suppressed because it is too large Load Diff
File diff suppressed because one or more lines are too long
File diff suppressed because it is too large Load Diff
File diff suppressed because one or more lines are too long