From 709937eee3d3e025e250e31ba8f26f8ba757c5c4 Mon Sep 17 00:00:00 2001 From: Rene Evertz Date: Thu, 21 May 2026 13:49:57 +0200 Subject: [PATCH] Ansatz 1. Wenn das nix wird, esse ich einen Besen --- BeWo/AI/View/AiTranskriptionView.xaml.cs | 2 - BeWo/BeWo.csproj | 18 +++ BeWo/Core/EventArg/TextAcceptedEventArgs.cs | 18 +++ BeWo/Styles/DataTemplates/DataTemplates.xaml | 2 +- BeWo/Styles/Features/AIChatStyles.xaml | 12 +- BeWo/Styles/ModernOrangeBlack.xaml | 2 +- BeWo/View/Controls/AI/AiChatButton.xaml | 79 ++++++++++++ BeWo/View/Controls/AI/AiChatButton.xaml.cs | 99 ++++++++++++++ .../Controls/AI/AiConversationButton.xaml.cs | 7 +- .../AI/AiPromptbausteinChatResultView.xaml | 20 +++ .../AI/AiPromptbausteinChatResultView.xaml.cs | 28 ++++ .../Zeiterfassung/ServiceRecordView2.xaml | 12 +- .../Zeiterfassung/ServiceRecordView2.xaml.cs | 39 ++---- .../Controls/AI/AiChatButtonViewModel.cs | 66 ++++++++++ .../AI/AiChatButtonWithHistoryViewModel.cs | 110 ++++++++++++++++ .../ListViewModel/ServiceRecordListVM.cs | 122 ++++-------------- .../AI/AiPromptbausteinChatResultViewModel.cs | 31 +++++ ...PromptbausteinComplexSelectionViewModel.cs | 1 - Data/Entities/AiPromptbausteinRoutine.cs | 1 - Service/BusinessLogic/GenericBusinessLogic.cs | 1 - Service/Plugins/AiFunctionService.cs | 1 - .../AICore/IAiPromptbausteinRoutine.cs | 1 - .../AICore/IAiPromptbausteinRoutineStep.cs | 3 +- 23 files changed, 518 insertions(+), 157 deletions(-) create mode 100644 BeWo/Core/EventArg/TextAcceptedEventArgs.cs create mode 100644 BeWo/View/Controls/AI/AiChatButton.xaml create mode 100644 BeWo/View/Controls/AI/AiChatButton.xaml.cs create mode 100644 BeWo/View/Detail/AI/AiPromptbausteinChatResultView.xaml create mode 100644 BeWo/View/Detail/AI/AiPromptbausteinChatResultView.xaml.cs create mode 100644 BeWo/ViewModel/Controls/AI/AiChatButtonViewModel.cs create mode 100644 BeWo/ViewModel/Controls/AI/AiChatButtonWithHistoryViewModel.cs create mode 100644 BeWo/ViewModel/View/AI/AiPromptbausteinChatResultViewModel.cs diff --git a/BeWo/AI/View/AiTranskriptionView.xaml.cs b/BeWo/AI/View/AiTranskriptionView.xaml.cs index 9cd82b623..803c2e361 100644 --- a/BeWo/AI/View/AiTranskriptionView.xaml.cs +++ b/BeWo/AI/View/AiTranskriptionView.xaml.cs @@ -21,8 +21,6 @@ using BeWo.ViewModel.View.AI; using BS.Shared; using BS.Shared.Core; using BS.Shared.DataContracts; -using BS.Shared.DataContracts.Feature.AI; -using BS.Shared.DataContracts.Feature.AI.Functions.ServiceRecords; using BS.Shared.Extensions; using BS.Shared.Translation; using DevExpress.Mvvm; diff --git a/BeWo/BeWo.csproj b/BeWo/BeWo.csproj index 874ee2d4f..26175c0cc 100644 --- a/BeWo/BeWo.csproj +++ b/BeWo/BeWo.csproj @@ -120,6 +120,7 @@ + AbsenceTimesCreationView.xaml @@ -147,6 +148,8 @@ DataTemplates.xaml + + @@ -168,6 +171,7 @@ + @@ -175,12 +179,18 @@ AiConversationButton.xaml + + AiChatButton.xaml + AiPromptbausteinButton.xaml AiPromptbausteinActionResultView.xaml + + AiPromptbausteinChatResultView.xaml + AiPromptbausteinComplexSelectionFavoritenView.xaml @@ -300,6 +310,10 @@ Designer MSBuild:Compile + + Designer + MSBuild:Compile + Designer MSBuild:Compile @@ -308,6 +322,10 @@ Designer MSBuild:Compile + + Designer + MSBuild:Compile + Designer MSBuild:Compile diff --git a/BeWo/Core/EventArg/TextAcceptedEventArgs.cs b/BeWo/Core/EventArg/TextAcceptedEventArgs.cs new file mode 100644 index 000000000..920254c48 --- /dev/null +++ b/BeWo/Core/EventArg/TextAcceptedEventArgs.cs @@ -0,0 +1,18 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace BeWo.Core.EventArg +{ + public class TextAcceptedEventArgs : EventArgs + { + public string Text { get; } + + public TextAcceptedEventArgs(string text) + { + Text = text; + } + } +} diff --git a/BeWo/Styles/DataTemplates/DataTemplates.xaml b/BeWo/Styles/DataTemplates/DataTemplates.xaml index 5c5e7b133..29a03e93f 100644 --- a/BeWo/Styles/DataTemplates/DataTemplates.xaml +++ b/BeWo/Styles/DataTemplates/DataTemplates.xaml @@ -39,8 +39,8 @@ BorderThickness="0" Cursor="Arrow" Focusable="False" - FontWeight="{Binding FontWeight}" FontSize="12" + FontWeight="{Binding FontWeight}" IsReadOnly="True" Text="{Binding Path=Title, UpdateSourceTrigger=PropertyChanged, Mode=OneWay}" ToolTipService.ShowDuration="100000"> diff --git a/BeWo/Styles/Features/AIChatStyles.xaml b/BeWo/Styles/Features/AIChatStyles.xaml index e86a1ea97..94ecf1da9 100644 --- a/BeWo/Styles/Features/AIChatStyles.xaml +++ b/BeWo/Styles/Features/AIChatStyles.xaml @@ -148,7 +148,7 @@ - + @@ -174,7 +174,7 @@ BorderBrush="Black" BorderThickness="0" CornerRadius="0, 10, 10, 10"> - + @@ -186,7 +186,7 @@ - + @@ -249,7 +249,7 @@ - + diff --git a/BeWo/View/Controls/AI/AiChatButton.xaml b/BeWo/View/Controls/AI/AiChatButton.xaml new file mode 100644 index 000000000..ad62fe95c --- /dev/null +++ b/BeWo/View/Controls/AI/AiChatButton.xaml @@ -0,0 +1,79 @@ + + + + + + + + + + + + + + + + + Die aktuelle Ansicht beinhaltet zu viele Daten. + Es können keine neuen Chats zu dieser Ansicht erstellt werden. + + + + + + + + + diff --git a/BeWo/View/Controls/AI/AiChatButton.xaml.cs b/BeWo/View/Controls/AI/AiChatButton.xaml.cs new file mode 100644 index 000000000..3f2ac6e6d --- /dev/null +++ b/BeWo/View/Controls/AI/AiChatButton.xaml.cs @@ -0,0 +1,99 @@ +using BeWo.ServiceProxy; +using BeWo.View.Detail.AI; +using BeWo.ViewModel; +using BeWo.ViewModel.Controls.AI; +using BeWo.ViewModel.View.AI; +using BS.Shared; +using BS.Shared.DataContracts.Feature.AI; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Windows; +using System.Windows.Controls; +using System.Windows.Data; +using System.Windows.Documents; +using System.Windows.Input; +using System.Windows.Media; +using System.Windows.Media.Imaging; +using System.Windows.Navigation; +using System.Windows.Shapes; + +namespace BeWo.View.Controls.AI +{ + /// + /// Interaktionslogik für AiGenericConversationButton.xaml + /// + public partial class AiChatButton : UserControl + { + public static readonly DependencyProperty ActionTypeProperty = + DependencyProperty.Register("ActionType", typeof(AiActionType), typeof(AiChatButton), new PropertyMetadata(AiActionType.ServiceRecord, OnActionTypeChanged)); + + public AiActionType ActionType + { + get { return (AiActionType)GetValue(ActionTypeProperty); } + set { SetValue(ActionTypeProperty, value); } + } + + public AiChatButtonViewModel ViewModel => DataContext as AiChatButtonViewModel; + + public AiChatButton() + { + InitializeComponent(); + } + + private static void OnActionTypeChanged(DependencyObject d, DependencyPropertyChangedEventArgs e) + { + var control = (AiChatButton)d; + var actionType = (AiActionType)e.NewValue; + if (BeWoApp.AppSettings.ShowAI && BeWoApp.HasLoggedOnUserRight(UserRightType.AiModulePromptbausteineView)) + { + ServiceFacade.DoAiEnhancedServiceAsnyc(x => x.GetAiPromptbausteinFolder(actionType), folders => control.InitPromptbausteine(actionType, folders)); + } + } + + public void AiPromptOpenAll() + { + //popup_promptbaustein_all.IsOpen = true; + //OpenAiPromptClick?.Invoke(this, e); + BeWoApp.MainControl.WindowService.Show(ViewModel.AllPromptsViewModel); + } + public void AiPromptOpenFavorite() + { + popup_promptbaustein_favoriten.IsOpen = true; + } + + private void InitPromptbausteine(AiActionType actionType, List folders) + { + VMFactory.CreateAiPromptbausteinFolderListVM(folders, (listvm) => + { + var viewmodel = new AiPromptbausteinSelectionComplexViewModel(actionType, listvm); + viewmodel.ItemAccepted += ItemAccepted; + viewmodel.RequestClose += (s, e) => viewmodel.ResetSelection(); + ViewModel.AllPromptsViewModel = viewmodel; + + var viewmodel2 = new AiPromptbausteinSelectionComplexViewModel(actionType, listvm, true); + viewmodel2.ItemAccepted += ItemAccepted; + popup_promptbaustein_favoriten.Closed += (s, e) => viewmodel2.ResetSelection(); + var view2 = new AiPromptbausteinComplexSelectionFavoritenView(viewmodel2); + viewmodel2.SelectedFolder = viewmodel2.Folders.VMList[0]; + view2.Padding = new Thickness(3); + view2.Background = FindResource("ObjectEditBackgroundBrush") as System.Windows.Media.Brush; + border_promptbaustein_favoriten.Child = view2; + + viewmodel.VMListReloaded += (s, e) => viewmodel2.ReloadVMList(false); + }); + } + + private void ItemAccepted(object sender, AbstractBaseVM e) + { + throw new NotImplementedException(); + } + + private void btnOpenAi5_MouseRightButtonUp(object sender, MouseButtonEventArgs e) + { + ViewModel.OpenFavoritePromptsPopupCommand.Execute(null); + } + } +} diff --git a/BeWo/View/Controls/AI/AiConversationButton.xaml.cs b/BeWo/View/Controls/AI/AiConversationButton.xaml.cs index 7c5716419..24b4554bc 100644 --- a/BeWo/View/Controls/AI/AiConversationButton.xaml.cs +++ b/BeWo/View/Controls/AI/AiConversationButton.xaml.cs @@ -70,9 +70,6 @@ namespace BeWo.View.Controls.AI public AiPromptbausteinSelectionComplexViewModel AllPromptsViewModel { get; set; } - public ICommand AiPromptOpenAllCommand { get; set; } - public ICommand AiPromptOpenFavoriteCommand { get; set; } - public string Tooltip { get; set; } public bool IsButtonEnabled { get; set; } public bool IsButton2Enabled { get; set; } @@ -191,8 +188,8 @@ namespace BeWo.View.Controls.AI viewmodel.VMListReloaded += (s, e) => viewmodel2.ReloadVMList(false); - AiPromptOpenAllCommand = new DelegateCommand(AiPromptOpenAll); - AiPromptOpenFavoriteCommand = new DelegateCommand(AiPromptOpenFavorite); + //AiPromptOpenAllCommand = new DelegateCommand(AiPromptOpenAll); + //AiPromptOpenFavoriteCommand = new DelegateCommand(AiPromptOpenFavorite); }); } } diff --git a/BeWo/View/Detail/AI/AiPromptbausteinChatResultView.xaml b/BeWo/View/Detail/AI/AiPromptbausteinChatResultView.xaml new file mode 100644 index 000000000..c57dd555a --- /dev/null +++ b/BeWo/View/Detail/AI/AiPromptbausteinChatResultView.xaml @@ -0,0 +1,20 @@ + + + + + + + + + + + + diff --git a/BeWo/View/Detail/AI/AiPromptbausteinChatResultView.xaml.cs b/BeWo/View/Detail/AI/AiPromptbausteinChatResultView.xaml.cs new file mode 100644 index 000000000..dae084b27 --- /dev/null +++ b/BeWo/View/Detail/AI/AiPromptbausteinChatResultView.xaml.cs @@ -0,0 +1,28 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Windows; +using System.Windows.Controls; +using System.Windows.Data; +using System.Windows.Documents; +using System.Windows.Input; +using System.Windows.Media; +using System.Windows.Media.Imaging; +using System.Windows.Navigation; +using System.Windows.Shapes; + +namespace BeWo.View.Detail.AI +{ + /// + /// Interaktionslogik für AiPromptbausteinChatResultView.xaml + /// + public partial class AiPromptbausteinChatResultView : UserControl + { + public AiPromptbausteinChatResultView() + { + InitializeComponent(); + } + } +} diff --git a/BeWo/View/Detail/Zeiterfassung/ServiceRecordView2.xaml b/BeWo/View/Detail/Zeiterfassung/ServiceRecordView2.xaml index a4a600eb1..ecb6c1e7e 100644 --- a/BeWo/View/Detail/Zeiterfassung/ServiceRecordView2.xaml +++ b/BeWo/View/Detail/Zeiterfassung/ServiceRecordView2.xaml @@ -1707,7 +1707,7 @@ - @@ -1729,8 +1729,9 @@ Margin="3,0,0,0" ActionType="ServiceRecordDocumentation" CanExecute="{Binding PrototypeVM.Notice, Converter={StaticResource StringEmptyBoolConverter}}" - ItemAccepted="btn_AiPromptbaustein2_ItemAccepted" /> - + ItemAccepted="btn_AiPromptbaustein2_ItemAccepted" />--> + + @@ -3334,13 +3335,14 @@ Margin="0" VerticalAlignment="Center" Orientation="Horizontal"> - + getAiConversationChatViewModel(); + + btn_ai_docu.DataContext = pViewModel.AiChatButtonDocumentationViewModel; } public ICommand OpenAiWindowCommand { get; set; } @@ -1189,9 +1193,9 @@ namespace BeWo.View.Detail.Zeiterfassung serviceRecordEditView = new ServiceRecordEditView(); } - ViewModel.ResetEditAiAction(); + ViewModel.AiChatButtonDocumentationEditViewModel.ClearHistory(); - popup_content.Child = serviceRecordEditView; + popup_content.Child = serviceRecordEditView; double height = MainControl.ActualHeight * 0.8; double width = 810; @@ -2257,7 +2261,7 @@ namespace BeWo.View.Detail.Zeiterfassung ComboBoxTreeViewControl.TreeViewSourceList = ViewModel.PrototypeVM.GoalTree; } - ViewModel.ResetAiAction(); + ViewModel.AiChatButtonDocumentationViewModel.ClearHistory(); } return lValid; @@ -5078,11 +5082,6 @@ namespace BeWo.View.Detail.Zeiterfassung ComboBoxTreeViewControl.TreeViewSourceList = ViewModel.PrototypeVM.GoalTree; } - private void AiConversationButton_OpenAiWindowClick(object sender, RoutedEventArgs e) - { - OpenAiWindow(); - } - private AiConversationChatViewModel getAiConversationChatViewModel() { var records = GetVisibleRecordVMs(); @@ -5100,28 +5099,6 @@ namespace BeWo.View.Detail.Zeiterfassung MainControl.WindowService.ShowAiConversationWindow(getAiConversationChatViewModel()); } - private void PromptAccepted(object sender, AiPromptbausteinPromptVM prompt) - { - if (prompt is null) - throw new NotImplementedException(); - - // 1. Information aufbereiten - // 1.1 Prompt - var prompt_oid = prompt.DataContract.Oid.Value; - var prompt_version = prompt.DataContract.Version; - - // 1.2 Restliche Informationen - var vm = getAiConversationChatViewModel(); - - // 2 Validieren - - // 3 Auswerten - vm.MessageInput = prompt.Prompt; - vm.SendAfterLoaded = true; - - MainControl.WindowService.ShowAiConversationWindow(vm); - } - private IEnumerable GetVisibleRecordVMs() { var list = new List(); diff --git a/BeWo/ViewModel/Controls/AI/AiChatButtonViewModel.cs b/BeWo/ViewModel/Controls/AI/AiChatButtonViewModel.cs new file mode 100644 index 000000000..16554c944 --- /dev/null +++ b/BeWo/ViewModel/Controls/AI/AiChatButtonViewModel.cs @@ -0,0 +1,66 @@ +using BeWo.ViewModel.View.AI; +using DevExpress.Mvvm; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace BeWo.ViewModel.Controls.AI +{ + public class AiChatButtonViewModel : AbstractBaseVM + { + private bool canExecute; + + public bool IsFavoritenOpen { get; set; } + public List AssistentCommands { get; protected set; } + + public virtual bool IsHistoryEnabled => false; + + public bool CanExecute + { + get => canExecute; + set => SetProperty(ref canExecute, value, nameof(CanExecute)); + } + + public Func GetAiConversationChatViewModel { get; set; } + + public AiPromptbausteinSelectionComplexViewModel AllPromptsViewModel { get; set; } + + public DelegateCommand OpenConversationPopupCommand { get; protected set; } + public DelegateCommand OpenAllPromptsPopupCommand { get; protected set; } + public DelegateCommand OpenFavoritePromptsPopupCommand { get; protected set; } + + public AiChatButtonViewModel() + { + canExecute = true; + + OpenConversationPopupCommand = new DelegateCommand(OpenConversationPopup); + OpenAllPromptsPopupCommand = new DelegateCommand(OpenAllPromptsPopup); + OpenFavoritePromptsPopupCommand = new DelegateCommand(OpenFavoritePromptsPopup); + } + + public void OpenConversationPopup() + { + BeWoApp.MainControl.WindowService.ShowAiConversationWindow(GetAiConversationChatViewModel()); + } + + public void OpenAllPromptsPopup() + { + BeWoApp.MainControl.WindowService.Show(AllPromptsViewModel); + } + + public void OpenFavoritePromptsPopup() + { + IsFavoritenOpen = true; + FirePropertyChanged(nameof(IsFavoritenOpen)); + } + } + + public class AiMenuItemTemplate + { + public string Icon { get; set; } + public string Name { get; set; } + public DelegateCommand Command { get; set; } + } +} diff --git a/BeWo/ViewModel/Controls/AI/AiChatButtonWithHistoryViewModel.cs b/BeWo/ViewModel/Controls/AI/AiChatButtonWithHistoryViewModel.cs new file mode 100644 index 000000000..8dc897fe7 --- /dev/null +++ b/BeWo/ViewModel/Controls/AI/AiChatButtonWithHistoryViewModel.cs @@ -0,0 +1,110 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace BeWo.ViewModel.Controls.AI +{ + public class AiChatButtonWithHistoryViewModel : AiChatButtonViewModel + { + private string currentValue; + + public int CurrentIndex { get; set; } + public List History { get; set; } + + public string CurrentValue + { + get => currentValue; + set => SetProperty(ref currentValue, value, nameof(CurrentValue)); + } + + public bool IsUndoButtonVisible => CurrentIndex > 0; + public bool IsRedoButtonVisible => CurrentIndex < History.Count - 1; + + public override bool IsHistoryEnabled => true; + + public AiChatButtonWithHistoryViewModel() : base() + { + History = new List(); + CurrentIndex = 0; + AssistentCommands = new List() + { + new AiMenuItemTemplate() + { + Command = new DevExpress.Mvvm.DelegateCommand(x => Accept1(x.Message)), + Icon = null, + Name = "Akzeptieren" + }, + new AiMenuItemTemplate() + { + Command = new DevExpress.Mvvm.DelegateCommand(x => Accept2(x.Message)), + Icon = null, + Name = "Ersetzen" + }, + }; + } + + public void ClearHistory() + { + History.Clear(); + History.Add(CurrentValue); + CurrentIndex = 0; + + FirePropertyChanged(nameof(IsRedoButtonVisible)); + FirePropertyChanged(nameof(IsUndoButtonVisible)); + } + + public void Accept(string str) + { + var idx = CurrentIndex; + var count = History.Count; + + var last_idx = count - 1; + + if (last_idx > idx) + { + History.RemoveRange(idx + 1, last_idx - idx); + } + + if (CurrentValue != History[CurrentIndex]) + { + History.Add(CurrentValue); + CurrentIndex++; + } + + History.Add(str); + CurrentIndex++; + + CurrentValue = str; + } + + public void UndoAiAction() + { + if (CurrentIndex <= 0) + return; + + CurrentIndex--; + CurrentValue = History[CurrentIndex]; + } + + public void RedoAiAction() + { + if (CurrentIndex >= History.Count - 1) + return; + + CurrentIndex++; + CurrentValue = History[CurrentIndex]; + } + + public void Accept1(string s) + { + + } + + public void Accept2(string s) + { + + } + } +} diff --git a/BeWo/ViewModel/ListViewModel/ServiceRecordListVM.cs b/BeWo/ViewModel/ListViewModel/ServiceRecordListVM.cs index 5185de13b..bef1191e9 100644 --- a/BeWo/ViewModel/ListViewModel/ServiceRecordListVM.cs +++ b/BeWo/ViewModel/ListViewModel/ServiceRecordListVM.cs @@ -14,6 +14,7 @@ using BeWo.Core.Commands; using BeWo.Core.Service; using BeWo.ServiceProxy; using BeWo.View.Controls.AI; +using BeWo.ViewModel.Controls.AI; using BeWo.ViewModel.View.AI; using BS.Shared; using BS.Shared.Core; @@ -116,6 +117,10 @@ namespace BeWo.ViewModel.ListViewModel public AiUserSettingVM AiUserSetting { get; set; } + public AiChatButtonViewModel AiChatButtonConversationViewModel { get; set; } + public AiChatButtonWithHistoryViewModel AiChatButtonDocumentationViewModel { get; set; } + public AiChatButtonWithHistoryViewModel AiChatButtonDocumentationEditViewModel { get; set; } + public ServiceRecordListVM( Dictionary> pCategory2Services, IEnumerable pAllGoalCategories, @@ -188,42 +193,20 @@ namespace BeWo.ViewModel.ListViewModel private void InitAiStuff() { - //var vm_doku = new AiPromptbausteinSelectionComplexViewModel(AiActionType.ServiceRecordDocumentation); + AiChatButtonConversationViewModel = new AiChatButtonViewModel() + { + + }; - //vm_doku.PromptAccepted += PromptAccepted; + AiChatButtonDocumentationViewModel = new AiChatButtonWithHistoryViewModel() + { - //OpenAiPromptSelectionCommand = CommandFactory.GetAiViewCommand( - // () => BeWoApp.MainControl.WindowService.Show(vm_doku), - // null, - // () => !string.IsNullOrWhiteSpace(AktuellerDokutext)); + }; - UndoAiActionCommand = new DelegateCommand(UndoAiAction); - RedoAiActionCommand = new DelegateCommand(RedoAiAction); + AiChatButtonDocumentationEditViewModel = new AiChatButtonWithHistoryViewModel() + { - //var vm_edit_doku = new AiPromptbausteinSelectionComplexViewModel(AiActionType.ServiceRecordDocumentation); - - //vm_edit_doku.PromptAccepted += EditPromptAccepted; - - //OpenEditAiPromptSelectionCommand = CommandFactory.GetAiViewCommand(() => - //{ - // _EditAiActionHistory = new List(); - // _EditAiActionHistory.Add(AktuellerEditDokutext); - // _EditAiActionHistoryIndex = 0; - // BeWoApp.MainControl.WindowService.Show(vm_edit_doku); - //}, - //null, - //() => !string.IsNullOrWhiteSpace(AktuellerEditDokutext)); - - UndoEditAiActionCommand = new DelegateCommand(UndoEditAiAction); - RedoEditAiActionCommand = new DelegateCommand(RedoEditAiAction); - - _AiActionHistory = new List(); - _AiActionHistory.Add(AktuellerDokutext); - _AiActionHistoryIndex = 0; - - _EditAiActionHistory = new List(); - _EditAiActionHistory.Add(AktuellerEditDokutext); - _EditAiActionHistoryIndex = 0; + }; } private void InitAiTranscriptionStuff() @@ -254,9 +237,9 @@ namespace BeWo.ViewModel.ListViewModel set { PrototypeVM.Notice = value; - FirePropertyChanged(nameof(IsAiDocuButtonCanExecute)); - FirePropertyChanged(nameof(IsRedoButtonVisible)); - FirePropertyChanged(nameof(IsUndoButtonVisible)); + //FirePropertyChanged(nameof(IsAiDocuButtonCanExecute)); + //FirePropertyChanged(nameof(IsRedoButtonVisible)); + //FirePropertyChanged(nameof(IsUndoButtonVisible)); } } public string AktuellerEditDokutext @@ -265,8 +248,8 @@ namespace BeWo.ViewModel.ListViewModel set { EditVM.Notice = value; - FirePropertyChanged(nameof(IsEditUndoButtonVisible)); - FirePropertyChanged(nameof(IsEditRedoButtonVisible)); + //FirePropertyChanged(nameof(IsEditUndoButtonVisible)); + //FirePropertyChanged(nameof(IsEditRedoButtonVisible)); } } @@ -274,13 +257,8 @@ namespace BeWo.ViewModel.ListViewModel public bool IsAiChatButtonVisible => SelectedCustomerNode is object && IsAiModuleEnabled && BeWoApp.HasLoggedOnUserRight(UserRightType.AiModuleServiceRecordChat); public bool IsAiDocuButtonVisible => SelectedCustomerNode is object && IsAiModuleEnabled && BeWoApp.HasLoggedOnUserRight(UserRightType.AiModuleServiceRecordDocu); public bool IsAiRowVisible => IsAiDocuButtonVisible || VoiceToTextButtonControl.HasRightToUseAIVoice; - public bool IsAiDocuButtonCanExecute => !string.IsNullOrWhiteSpace(AktuellerDokutext); - public bool IsUndoButtonVisible => _AiActionHistoryIndex > 0; - public bool IsRedoButtonVisible => _AiActionHistoryIndex < _AiActionHistory.Count - 1; - - public bool IsEditUndoButtonVisible => _EditAiActionHistoryIndex > 0; - public bool IsEditRedoButtonVisible => _EditAiActionHistoryIndex < (_EditAiActionHistory?.Count ?? 0) - 1; - + + public void ItemAccepted(object sender, AbstractBaseVM item) { if(item is AiPromptbausteinRoutineVM) @@ -526,25 +504,7 @@ namespace BeWo.ViewModel.ListViewModel (exp) => AiConversationButtonState = AiConversationButtonState.Disabled); } } - public void ResetAiAction() - { - _AiActionHistory.Clear(); - _AiActionHistory.Add(AktuellerDokutext); - _AiActionHistoryIndex = 0; - - FirePropertyChanged(nameof(IsRedoButtonVisible)); - FirePropertyChanged(nameof(IsUndoButtonVisible)); - } - public void ResetEditAiAction() - { - _EditAiActionHistory.Clear(); - _EditAiActionHistory.Add(AktuellerDokutext); - _EditAiActionHistoryIndex = 0; - - FirePropertyChanged(nameof(IsEditRedoButtonVisible)); - FirePropertyChanged(nameof(IsEditUndoButtonVisible)); - } - + public Dictionary GetVisibleInformationReferences(IEnumerable selected_records) { var current = SelectedCustomerNode; @@ -982,42 +942,6 @@ namespace BeWo.ViewModel.ListViewModel private DateTime? enddate; - public void UndoAiAction() - { - if (_AiActionHistoryIndex <= 0) - return; - - _AiActionHistoryIndex--; - AktuellerDokutext = _AiActionHistory[_AiActionHistoryIndex]; - } - - public void RedoAiAction() - { - if (_AiActionHistoryIndex >= _AiActionHistory.Count - 1) - return; - - _AiActionHistoryIndex++; - AktuellerDokutext = _AiActionHistory[_AiActionHistoryIndex]; - } - - public void UndoEditAiAction() - { - if (_EditAiActionHistoryIndex <= 0) - return; - - _EditAiActionHistoryIndex--; - AktuellerEditDokutext = _EditAiActionHistory[_EditAiActionHistoryIndex]; - } - - public void RedoEditAiAction() - { - if (_EditAiActionHistoryIndex >= _EditAiActionHistory.Count - 1) - return; - - _EditAiActionHistoryIndex++; - AktuellerEditDokutext = _EditAiActionHistory[_EditAiActionHistoryIndex]; - } - public List CreateFromPrototype() { var lResult = new List(); diff --git a/BeWo/ViewModel/View/AI/AiPromptbausteinChatResultViewModel.cs b/BeWo/ViewModel/View/AI/AiPromptbausteinChatResultViewModel.cs new file mode 100644 index 000000000..ad1b72141 --- /dev/null +++ b/BeWo/ViewModel/View/AI/AiPromptbausteinChatResultViewModel.cs @@ -0,0 +1,31 @@ +using BeWo.Core.EventArg; +using BS.Shared.Core; +using DevExpress.Mvvm; +using System; +using System.Collections.Generic; +using System.Collections.ObjectModel; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Windows; +using System.Windows.Input; + +namespace BeWo.ViewModel.View.AI +{ + public class AiPromptbausteinChatResultViewModel : DialogViewModel + { + public AiPromptbausteinChatResultViewModel() + { + + } + + public string SelectedText => "Example"; + public event EventHandler Accepted; + + private void Accept_Click(object sender, RoutedEventArgs e) + { + Accepted?.Invoke(this, + new TextAcceptedEventArgs(SelectedText)); + } + } +} diff --git a/BeWo/ViewModel/View/AI/AiPromptbausteinComplexSelectionViewModel.cs b/BeWo/ViewModel/View/AI/AiPromptbausteinComplexSelectionViewModel.cs index 2879acc7d..bdb00b802 100644 --- a/BeWo/ViewModel/View/AI/AiPromptbausteinComplexSelectionViewModel.cs +++ b/BeWo/ViewModel/View/AI/AiPromptbausteinComplexSelectionViewModel.cs @@ -4,7 +4,6 @@ using BeWo.ViewModel.ListViewModel; using BeWo.ViewModel.View.Administration; using BS.Shared; using BS.Shared.DataContracts.Compact; -using BS.Shared.DataContracts.Feature.AI; using BS.Shared.Extensions.CustomInterfaces; using DevExpress.Mvvm; using DevExpress.Mvvm.POCO; diff --git a/Data/Entities/AiPromptbausteinRoutine.cs b/Data/Entities/AiPromptbausteinRoutine.cs index b18558a42..84ad33cbb 100644 --- a/Data/Entities/AiPromptbausteinRoutine.cs +++ b/Data/Entities/AiPromptbausteinRoutine.cs @@ -4,7 +4,6 @@ using System.Collections.Generic; using BS.Shared; using BS.Shared.Core; using BS.Shared.DataContracts.Compact; -using BS.Shared.DataContracts.Feature.AI; namespace BeWo.Data.Entities { diff --git a/Service/BusinessLogic/GenericBusinessLogic.cs b/Service/BusinessLogic/GenericBusinessLogic.cs index 881eee5ec..f4e255248 100644 --- a/Service/BusinessLogic/GenericBusinessLogic.cs +++ b/Service/BusinessLogic/GenericBusinessLogic.cs @@ -3,7 +3,6 @@ using BeWo.Data.Entities; using BeWo.Service.Core; using BeWo.Service.DCEntityMapper; using BS.Shared.DataContracts; -using BS.Shared.DataContracts.Feature.AI; using System; using System.Collections.Generic; using System.Linq; diff --git a/Service/Plugins/AiFunctionService.cs b/Service/Plugins/AiFunctionService.cs index 22389a96e..275eb3d69 100644 --- a/Service/Plugins/AiFunctionService.cs +++ b/Service/Plugins/AiFunctionService.cs @@ -3,7 +3,6 @@ using BeWo.Data.Entities; using BeWo.Service.ServiceProxy; using BeWo.Service.ServiceUtils; using BS.Shared; -using BS.Shared.DataContracts.Feature.AI; using BS.Shared.DataContracts.Feature.AI.Functions.ServiceRecords; using DevExpress.DataAccess.Native.Web; using RestSharp.Validation; diff --git a/Shared/Interface/Feature/AICore/IAiPromptbausteinRoutine.cs b/Shared/Interface/Feature/AICore/IAiPromptbausteinRoutine.cs index fa27a45ca..be2f190fb 100644 --- a/Shared/Interface/Feature/AICore/IAiPromptbausteinRoutine.cs +++ b/Shared/Interface/Feature/AICore/IAiPromptbausteinRoutine.cs @@ -1,5 +1,4 @@ using BS.Shared.DataContracts.Compact; -using BS.Shared.DataContracts.Feature.AI; using System; using System.Collections.Generic; using System.Linq; diff --git a/Shared/Interface/Feature/AICore/IAiPromptbausteinRoutineStep.cs b/Shared/Interface/Feature/AICore/IAiPromptbausteinRoutineStep.cs index d2a511158..df1ffcdf3 100644 --- a/Shared/Interface/Feature/AICore/IAiPromptbausteinRoutineStep.cs +++ b/Shared/Interface/Feature/AICore/IAiPromptbausteinRoutineStep.cs @@ -1,5 +1,4 @@ -using BS.Shared.DataContracts.Feature.AI; -using System; +using System; using System.Collections.Generic; using System.Linq; using System.Runtime.Serialization;