Build hierarchy instead of using Automapper

Add entities before removing them
This commit is contained in:
Geoffroy BONNEVILLE
2020-04-01 12:48:36 +02:00
parent 90c592d7ee
commit 57be6bb917
22 changed files with 84 additions and 77 deletions

View File

@@ -39,7 +39,7 @@ namespace ModernKeePass.Application.Database.Commands.CreateDatabase
KeyFilePath = message.KeyFilePath, KeyFilePath = message.KeyFilePath,
Password = message.Password Password = message.Password
}); });
return _mapper.Map<GroupVm>(rootGroup); return GroupVm.BuildHierarchy(null, rootGroup, _mapper);
} }
} }

View File

@@ -28,7 +28,7 @@ namespace ModernKeePass.Application.Database.Queries.GetDatabase
if (database.IsOpen) if (database.IsOpen)
{ {
database.Name = _databaseProxy.Name; database.Name = _databaseProxy.Name;
database.RootGroup = _mapper.Map<GroupVm>(_databaseProxy.RootGroup); database.RootGroup = GroupVm.BuildHierarchy(null, _databaseProxy.RootGroup, _mapper);
database.IsRecycleBinEnabled = _databaseProxy.IsRecycleBinEnabled; database.IsRecycleBinEnabled = _databaseProxy.IsRecycleBinEnabled;
database.RecycleBin = _mapper.Map<GroupVm>(_databaseProxy.RecycleBin); database.RecycleBin = _mapper.Map<GroupVm>(_databaseProxy.RecycleBin);
database.Compression = _databaseProxy.Compression; database.Compression = _databaseProxy.Compression;

View File

@@ -42,30 +42,9 @@ namespace ModernKeePass.Application.Database.Queries.OpenDatabase
KeyFilePath = request.KeyFilePath, KeyFilePath = request.KeyFilePath,
Password = request.Password Password = request.Password
}); });
return BuildHierarchy(null, rootGroup); return GroupVm.BuildHierarchy(null, rootGroup, _mapper);
}
private GroupVm BuildHierarchy(GroupVm parentGroup, GroupEntity groupEntity)
{
var groupVm = _mapper.Map<GroupVm>(groupEntity);
groupVm.ParentGroup = parentGroup;
if (parentGroup != null)
{
groupVm.Breadcrumb.AddRange(parentGroup.Breadcrumb);
groupVm.Breadcrumb.Add(parentGroup);
}
groupVm.Entries = groupEntity.Entries.Select(e =>
{
var entry = _mapper.Map<EntryVm>(e);
entry.ParentGroup = groupVm;
entry.Breadcrumb.AddRange(groupVm.Breadcrumb);
entry.Breadcrumb.Add(groupVm);
return entry;
}).OrderBy(e => e.Title).ToList();
groupVm.SubGroups = groupEntity.SubGroups.Select(g => BuildHierarchy(groupVm, g)).ToList();
return groupVm;
} }
} }
} }
} }

View File

@@ -25,7 +25,7 @@ namespace ModernKeePass.Application.Database.Queries.ReOpenDatabase
if (!_database.IsOpen) throw new DatabaseClosedException(); if (!_database.IsOpen) throw new DatabaseClosedException();
var rootGroup = await _database.ReOpen(); var rootGroup = await _database.ReOpen();
return _mapper.Map<GroupVm>(rootGroup); return GroupVm.BuildHierarchy(null, rootGroup, _mapper);
} }
} }
} }

View File

@@ -37,7 +37,7 @@ namespace ModernKeePass.Application.Entry.Models
public void Mapping(Profile profile) public void Mapping(Profile profile)
{ {
profile.CreateMap<EntryEntity, EntryVm>() profile.CreateMap<EntryEntity, EntryVm>()
//.ForMember(d => d.ParentGroup, opts => opts.MapFrom(s => s.Parent)) .ForMember(d => d.ParentGroup, opts => opts.Ignore())
.ForMember(d => d.Id, opts => opts.MapFrom(s => s.Id)) .ForMember(d => d.Id, opts => opts.MapFrom(s => s.Id))
.ForMember(d => d.Title, opts => opts.MapFrom(s => s.Name)) .ForMember(d => d.Title, opts => opts.MapFrom(s => s.Name))
.ForMember(d => d.Username, opts => opts.MapFrom(s => s.UserName)) .ForMember(d => d.Username, opts => opts.MapFrom(s => s.UserName))

View File

@@ -29,6 +29,7 @@ namespace ModernKeePass.Application.Group.Commands.CreateGroup
var group = _database.CreateGroup(message.ParentGroup.Id, message.Name, message.IsRecycleBin); var group = _database.CreateGroup(message.ParentGroup.Id, message.Name, message.IsRecycleBin);
var groupVm = _mapper.Map<GroupVm>(group); var groupVm = _mapper.Map<GroupVm>(group);
groupVm.ParentGroup = message.ParentGroup;
message.ParentGroup.SubGroups.Add(groupVm); message.ParentGroup.SubGroups.Add(groupVm);
return groupVm; return groupVm;
} }

View File

@@ -1,4 +1,5 @@
using System.Collections.Generic; using System;
using System.Collections.Generic;
using System.Linq; using System.Linq;
using AutoMapper; using AutoMapper;
using ModernKeePass.Application.Common.Interfaces; using ModernKeePass.Application.Common.Interfaces;
@@ -29,13 +30,34 @@ namespace ModernKeePass.Application.Group.Models
public void Mapping(Profile profile) public void Mapping(Profile profile)
{ {
profile.CreateMap<GroupEntity, GroupVm>() profile.CreateMap<GroupEntity, GroupVm>()
//.ForMember(d => d.ParentGroup, opts => opts.MapFrom(s => s.Parent)) .ForMember(d => d.ParentGroup, opts => opts.Ignore())
.ForMember(d => d.Id, opts => opts.MapFrom(s => s.Id)) .ForMember(d => d.Id, opts => opts.MapFrom(s => s.Id))
.ForMember(d => d.Title, opts => opts.MapFrom(s => s.Name)) .ForMember(d => d.Title, opts => opts.MapFrom(s => s.Name))
.ForMember(d => d.Icon, opts => opts.MapFrom(s => s.Icon)); .ForMember(d => d.Icon, opts => opts.MapFrom(s => s.Icon))
//.ForMember(d => d.Entries, opts => opts.MapFrom(s => s.Entries.OrderBy(e => e.Name))) .ForMember(d => d.Entries, opts => opts.Ignore())
//.ForMember(d => d.SubGroups, opts => opts.MapFrom(s => s.SubGroups)); .ForMember(d => d.SubGroups, opts => opts.Ignore());
} }
internal static GroupVm BuildHierarchy(GroupVm parentGroup, GroupEntity groupEntity, IMapper mapper)
{
var groupVm = mapper.Map<GroupVm>(groupEntity);
groupVm.ParentGroup = parentGroup;
if (parentGroup != null)
{
groupVm.Breadcrumb.AddRange(parentGroup.Breadcrumb);
groupVm.Breadcrumb.Add(parentGroup);
}
groupVm.Entries = groupEntity.Entries.Select(e =>
{
var entry = mapper.Map<EntryVm>(e);
entry.ParentGroup = groupVm;
entry.Breadcrumb.AddRange(groupVm.Breadcrumb);
entry.Breadcrumb.Add(groupVm);
return entry;
}).OrderBy(e => e.Title).ToList();
groupVm.SubGroups = groupEntity.SubGroups.Select(g => BuildHierarchy(groupVm, g, mapper)).ToList();
return groupVm;
}
} }
} }

View File

@@ -6,7 +6,7 @@ namespace ModernKeePass.Domain.Entities
{ {
public string Id { get; set; } public string Id { get; set; }
public string Name { get; set; } public string Name { get; set; }
public GroupEntity Parent { get; set; } public GroupEntity ParentGroup { get; set; }
public string ParentId { get; set; } public string ParentId { get; set; }
public DateTimeOffset LastModificationDate { get; set; } public DateTimeOffset LastModificationDate { get; set; }
} }

View File

@@ -19,6 +19,7 @@ namespace ModernKeePass.Infrastructure.KeePass
{ {
Uri url; Uri url;
CreateMap<PwEntry, EntryEntity>() CreateMap<PwEntry, EntryEntity>()
.ForMember(dest => dest.ParentGroup, opt => opt.Ignore())
.ForMember(dest => dest.ParentId, opt => opt.MapFrom(src => src.ParentGroup.Uuid.ToHexString())) .ForMember(dest => dest.ParentId, opt => opt.MapFrom(src => src.ParentGroup.Uuid.ToHexString()))
.ForMember(dest => dest.Id, opt => opt.MapFrom(src => src.Uuid.ToHexString())) .ForMember(dest => dest.Id, opt => opt.MapFrom(src => src.Uuid.ToHexString()))
.ForMember(dest => dest.Name, opt => opt.MapFrom(src => GetEntryValue(src, PwDefs.TitleField))) .ForMember(dest => dest.Name, opt => opt.MapFrom(src => GetEntryValue(src, PwDefs.TitleField)))

View File

@@ -15,13 +15,14 @@ namespace ModernKeePass.Infrastructure.KeePass
private void FromDtoToModel() private void FromDtoToModel()
{ {
CreateMap<PwGroup, GroupEntity>() CreateMap<PwGroup, GroupEntity>()
.ForMember(dest => dest.ParentGroup, opt => opt.Ignore())
.ForMember(d => d.ParentId, opts => opts.MapFrom(s => s.ParentGroup.Uuid.ToHexString())) .ForMember(d => d.ParentId, opts => opts.MapFrom(s => s.ParentGroup.Uuid.ToHexString()))
.ForMember(d => d.Id, opts => opts.MapFrom(s => s.Uuid.ToHexString())) .ForMember(d => d.Id, opts => opts.MapFrom(s => s.Uuid.ToHexString()))
.ForMember(d => d.Name, opts => opts.MapFrom(s => s.Name)) .ForMember(d => d.Name, opts => opts.MapFrom(s => s.Name))
.ForMember(d => d.Icon, opts => opts.MapFrom(s => IconMapper.MapPwIconToIcon(s.IconId))) .ForMember(d => d.Icon, opts => opts.MapFrom(s => IconMapper.MapPwIconToIcon(s.IconId)))
.ForMember(d => d.LastModificationDate, opts => opts.MapFrom(s => s.LastModificationTime)); .ForMember(d => d.LastModificationDate, opts => opts.MapFrom(s => s.LastModificationTime))
//.ForMember(d => d.Entries, opts => opts.MapFrom(s => s.Entries)) .ForMember(d => d.Entries, opts => opts.Ignore())
//.ForMember(d => d.SubGroups, opts => opts.MapFrom(s => s.Groups)); .ForMember(d => d.SubGroups, opts => opts.Ignore());
} }
private void FromModelToDto() private void FromModelToDto()

View File

@@ -340,11 +340,11 @@ namespace ModernKeePass.Infrastructure.KeePass
private GroupEntity BuildHierarchy(GroupEntity parentGroup, PwGroup pwGroup) private GroupEntity BuildHierarchy(GroupEntity parentGroup, PwGroup pwGroup)
{ {
var group = _mapper.Map<GroupEntity>(pwGroup); var group = _mapper.Map<GroupEntity>(pwGroup);
group.Parent = parentGroup; group.ParentGroup = parentGroup;
group.Entries = pwGroup.Entries.Select(e => group.Entries = pwGroup.Entries.Select(e =>
{ {
var entry = _mapper.Map<EntryEntity>(e); var entry = _mapper.Map<EntryEntity>(e);
entry.Parent = group; entry.ParentGroup = group;
return entry; return entry;
}).ToList(); }).ToList();
group.SubGroups = pwGroup.Groups.Select(g => BuildHierarchy(group, g)).ToList(); group.SubGroups = pwGroup.Groups.Select(g => BuildHierarchy(group, g)).ToList();

View File

@@ -44,7 +44,7 @@ namespace ModernKeePass.Actions
public object Execute(object sender, object parameter) public object Execute(object sender, object parameter)
{ {
var resource = new ResourcesService(); var resource = new ResourcesService();
var type = Entity is GroupVm ? "Group" : "Entry"; var type = Entity is GroupDetailVm ? "Group" : "Entry";
var isRecycleOnDelete = _mediator.Send(new GetDatabaseQuery()).GetAwaiter().GetResult().IsRecycleBinEnabled; var isRecycleOnDelete = _mediator.Send(new GetDatabaseQuery()).GetAwaiter().GetResult().IsRecycleBinEnabled;
var message = isRecycleOnDelete var message = isRecycleOnDelete

View File

@@ -22,7 +22,7 @@ using ModernKeePass.Interfaces;
namespace ModernKeePass.ViewModels namespace ModernKeePass.ViewModels
{ {
public class EntryVm : NotifyPropertyChangedBase, IVmEntity, ISelectableModel public class EntryDetailVm : NotifyPropertyChangedBase, IVmEntity, ISelectableModel
{ {
public bool IsRevealPasswordEnabled => !string.IsNullOrEmpty(Password); public bool IsRevealPasswordEnabled => !string.IsNullOrEmpty(Password);
public bool HasExpired => HasExpirationDate && ExpiryDate < DateTime.Now; public bool HasExpired => HasExpirationDate && ExpiryDate < DateTime.Now;
@@ -68,11 +68,7 @@ namespace ModernKeePass.ViewModels
public string UserName public string UserName
{ {
get { return _entry.Username; } get { return _entry.Username; }
set set { _entry.Username = value; }
{
_mediator.Send(new SetFieldValueCommand { EntryId = Id, FieldName = nameof(UserName), FieldValue = value }).Wait();
_entry.Username = value;
}
} }
public string Password public string Password
@@ -225,11 +221,11 @@ namespace ModernKeePass.ViewModels
private double _passwordLength = 25; private double _passwordLength = 25;
private bool _isVisible = true; private bool _isVisible = true;
public EntryVm() { } public EntryDetailVm() { }
internal EntryVm(Application.Entry.Models.EntryVm entry, bool isNewEntry = false) : this(entry, App.Mediator, isNewEntry) { } internal EntryDetailVm(Application.Entry.Models.EntryVm entry, bool isNewEntry = false) : this(entry, App.Mediator, isNewEntry) { }
public EntryVm(Application.Entry.Models.EntryVm entry, IMediator mediator, bool isNewEntry = false) public EntryDetailVm(Application.Entry.Models.EntryVm entry, IMediator mediator, bool isNewEntry = false)
{ {
_entry = entry; _entry = entry;
_mediator = mediator; _mediator = mediator;
@@ -263,19 +259,18 @@ namespace ModernKeePass.ViewModels
public async Task MarkForDelete(string recycleBinTitle) public async Task MarkForDelete(string recycleBinTitle)
{ {
if (_database.IsRecycleBinEnabled && _database.RecycleBin == null) if (_database.IsRecycleBinEnabled && _database.RecycleBin == null)
await _mediator.Send(new CreateGroupCommand { ParentGroup = _database.RootGroup, IsRecycleBin = true, Name = recycleBinTitle}); _database.RecycleBin = await _mediator.Send(new CreateGroupCommand { ParentGroup = _database.RootGroup, IsRecycleBin = true, Name = recycleBinTitle});
await Move(_database.IsRecycleBinEnabled && _entry.ParentGroup == _database.RecycleBin ? _database.RecycleBin : null); await Move(_database.IsRecycleBinEnabled && _entry.ParentGroup != _database.RecycleBin ? _database.RecycleBin : null);
} }
public async Task Move(Application.Group.Models.GroupVm destination) public async Task Move(Application.Group.Models.GroupVm destination)
{ {
await _mediator.Send(new AddEntryCommand { ParentGroup = destination, Entry = _entry });
await _mediator.Send(new RemoveEntryCommand { ParentGroup = _entry.ParentGroup, Entry = _entry }); await _mediator.Send(new RemoveEntryCommand { ParentGroup = _entry.ParentGroup, Entry = _entry });
if (destination == null) if (destination == null)
{ {
await _mediator.Send(new DeleteEntryCommand { Entry = _entry }); await _mediator.Send(new DeleteEntryCommand { Entry = _entry });
return;
} }
await _mediator.Send(new AddEntryCommand { ParentGroup = destination, Entry = _entry });
} }
public async Task CommitDelete() public async Task CommitDelete()
@@ -287,5 +282,10 @@ namespace ModernKeePass.ViewModels
{ {
return _entry; return _entry;
} }
public async Task SetFieldValue(string fieldName, object value)
{
await _mediator.Send(new SetFieldValueCommand { EntryId = Id, FieldName = fieldName, FieldValue = value });
}
} }
} }

View File

@@ -26,7 +26,7 @@ using ModernKeePass.Interfaces;
namespace ModernKeePass.ViewModels namespace ModernKeePass.ViewModels
{ {
public class GroupVm : NotifyPropertyChangedBase, IVmEntity, ISelectableModel public class GroupDetailVm : NotifyPropertyChangedBase, IVmEntity, ISelectableModel
{ {
public ObservableCollection<Application.Entry.Models.EntryVm> Entries => new ObservableCollection<Application.Entry.Models.EntryVm>(_group.Entries); public ObservableCollection<Application.Entry.Models.EntryVm> Entries => new ObservableCollection<Application.Entry.Models.EntryVm>(_group.Entries);
@@ -47,7 +47,6 @@ namespace ModernKeePass.ViewModels
} }
} }
public bool IsNotRoot => _database.RootGroup != _group; public bool IsNotRoot => _database.RootGroup != _group;
public bool ShowRestore => IsNotRoot && _database.RecycleBin != _group; public bool ShowRestore => IsNotRoot && _database.RecycleBin != _group;
@@ -117,12 +116,12 @@ namespace ModernKeePass.ViewModels
private Application.Entry.Models.EntryVm _reorderedEntry; private Application.Entry.Models.EntryVm _reorderedEntry;
private bool _isMenuClosed = true; private bool _isMenuClosed = true;
public GroupVm() {} public GroupDetailVm() {}
internal GroupVm(Application.Group.Models.GroupVm group) : this(group, App.Mediator) internal GroupDetailVm(Application.Group.Models.GroupVm group) : this(group, App.Mediator)
{ } { }
public GroupVm(Application.Group.Models.GroupVm group, IMediator mediator, bool isEditMode = false) public GroupDetailVm(Application.Group.Models.GroupVm group, IMediator mediator, bool isEditMode = false)
{ {
_group = group; _group = group;
_mediator = mediator; _mediator = mediator;
@@ -151,7 +150,7 @@ namespace ModernKeePass.ViewModels
case NotifyCollectionChangedAction.Add: case NotifyCollectionChangedAction.Add:
if (_reorderedEntry == null) if (_reorderedEntry == null)
{ {
var entry = ((EntryVm) e.NewItems[0]).GetEntry(); var entry = ((EntryDetailVm) e.NewItems[0]).GetEntry();
await _mediator.Send(new AddEntryCommand {Entry = entry, ParentGroup = _group}); await _mediator.Send(new AddEntryCommand {Entry = entry, ParentGroup = _group});
} }
else else
@@ -175,20 +174,19 @@ namespace ModernKeePass.ViewModels
public async Task MarkForDelete(string recycleBinTitle) public async Task MarkForDelete(string recycleBinTitle)
{ {
if (_database.IsRecycleBinEnabled && _database.RecycleBin == null) if (_database.IsRecycleBinEnabled && _database.RecycleBin == null)
await _mediator.Send(new CreateGroupCommand {ParentGroup = _database.RootGroup, IsRecycleBin = true, Name = recycleBinTitle}); _database.RecycleBin = await _mediator.Send(new CreateGroupCommand {ParentGroup = _database.RootGroup, IsRecycleBin = true, Name = recycleBinTitle});
await Move(_database.IsRecycleBinEnabled && !IsSelected ? _database.RecycleBin : null); await Move(_database.IsRecycleBinEnabled && !IsSelected ? _database.RecycleBin : null);
((RelayCommand)UndoDeleteCommand).RaiseCanExecuteChanged(); ((RelayCommand)UndoDeleteCommand).RaiseCanExecuteChanged();
} }
public async Task Move(Application.Group.Models.GroupVm destination) public async Task Move(Application.Group.Models.GroupVm destination)
{ {
await _mediator.Send(new AddGroupCommand {ParentGroup = destination, Group = _group});
await _mediator.Send(new RemoveGroupCommand {ParentGroup = _group.ParentGroup, Group = _group}); await _mediator.Send(new RemoveGroupCommand {ParentGroup = _group.ParentGroup, Group = _group});
if (destination == null) if (destination == null)
{ {
await _mediator.Send(new DeleteGroupCommand { Group = _group }); await _mediator.Send(new DeleteGroupCommand { Group = _group });
return;
} }
await _mediator.Send(new AddGroupCommand {ParentGroup = destination, Group = _group});
} }
public async Task CommitDelete() public async Task CommitDelete()

View File

@@ -23,7 +23,7 @@ namespace ModernKeePass.ViewModels
{ {
private readonly IMediator _mediator; private readonly IMediator _mediator;
private readonly DatabaseVm _database; private readonly DatabaseVm _database;
private GroupVm _selectedItem; private GroupDetailVm _selectedItem;
public bool HasRecycleBin public bool HasRecycleBin
{ {
@@ -104,7 +104,7 @@ namespace ModernKeePass.ViewModels
_selectedItem.IsSelected = false; _selectedItem.IsSelected = false;
} }
SetProperty(ref _selectedItem, (GroupVm)value); SetProperty(ref _selectedItem, (GroupDetailVm)value);
if (_selectedItem != null) if (_selectedItem != null)
{ {

View File

@@ -372,7 +372,7 @@
</Style> </Style>
</Page.Resources> </Page.Resources>
<Page.DataContext> <Page.DataContext>
<viewModels:EntryVm /> <viewModels:EntryDetailVm />
</Page.DataContext> </Page.DataContext>
<Grid Background="{ThemeResource ApplicationPageBackgroundThemeBrush}"> <Grid Background="{ThemeResource ApplicationPageBackgroundThemeBrush}">
<Grid.ChildrenTransitions> <Grid.ChildrenTransitions>
@@ -410,7 +410,7 @@
</Style> </Style>
</StackPanel.Resources> </StackPanel.Resources>
<TextBlock x:Uid="EntryLogin" /> <TextBlock x:Uid="EntryLogin" />
<local:TextBoxWithButton x:Uid="LoginTextBox" Text="{Binding UserName, Mode=TwoWay}" Style="{StaticResource EntryTextBoxWithButtonStyle}" ButtonSymbol="&#xE16F;" IsEnabled="{Binding IsSelected}"> <local:TextBoxWithButton x:Uid="LoginTextBox" Text="{Binding UserName, Mode=TwoWay}" LostFocus="Username_OnLostFocus" Style="{StaticResource EntryTextBoxWithButtonStyle}" ButtonSymbol="&#xE16F;" IsEnabled="{Binding IsSelected}">
<interactivity:Interaction.Behaviors> <interactivity:Interaction.Behaviors>
<core:EventTriggerBehavior EventName="ButtonClick"> <core:EventTriggerBehavior EventName="ButtonClick">
<actions:ClipboardAction Text="{Binding UserName}" /> <actions:ClipboardAction Text="{Binding UserName}" />

View File

@@ -14,7 +14,7 @@ namespace ModernKeePass.Views
/// </summary> /// </summary>
public sealed partial class EntryDetailPage public sealed partial class EntryDetailPage
{ {
public EntryVm Model => (EntryVm) DataContext; public EntryDetailVm Model => (EntryDetailVm) DataContext;
/// <summary> /// <summary>
/// NavigationHelper est utilisé sur chaque page pour faciliter la navigation et /// NavigationHelper est utilisé sur chaque page pour faciliter la navigation et
@@ -45,7 +45,7 @@ namespace ModernKeePass.Views
/*if (!(e.Parameter is EntryVm)) return; /*if (!(e.Parameter is EntryVm)) return;
DataContext = (EntryVm)e.Parameter;*/ DataContext = (EntryVm)e.Parameter;*/
var args = e.Parameter as Application.Entry.Models.EntryVm; var args = e.Parameter as Application.Entry.Models.EntryVm;
if (args != null) DataContext = new EntryVm(args); if (args != null) DataContext = new EntryDetailVm(args);
} }
protected override void OnNavigatedFrom(NavigationEventArgs e) protected override void OnNavigatedFrom(NavigationEventArgs e)
@@ -75,5 +75,10 @@ namespace ModernKeePass.Views
break; break;
} }
} }
private async void Username_OnLostFocus(object sender, RoutedEventArgs e)
{
await Model.SetFieldValue(nameof(Model.UserName), ((TextBox) sender).Text);
}
} }
} }

View File

@@ -19,7 +19,7 @@
<converters:InverseBooleanToVisibilityConverter x:Key="InverseBooleanToVisibilityConverter"/> <converters:InverseBooleanToVisibilityConverter x:Key="InverseBooleanToVisibilityConverter"/>
</Page.Resources> </Page.Resources>
<Page.DataContext> <Page.DataContext>
<viewModels:GroupVm /> <viewModels:GroupDetailVm />
</Page.DataContext> </Page.DataContext>
<Grid> <Grid>
<Grid.Resources> <Grid.Resources>

View File

@@ -25,7 +25,7 @@ namespace ModernKeePass.Views
/// process lifetime management /// process lifetime management
/// </summary> /// </summary>
public NavigationHelper NavigationHelper { get; } public NavigationHelper NavigationHelper { get; }
public GroupVm Model => (GroupVm)DataContext; public GroupDetailVm Model => (GroupDetailVm)DataContext;
public GroupDetailPage() public GroupDetailPage()
{ {
@@ -50,12 +50,12 @@ namespace ModernKeePass.Views
var args = e.Parameter as PasswordEventArgs; var args = e.Parameter as PasswordEventArgs;
if (args != null) if (args != null)
DataContext = new GroupVm(args.RootGroup); DataContext = new GroupDetailVm(args.RootGroup);
else else
{ {
var vm = e.Parameter as Application.Group.Models.GroupVm; var vm = e.Parameter as Application.Group.Models.GroupVm;
if (vm != null) if (vm != null)
DataContext = new GroupVm(vm); DataContext = new GroupDetailVm(vm);
} }
} }

View File

@@ -224,8 +224,8 @@
<DependentUpon>SaveDatabasePage.xaml</DependentUpon> <DependentUpon>SaveDatabasePage.xaml</DependentUpon>
</Compile> </Compile>
<Compile Include="Properties\AssemblyInfo.cs" /> <Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="ViewModels\EntryVm.cs" /> <Compile Include="ViewModels\EntryDetailVm.cs" />
<Compile Include="ViewModels\GroupVm.cs" /> <Compile Include="ViewModels\GroupDetailVm.cs" />
<Compile Include="ViewModels\Items\SettingsNewVm.cs" /> <Compile Include="ViewModels\Items\SettingsNewVm.cs" />
<Compile Include="ViewModels\SettingsVm.cs" /> <Compile Include="ViewModels\SettingsVm.cs" />
<Compile Include="ViewModels\MainVm.cs" /> <Compile Include="ViewModels\MainVm.cs" />

View File

@@ -26,11 +26,11 @@ namespace ModernKeePassApp.Test.Mock
public string Name => "MockDatabase"; public string Name => "MockDatabase";
public GroupVm RecycleBin { get; set; } public GroupDetailVm RecycleBin { get; set; }
public bool RecycleBinEnabled { get; set; } public bool RecycleBinEnabled { get; set; }
public GroupVm RootGroup { get; set; } public GroupDetailVm RootGroup { get; set; }
public void AddDeletedItem(PwUuid id) public void AddDeletedItem(PwUuid id)
{ {

View File

@@ -116,7 +116,7 @@ namespace ModernKeePassApp.Test
public void TestEntryVm() public void TestEntryVm()
{ {
var database = new DatabaseServiceMock(); var database = new DatabaseServiceMock();
var entryVm = new EntryVm(new PwEntry(true, true), new GroupVm(), database, _resource) var entryVm = new EntryDetailVm(new PwEntry(true, true), new GroupDetailVm(), database, _resource)
{ {
Title = "Test", Title = "Test",
UserName = "login", UserName = "login",
@@ -128,7 +128,7 @@ namespace ModernKeePassApp.Test
public void TestGroupVm() public void TestGroupVm()
{ {
var database = new DatabaseServiceMock(); var database = new DatabaseServiceMock();
var entryVm = new GroupVm(new PwGroup(true, true), new GroupVm(), database) var entryVm = new GroupDetailVm(new PwGroup(true, true), new GroupDetailVm(), database)
{ {
Title = "Test" Title = "Test"
}; };