Merge pull request #1663 from sbwalker/dev

file manager component improvements
This commit is contained in:
Shaun Walker 2021-09-16 17:58:20 -04:00 committed by GitHub
commit 2ac069082d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 21 additions and 18 deletions

View File

@ -59,7 +59,7 @@
</div>
}
</div>
@if (_image != string.Empty && ShowImage)
@if (_image != string.Empty)
{
<div class="col-auto">
@((MarkupString) _image)
@ -126,7 +126,7 @@
public EventCallback<int> OnUpload { get; set; } // optional - executes a method in the calling component when a file is uploaded
[Parameter]
public EventCallback<int> OnChange { get; set; } // optional - executes a method in the calling component when a file is selected
public EventCallback<int> OnSelect { get; set; } // optional - executes a method in the calling component when a file is selected
[Parameter]
public EventCallback<int> OnDelete { get; set; } // optional - executes a method in the calling component when a file is deleted
@ -138,6 +138,11 @@
_id = Id;
}
if (!ShowFiles)
{
ShowImage = false;
}
if (!string.IsNullOrEmpty(Folder))
{
_folders = new List<Folder> { new Folder { FolderId = -1, Name = Folder } };
@ -154,12 +159,14 @@
if (file != null)
{
FolderId = file.FolderId;
await OnSelect.InvokeAsync(FileId);
}
else
{
FileId = -1; // file does not exist
}
}
await SetImage();
if (!string.IsNullOrEmpty(Filter))
@ -237,7 +244,10 @@
{
_message = string.Empty;
FileId = int.Parse((string)e.Value);
await OnChange.InvokeAsync(FileId);
if (FileId != -1)
{
await OnSelect.InvokeAsync(FileId);
}
await SetImage();
StateHasChanged();
@ -250,7 +260,7 @@
if (FileId != -1)
{
_file = await FileService.GetFileAsync(FileId);
if (_file != null && _file.ImageHeight != 0 && _file.ImageWidth != 0)
if (_file != null && ShowImage && _file.ImageHeight != 0 && _file.ImageWidth != 0)
{
var maxwidth = 200;
var maxheight = 200;
@ -292,21 +302,14 @@
_message = Localizer["Success.File.Upload"];
_messagetype = MessageType.Success;
// set FileId to first file in upload collection
await GetFiles();
if (upload.Length == 1)
var file = _files.Where(item => item.Name == upload[0]).FirstOrDefault();
if (file != null)
{
var file = _files.Where(item => item.Name == upload[0]).FirstOrDefault();
if (file != null)
{
FileId = file.FileId;
await SetImage();
await OnUpload.InvokeAsync(FileId);
}
}
else
{
await OnUpload.InvokeAsync(-1);
FileId = file.FileId;
await SetImage();
await OnUpload.InvokeAsync(FileId);
}
StateHasChanged();
}

View File

@ -136,7 +136,7 @@ namespace Oqtane.Repository
Permissions = new List<Permission>
{
new Permission(PermissionNames.Browse, RoleNames.Admin, true),
new Permission(PermissionNames.View, RoleNames.Admin, true),
new Permission(PermissionNames.View, RoleNames.Everyone, true),
new Permission(PermissionNames.Edit, RoleNames.Admin, true)
}.EncodePermissions()
});