From d5f0575bf062705f1b243129a7c210e12b4afd03 Mon Sep 17 00:00:00 2001 From: Rene Evertz Date: Tue, 26 May 2026 15:22:54 +0200 Subject: [PATCH] ITextProvider --- .../Zeiterfassung/ServiceRecordView2.xaml | 2 +- .../Controls/AI/AiChatButtonViewModel.cs | 1 + .../AI/AiChatButtonWithHistoryViewModel.cs | 13 ++++-- .../ListViewModel/ServiceRecordListVM.cs | 44 ++++++++++++++----- Shared/Interface/ITextProvider.cs | 14 ++++++ Shared/Shared.csproj | 1 + 6 files changed, 59 insertions(+), 16 deletions(-) create mode 100644 Shared/Interface/ITextProvider.cs diff --git a/BeWo/View/Detail/Zeiterfassung/ServiceRecordView2.xaml b/BeWo/View/Detail/Zeiterfassung/ServiceRecordView2.xaml index fcb668b82..6ffc57931 100644 --- a/BeWo/View/Detail/Zeiterfassung/ServiceRecordView2.xaml +++ b/BeWo/View/Detail/Zeiterfassung/ServiceRecordView2.xaml @@ -1772,7 +1772,7 @@ HorizontalScrollBarVisibility="Hidden" Language="de-DE" SpellCheck.IsEnabled="True" - Text="{val:ValidationBinding Path=AktuellerDokutext, + Text="{val:ValidationBinding Path=PrototypeVM.Notice, UpdateSourceTrigger=PropertyChanged}" TextWrapping="Wrap" VerticalScrollBarVisibility="Auto" diff --git a/BeWo/ViewModel/Controls/AI/AiChatButtonViewModel.cs b/BeWo/ViewModel/Controls/AI/AiChatButtonViewModel.cs index 8b160761f..03979ba74 100644 --- a/BeWo/ViewModel/Controls/AI/AiChatButtonViewModel.cs +++ b/BeWo/ViewModel/Controls/AI/AiChatButtonViewModel.cs @@ -173,6 +173,7 @@ namespace BeWo.ViewModel.Controls.AI vm.SendAfterLoaded = true; vm.MessageInput = prompt.Prompt; BeWoApp.MainControl.WindowService.Show(vm); + return; } else if(e is AiPromptbausteinRoutineVM routine) { diff --git a/BeWo/ViewModel/Controls/AI/AiChatButtonWithHistoryViewModel.cs b/BeWo/ViewModel/Controls/AI/AiChatButtonWithHistoryViewModel.cs index ae4ed44b7..130cc35f7 100644 --- a/BeWo/ViewModel/Controls/AI/AiChatButtonWithHistoryViewModel.cs +++ b/BeWo/ViewModel/Controls/AI/AiChatButtonWithHistoryViewModel.cs @@ -1,4 +1,5 @@ using BS.Shared; +using BS.Shared.Interface; using DevExpress.Mvvm; using DevExpress.XtraPrinting; using System; @@ -11,15 +12,16 @@ namespace BeWo.ViewModel.Controls.AI { public class AiChatButtonWithHistoryViewModel : AiChatButtonViewModel { - private string currentValue; + private readonly ITextProvider _provider; + private readonly string _key; public int CurrentIndex { get; set; } public List History { get; set; } public string CurrentValue { - get => currentValue; - set => SetProperty(ref currentValue, value, nameof(CurrentValue)); + get => _provider.GetText(_key); + set => _provider.SetText(_key, value); } public override bool IsHistoryEnabled => true; @@ -30,7 +32,7 @@ namespace BeWo.ViewModel.Controls.AI public DelegateCommand UndoAiActionCommand { get; protected set; } public DelegateCommand RedoAiActionCommand { get; protected set; } - public AiChatButtonWithHistoryViewModel(AiActionType aiActionType) : base(aiActionType) + public AiChatButtonWithHistoryViewModel(AiActionType aiActionType, ITextProvider provider, string key) : base(aiActionType) { History = new List(); CurrentIndex = 0; @@ -51,6 +53,9 @@ namespace BeWo.ViewModel.Controls.AI }; UndoAiActionCommand= new DelegateCommand(UndoAiAction); RedoAiActionCommand= new DelegateCommand(RedoAiAction); + + _provider = provider; + _key = key; } public override bool CanSendNewMessage => base.CanSendNewMessage && !string.IsNullOrEmpty(CurrentValue); diff --git a/BeWo/ViewModel/ListViewModel/ServiceRecordListVM.cs b/BeWo/ViewModel/ListViewModel/ServiceRecordListVM.cs index de84fd832..36823e83f 100644 --- a/BeWo/ViewModel/ListViewModel/ServiceRecordListVM.cs +++ b/BeWo/ViewModel/ListViewModel/ServiceRecordListVM.cs @@ -22,7 +22,9 @@ using BS.Shared.DataContracts; using BS.Shared.DataContracts.Compact; using BS.Shared.DataContracts.Feature.AI; using BS.Shared.DataContracts.Feature.AI.Functions.ServiceRecords; +using BS.Shared.Exceptions; using BS.Shared.Extensions; +using BS.Shared.Interface; using BS.Shared.Services; using DevExpress.Mvvm; using DevExpress.Xpf.Editors.ExpressionEditor; @@ -32,7 +34,7 @@ using DispatcherObject = System.Windows.Threading.DispatcherObject; namespace BeWo.ViewModel.ListViewModel { - public class ServiceRecordListVM : AbstractDCListMapperVM + public class ServiceRecordListVM : AbstractDCListMapperVM, ITextProvider { public static string PropertyName_CustomerNodes = "CustomerNodes"; public static string PropertyName_Information = "Information"; @@ -184,12 +186,12 @@ namespace BeWo.ViewModel.ListViewModel { }; - AiChatButtonDocumentationViewModel = new AiChatButtonWithHistoryViewModel(AiActionType.ServiceRecordDocumentation) + AiChatButtonDocumentationViewModel = new AiChatButtonWithHistoryViewModel(AiActionType.ServiceRecordDocumentation, this, "docu") { }; - AiChatButtonDocumentationEditViewModel = new AiChatButtonWithHistoryViewModel(AiActionType.ServiceRecordDocumentation) + AiChatButtonDocumentationEditViewModel = new AiChatButtonWithHistoryViewModel(AiActionType.ServiceRecordDocumentation, this, "edit_docu") { }; @@ -217,12 +219,6 @@ namespace BeWo.ViewModel.ListViewModel set { PrototypeVM.Notice = value; - AiChatButtonDocumentationViewModel.CurrentValue = value; - FirePropertyChanged(nameof(AktuellerDokutext)); - - //FirePropertyChanged(nameof(IsAiDocuButtonCanExecute)); - //FirePropertyChanged(nameof(IsRedoButtonVisible)); - //FirePropertyChanged(nameof(IsUndoButtonVisible)); } } public string AktuellerEditDokutext @@ -231,8 +227,6 @@ namespace BeWo.ViewModel.ListViewModel set { EditVM.Notice = value; - //FirePropertyChanged(nameof(IsEditUndoButtonVisible)); - //FirePropertyChanged(nameof(IsEditRedoButtonVisible)); } } @@ -2028,5 +2022,33 @@ namespace BeWo.ViewModel.ListViewModel return json; } + + public string GetText(string key) + { + if (key == "docu") + { + return AktuellerDokutext; + } + else if(key == "edit_docu") + { + return AktuellerEditDokutext; + } + + throw new BeWoNotImplementedException($"key '{key}' unbekannt"); + } + + public void SetText(string key, string value) + { + if (key == "docu") + { + AktuellerDokutext = value; + } + else if (key == "edit_docu") + { + AktuellerEditDokutext = value; + } + + throw new BeWoNotImplementedException($"key '{key}' unbekannt"); + } } } \ No newline at end of file diff --git a/Shared/Interface/ITextProvider.cs b/Shared/Interface/ITextProvider.cs new file mode 100644 index 000000000..bb60a7c49 --- /dev/null +++ b/Shared/Interface/ITextProvider.cs @@ -0,0 +1,14 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace BS.Shared.Interface +{ + public interface ITextProvider + { + string GetText(string key); + void SetText(string key, string value); + } +} diff --git a/Shared/Shared.csproj b/Shared/Shared.csproj index 17acba129..9244a7ac7 100644 --- a/Shared/Shared.csproj +++ b/Shared/Shared.csproj @@ -443,6 +443,7 @@ +