Skip to content

Commit

Permalink
Merge pull request #446 from kzi-nastava/fix/refresh-tabs-director-wi…
Browse files Browse the repository at this point in the history
…ndow

[fix] The tabs that are linked are now being refreshed
  • Loading branch information
anasinik authored May 28, 2024
2 parents 7ea489b + 97617d4 commit f9a8e37
Show file tree
Hide file tree
Showing 3 changed files with 43 additions and 7 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
using LangLang.WPF.Views.DirectorView.Tabs;

namespace LangLang.WPF.ViewModels.DirectorViewModels
{
public class DirectorWindowViewModel
{
public DirectorWindowViewModel() {}

public void UpdateCourses(CoursesReview coursesTab)
{
coursesTab.Update();
}

public void UpdateExams(ExamSlotsReview examsTab)
{
examsTab.Update();
}

}
}
25 changes: 19 additions & 6 deletions LangLang/WPF/Views/DirectorView/DirectorWindow.xaml.cs
Original file line number Diff line number Diff line change
@@ -1,39 +1,52 @@
using System.Windows;
using System.Windows.Controls;
using LangLang.BusinessLogic.UseCases;
using LangLang.Domain.Models;
using LangLang.WPF.ViewModels.DirectorViewModels;
using LangLang.WPF.Views.DirectorView.Tabs;
using LangLang.WPF.Views.StudentView.Tabs;
using System.Windows;
using System.Windows.Controls;

namespace LangLang.WPF.Views.DirectorView
{
public partial class DirectorWindow : Window
{
public Director CurrentlyLoggedIn { get; set; }
public CoursesReview coursesTab { get; set; }
public ExamSlotsReview examsTab { get; set; }
public DirectorWindowViewModel ViewModel { get; set; }

public DirectorWindow(Profile currentlyLoggedIn)
{
InitializeComponent();
DataContext = this;
ViewModel = new DirectorWindowViewModel();
DataContext = ViewModel;
var directorService = new DirectorService();
CurrentlyLoggedIn = directorService.Get(currentlyLoggedIn.Id);
GenerateTabs();
}

private void GenerateTabs()
{
var reviewTab = new TutorReview();
var reviewTab = new TutorReview(this);
AddTab("Tutor review", reviewTab);
var resultsTab = new ResultsSending();
AddTab("Results Sending", resultsTab);
var gradedCoursesTab = new GradedCourses();
AddTab("Graded courses", gradedCoursesTab);
var reportsTab = new Reports(CurrentlyLoggedIn);
AddTab("Reports", reportsTab);
var coursesTab = new CoursesReview();
coursesTab = new CoursesReview();
AddTab("Courses", coursesTab);
var examsTab = new ExamSlotsReview();
examsTab = new ExamSlotsReview();
AddTab("Exams", examsTab);
}

public void Update()
{
ViewModel.UpdateCourses(coursesTab);
ViewModel.UpdateExams(examsTab);
}

private void AddTab(string header, UserControl content)
{
TabItem tabItem = new()
Expand Down
5 changes: 4 additions & 1 deletion LangLang/WPF/Views/DirectorView/Tabs/TutorReview.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,12 @@ namespace LangLang.WPF.Views.DirectorView.Tabs
public partial class TutorReview : UserControl
{
public TutorReviewPageViewModel TutorReviewViewModel { get; set; }
private DirectorWindow _parent;

public TutorReview()
public TutorReview(DirectorWindow parent)
{
InitializeComponent();
_parent = parent;
TutorReviewViewModel = new();
DataContext = TutorReviewViewModel;
DisableButtons();
Expand All @@ -33,6 +35,7 @@ private void UpdateTutor_Click(object sender, RoutedEventArgs e)
private void DeleteTutor_Click(object sender, RoutedEventArgs e)
{
TutorReviewViewModel.DeleteTutor();
_parent.Update();
}

private void Search_Click(object sender, RoutedEventArgs e)
Expand Down

0 comments on commit f9a8e37

Please sign in to comment.