Skip to content

Commit

Permalink
feat: update Customer Information management logic and UI
Browse files Browse the repository at this point in the history
- Added AddCustomerPetCommand logic in the AddCustomersView. It allows user to add pets to a customer.

- Additional minor tweaks include updating scrollbar styles, CustomerViewModel and several other elements for accommodating the new changes and improving overall user experience.

Signed-off-by: Russell Camo <[email protected]>
  • Loading branch information
russkyc committed Aug 29, 2023
1 parent bdb51a3 commit 4bc3914
Show file tree
Hide file tree
Showing 11 changed files with 296 additions and 62 deletions.
8 changes: 8 additions & 0 deletions GroomWise.Application/Mappers/CustomerMapper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
using GroomWise.Application.Observables;
using GroomWise.Domain.Entities;
using Mapster;
using Swordfish.NET.Collections;

namespace GroomWise.Application.Mappers;

Expand All @@ -18,6 +19,13 @@ public static ObservableCustomer ToObservable(this Customer customer)

public static Customer ToEntity(this ObservableCustomer observableCustomer)
{
TypeAdapterConfig<ObservableCustomer, Customer>
.NewConfig()
.Map(dest => dest.Pets, src => src.Pets.Select(pet => pet.ToEntity()).ToList())
.Map(
dest => dest.Appointments,
src => src.Appointments.Select(appointment => appointment.ToEntity()).ToList()
);
return observableCustomer.Adapt<Customer>();
}
}
18 changes: 18 additions & 0 deletions GroomWise.Application/Mappers/PetMapper.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
// Copyright (C) 2023 Russell Camo (Russkyc).- All Rights Reserved
//
// Unauthorized copying or redistribution of all files, in source and binary forms via any medium
// without written, signed consent from the author is strictly prohibited.

using GroomWise.Application.Observables;
using GroomWise.Domain.Entities;
using Mapster;

namespace GroomWise.Application.Mappers;

public static class PetMapper
{
public static Pet ToEntity(this ObservablePet observablePet)
{
return observablePet.Adapt<Pet>();
}
}
4 changes: 2 additions & 2 deletions GroomWise.Application/Observables/ObservableCustomer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,8 @@ public partial class ObservableCustomer
private string _email;

[Property(PropertyChangeType = PropertyChangeType.PropertyChanged)]
private ConcurrentObservableCollection<Appointment> _appointments = new();
private ConcurrentObservableCollection<ObservableAppointment> _appointments = new();

[Property(PropertyChangeType = PropertyChangeType.PropertyChanged)]
private ConcurrentObservableCollection<Pet> _pets = new();
private ConcurrentObservableCollection<ObservablePet> _pets = new();
}
4 changes: 1 addition & 3 deletions GroomWise.Application/Observables/ObservablePet.cs
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,6 @@ public partial class ObservablePet
private string? _breed;

[Property(PropertyChangeType = PropertyChangeType.PropertyChanged)]
private int? _gender;
private string? _gender;

[Property(PropertyChangeType = PropertyChangeType.PropertyChanged)]
private Customer _owner;
}
16 changes: 16 additions & 0 deletions GroomWise.Application/ViewModels/CustomerViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
using GroomWise.Application.Events;
using GroomWise.Application.Mappers;
using GroomWise.Application.Observables;
using GroomWise.Domain.Entities;
using GroomWise.Domain.Enums;
using GroomWise.Infrastructure.Database;
using GroomWise.Infrastructure.Logging.Interfaces;
Expand Down Expand Up @@ -100,6 +101,21 @@ await Task.Run(() =>
});
}

[Command]
private async Task AddCustomerPet()
{
ActiveCustomer.Pets.Insert(0, new ObservablePet());
}

[Command]
private async Task RemoveCustomerPet(object param)
{
if (param is ObservablePet pet)
{
ActiveCustomer.Pets.Remove(pet);
}
}

[Command]
private async Task UpdateCustomer(object param)
{
Expand Down
3 changes: 1 addition & 2 deletions GroomWise.Domain/Entities/Pet.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,5 @@ public class Pet : IEntity
public string? Name { get; set; }
public int? Age { get; set; }
public string? Breed { get; set; }
public int? Gender { get; set; }
public IList<Customer> Owner { get; set; }
public string? Gender { get; set; }
}
54 changes: 54 additions & 0 deletions GroomWise.WPF/Views/Dialogs/AddCustomersView.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
xmlns:d="https://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="https://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:russkyc="clr-namespace:org.russkyc.moderncontrols;assembly=Russkyc.ModernControls.WPF"
xmlns:templates="clr-namespace:GroomWise.Views.Templates"
xmlns:viewModels="clr-namespace:GroomWise.Application.ViewModels;assembly=GroomWise.Application"
xmlns:wpf="clr-namespace:Material.Icons.WPF;assembly=Material.Icons.WPF"
Title="AddCustomersView"
Expand Down Expand Up @@ -72,6 +73,59 @@
HelperText="Max Length (200)"
Placeholder="Primary Address"
Text="{Binding ActiveCustomer.Address, UpdateSourceTrigger=PropertyChanged}" />
<russkyc:ModernButton
Margin="0,12,0,0"
HorizontalAlignment="Stretch"
VerticalAlignment="Top"
Command="{Binding AddCustomerPetCommand}"
Content="Add Pet"
CornerRadius="5"
DefaultBackground="{DynamicResource bg-000}"
FontWeight="Medium"
Foreground="{DynamicResource fg-200}"
HoverBackground="{DynamicResource bg-000}"
LeftCenterIcon="{wpf:MaterialIconExt Kind=Add}"
PressedBackground="{DynamicResource bg-100}" />
<ItemsControl
MaxHeight="170"
Margin="0,10,0,0"
HorizontalAlignment="Stretch"
ItemsSource="{Binding ActiveCustomer.Pets.EditableCollectionView, UpdateSourceTrigger=PropertyChanged}">
<ItemsControl.ItemTemplate>
<DataTemplate>
<templates:CustomerPetInfoCardTemplate />
</DataTemplate>
</ItemsControl.ItemTemplate>

<ItemsControl.ItemsPanel>
<ItemsPanelTemplate>
<VirtualizingStackPanel IsVirtualizing="True" VirtualizationMode="Recycling" />
</ItemsPanelTemplate>
</ItemsControl.ItemsPanel>

<ItemsControl.ItemContainerStyle>
<Style TargetType="{x:Type FrameworkElement}">
<Setter Property="Margin" Value="0,0,0,10" />
</Style>
</ItemsControl.ItemContainerStyle>

<ItemsControl.Template>
<ControlTemplate TargetType="ItemsControl">
<Border
Background="{TemplateBinding Background}"
BorderBrush="{TemplateBinding BorderBrush}"
BorderThickness="{TemplateBinding BorderThickness}">
<ScrollViewer
Padding="{TemplateBinding Padding}"
CanContentScroll="True"
Focusable="False"
VerticalScrollBarVisibility="Auto">
<ItemsPresenter />
</ScrollViewer>
</Border>
</ControlTemplate>
</ItemsControl.Template>
</ItemsControl>
<StackPanel
Margin="0,24,0,0"
HorizontalAlignment="Right"
Expand Down
148 changes: 135 additions & 13 deletions GroomWise.WPF/Views/Pages/ServicesView.xaml
Original file line number Diff line number Diff line change
@@ -1,14 +1,136 @@
<UserControl x:Class="GroomWise.Views.Pages.ServicesView"
xmlns="https://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="https://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="https://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="https://schemas.openxmlformats.org/markup-compatibility/2006"
HorizontalAlignment="Stretch"
d:DesignHeight="300"
d:DesignWidth="300"
Style="{StaticResource FadeInFromBottomAnimation}"
mc:Ignorable="d">
<TextBlock HorizontalAlignment="Center"
VerticalAlignment="Center"
Text="Services" />
<UserControl
x:Class="GroomWise.Views.Pages.ServicesView"
xmlns="https://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="https://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="https://schemas.microsoft.com/expression/blend/2008"
xmlns:icons="clr-namespace:Material.Icons.WPF;assembly=Material.Icons.WPF"
xmlns:mc="https://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:russkyc="clr-namespace:org.russkyc.moderncontrols;assembly=Russkyc.ModernControls.WPF"
xmlns:templates="clr-namespace:GroomWise.Views.Templates"
xmlns:viewModels="clr-namespace:GroomWise.Application.ViewModels;assembly=GroomWise.Application"
HorizontalAlignment="Stretch"
d:DataContext="{d:DesignInstance viewModels:GroomingServiceViewModel,
IsDesignTimeCreatable=True}"
d:DesignHeight="720"
d:DesignWidth="1280"
Style="{StaticResource FadeInFromBottomAnimation}"
mc:Ignorable="d">
<Grid Style="{StaticResource FadeInFromBottomAnimation}">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*" />
<ColumnDefinition Width="320" />
</Grid.ColumnDefinitions>
<Grid Grid.Column="0" Margin="16,20,16,16">
<Grid.RowDefinitions>
<RowDefinition Height="Auto" />
<RowDefinition Height="*" />
</Grid.RowDefinitions>
<Grid
Grid.Row="0"
Margin="0,0,0,12"
HorizontalAlignment="Stretch">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="Auto" />
<ColumnDefinition Width="*" />
<ColumnDefinition Width="Auto" />
<ColumnDefinition Width="Auto" />
</Grid.ColumnDefinitions>
<TextBlock
Grid.Column="0"
VerticalAlignment="Center"
FontSize="16"
Text="Services" />
<russkyc:ModernTextBox
Grid.Column="2"
Width="200"
Margin="12,0"
CornerRadius="5"
LeftIcon="{icons:MaterialIconExt Search}"
Placeholder="Find Employee"
Text="{Binding Filter, UpdateSourceTrigger=PropertyChanged}" />
<russkyc:ModernButton
Grid.Column="3"
HorizontalAlignment="Right"
Content="Add Employee"
CornerRadius="5"
FontWeight="Medium"
IconSize="18"
LeftIcon="{icons:MaterialIconExt Kind=AddBold}" />
</Grid>
<ScrollViewer
Grid.Row="1"
VerticalAlignment="Stretch"
HorizontalContentAlignment="Stretch"
VerticalScrollBarVisibility="Auto">
<ItemsControl ItemsSource="{Binding Employees.EditableCollectionView, UpdateSourceTrigger=PropertyChanged}">
<ItemsControl.ItemsPanel>
<ItemsPanelTemplate>
<VirtualizingStackPanel IsVirtualizing="True" VirtualizationMode="Recycling" />
</ItemsPanelTemplate>
</ItemsControl.ItemsPanel>
<ItemsControl.ItemTemplate>
<DataTemplate>
<templates:EmployeeListCardTemplate />
</DataTemplate>
</ItemsControl.ItemTemplate>
<ItemsControl.ItemContainerStyle>
<Style TargetType="{x:Type FrameworkElement}">
<Setter Property="Margin" Value="0,0,0,10" />
</Style>
</ItemsControl.ItemContainerStyle>
</ItemsControl>
</ScrollViewer>
</Grid>
<Grid Grid.Column="1" Margin="0,20,16,16">
<Grid Margin="0,0,0,0" VerticalAlignment="Stretch">
<Grid.RowDefinitions>
<RowDefinition Height="Auto" />
<RowDefinition Height="*" />
</Grid.RowDefinitions>
<Grid Grid.Row="0" Margin="0,0,0,12">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="Auto" />
<ColumnDefinition Width="*" />
<ColumnDefinition Width="Auto" />
</Grid.ColumnDefinitions>
<TextBlock
Grid.Column="0"
VerticalAlignment="Center"
FontSize="16"
Text="Roles" />
<russkyc:ModernButton
Grid.Column="2"
HorizontalAlignment="Right"
Content="Add Role"
CornerRadius="5"
FontWeight="Medium"
IconSize="18"
LeftIcon="{icons:MaterialIconExt Kind=AddBold}" />
</Grid>
<ScrollViewer
Grid.Row="1"
VerticalAlignment="Stretch"
HorizontalContentAlignment="Stretch"
VerticalScrollBarVisibility="Auto">
<ItemsControl ItemsSource="{Binding Roles.EditableCollectionView, UpdateSourceTrigger=PropertyChanged}">
<ItemsControl.ItemsPanel>
<ItemsPanelTemplate>
<VirtualizingStackPanel IsVirtualizing="True" VirtualizationMode="Recycling" />
</ItemsPanelTemplate>
</ItemsControl.ItemsPanel>
<ItemsControl.ItemTemplate>
<DataTemplate>
<templates:RoleListCardTemplate />
</DataTemplate>
</ItemsControl.ItemTemplate>
<ItemsControl.ItemContainerStyle>
<Style TargetType="{x:Type FrameworkElement}">
<Setter Property="Margin" Value="0,0,0,10" />
</Style>
</ItemsControl.ItemContainerStyle>
</ItemsControl>
</ScrollViewer>
</Grid>
</Grid>
</Grid>
</UserControl>
8 changes: 7 additions & 1 deletion GroomWise.WPF/Views/Resources/Styles/ScrollbarStyles.xaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
<ResourceDictionary xmlns="https://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="https://schemas.microsoft.com/winfx/2006/xaml">
<Style x:Key="ScrollBarTrackThumb" TargetType="{x:Type Thumb}">
<Setter Property="Margin" Value="0" />
<Setter Property="Opacity" Value="0.4" />
<Setter Property="Width" Value="{Binding Width, RelativeSource={RelativeSource AncestorType={x:Type ScrollBar}}}" />
<Setter Property="Template">
<Setter.Value>
Expand All @@ -27,6 +28,9 @@
CornerRadius="3" />
</Grid>
<ControlTemplate.Triggers>
<Trigger Property="IsDragging" Value="True">
<Setter Property="Opacity" Value="1" />
</Trigger>
<Trigger Property="Tag" Value="Horizontal">
<Setter TargetName="CornerScrollBarRectangle" Property="Width" Value="Auto" />
<Setter TargetName="CornerScrollBarRectangle" Property="Height" Value="Auto" />
Expand Down Expand Up @@ -85,10 +89,12 @@
<Trigger SourceName="Thumb" Property="IsDragging" Value="true">
<Setter TargetName="Thumb" Property="Background" Value="{DynamicResource bg-500}" />
</Trigger>

<Trigger Property="IsEnabled" Value="false">
<Setter TargetName="Thumb" Property="Visibility" Value="Collapsed" />
</Trigger>
<Trigger Property="IsMouseOver" Value="True">
<Setter TargetName="Thumb" Property="Opacity" Value="0.6" />
</Trigger>
<Trigger Property="Orientation" Value="Horizontal">
<Setter TargetName="GridRoot" Property="LayoutTransform">
<Setter.Value>
Expand Down
Loading

0 comments on commit 4bc3914

Please sign in to comment.