diff --git a/BeWo/BeWo.csproj b/BeWo/BeWo.csproj index 8ed9d7433..a7539b52a 100644 --- a/BeWo/BeWo.csproj +++ b/BeWo/BeWo.csproj @@ -165,6 +165,7 @@ + @@ -205,6 +206,9 @@ AiConfigView.xaml + + AiPromptbausteinRoutineView.xaml + DatenbereinigungView.xaml @@ -216,6 +220,7 @@ + AnimatedBeWoWindow.xaml @@ -343,6 +348,10 @@ Designer MSBuild:Compile + + Designer + MSBuild:Compile + MSBuild:Compile Designer diff --git a/BeWo/ServiceProxy/GeneratedAiEnhancedService.cs b/BeWo/ServiceProxy/GeneratedAiEnhancedService.cs index c90adc2e7..c17dfc380 100644 --- a/BeWo/ServiceProxy/GeneratedAiEnhancedService.cs +++ b/BeWo/ServiceProxy/GeneratedAiEnhancedService.cs @@ -75,6 +75,11 @@ namespace BeWo.ServiceProxy [System.ServiceModel.FaultContractAttribute(typeof(BS.Shared.Core.BeWoFault), Action="http://tempuri.org/IAiEnhancedService/InsertAiPromptbausteinPromptBeWoFaultFault", Name="BeWoFault", Namespace="http://schemas.datacontract.org/2004/07/BS.Shared.Core")] System.Collections.Generic.List InsertAiPromptbausteinPrompt(System.Collections.Generic.List prompts); + [System.ServiceModel.OperationContractAttribute(Action="http://tempuri.org/IAiEnhancedService/InsertAiPromptbausteinRoutine", ReplyAction="http://tempuri.org/IAiEnhancedService/InsertAiPromptbausteinRoutineResponse")] + [System.ServiceModel.FaultContractAttribute(typeof(BS.Shared.Core.BeWoFault), Action="http://tempuri.org/IAiEnhancedService/InsertAiPromptbausteinRoutineBeWoFaultFault" + + "", Name="BeWoFault", Namespace="http://schemas.datacontract.org/2004/07/BS.Shared.Core")] + System.Collections.Generic.List InsertAiPromptbausteinRoutine(System.Collections.Generic.List routine); + [System.ServiceModel.OperationContractAttribute(Action="http://tempuri.org/IAiEnhancedService/UpdateAiPromptbausteinFolder", ReplyAction="http://tempuri.org/IAiEnhancedService/UpdateAiPromptbausteinFolderResponse")] [System.ServiceModel.FaultContractAttribute(typeof(BS.Shared.Core.BeWoFault), Action="http://tempuri.org/IAiEnhancedService/UpdateAiPromptbausteinFolderBeWoFaultFault", Name="BeWoFault", Namespace="http://schemas.datacontract.org/2004/07/BS.Shared.Core")] System.Collections.Generic.List UpdateAiPromptbausteinFolder(System.Collections.Generic.List folders); @@ -83,6 +88,11 @@ namespace BeWo.ServiceProxy [System.ServiceModel.FaultContractAttribute(typeof(BS.Shared.Core.BeWoFault), Action="http://tempuri.org/IAiEnhancedService/UpdateAiPromptbausteinPromptBeWoFaultFault", Name="BeWoFault", Namespace="http://schemas.datacontract.org/2004/07/BS.Shared.Core")] System.Collections.Generic.List UpdateAiPromptbausteinPrompt(System.Collections.Generic.List prompts); + [System.ServiceModel.OperationContractAttribute(Action="http://tempuri.org/IAiEnhancedService/UpdateAiPromptbausteinRoutine", ReplyAction="http://tempuri.org/IAiEnhancedService/UpdateAiPromptbausteinRoutineResponse")] + [System.ServiceModel.FaultContractAttribute(typeof(BS.Shared.Core.BeWoFault), Action="http://tempuri.org/IAiEnhancedService/UpdateAiPromptbausteinRoutineBeWoFaultFault" + + "", Name="BeWoFault", Namespace="http://schemas.datacontract.org/2004/07/BS.Shared.Core")] + System.Collections.Generic.List UpdateAiPromptbausteinRoutine(System.Collections.Generic.List routine); + [System.ServiceModel.OperationContractAttribute(Action="http://tempuri.org/IAiEnhancedService/DeleteAiPromptbausteinFolder", ReplyAction="http://tempuri.org/IAiEnhancedService/DeleteAiPromptbausteinFolderResponse")] [System.ServiceModel.FaultContractAttribute(typeof(BS.Shared.Core.BeWoFault), Action="http://tempuri.org/IAiEnhancedService/DeleteAiPromptbausteinFolderBeWoFaultFault", Name="BeWoFault", Namespace="http://schemas.datacontract.org/2004/07/BS.Shared.Core")] void DeleteAiPromptbausteinFolder(System.Collections.Generic.Dictionary oid2version); @@ -91,6 +101,11 @@ namespace BeWo.ServiceProxy [System.ServiceModel.FaultContractAttribute(typeof(BS.Shared.Core.BeWoFault), Action="http://tempuri.org/IAiEnhancedService/DeleteAiPromptbausteinPromptBeWoFaultFault", Name="BeWoFault", Namespace="http://schemas.datacontract.org/2004/07/BS.Shared.Core")] void DeleteAiPromptbausteinPrompt(System.Collections.Generic.Dictionary oid2version); + [System.ServiceModel.OperationContractAttribute(Action="http://tempuri.org/IAiEnhancedService/DeleteAiPromptbausteinRoutine", ReplyAction="http://tempuri.org/IAiEnhancedService/DeleteAiPromptbausteinRoutineResponse")] + [System.ServiceModel.FaultContractAttribute(typeof(BS.Shared.Core.BeWoFault), Action="http://tempuri.org/IAiEnhancedService/DeleteAiPromptbausteinRoutineBeWoFaultFault" + + "", Name="BeWoFault", Namespace="http://schemas.datacontract.org/2004/07/BS.Shared.Core")] + void DeleteAiPromptbausteinRoutine(System.Collections.Generic.Dictionary oid2version); + [System.ServiceModel.OperationContractAttribute(Action="http://tempuri.org/IAiEnhancedService/ExecuteAiFunctionServiceRecordDocumentation" + "", ReplyAction="http://tempuri.org/IAiEnhancedService/ExecuteAiFunctionServiceRecordDocumentation" + "Response")] @@ -211,6 +226,11 @@ namespace BeWo.ServiceProxy return base.Channel.InsertAiPromptbausteinPrompt(prompts); } + public System.Collections.Generic.List InsertAiPromptbausteinRoutine(System.Collections.Generic.List routine) + { + return base.Channel.InsertAiPromptbausteinRoutine(routine); + } + public System.Collections.Generic.List UpdateAiPromptbausteinFolder(System.Collections.Generic.List folders) { return base.Channel.UpdateAiPromptbausteinFolder(folders); @@ -221,6 +241,11 @@ namespace BeWo.ServiceProxy return base.Channel.UpdateAiPromptbausteinPrompt(prompts); } + public System.Collections.Generic.List UpdateAiPromptbausteinRoutine(System.Collections.Generic.List routine) + { + return base.Channel.UpdateAiPromptbausteinRoutine(routine); + } + public void DeleteAiPromptbausteinFolder(System.Collections.Generic.Dictionary oid2version) { base.Channel.DeleteAiPromptbausteinFolder(oid2version); @@ -231,6 +256,11 @@ namespace BeWo.ServiceProxy base.Channel.DeleteAiPromptbausteinPrompt(oid2version); } + public void DeleteAiPromptbausteinRoutine(System.Collections.Generic.Dictionary oid2version) + { + base.Channel.DeleteAiPromptbausteinRoutine(oid2version); + } + public BS.Shared.DataContracts.Feature.AI.Functions.ServiceRecords.AiFunctionDocResponse ExecuteAiFunctionServiceRecordDocumentation(BS.Shared.DataContracts.Feature.AI.Functions.ServiceRecords.AiFunctionDocRequest request) { return base.Channel.ExecuteAiFunctionServiceRecordDocumentation(request); diff --git a/BeWo/Services/BeWoWindowService.cs b/BeWo/Services/BeWoWindowService.cs index 978aff5d1..b2070620c 100644 --- a/BeWo/Services/BeWoWindowService.cs +++ b/BeWo/Services/BeWoWindowService.cs @@ -68,6 +68,10 @@ namespace BeWo.Services { ShowAiPromptbausteinSelectionComplexWindow(viewModel6); } + else if (windowViewModel is AiPromptbausteinRoutineViewModel viewModel7) + { + ShowAiPromptbausteinRoutineWindow(viewModel7); + } else { throw new NotImplementedException($"type not implemented: {typeof(T)}"); @@ -105,6 +109,16 @@ namespace BeWo.Services }; Show("KI Promptbaustein Prompt", control, viewModel, options); } + public void ShowAiPromptbausteinRoutineWindow(AiPromptbausteinRoutineViewModel viewModel) + { + var control = new AiPromptbausteinRoutineView(viewModel); + var options = new BeWoWindowOptions() + { + Height = 400, + Width = 600 + }; + Show("KI Promptbaustein Prompt", control, viewModel, options); + } public void ShowAiPromptbausteinActionResultWindow(AiPromptbausteinActionResultViewModel viewModel) { var control = new AiPromptbausteinActionResultView(viewModel); diff --git a/BeWo/Styles/DataTemplates/DataTemplates.xaml b/BeWo/Styles/DataTemplates/DataTemplates.xaml index 71f5c2d98..f39d699df 100644 --- a/BeWo/Styles/DataTemplates/DataTemplates.xaml +++ b/BeWo/Styles/DataTemplates/DataTemplates.xaml @@ -12,14 +12,25 @@ ItemsSource="{Binding Path=SubFolders.VMList}"> + + + + @@ -48,6 +59,49 @@ + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/BeWo/View/BeWoFileView.xaml b/BeWo/View/BeWoFileView.xaml index 4b06691b2..4f19b2d73 100644 --- a/BeWo/View/BeWoFileView.xaml +++ b/BeWo/View/BeWoFileView.xaml @@ -37,7 +37,10 @@ - + @@ -54,7 +57,6 @@ Height="20" Source="..\Ressources\Icons\Folder.png" Stretch="Fill" /> - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + diff --git a/BeWo/View/Detail/AI/AiPromptbausteinComplexSelectionView.xaml b/BeWo/View/Detail/AI/AiPromptbausteinComplexSelectionView.xaml index a11947ac0..011631be4 100644 --- a/BeWo/View/Detail/AI/AiPromptbausteinComplexSelectionView.xaml +++ b/BeWo/View/Detail/AI/AiPromptbausteinComplexSelectionView.xaml @@ -60,6 +60,7 @@ Padding="4,16,4,16" AllowDrop="True" ContextMenuOpening="treeView_ContextMenuOpening" + ContextMenuService.IsEnabled="{Binding CanOpenContextMenu}" ItemContainerStyle="{DynamicResource igoal_treeitemstyle}" ItemTemplate="{StaticResource ai_promptbaustein_folder_itemtemplate}" ItemsSource="{Binding Folders.VMList, UpdateSourceTrigger=PropertyChanged}" @@ -122,6 +123,7 @@ VerticalContentAlignment="Stretch" AllowDrop="False" ContextMenuOpening="ListBox_ContextMenuOpening" + ContextMenuService.IsEnabled="{Binding CanOpenContextMenu}" EditValue="{Binding SelectedPrompt, Mode=TwoWay}" ItemContainerStyle="{StaticResource PromptListBoxItem}" ItemsSource="{Binding SelectedFolder.Prompts, UpdateSourceTrigger=PropertyChanged}" @@ -300,10 +302,10 @@ Style="{StaticResource ObjectEditGroupBox}"> + Content="{Binding AcceptButtonText}" + Style="{StaticResource PrimaryButton}" /> diff --git a/BeWo/View/Detail/AI/AiPromptbausteinComplexTreeView.xaml b/BeWo/View/Detail/AI/AiPromptbausteinComplexTreeView.xaml index daa1cbe06..0a425bf45 100644 --- a/BeWo/View/Detail/AI/AiPromptbausteinComplexTreeView.xaml +++ b/BeWo/View/Detail/AI/AiPromptbausteinComplexTreeView.xaml @@ -9,6 +9,7 @@ xmlns:dxlc="http://schemas.devexpress.com/winfx/2008/xaml/layoutcontrol" xmlns:local1="clr-namespace:BeWo.View.Detail.AI" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" + xmlns:templateselectors="clr-namespace:BeWo.View.TemplateSelectors" xmlns:view="clr-namespace:BeWo.View" xmlns:vm="clr-namespace:BeWo.ViewModel" d:DataContext="{d:DesignInstance Type=administration:AiPromptbausteinComplexTreeViewModel, @@ -27,6 +28,256 @@ TargetType="ListBoxItem"> + + + + + + + + + + + + + + + + + + + + + + + + + (i) + + + + + + + + + Bearbeitet vor x Minuten + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + (i) + + + + + + + + + 3 Schritte · 2 min + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -57,8 +308,10 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - (i) - - - - - - - + Padding="0" + BorderThickness="0,1,1,1" + BorderBrush="Gray" + SelectionChanged="TabControl_SelectionChanged"> + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/BeWo/View/Detail/AI/AiPromptbausteinComplexTreeView.xaml.cs b/BeWo/View/Detail/AI/AiPromptbausteinComplexTreeView.xaml.cs index abdd2fc31..fe74b91d1 100644 --- a/BeWo/View/Detail/AI/AiPromptbausteinComplexTreeView.xaml.cs +++ b/BeWo/View/Detail/AI/AiPromptbausteinComplexTreeView.xaml.cs @@ -118,38 +118,9 @@ namespace BeWo.View.Detail.AI private void ListBox_ContextMenuOpening(object sender, ContextMenuEventArgs e) { ViewModel.UpdatePromptCommands(); - favorite.Header = (ViewModel.SelectedPrompt?.IsFavorite ?? false) ? "Favorit entfernen" : "Favorit hinzufügen"; + favorite.Header = ((ViewModel.SelectedItem as AiPromptbausteinPromptVM)?.IsFavorite ?? false) ? "Favorit entfernen" : "Favorit hinzufügen"; } - //private void listBox_Prompts_PreviewMouseUp(object sender, MouseButtonEventArgs e) - //{ - // IsDragging = false; - //} - - //private void listBox_Prompts_Drop(object sender, DragEventArgs e) - //{ - // HitTestResult hitTest = VisualTreeHelper.HitTest(listBoxEdit1, e.GetPosition(listBoxEdit1)); - // ListBoxEditItem item = LayoutHelper.FindParentObject((DependencyObject)hitTest.VisualHit); - // int insertIndex = ViewModel.SelectedFolder.SubPrompts.VMList.IndexOf((AiPromptbausteinPromptVM)item.Content); - // ViewModel.SelectedFolder.SubPrompts.VMList.Remove((AiPromptbausteinPromptVM)e.Data.GetData(typeof(AiPromptbausteinPromptVM))); - // if (listBoxEdit1.SelectedIndex > insertIndex) - // insertIndex++; - // ViewModel.SelectedFolder.SubPrompts.VMList.Insert(insertIndex, (AiPromptbausteinPromptVM)e.Data.GetData(typeof(AiPromptbausteinPromptVM))); - //} - - //private void listBox_Prompts_DragOver(object sender, DragEventArgs e) - //{ - // e.Effects = DragDropEffects.Move; - //} - - //private void listBox_Prompts_MouseMove(object sender, MouseEventArgs e) - //{ - // if (IsDragging && listBoxEdit1.SelectedItem != null) - // { - // DragDrop.DoDragDrop(listBoxEdit1, listBoxEdit1.SelectedItem, DragDropEffects.Move); - // } - //} - private void Hyperlink_RequestNavigate(object sender, System.Windows.Navigation.RequestNavigateEventArgs e) { Process.Start(new ProcessStartInfo(e.Uri.AbsoluteUri)); @@ -167,5 +138,13 @@ namespace BeWo.View.Detail.AI e.Handled = true; } } + + private void TabControl_SelectionChanged(object sender, SelectionChangedEventArgs e) + { + if(e.OriginalSource is TabControl) + { + ViewModel.SelectedItem = null; + } + } } } diff --git a/BeWo/View/Detail/AI/AiPromptbausteinRoutineView.xaml b/BeWo/View/Detail/AI/AiPromptbausteinRoutineView.xaml new file mode 100644 index 000000000..740976afa --- /dev/null +++ b/BeWo/View/Detail/AI/AiPromptbausteinRoutineView.xaml @@ -0,0 +1,195 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/BeWo/View/Detail/AI/AiPromptbausteinRoutineView.xaml.cs b/BeWo/View/Detail/AI/AiPromptbausteinRoutineView.xaml.cs new file mode 100644 index 000000000..7b990942d --- /dev/null +++ b/BeWo/View/Detail/AI/AiPromptbausteinRoutineView.xaml.cs @@ -0,0 +1,93 @@ +using BeWo.ViewModel; +using BeWo.ViewModel.ListViewModel; +using BeWo.ViewModel.View.Administration; +using BeWo.ViewModel.View.AI; +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.Detail.AI +{ + /// + /// Interaktionslogik für AiPromptbausteinRoutineView.xaml + /// + public partial class AiPromptbausteinRoutineView : UserControl + { + //public static readonly DependencyProperty RoutineProperty = + // DependencyProperty.Register("Routine", typeof(AiPromptbausteinRoutineVM), typeof(AiPromptbausteinRoutineView), new PropertyMetadata(null)); + + //public static readonly DependencyProperty FolderListVMProperty = + // DependencyProperty.Register("FolderListVM", typeof(AiPromptbausteinFolderListVM), typeof(AiPromptbausteinRoutineView), new PropertyMetadata(null)); + + //public AiPromptbausteinRoutineVM Routine + //{ + // get { return (AiPromptbausteinRoutineVM)GetValue(RoutineProperty); } + // set { SetValue(RoutineProperty, value); } + //} + + //public AiPromptbausteinFolderListVM FolderListVM + //{ + // get { return (AiPromptbausteinFolderListVM)GetValue(FolderListVMProperty); } + // set { SetValue(FolderListVMProperty, value); } + //} + + public AiPromptbausteinRoutineViewModel ViewModel { get; set; } + + public AiPromptbausteinRoutineView(AiPromptbausteinRoutineViewModel viewmodel) + { + InitializeComponent(); + + DataContext = ViewModel = viewmodel; + + var viewmodel2 = new AiPromptbausteinSelectionComplexViewModel(ViewModel.ViewModel.ActionType, ViewModel.FolderListVM, false, false); + var control = new AiPromptbausteinComplexSelectionView(viewmodel2); + + viewmodel2.PromptAccepted += (s, e) => + { + if (e is null) + return; + + if (e.DataContract.Version is null) + { + MessageBox.Show("Es können keine Promptbausteine hinzugefügt werden, die noch nicht gespeichert wurden. Speichern Sie bitte zuvor."); + return; + } + + var step = new AiPromptbausteinRoutineStepDC(); + step.PromptReference = e.DataContract; + step.ReferenceVersion = e.DataContract.Version.Value; + var step_vm = new AiPromptbausteinRoutineStepVM(step); + + ViewModel.ViewModel.Steps.VMList.Add(step_vm); + myPopup.IsOpen = false; + }; + + myPopupBorder.Child = control; + } + + private void Button_Plus_Click(object sender, RoutedEventArgs e) + { + myPopup.IsOpen = true; + } + + private void Button_Minus_Click(object sender, RoutedEventArgs e) + { + if (!(steps.SelectedItem is AiPromptbausteinRoutineStepVM step)) + return; + + ViewModel.ViewModel.Steps.VMList.Remove(step); + } + } +} diff --git a/BeWo/View/TemplateSelectors/AiPromptbausteinFolderItemTemplateSelector.cs b/BeWo/View/TemplateSelectors/AiPromptbausteinFolderItemTemplateSelector.cs new file mode 100644 index 000000000..acfd674b9 --- /dev/null +++ b/BeWo/View/TemplateSelectors/AiPromptbausteinFolderItemTemplateSelector.cs @@ -0,0 +1,29 @@ +using BeWo.ViewModel; +using DevExpress.Web.Internal.XmlProcessor; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Windows; +using System.Windows.Controls; + +namespace BeWo.View.TemplateSelectors +{ + public class AiPromptbausteinFolderItemTemplateSelector : DataTemplateSelector + { + public DataTemplate AiPromptbausteinPromptTemplate { get; set; } + public DataTemplate AiPromptbausteinRoutineTemplate { get; set; } + + public override DataTemplate SelectTemplate(object item, DependencyObject container) + { + if (item is AiPromptbausteinPromptVM prompt) + return AiPromptbausteinPromptTemplate; + + if (item is AiPromptbausteinRoutineVM routine) + return AiPromptbausteinRoutineTemplate; + + throw new NotImplementedException("item is not AiPromptbausteinPromptVM or AiPromptbausteinRoutineVM"); + } + } +} diff --git a/BeWo/ViewModel/AiPromptbausteinFolderVM.cs b/BeWo/ViewModel/AiPromptbausteinFolderVM.cs index 306f9f6df..debd70390 100644 --- a/BeWo/ViewModel/AiPromptbausteinFolderVM.cs +++ b/BeWo/ViewModel/AiPromptbausteinFolderVM.cs @@ -22,6 +22,7 @@ namespace BeWo.ViewModel private AiActionType _ActionType; private AiPromptbausteinFolderListVM _SubFolders; private AiPromptbausteinPromptListVM _SubPrompts; + private AiPromptbausteinRoutineListVM _SubRoutines; public AiPromptbausteinFolderVM(AiPromptbausteinFolderDC dc) : base(dc, dc.Oid) { @@ -36,8 +37,6 @@ namespace BeWo.ViewModel var success = SetProperty(ref _Title, value, nameof(Title), () => DataContract.Title); if (!success) return; - - FirePropertyChanged(nameof(Displayname)); } } @@ -99,7 +98,8 @@ namespace BeWo.ViewModel return; _SubPrompts.VMList.ListChanged += (s, e) => { - FirePropertyChanged(nameof(Displayname)); + FirePropertyChanged(nameof(TotalPromptCount)); + FirePropertyChanged(nameof(AlleFolderItems)); if (e.ListChangedType == System.ComponentModel.ListChangedType.ItemChanged) return; @@ -109,6 +109,40 @@ namespace BeWo.ViewModel } } + public AiPromptbausteinRoutineListVM SubRoutines + { + get => _SubRoutines; + set + { + var success = SetProperty(ref _SubRoutines, value, nameof(SubRoutines)); + if (!success) + return; + + _SubRoutines.VMList.ListChanged += (s, e) => { + FirePropertyChanged(nameof(TotalRoutineCount)); + FirePropertyChanged(nameof(AlleFolderItems)); + + if (e.ListChangedType == System.ComponentModel.ListChangedType.ItemChanged) + return; + + FirePropertyChanged(nameof(Routines)); + }; + } + } + + public List AlleFolderItems + { + get + { + var l1 = Prompts.Cast(); + var l2 = Routines.Cast(); + + var l12 = l1.Union(l2); + + return l12.ToList(); + } + } + public List Prompts { get @@ -126,6 +160,23 @@ namespace BeWo.ViewModel } } + public List Routines + { + get + { + var res = new List(); + + res.AddRange(SubRoutines.VMList); + + foreach (var folder in SubFolders.VMList) + { + res.AddRange(folder.Routines); + } + + return res; + } + } + public bool CanAddFolder { get => DataContract.CanAddFolder; @@ -136,6 +187,11 @@ namespace BeWo.ViewModel get => DataContract.CanAddPrompt; set => DataContract.CanAddPrompt = value; } + public bool CanAddRoutine + { + get => DataContract.CanAddRoutine; + set => DataContract.CanAddRoutine = value; + } public bool CanEdit { get => DataContract.CanEdit && BeWoApp.HasLoggedOnUserRight(UserRightType.AiModulePromptbausteineEdit); @@ -155,18 +211,18 @@ namespace BeWo.ViewModel public FontWeight FontWeight => !IsNew && Parent is null ? FontWeights.SemiBold : FontWeights.Medium; public bool HasSubFolders => SubFolders is object && SubFolders.Count > 0; - public string Displayname - { - get - { - if (TotalPromptCount > 0) - { - return $"{Title} ({TotalPromptCount})"; - } + //public string Displayname + //{ + // get + // { + // if (TotalPromptCount > 0) + // { + // return $"{Title} ({TotalPromptCount})"; + // } - return Title; - } - } + // return Title; + // } + //} public int TotalPromptCount { @@ -183,6 +239,21 @@ namespace BeWo.ViewModel } } + public int TotalRoutineCount + { + get + { + var total = SubRoutines.Count; + + foreach (var folder in SubFolders.VMList) + { + total += folder.TotalRoutineCount; + } + + return total; + } + } + protected override void InitByDataContract(AiPromptbausteinFolderDC pDataContract) { _Title = pDataContract.Title; @@ -193,8 +264,9 @@ namespace BeWo.ViewModel _Position = pDataContract.Position; _IsExpanded = pDataContract.IsExpanded; _ActionType = pDataContract.ActionType; - _SubFolders = new AiPromptbausteinFolderListVM(pDataContract.SubFolders, this); + SubFolders = new AiPromptbausteinFolderListVM(pDataContract.SubFolders, this); SubPrompts = new AiPromptbausteinPromptListVM(pDataContract.SubPrompts); + SubRoutines = new AiPromptbausteinRoutineListVM(pDataContract.SubRoutines); } protected override AiPromptbausteinFolderDC MapToDataContract(AiPromptbausteinFolderDC pDataContract, bool doCommit) @@ -208,6 +280,7 @@ namespace BeWo.ViewModel pDataContract.ActionType = _ActionType; pDataContract.SubFolders = _SubFolders.CopyToDCList(doCommit); pDataContract.SubPrompts = _SubPrompts.CopyToDCList(doCommit); + pDataContract.SubRoutines = _SubRoutines.CopyToDCList(doCommit); return pDataContract; } diff --git a/BeWo/ViewModel/AiPromptbausteinRoutineVM.cs b/BeWo/ViewModel/AiPromptbausteinRoutineVM.cs index a80cf0aa0..fe8bf9f83 100644 --- a/BeWo/ViewModel/AiPromptbausteinRoutineVM.cs +++ b/BeWo/ViewModel/AiPromptbausteinRoutineVM.cs @@ -4,6 +4,7 @@ using BS.Shared; using BS.Shared.DataContracts; using BS.Shared.DataContracts.Compact; using BS.Shared.DataContracts.Feature.AI; +using BS.Shared.Extensions; namespace BeWo.ViewModel { @@ -85,6 +86,13 @@ namespace BeWo.ViewModel set => SetProperty(ref _Steps, value, nameof(Steps)); } + public bool CanShareEdit + { + get => BeWoApp.HasLoggedOnUserRight(UserRightType.AiModulePromptbausteinShare); + } + + public override bool IsDirty => base.IsDirty || Steps.IsDirty; + protected override void InitByDataContract(AiPromptbausteinRoutineDC pDataContract) { _Title = pDataContract.Title; @@ -111,10 +119,22 @@ namespace BeWo.ViewModel pDataContract.IsFavorite = _IsFavorite; pDataContract.ActionType = _ActionType; pDataContract.CanEdit = _CanEdit; - - pDataContract.Steps = _Steps.CopyToDCList(doCommit); + pDataContract.Steps = _Steps.CopyToDCList(true); return pDataContract; } + + public override void UpdateByDataContract(AiPromptbausteinRoutineDC pDataContract) + { + Title = pDataContract.Title; + Description = pDataContract.Description; + IsPublic = pDataContract.IsPublic; + IsFavorite = pDataContract.IsFavorite; + + var steps = new AiPromptbausteinRoutineStepListVM(pDataContract.Steps); + + Steps.VMList.Clear(); + Steps.VMList.AddRange(steps.VMList); + } } } diff --git a/BeWo/ViewModel/View/AI/AiPromptbausteinComplexSelectionViewModel.cs b/BeWo/ViewModel/View/AI/AiPromptbausteinComplexSelectionViewModel.cs index 2bb8b9fcd..ebbb46b48 100644 --- a/BeWo/ViewModel/View/AI/AiPromptbausteinComplexSelectionViewModel.cs +++ b/BeWo/ViewModel/View/AI/AiPromptbausteinComplexSelectionViewModel.cs @@ -58,6 +58,9 @@ namespace BeWo.ViewModel.View.AI public bool HasCopiedPrompt => CopiedPrompt is object; public CompactEmployeeDC CurrentEmployee => BeWoApp.CompactLoggedOnEmployee; + public bool CanOpenContextMenu { get; set; } + public string AcceptButtonText => CanOpenContextMenu ? "Absenden" : "Hinzufügen"; + public AiPromptbausteinSelectionComplexViewModel() { SendCommand = new DelegateCommand(Send, CanSend, true); @@ -73,11 +76,12 @@ namespace BeWo.ViewModel.View.AI WindowService = BeWoApp.MainControl.WindowService; InitCommands(); } - public AiPromptbausteinSelectionComplexViewModel(AiActionType aiActionType, AiPromptbausteinFolderListVM viewModel, bool isFavorite = false) : this(aiActionType) + public AiPromptbausteinSelectionComplexViewModel(AiActionType aiActionType, AiPromptbausteinFolderListVM viewModel, bool isFavorite = false, bool canOpen = true) : this(aiActionType) { LoadedActionType = aiActionType; Folders = viewModel; IsFavorite = isFavorite; + CanOpenContextMenu = canOpen; } private void InitCommands() @@ -387,7 +391,27 @@ namespace BeWo.ViewModel.View.AI void OpenAddRoutineDialog() { - + //var sel_folder = SelectedFolder; + //var new_vm = sel_folder.SubRoutines.CreateNewVM(); + + //new_vm.Creator = CurrentEmployee; + //new_vm.ParentFolderOid = sel_folder.DataContract.Oid; + //new_vm.CanEdit = true; + //new_vm.ActionType = AiActionType; + + //var vm = new AiPromptbausteinRoutineViewModel(new_vm, Folders, true); + + //vm.Accept_Button_Clicked += (s, e) => + //{ + // var new_dc = new_vm.CommitToDataContract(); + + // ServiceFacade.DoAiEnhancedServiceAsnyc(x => x.InsertAiPromptbausteinPrompt(new List { new_dc }), + // (new_dcs) => ReloadVMList()); + //}; + + //Close(); + + //WindowService.Show(vm); } void OpenEditRoutineDialog() { diff --git a/BeWo/ViewModel/View/Administration/AiPromptbausteinComplexTreeViewModel.cs b/BeWo/ViewModel/View/Administration/AiPromptbausteinComplexTreeViewModel.cs index 6d2dfe728..326ea6ec7 100644 --- a/BeWo/ViewModel/View/Administration/AiPromptbausteinComplexTreeViewModel.cs +++ b/BeWo/ViewModel/View/Administration/AiPromptbausteinComplexTreeViewModel.cs @@ -21,6 +21,7 @@ namespace BeWo.ViewModel.View.Administration public class AiPromptbausteinComplexTreeViewModel : WindowViewModel { private AiPromptbausteinFolderVM _SelectedFolder; + private AbstractBaseVM _SelectedItem; private IBeWoWindowService WindowService { get; set; } private AiActionType AiActionType { get; set; } @@ -28,7 +29,6 @@ namespace BeWo.ViewModel.View.Administration public AiPromptbausteinFolderListVM Folders { get; set; } public AiPromptbausteinFolderVM Favoriten { get; set; } - public AiPromptbausteinPromptVM SelectedPrompt { get; set; } public AiPromptbausteinFolderVM CopiedFolder { get; set; } public AiPromptbausteinPromptVM CopiedPrompt { get; set; } @@ -45,6 +45,11 @@ namespace BeWo.ViewModel.View.Administration public DelegateCommand DeletePromptCommand { get; private set; } public DelegateCommand ChangeFavoritenStatePromptCommand { get; private set; } + public DelegateCommand OpenAddRoutineDialogCommand { get; private set; } + public DelegateCommand OpenEditRoutineDialogCommand { get; private set; } + public DelegateCommand DeleteRoutineCommand { get; private set; } + public DelegateCommand ChangeFavoritenStateRoutineCommand { get; private set; } + public bool CanEditPromptbausteine { get; set; } public AiPromptbausteinFolderVM SelectedFolder @@ -52,13 +57,19 @@ namespace BeWo.ViewModel.View.Administration get => _SelectedFolder; set => SetProperty(ref _SelectedFolder, value, nameof(SelectedFolder)); } - + + public AbstractBaseVM SelectedItem + { + get => _SelectedItem; + set => SetProperty(ref _SelectedItem, value, nameof(SelectedItem)); + } public AiPromptbausteinComplexTreeViewModel() : this(null, AiActionType.ServiceRecordConversation) { if (BeWoApp.IsInDesignMode) { - ReloadVMList(); + //ReloadVMList(); + InitDesigner(); SelectedFolder = Folders.VMList.FirstOrDefault(); return; } @@ -81,6 +92,11 @@ namespace BeWo.ViewModel.View.Administration DeletePromptCommand = new DelegateCommand(OpenDeletePromptDialog, canOpenDeletePromptDialog, false); ChangeFavoritenStatePromptCommand = new DelegateCommand(ChangeFavoritenStatePrompt, canChangeFavoritenStatePrompt, false); + OpenAddRoutineDialogCommand = new DelegateCommand(OpenAddRoutineDialog, canOpenAddRoutineDialog, false); + OpenEditRoutineDialogCommand = new DelegateCommand(OpenEditRoutineDialog, canOpenEditRoutineDialog, false); + DeleteRoutineCommand = new DelegateCommand(OpenDeleteRoutineDialog, canOpenDeleteRoutineDialog, false); + ChangeFavoritenStateRoutineCommand = new DelegateCommand(ChangeFavoritenStateRoutine, canChangeFavoritenStateRoutine, false); + CanEditPromptbausteine = BeWoApp.HasLoggedOnUserRight(UserRightType.AiModulePromptbausteineEdit); } @@ -111,6 +127,10 @@ namespace BeWo.ViewModel.View.Administration PastePromptCommand.RaiseCanExecuteChanged(); DeletePromptCommand.RaiseCanExecuteChanged(); ChangeFavoritenStatePromptCommand.RaiseCanExecuteChanged(); + OpenAddRoutineDialogCommand.RaiseCanExecuteChanged(); + OpenEditRoutineDialogCommand.RaiseCanExecuteChanged(); + DeleteRoutineCommand.RaiseCanExecuteChanged(); + ChangeFavoritenStateRoutineCommand.RaiseCanExecuteChanged(); } public void SaveVMList() @@ -355,16 +375,20 @@ namespace BeWo.ViewModel.View.Administration vm.Accept_Button_Clicked += (s, e) => { sel_folder.SubPrompts.VMList.Add(new_vm); - SelectedPrompt = new_vm; + SelectedItem = new_vm; }; WindowService.Show(vm); } void OpenEditPromptDialog() { - var sel_prompt = SelectedPrompt; + var sel_prompt = SelectedItem as AiPromptbausteinPromptVM; + + if (SelectedItem is null) + throw new Exception("invalid operation"); + var sel_dc = sel_prompt.CopyToEmptyDataContract(); - sel_dc.CanEdit = SelectedPrompt.CanEdit; + sel_dc.CanEdit = sel_prompt.CanEdit; var edit_vm = new AiPromptbausteinPromptVM(sel_dc); var vm = new AiPromptbausteinPromptViewModel(edit_vm, false); @@ -383,7 +407,7 @@ namespace BeWo.ViewModel.View.Administration private void UpdateSelectedPromptFavorite(AiPromptbausteinPromptVM sel_prompt = null) { if (sel_prompt is null) - sel_prompt = SelectedPrompt; + sel_prompt = SelectedItem as AiPromptbausteinPromptVM; if (sel_prompt.IsFavorite && !Favoriten.SubPrompts.VMList.Contains(sel_prompt)) Favoriten.SubPrompts.VMList.Add(sel_prompt); @@ -391,7 +415,27 @@ namespace BeWo.ViewModel.View.Administration { Favoriten.SubPrompts.VMList.Remove(sel_prompt); - if (Favoriten.SubPrompts.Count == 0) + if (Favoriten.SubRoutines.Count == 0 && Favoriten.SubPrompts.Count == 0) + { + var selected_folder = SelectedFolder; + SelectedFolder = null; + SelectedFolder = selected_folder; + } + } + } + + private void UpdateSelectedRoutineFavorite(AiPromptbausteinRoutineVM sel_routine = null) + { + if (sel_routine is null) + sel_routine = SelectedItem as AiPromptbausteinRoutineVM; + + if (sel_routine.IsFavorite && !Favoriten.SubRoutines.VMList.Contains(sel_routine)) + Favoriten.SubRoutines.VMList.Add(sel_routine); + else if (!sel_routine.IsFavorite && Favoriten.SubRoutines.VMList.Contains(sel_routine)) + { + Favoriten.SubRoutines.VMList.Remove(sel_routine); + + if (Favoriten.SubRoutines.Count == 0 && Favoriten.SubPrompts.Count == 0) { var selected_folder = SelectedFolder; SelectedFolder = null; @@ -402,7 +446,7 @@ namespace BeWo.ViewModel.View.Administration void CopyPrompt() { - CopiedPrompt = SelectedPrompt; + CopiedPrompt = SelectedItem as AiPromptbausteinPromptVM; } void PastePrompt() { @@ -421,7 +465,7 @@ namespace BeWo.ViewModel.View.Administration } void OpenDeletePromptDialog() { - var sel_prompt = SelectedPrompt; + var sel_prompt = SelectedItem as AiPromptbausteinPromptVM; var folder = SelectedFolder; var txt = "Möchten Sie den ausgewählten Prompt wirklich löschen?"; @@ -430,12 +474,12 @@ namespace BeWo.ViewModel.View.Administration if (result != MessageBoxResult.OK) return; - folder.SubPrompts.VMList.Remove(SelectedPrompt); + folder.SubPrompts.VMList.Remove(sel_prompt); } void ChangeFavoritenStatePrompt() { - var sel_prompt = SelectedPrompt; + var sel_prompt = SelectedItem as AiPromptbausteinPromptVM; sel_prompt.IsFavorite = !sel_prompt.IsFavorite; @@ -448,11 +492,11 @@ namespace BeWo.ViewModel.View.Administration } bool canOpenEditPromptDialog() { - return SelectedPrompt is object; + return SelectedItem as AiPromptbausteinPromptVM is object; } bool canCopyPrompt() { - return CanEditPromptbausteine && SelectedPrompt is object; + return CanEditPromptbausteine && SelectedItem as AiPromptbausteinPromptVM is object; } bool canPastePrompt() { @@ -460,36 +504,93 @@ namespace BeWo.ViewModel.View.Administration } bool canOpenDeletePromptDialog() { - return CanEditPromptbausteine && (SelectedPrompt?.CanEdit ?? false); + return CanEditPromptbausteine && ((SelectedItem as AiPromptbausteinPromptVM)?.CanEdit ?? false); } bool canChangeFavoritenStatePrompt() { - return SelectedPrompt is object; + return SelectedItem as AiPromptbausteinPromptVM is object; } // --- Routine Commands void OpenAddRoutineDialog() { + var sel_folder = SelectedFolder; + var new_vm = sel_folder.SubRoutines.CreateNewVM(); + new_vm.Creator = CurrentEmployee; + new_vm.ParentFolderOid = sel_folder.DataContract.Oid; + new_vm.CanEdit = true; + new_vm.ActionType = AiActionType; + + var vm = new AiPromptbausteinRoutineViewModel(new_vm, Folders, true); + + vm.Accept_Button_Clicked += (s, e) => + { + sel_folder.SubRoutines.VMList.Add(new_vm); + SelectedItem = new_vm; + }; + + WindowService.Show(vm); } void OpenEditRoutineDialog() { + var sel_prompt = SelectedItem as AiPromptbausteinRoutineVM; + if (SelectedItem is null) + throw new Exception("invalid operation"); + + var sel_dc = sel_prompt.CopyToEmptyDataContract(); + sel_dc.CanEdit = sel_prompt.CanEdit; + var edit_vm = new AiPromptbausteinRoutineVM(sel_dc); + + var vm = new AiPromptbausteinRoutineViewModel(edit_vm, Folders, false); + + vm.Accept_Button_Clicked += (s, e) => + { + var edit_dc = edit_vm.CommitToDataContract(); + sel_prompt.UpdateByDataContract(edit_dc); + + UpdateSelectedRoutineFavorite(sel_prompt); + }; + + WindowService.Show(vm); } void OpenDeleteRoutineDialog() { + var sel_prompt = SelectedItem as AiPromptbausteinRoutineVM; + var folder = SelectedFolder; + var txt = "Möchten Sie die ausgewählte Routine wirklich löschen?"; + var result = MessageBox.Show(txt, "Hinweis", MessageBoxButton.OKCancel); + + if (result != MessageBoxResult.OK) + return; + + folder.SubRoutines.VMList.Remove(sel_prompt); } void ChangeFavoritenStateRoutine() { + var sel_routine = SelectedItem as AiPromptbausteinRoutineVM; + sel_routine.IsFavorite = !sel_routine.IsFavorite; + + UpdateSelectedRoutineFavorite(sel_routine); } - //bool canOpenAddRoutineDialog() => CanEditPromptbausteine && (SelectedFolder?.CanAddPrompt ?? false); - //bool canOpenEditRoutineDialog() => SelectedRoutine is object; - //bool canOpenDeleteRoutineDialog() => CanEditPromptbausteine && (SelectedRoutine?.CanEdit ?? false); - //bool canChangeFavoritenStateRoutine() => SelectedRoutine is object; + bool canOpenAddRoutineDialog() => CanEditPromptbausteine && (SelectedFolder?.CanAddPrompt ?? false); + bool canOpenEditRoutineDialog() => SelectedItem is AiPromptbausteinRoutineVM; + bool canOpenDeleteRoutineDialog() => CanEditPromptbausteine && ((SelectedItem as AiPromptbausteinRoutineVM)?.CanEdit ?? false); + bool canChangeFavoritenStateRoutine() => SelectedItem is AiPromptbausteinRoutineVM; + + void InitDesigner() + { + var root = PredefinedAiPromptbausteinFolders.CreateSubTree(AiActionType.ServiceRecordConversation); + + var root_vm = new AiPromptbausteinFolderListVM(root); + + Folders = root_vm; + } } } diff --git a/BeWo/ViewModel/View/Administration/AiPromptbausteinRoutineViewModel.cs b/BeWo/ViewModel/View/Administration/AiPromptbausteinRoutineViewModel.cs new file mode 100644 index 000000000..a08247cc7 --- /dev/null +++ b/BeWo/ViewModel/View/Administration/AiPromptbausteinRoutineViewModel.cs @@ -0,0 +1,49 @@ +using BeWo.ViewModel.ListViewModel; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace BeWo.ViewModel.View.Administration +{ + public class AiPromptbausteinRoutineViewModel : AcceptCancelDialogViewModel + { + private readonly bool _IsNew; + public AiPromptbausteinRoutineStepVM _SelectedStep; + + public AiPromptbausteinRoutineViewModel(AiPromptbausteinRoutineVM viewModel, AiPromptbausteinFolderListVM folders, bool isNew) : base() + { + ViewModel = viewModel; + FolderListVM = folders; + _IsNew = isNew; + + ViewModel.PropertyChanged += (s, e) => + { + AcceptCommand.RaiseCanExecuteChanged(); + }; + + ViewModel.Steps.VMList.ListChanged += (s, e) => + { + AcceptCommand.RaiseCanExecuteChanged(); + }; + } + + + public AiPromptbausteinFolderListVM FolderListVM { get; set; } + public AiPromptbausteinRoutineVM ViewModel { get; private set; } + + public AiPromptbausteinRoutineStepVM SelectedStep + { + get => _SelectedStep; + set => SetProperty(ref _SelectedStep, value, nameof(SelectedStep)); + } + + public string AcceptButtonText => _IsNew ? "Hinzufügen" : "Speichern"; + + protected override bool canAccept() + { + return (_IsNew || ViewModel.IsDirty) && !string.IsNullOrWhiteSpace(ViewModel.Title) && (ViewModel.Steps?.VMList.Any() ?? false); + } + } +} diff --git a/Service/Plugins/AiPromptbausteineService.cs b/Service/Plugins/AiPromptbausteineService.cs index caea7cbb4..66fc0866f 100644 --- a/Service/Plugins/AiPromptbausteineService.cs +++ b/Service/Plugins/AiPromptbausteineService.cs @@ -41,7 +41,6 @@ namespace BeWo.Service.Plugins return result; } - public IEnumerable InsertAiPromptbausteinFolder(IEnumerable folders) { var entities = MapperFactory.AiPromptbausteinFolder.MapToNewEntities(folders); @@ -50,7 +49,6 @@ namespace BeWo.Service.Plugins return null; } - public IEnumerable InsertAiPromptbausteinPrompt(IEnumerable prompts) { var entities = MapperFactory.AiPromptbausteinPrompt.MapToNewEntities(prompts); @@ -59,7 +57,14 @@ namespace BeWo.Service.Plugins return null; } + public IEnumerable InsertAiPromptbausteinRoutine(IEnumerable routine) + { + var entities = MapperFactory.AiPromptbausteinRoutine.MapToNewEntities(routine); + DAOFactory.GenericDAO.Insert(entities); + + return null; + } public IEnumerable UpdateAiPromptbausteinFolder(IEnumerable folders) { var originale = DAOFactory.GenericDAO.LoadByIDs(folders.Select(sc => sc.Oid.Value)); @@ -70,7 +75,6 @@ namespace BeWo.Service.Plugins return null; } - public IEnumerable UpdateAiPromptbausteinPrompt(IEnumerable prompts) { var originale = DAOFactory.GenericDAO.LoadByIDs(prompts.Select(sc => sc.Oid.Value)); @@ -81,6 +85,16 @@ namespace BeWo.Service.Plugins return null; } + public IEnumerable UpdateAiPromptbausteinRoutine(IEnumerable routine) + { + var originale = DAOFactory.GenericDAO.LoadByIDs(routine.Select(sc => sc.Oid.Value)); + var routine2 = routine.ToList(); + MapperFactory.AiPromptbausteinRoutine.MergeWithEntitys(routine2, originale); + + DAOFactory.GenericDAO.Update(originale); + + return null; + } public void DeleteAiPromptbausteinFolder(Dictionary oid2version) { @@ -107,6 +121,13 @@ namespace BeWo.Service.Plugins DAOFactory.GenericDAO.SetActivationType(originale, BS.Shared.ActivationTypeId.Deleted); } + public void DeleteAiPromptbausteinRoutine(Dictionary oid2version) + { + var originale = DAOFactory.GenericDAO.LoadByIDs(oid2version.Select(e => e.Key)); + originale.DoForEach(or => MapperFactory.AiPromptbausteinRoutine.ConcurrencyCheck(oid2version[or.Oid.Value], or)); + + DAOFactory.GenericDAO.SetActivationType(originale, BS.Shared.ActivationTypeId.Deleted); + } private AiPromptbausteinFolderDC getOwnFolder(AiActionType aiActionType) { @@ -134,6 +155,39 @@ namespace BeWo.Service.Plugins own_bib.SubPrompts.AddRange(own_prompts_dcs); + + + var example_routine = new AiPromptbausteinRoutineDC(); + example_routine.ActionType = aiActionType; + example_routine.CanEdit = true; + example_routine.IsPublic = true; + example_routine.Description = "Beschreibung"; + example_routine.Oid = 1000; + example_routine.ParentFolderOid = own_bib.Oid; + example_routine.Title = "Routine Title"; + example_routine.Steps = new List(); + + if (own_prompts_dcs.Count > 0) + example_routine.Steps.Add(new AiPromptbausteinRoutineStepDC() + { + Oid = 1001, + Position = 0, + PromptReference = own_prompts_dcs?[0], + }); + + if (own_bib.SubFolders.Count > 0 && own_bib.SubFolders[0].SubPrompts.Count > 0) + example_routine.Steps.Add(new AiPromptbausteinRoutineStepDC() + { + Oid = 1001, + Position = 0, + PromptReference = own_bib.SubFolders[0].SubPrompts[0], + }); + + if (own_prompts_dcs.Count > 0) + { + own_bib.SubRoutines = new List { example_routine }; + } + return own_bib; } private void initOwnFolder(AiPromptbausteinFolderDC folder) diff --git a/Service/ServiceContracts/Enhanced/IAiEnhancedService.cs b/Service/ServiceContracts/Enhanced/IAiEnhancedService.cs index d39bfb75a..87ff5b096 100644 --- a/Service/ServiceContracts/Enhanced/IAiEnhancedService.cs +++ b/Service/ServiceContracts/Enhanced/IAiEnhancedService.cs @@ -86,6 +86,11 @@ namespace BeWo.Service.ServiceContracts.Enhanced [OperationContract] [RequireWcfAuthorization(UserRightType.AiModulePromptbausteineEdit)] IEnumerable InsertAiPromptbausteinPrompt(IEnumerable prompts); + + [FaultContract(typeof(BeWoFault))] + [OperationContract] + [RequireWcfAuthorization(UserRightType.AiModulePromptbausteineEdit)] + IEnumerable InsertAiPromptbausteinRoutine(IEnumerable routine); [FaultContract(typeof(BeWoFault))] [OperationContract] @@ -94,8 +99,13 @@ namespace BeWo.Service.ServiceContracts.Enhanced [FaultContract(typeof(BeWoFault))] [OperationContract] - [RequireWcfAuthorization(UserRightType.AiModulePromptbausteineView)] + [RequireWcfAuthorization(UserRightType.AiModulePromptbausteineEdit)] IEnumerable UpdateAiPromptbausteinPrompt(IEnumerable prompts); + + [FaultContract(typeof(BeWoFault))] + [OperationContract] + [RequireWcfAuthorization(UserRightType.AiModulePromptbausteineEdit)] + IEnumerable UpdateAiPromptbausteinRoutine(IEnumerable routine); [FaultContract(typeof(BeWoFault))] [OperationContract] @@ -106,6 +116,11 @@ namespace BeWo.Service.ServiceContracts.Enhanced [OperationContract] [RequireWcfAuthorization(UserRightType.AiModulePromptbausteineEdit)] void DeleteAiPromptbausteinPrompt(Dictionary oid2version); + + [FaultContract(typeof(BeWoFault))] + [OperationContract] + [RequireWcfAuthorization(UserRightType.AiModulePromptbausteineEdit)] + void DeleteAiPromptbausteinRoutine(Dictionary oid2version); [FaultContract(typeof(BeWoFault))] [OperationContract] diff --git a/Service/ServiceImplementations/Enhanced/AiEnhancedServiceImp.cs b/Service/ServiceImplementations/Enhanced/AiEnhancedServiceImp.cs index 490a56888..312ac7221 100644 --- a/Service/ServiceImplementations/Enhanced/AiEnhancedServiceImp.cs +++ b/Service/ServiceImplementations/Enhanced/AiEnhancedServiceImp.cs @@ -71,18 +71,27 @@ namespace BeWo.Service.ServiceImplementations.Enhanced public IEnumerable InsertAiPromptbausteinPrompt(IEnumerable prompts) => GetAiPromptbausteineService().InsertAiPromptbausteinPrompt(prompts); + + public IEnumerable InsertAiPromptbausteinRoutine(IEnumerable routine) + => GetAiPromptbausteineService().InsertAiPromptbausteinRoutine(routine); public IEnumerable UpdateAiPromptbausteinFolder(IEnumerable folders) => GetAiPromptbausteineService().UpdateAiPromptbausteinFolder(folders); public IEnumerable UpdateAiPromptbausteinPrompt(IEnumerable prompts) => GetAiPromptbausteineService().UpdateAiPromptbausteinPrompt(prompts); + + public IEnumerable UpdateAiPromptbausteinRoutine(IEnumerable routine) + => GetAiPromptbausteineService().UpdateAiPromptbausteinRoutine(routine); public void DeleteAiPromptbausteinFolder(Dictionary oid2version) => GetAiPromptbausteineService().DeleteAiPromptbausteinFolder(oid2version); public void DeleteAiPromptbausteinPrompt(Dictionary oid2version) => GetAiPromptbausteineService().DeleteAiPromptbausteinPrompt(oid2version); + + public void DeleteAiPromptbausteinRoutine(Dictionary oid2version) + => GetAiPromptbausteineService().DeleteAiPromptbausteinRoutine(oid2version); private AiPromptbausteineService GetAiPromptbausteineService() { diff --git a/Shared/DataContracts/Feature/AI/AiPromptbausteinFolderDC.cs b/Shared/DataContracts/Feature/AI/AiPromptbausteinFolderDC.cs index fb7b66e29..0e1d2c169 100644 --- a/Shared/DataContracts/Feature/AI/AiPromptbausteinFolderDC.cs +++ b/Shared/DataContracts/Feature/AI/AiPromptbausteinFolderDC.cs @@ -19,9 +19,11 @@ namespace BS.Shared.DataContracts.Feature.AI [DataMember] public AiActionType ActionType { get; set; } [DataMember] public List SubFolders { get; set; } [DataMember] public List SubPrompts { get; set; } + [DataMember] public List SubRoutines { get; set; } [DataMember] public bool CanAddFolder { get; set; } [DataMember] public bool CanAddPrompt { get; set; } + [DataMember] public bool CanAddRoutine { get; set; } [DataMember] public bool CanEdit { get; set; } [DataMember] public bool IsNewFeature { get; set; } }