Skip to content

Commit

Permalink
[Update] Enhanced the search to filter as text is typed
Browse files Browse the repository at this point in the history
  • Loading branch information
natasakasikovic committed Apr 2, 2024
1 parent 58088f8 commit db0b128
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 22 deletions.
4 changes: 2 additions & 2 deletions LangLang/Core/Model/DAO/TutorDAO.cs
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,8 @@ public Dictionary<int, Tutor> Search(TutorController tutorController, DateTime d
Dictionary<int, Tutor> allTutors = tutorController.GetAllTutors();

Dictionary<int, Tutor> filteredTutors = allTutors.Where(tutor =>
(date == default || tutor.Value.EmploymentDate == date) &&
(language == "" || tutor.Value.Skill.Language.Any(skill => skill == language)) &&
(date == default || tutor.Value.EmploymentDate.Date == date.Date) &&
(language == "" || tutor.Value.Skill.Language.Any(skill => skill.Contains(language))) &&
(level == null || tutor.Value.Skill.Level.Any(skilll => skilll == level))).ToDictionary(x => x.Key, x => x.Value);


Expand Down
17 changes: 8 additions & 9 deletions LangLang/View/DirectorGUI/DirectorWindow.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -29,11 +29,11 @@
</Grid.ColumnDefinitions>
<Grid Grid.Column="0" Margin="10,24,417,0" Grid.ColumnSpan="2">
<TabControl Margin="5,0,0,0" RenderTransformOrigin="0.52,0.5" Height="250" VerticalAlignment="Top">
<TabItem Header="All tutors" Margin="13,0,0,1" Height="35" VerticalAlignment="Bottom" HorizontalAlignment="Left" Width="546" AutomationProperties.IsColumnHeader="True">
<TabItem Header="All tutors" Margin="0,0,0,1" Height="35" VerticalAlignment="Bottom" HorizontalAlignment="Left" Width="565" AutomationProperties.IsColumnHeader="True" BorderBrush="White">
<TabItem.Background>
<LinearGradientBrush EndPoint="0,1">
<GradientStop Color="#FFF0F0F0"/>
<GradientStop Color="#FFFFD3D3" Offset="1"/>
<GradientStop Color="#FF3D3D3D" Offset="1"/>
</LinearGradientBrush>
</TabItem.Background>
<DataGrid Height="209"
Expand Down Expand Up @@ -90,10 +90,10 @@
<ColumnDefinition Width="441*"/>
</Grid.ColumnDefinitions>
<GroupBox x:Name="languagegb" HorizontalAlignment="Left" Height="53" Header="Language" Margin="16,20,0,0" VerticalAlignment="Top" Width="249" Grid.Column="1">
<TextBox x:Name="languagetb" HorizontalAlignment="Left" Height="20" TextWrapping="Wrap" Text="" Width="209" Background="White" SelectionBrush="#FFFAE0E0" BorderBrush="#FFFAE0E0" Margin="10,0,0,0"/>
<TextBox x:Name="languagetb" HorizontalAlignment="Left" Height="20" TextWrapping="Wrap" Text="" Width="209" Background="White" SelectionBrush="#FFFAE0E0" BorderBrush="#FFFAE0E0" Margin="10,0,0,0" TextChanged="Search_Click"/>
</GroupBox>
<GroupBox x:Name="startdategb" HorizontalAlignment="Left" Height="53" Header="Employment date" Margin="80,90,0,0" VerticalAlignment="Top" Width="266" Grid.Column="1">
<DatePicker x:Name="datePickerEmployment" HorizontalAlignment="Center" Height="24" Width="233" Background="#FFFAE0E0">
<DatePicker x:Name="datePickerEmployment" HorizontalAlignment="Center" SelectedDateChanged="Search_Click" Height="24" Width="233" Background="#FFFAE0E0" >
<DatePicker.BorderBrush>
<LinearGradientBrush EndPoint="0.5,0" StartPoint="0.5,1">
<GradientStop Color="#FFFAE0E0"/>
Expand All @@ -103,14 +103,13 @@
</DatePicker>
</GroupBox>
<GroupBox x:Name="levelgb" HorizontalAlignment="Left" Height="53" Header="Level" Margin="296,20,0,0" VerticalAlignment="Top" Width="100" Grid.Column="1">
<ComboBox x:Name="levelCB" HorizontalAlignment="Left" Height="17" Width="71" Margin="10,0,0,0" BorderBrush="#FFE8E8E8"/>
<ComboBox x:Name="levelCB" HorizontalAlignment="Left" Height="22" Width="71" Margin="10,0,0,0" BorderBrush="#FFE8E8E8" SelectionChanged="Search_Click" />
</GroupBox>
<Button x:Name="searchbtn" Content="Search" HorizontalAlignment="Left" Height="29" Margin="80,160,0,0" VerticalAlignment="Top" Width="101" BorderBrush="White" Background="#FFFFDBDB" Foreground="#FF514141" FontFamily="Segoe UI Black" Click="Search_Click" Grid.Column="1"/>
<Button x:Name="clearhbtn" Content="Clear" HorizontalAlignment="Left" Height="29" Margin="218,160,0,0" VerticalAlignment="Top" Width="103" BorderBrush="White" Background="#FFFFDBDB" Foreground="#FF514141" FontFamily="Segoe UI Black" Click="Clear_Click" Grid.Column="1"/>
<Button x:Name="clearhbtn" Content="Clear filters" HorizontalAlignment="Left" Height="29" Margin="109,160,0,0" VerticalAlignment="Top" Width="212" BorderBrush="White" Background="#FFFFDBDB" Foreground="#FF514141" FontFamily="Segoe UI Black" Click="Clear_Click" Grid.Column="1"/>

</Grid>
</GroupBox>
<TextBlock HorizontalAlignment="Left" Height="40" Margin="117,399,0,0" Padding="90,15,0,0" FontFamily="Gill Sans Ultra Bold" TextWrapping="Wrap" Text="FILTER ALL TUTORS" VerticalAlignment="Top" Width="324"/>
<TextBlock HorizontalAlignment="Left" Height="40" Margin="117,399,0,0" Padding="90,15,0,0" FontFamily="Gill Sans Ultra Bold" TextWrapping="Wrap" Text="FILTER ALL TUTORS" VerticalAlignment="Top" Width="324" Foreground="#FFFED2D2"/>
</Grid>

<!-- Second panel -->
Expand Down Expand Up @@ -320,7 +319,7 @@
<GradientStop Color="#FFFFF7F7" Offset="0.2"/>
</LinearGradientBrush>
</Label.Background>
</Label>
</Label>

<!--birthday picker-->
<DatePicker x:Name="BirthDatePicker"
Expand Down
16 changes: 5 additions & 11 deletions LangLang/View/DirectorGUI/DirectorWindow.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -156,28 +156,23 @@ private void ClearFields()
EmploymentDatePicker.SelectedDate = null;
}


private void Search_Click(object sender, RoutedEventArgs e)
{
string language = languagetb.Text;
DateTime date = datePickerEmployment.SelectedDate ?? default; // if picker s null, pick up a minVal
LanguageLevel? level = null;
if (levelCB.SelectedValue != null)
level = (LanguageLevel)levelCB.SelectedValue;

if (language == "" && date == DateTime.MinValue && level == null)
{
MessageBox.Show("Please select some criterion");
}
else
{
data = tutorsController.Search(languagetb.Text, date, level);
Update();
}

data = tutorsController.Search(languagetb.Text, date, level);
Update();
}

private void Clear_Click(object sender, RoutedEventArgs e)
{
data = tutorsController.GetAllTutors();
levelCB.SelectedItem = null;
Update();
}

Expand All @@ -199,6 +194,5 @@ private void TutorsDataGrid_SelectionChanged(object sender, System.Windows.Contr
dataGrid.ItemsSource = SelectedTutor.LanguageLevel;
}
}

}
}

0 comments on commit db0b128

Please sign in to comment.