mirror of
https://github.com/wismna/ModernKeePass.git
synced 2025-10-03 15:40:18 -04:00
Create entries and groups put them in Edit mode (as before)
Search now uses KeePassLib search Code cleanup
This commit is contained in:
@@ -181,12 +181,6 @@ namespace ModernKeePass.ViewModels
|
||||
set { SetProperty(ref _isEditMode, value); }
|
||||
}
|
||||
|
||||
public bool IsVisible
|
||||
{
|
||||
get { return _isVisible; }
|
||||
set { SetProperty(ref _isVisible, value); }
|
||||
}
|
||||
|
||||
public bool IsRevealPassword
|
||||
{
|
||||
get { return _isRevealPassword; }
|
||||
@@ -205,21 +199,18 @@ namespace ModernKeePass.ViewModels
|
||||
private bool _isEditMode;
|
||||
private bool _isRevealPassword;
|
||||
private double _passwordLength = 25;
|
||||
private bool _isVisible = true;
|
||||
private bool _isSelected;
|
||||
|
||||
public EntryDetailVm() { }
|
||||
|
||||
internal EntryDetailVm(string entryId, bool isNewEntry = false) : this(entryId, App.Services.GetRequiredService<IMediator>(), isNewEntry) { }
|
||||
internal EntryDetailVm(string entryId) : this(entryId, App.Services.GetRequiredService<IMediator>()) { }
|
||||
|
||||
public EntryDetailVm(string entryId, IMediator mediator, bool isNewEntry = false)
|
||||
public EntryDetailVm(string entryId, IMediator mediator)
|
||||
{
|
||||
_mediator = mediator;
|
||||
_entry = _mediator.Send(new GetEntryQuery {Id = entryId}).GetAwaiter().GetResult();
|
||||
_parent = _mediator.Send(new GetGroupQuery {Id = _entry.ParentGroupId}).GetAwaiter().GetResult();
|
||||
History = _entry.History;
|
||||
_isEditMode = isNewEntry;
|
||||
if (isNewEntry) GeneratePassword().GetAwaiter().GetResult();
|
||||
IsSelected = true;
|
||||
|
||||
SaveCommand = new RelayCommand(async () => await SaveChanges(), () => Database.IsDirty);
|
||||
|
@@ -23,6 +23,7 @@ using ModernKeePass.Application.Group.Commands.SortEntries;
|
||||
using ModernKeePass.Application.Group.Commands.SortGroups;
|
||||
using ModernKeePass.Application.Group.Models;
|
||||
using ModernKeePass.Application.Group.Queries.GetGroup;
|
||||
using ModernKeePass.Application.Group.Queries.SearchEntries;
|
||||
using ModernKeePass.Common;
|
||||
using ModernKeePass.Domain.AOP;
|
||||
using ModernKeePass.Domain.Enums;
|
||||
@@ -35,22 +36,7 @@ namespace ModernKeePass.ViewModels
|
||||
public ObservableCollection<EntryVm> Entries { get; }
|
||||
|
||||
public ObservableCollection<GroupVm> Groups { get; }
|
||||
|
||||
public IEnumerable<EntryVm> SubEntries
|
||||
{
|
||||
get
|
||||
{
|
||||
var subEntries = new List<EntryVm>();
|
||||
subEntries.AddRange(Entries);
|
||||
foreach (var group in Groups)
|
||||
{
|
||||
subEntries.AddRange(group.Entries);
|
||||
}
|
||||
|
||||
return subEntries;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public bool IsNotRoot => Database.RootGroupId != _group.Id;
|
||||
|
||||
public IOrderedEnumerable<IGrouping<char, EntryVm>> EntriesZoomedOut => from e in Entries
|
||||
@@ -83,12 +69,6 @@ namespace ModernKeePass.ViewModels
|
||||
}
|
||||
}
|
||||
|
||||
public bool IsMenuClosed
|
||||
{
|
||||
get { return _isMenuClosed; }
|
||||
set { SetProperty(ref _isMenuClosed, value); }
|
||||
}
|
||||
|
||||
public IEnumerable<GroupVm> BreadCrumb { get; }
|
||||
|
||||
public ICommand SaveCommand { get; }
|
||||
@@ -103,14 +83,13 @@ namespace ModernKeePass.ViewModels
|
||||
private readonly GroupVm _parent;
|
||||
private bool _isEditMode;
|
||||
private EntryVm _reorderedEntry;
|
||||
private bool _isMenuClosed = true;
|
||||
|
||||
public GroupDetailVm() {}
|
||||
|
||||
internal GroupDetailVm(string groupId) : this(groupId, App.Services.GetRequiredService<IMediator>())
|
||||
{ }
|
||||
|
||||
public GroupDetailVm(string groupId, IMediator mediator, bool isEditMode = false)
|
||||
public GroupDetailVm(string groupId, IMediator mediator)
|
||||
{
|
||||
_mediator = mediator;
|
||||
_group = _mediator.Send(new GetGroupQuery { Id = groupId }).GetAwaiter().GetResult();
|
||||
@@ -119,7 +98,6 @@ namespace ModernKeePass.ViewModels
|
||||
_parent = _mediator.Send(new GetGroupQuery { Id = _group.ParentGroupId }).GetAwaiter().GetResult();
|
||||
BreadCrumb = new List<GroupVm> {_parent};
|
||||
}
|
||||
_isEditMode = isEditMode;
|
||||
|
||||
SaveCommand = new RelayCommand(async () => await SaveChanges(), () => Database.IsDirty);
|
||||
SortEntriesCommand = new RelayCommand(async () => await SortEntriesAsync(), () => IsEditMode);
|
||||
@@ -152,6 +130,11 @@ namespace ModernKeePass.ViewModels
|
||||
await _mediator.Send(new RemoveGroupCommand {ParentGroup = _parent, Group = _group });
|
||||
}
|
||||
|
||||
public async Task<IEnumerable<EntryVm>> Search(string queryText)
|
||||
{
|
||||
return await _mediator.Send(new SearchEntriesQuery {GroupId = Id, SearchText = queryText});
|
||||
}
|
||||
|
||||
private async Task SaveChanges()
|
||||
{
|
||||
await _mediator.Send(new SaveDatabaseCommand());
|
||||
|
@@ -10,6 +10,7 @@ using ModernKeePass.Common;
|
||||
using ModernKeePass.Domain.AOP;
|
||||
using ModernKeePass.Domain.Dtos;
|
||||
using ModernKeePass.Domain.Interfaces;
|
||||
using ModernKeePass.Models;
|
||||
using ModernKeePass.Views;
|
||||
|
||||
namespace ModernKeePass.ViewModels
|
||||
@@ -128,7 +129,7 @@ namespace ModernKeePass.ViewModels
|
||||
Title = database.Name,
|
||||
PageType = typeof(GroupDetailPage),
|
||||
Destination = referenceFrame,
|
||||
Parameter = database.RootGroupId,
|
||||
Parameter = new NavigationItem { Id = database.RootGroupId },
|
||||
Group = "Databases",
|
||||
SymbolIcon = Symbol.ProtectedDocument
|
||||
});
|
||||
|
Reference in New Issue
Block a user