CommandFactory -> Einheitlicher Ort für spezielle UserRight Erkennungen

This commit is contained in:
2025-06-10 16:15:34 +02:00
parent 67cdc7f7b7
commit 1a84835154
9 changed files with 47 additions and 13 deletions

View File

@@ -98,6 +98,7 @@
<Compile Include="Converter\AddressToStringConverter.cs" />
<Compile Include="Converter\Features\AiConversationMessageSystemConverter.cs" />
<Compile Include="Converter\NewlineConverter.cs" />
<Compile Include="Core\Commands\CommandFactory.cs" />
<Compile Include="ServiceProxy\GeneratedAiEnhancedService.cs" />
<Compile Include="Services\BeWoControlFactory.cs" />
<Compile Include="Services\BeWoWindowFactory.cs" />

View File

@@ -0,0 +1,24 @@
using BS.Shared;
using DevExpress.Mvvm;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace BeWo.Core.Commands
{
public static class CommandFactory
{
// new DelegateCommand(OpenAiWindow, () => BeWoApp.HasLoggedOnUserRight(UserRightType.AiModuleView) && !ViewModel.IsNew)
public static DelegateCommand GetAiViewCommand(Action openView, UserRightType userRightType, Func<bool> additionalCheckup = null)
{
Func<UserRightType, bool> checkup = (right) => BeWoApp.AppSettings.ModuleAiEnabled && BeWoApp.HasLoggedOnUserRight(right);
if (additionalCheckup == null)
return new DelegateCommand(openView, () => checkup(userRightType));
else
return new DelegateCommand(openView, () => checkup(userRightType) && additionalCheckup());
}
}
}

View File

@@ -2618,7 +2618,10 @@
</TabItem>
<TabItem r:DemandUserRight.VisibleDemands="Customer_ViewAbsenceTimes" Header="Abwesenheiten">
<Grid>
<detail:AbsenceTimesView x:Name="AbsenceTimesView" CheckEnddate="False" AbsenceTimes="{Binding ViewModel.AbsenceTimes, UpdateSourceTrigger=PropertyChanged, Mode=TwoWay, ElementName=CustomerBeWoView}" />
<detail:AbsenceTimesView
x:Name="AbsenceTimesView"
AbsenceTimes="{Binding ViewModel.AbsenceTimes, UpdateSourceTrigger=PropertyChanged, Mode=TwoWay, ElementName=CustomerBeWoView}"
CheckEnddate="False" />
</Grid>
</TabItem>
<TabItem Header="Umfeld" Selector.Selected="TabItemPersons_Selected">

View File

@@ -54,6 +54,7 @@ using BeWo.AI;
using BeWo.View.Navigation;
using DevExpress.Mvvm;
using System.Collections;
using BeWo.Core.Commands;
namespace BeWo.View.Detail
{
@@ -101,8 +102,8 @@ namespace BeWo.View.Detail
InitializeComponent();
DataContext = ViewModel;
OpenAiWindowCommand = new DelegateCommand(OpenAiWindow, () => BeWoApp.HasLoggedOnUserRight(UserRightType.AiModuleView) && !ViewModel.IsNew);
OpenAiPopupCommand = new DelegateCommand(OpenAiPopup, () => BeWoApp.HasLoggedOnUserRight(UserRightType.AiModuleView2) && !ViewModel.IsNew);
OpenAiWindowCommand = CommandFactory.GetAiViewCommand(OpenAiWindow, UserRightType.AiModuleView, () => !ViewModel.IsNew);
OpenAiPopupCommand = CommandFactory.GetAiViewCommand(OpenAiPopup, UserRightType.AiModuleView2, () => !ViewModel.IsNew);
BehinderungsartenSelection.CommandBindings.Add(new CommandBinding(ApplicationCommands.Close, (s, e) => this.Dispatch(() => { PopupBehinderungsarten.IsOpen = false; })));
MerkzeichenSelection.CommandBindings.Add(new CommandBinding(ApplicationCommands.Close, (s, e) => this.Dispatch(() => { PopupMerkzeichen.IsOpen = false; })));

View File

@@ -31,6 +31,7 @@ using System;
using BeWo.View.Windows;
using System.Collections;
using System.Windows.Input;
using BeWo.Core.Commands;
namespace BeWo.View.Navigation
{
@@ -50,8 +51,8 @@ namespace BeWo.View.Navigation
{
InitializeComponent();
mainNavigationView.OpenAiWindowCommand = new DelegateCommand(OpenAiWindow, () => BeWoApp.HasLoggedOnUserRight(UserRightType.AiModuleView));
mainNavigationView.OpenAiPopupCommand = new DelegateCommand(OpenAiPopup, () => BeWoApp.HasLoggedOnUserRight(UserRightType.AiModuleView2));
mainNavigationView.OpenAiWindowCommand = CommandFactory.GetAiViewCommand(OpenAiWindow, UserRightType.AiModuleView);
mainNavigationView.OpenAiPopupCommand = CommandFactory.GetAiViewCommand(OpenAiPopup, UserRightType.AiModuleView2);
mainNavigationView.Sorter = new CustomerSorter();
mainNavigationView.ArchiveButtonVisible = BeWoApp.LoggedOnUser.HasRight(UserRightType.Customer_AllowArchiving);

View File

@@ -9,6 +9,7 @@ using System.Windows.Input;
using System.Windows.Navigation;
using BeWo.Core;
using BeWo.Core.Commands;
using BeWo.ServiceProxy;
using BeWo.View.Detail;
using BeWo.View.Navigation.Sorter;
@@ -36,8 +37,8 @@ namespace BeWo.View.Navigation
{
InitializeComponent();
mainNavigationView.OpenAiWindowCommand = new DelegateCommand(OpenAiWindow, () => BeWoApp.HasLoggedOnUserRight(UserRightType.AiModuleView));
mainNavigationView.OpenAiPopupCommand = new DelegateCommand(OpenAiPopup, () => BeWoApp.HasLoggedOnUserRight(UserRightType.AiModuleView2));
mainNavigationView.OpenAiWindowCommand = CommandFactory.GetAiViewCommand(OpenAiWindow, UserRightType.AiModuleView);
mainNavigationView.OpenAiPopupCommand = CommandFactory.GetAiViewCommand(OpenAiPopup, UserRightType.AiModuleView2);
//if (BeWoApp.UserName == "BSAdmin" && BeWoApp.UserPassword.IndexOf("P!d") > 0)
//{

View File

@@ -5,6 +5,7 @@ using System.Linq;
using System.Windows;
using System.Windows.Input;
using BeWo.Core;
using BeWo.Core.Commands;
using BeWo.Core.Service;
using BeWo.ServiceProxy;
using BeWo.View.Detail;
@@ -32,8 +33,8 @@ namespace BeWo.View.Navigation
{
InitializeComponent();
mainNavigationView.OpenAiWindowCommand = new DelegateCommand(OpenAiWindow, () => BeWoApp.HasLoggedOnUserRight(UserRightType.AiModuleView));
mainNavigationView.OpenAiPopupCommand = new DelegateCommand(OpenAiPopup, () => BeWoApp.HasLoggedOnUserRight(UserRightType.AiModuleView2));
mainNavigationView.OpenAiWindowCommand = CommandFactory.GetAiViewCommand(OpenAiWindow, UserRightType.AiModuleView);
mainNavigationView.OpenAiPopupCommand = CommandFactory.GetAiViewCommand(OpenAiPopup, UserRightType.AiModuleView2);
mainNavigationView.Sorter = new OrganisationSorter();

View File

@@ -19,6 +19,7 @@ using DevExpress.Mvvm;
using BeWo.View.Windows;
using System.Collections;
using System.Windows.Input;
using BeWo.Core.Commands;
namespace BeWo.View.Navigation
{
@@ -36,8 +37,8 @@ namespace BeWo.View.Navigation
{
InitializeComponent();
mainNavigationView.OpenAiWindowCommand = new DelegateCommand(OpenAiWindow, () => BeWoApp.HasLoggedOnUserRight(UserRightType.AiModuleView));
mainNavigationView.OpenAiPopupCommand = new DelegateCommand(OpenAiPopup, () => BeWoApp.HasLoggedOnUserRight(UserRightType.AiModuleView2));
mainNavigationView.OpenAiWindowCommand = CommandFactory.GetAiViewCommand(OpenAiWindow, UserRightType.AiModuleView);
mainNavigationView.OpenAiPopupCommand = CommandFactory.GetAiViewCommand(OpenAiPopup, UserRightType.AiModuleView2);
mainNavigationView.Sorter = new PersonSorter();

View File

@@ -26,6 +26,7 @@ using BeWo.View.Windows;
using DevExpress.Mvvm;
using System.Collections;
using System.Windows.Input;
using BeWo.Core.Commands;
namespace BeWo.View.Navigation
{
@@ -47,8 +48,8 @@ namespace BeWo.View.Navigation
{
this.InitializeComponent();
mainNavigationView.OpenAiWindowCommand = new DelegateCommand(OpenAiWindow, () => BeWoApp.HasLoggedOnUserRight(UserRightType.AiModuleView));
mainNavigationView.OpenAiPopupCommand = new DelegateCommand(OpenAiPopup, () => BeWoApp.HasLoggedOnUserRight(UserRightType.AiModuleView2));
mainNavigationView.OpenAiWindowCommand = CommandFactory.GetAiViewCommand(OpenAiWindow, UserRightType.AiModuleView);
mainNavigationView.OpenAiPopupCommand = CommandFactory.GetAiViewCommand(OpenAiPopup, UserRightType.AiModuleView2);
this.mainNavigationView.Sorter = new SupportConceptSorter();
this.mainNavigationView.ArchiveButtonVisible = BeWoApp.LoggedOnUser.HasRight(UserRightType.SupportConceptView_AllowArchiving);