59 lines
2.0 KiB
Plaintext
59 lines
2.0 KiB
Plaintext
@using Butter.Dtos.Folder
|
|
@using MilkStream.Services
|
|
@inject FoldersService FoldersService
|
|
@inject NavigationManager NavigationManager
|
|
|
|
<div class="card mb-3">
|
|
<div class="card-body align-items-center">
|
|
<div class="d-flex flex-row flex-grow-1 align-items-center">
|
|
<i class="bi bi-folder2 ms-3 mx-1"></i><p class="mx-1 mb-0 @Display">@Folder.BasePath</p>
|
|
<input class="form-control form-control-sm mx-1 @Edit" type="text" @bind="Folder.BasePath"/>
|
|
<button class="btn btn-sm btn-success @Edit" @onclick="OnConfirmEdit"><i class="bi bi-check"></i></button>
|
|
<div class="ms-auto form-switch">
|
|
<input class="form-check-input m-1" type="checkbox" id="@Folder.Id" @bind="@Folder.Active"/>
|
|
</div>
|
|
<button class="btn btn-outline-warning btn-sm @Display" @onclick="OnEdit"><i class="bi bi-pencil"></i></button>
|
|
<button class="btn btn-outline-danger btn-sm mx-1" @onclick="OnDelete"><i class="bi bi-folder-minus"></i></button>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
@code {
|
|
bool editing;
|
|
string Display => editing ? "d-none" : "";
|
|
string Edit => editing ? "" : "d-none";
|
|
|
|
[Parameter]
|
|
public FolderFullDto Folder { get; set; } = new FolderFullDto();
|
|
|
|
protected override void OnInitialized() {
|
|
FoldersService.SaveFolders += (_, _) => FoldersService.UpdateFolder(
|
|
Folder.Id,
|
|
new FolderUpdateDto() {
|
|
Active = Folder.Active,
|
|
BasePath = Folder.BasePath
|
|
}
|
|
);
|
|
}
|
|
|
|
void OnEdit() {
|
|
editing = true;
|
|
}
|
|
|
|
void OnConfirmEdit() {
|
|
FoldersService.UpdateFolder(
|
|
Folder.Id,
|
|
new FolderUpdateDto() {
|
|
Active = Folder.Active,
|
|
BasePath = Folder.BasePath
|
|
}
|
|
);
|
|
editing = false;
|
|
}
|
|
|
|
void OnDelete() {
|
|
FoldersService.RemoveFolder(Folder.Id);
|
|
NavigationManager.Refresh(true);
|
|
}
|
|
|
|
} |