mirror of
https://github.com/wismna/ModernKeePass.git
synced 2025-10-03 15:40:18 -04:00
Groups can now also be manually reordered
Design improvements
This commit is contained in:
@@ -97,6 +97,7 @@
|
||||
<Compile Include="Entry\Queries\GetEntry\GetEntryQuery.cs" />
|
||||
<Compile Include="Group\Commands\DeleteEntry\DeleteEntryCommand.cs" />
|
||||
<Compile Include="Group\Commands\DeleteGroup\DeleteGroupCommand.cs" />
|
||||
<Compile Include="Group\Commands\MoveGroup\MoveGroupCommand.cs" />
|
||||
<Compile Include="Group\Commands\UpdateGroup\UpdateGroupCommand.cs" />
|
||||
<Compile Include="Group\Queries\GetAllGroups\GetAllGroupsQuery.cs" />
|
||||
<Compile Include="Group\Queries\GetGroup\GetGroupQuery.cs" />
|
||||
|
@@ -41,6 +41,7 @@ namespace ModernKeePass.Application.Common.Interfaces
|
||||
|
||||
GroupEntity GetGroup(string id);
|
||||
Task AddGroup(string parentGroupId, string groupId);
|
||||
Task MoveGroup(string parentGroupId, string groupId, int index);
|
||||
void UpdateGroup(GroupEntity group);
|
||||
Task RemoveGroup(string parentGroupId, string groupId);
|
||||
void DeleteEntity(string entityId);
|
||||
|
@@ -0,0 +1,33 @@
|
||||
using System.Threading.Tasks;
|
||||
using MediatR;
|
||||
using ModernKeePass.Application.Common.Interfaces;
|
||||
using ModernKeePass.Application.Group.Models;
|
||||
using ModernKeePass.Domain.Exceptions;
|
||||
|
||||
namespace ModernKeePass.Application.Group.Commands.MoveGroup
|
||||
{
|
||||
public class MoveGroupCommand : IRequest
|
||||
{
|
||||
public GroupVm ParentGroup { get; set; }
|
||||
public GroupVm Group { get; set; }
|
||||
public int Index { get; set; }
|
||||
|
||||
public class MoveGroupCommandHandler : IAsyncRequestHandler<MoveGroupCommand>
|
||||
{
|
||||
private readonly IDatabaseProxy _database;
|
||||
|
||||
public MoveGroupCommandHandler(IDatabaseProxy database)
|
||||
{
|
||||
_database = database;
|
||||
}
|
||||
|
||||
public async Task Handle(MoveGroupCommand message)
|
||||
{
|
||||
if (!_database.IsOpen) throw new DatabaseClosedException();
|
||||
|
||||
await _database.MoveGroup(message.ParentGroup.Id, message.Group.Id, message.Index);
|
||||
message.ParentGroup.SubGroups.Insert(message.Index, message.Group);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user