AiButtonCommand gekoppelt durch Factory an: TestVersion > ModuleAiEnabled > UserPermission

This commit is contained in:
2025-06-11 10:06:25 +02:00
parent 340b33fdd9
commit ebcba1a1ea
2 changed files with 14 additions and 4 deletions

View File

@@ -13,12 +13,22 @@ namespace BeWo.Core.Commands
// 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);
Func<bool> checkup1 = () => BeWoApp.AppSettings.ModuleAiEnabled;
Func<UserRightType, bool> checkup2 = (right) => BeWoApp.HasLoggedOnUserRight(right);
Func<UserRightType, bool> checkup = (right) => CheckupTestVersion() && checkup1() && checkup2(right);
if (additionalCheckup == null)
return new DelegateCommand(openView, () => checkup(userRightType));
return new DelegateCommand(openView, () => checkup(userRightType), false);
else
return new DelegateCommand(openView, () => checkup(userRightType) && additionalCheckup());
return new DelegateCommand(openView, () => checkup(userRightType) && additionalCheckup(), false);
}
private static bool CheckupTestVersion()
{
var version = BeWoApp.Version.Split(' ');
var test_string = version[version.Length - 1].ToLower();
return test_string == "test";
}
}
}

View File

@@ -626,7 +626,7 @@
<Button
Margin="3"
HorizontalAlignment="Stretch"
Command="{Binding Path=OpenAiWindowCommand, RelativeSource={RelativeSource AncestorType={x:Type localView:BeWoView}}}">
Command="{Binding Path=OpenAiPopupCommand, RelativeSource={RelativeSource AncestorType={x:Type localView:BeWoView}}}">
AI Chat Popup
</Button>
</StackPanel>