diff --git a/BeWo/ViewModel/AiPromptbausteinTreeVM.cs b/BeWo/ViewModel/AiPromptbausteinTreeVM.cs index 4b727a16e..f765ed075 100644 --- a/BeWo/ViewModel/AiPromptbausteinTreeVM.cs +++ b/BeWo/ViewModel/AiPromptbausteinTreeVM.cs @@ -15,7 +15,7 @@ using BS.Shared.Interface; namespace BeWo.ViewModel { - public class AiPromptbausteinTreeVM : AbstractDCMapperVM, IAiPromptbaustein + public class AiPromptbausteinTreeVM : AbstractDCMapperVM, IAiPromptbaustein { private string _Displayname; private string _Content; @@ -108,12 +108,12 @@ namespace BeWo.ViewModel set => SetProperty(ref _Children, value, nameof(Children)); } - public bool HasChildren => Children is object && Children.Count > 0; - - public FontWeight FontWeight => PromptbausteinType != AiPromptbausteinType.Prompt ? FontWeights.Bold : FontWeights.Regular; - public AiPromptbausteinTreeVM Parent { get; set; } + public bool HasChildren => Children is object && Children.Count > 0; + public FontWeight FontWeight => PromptbausteinType != AiPromptbausteinType.Prompt ? FontWeights.Bold : FontWeights.Regular; + public long? Oid => DataContract.Oid; + protected override void InitByDataContract(AiPromptbausteinTreeDC pDataContract) { if (pDataContract is null) diff --git a/BeWo/ViewModel/View/Administration/AiPromptbausteinTreeViewModel.cs b/BeWo/ViewModel/View/Administration/AiPromptbausteinTreeViewModel.cs index 8a7f13bb3..e6faf5284 100644 --- a/BeWo/ViewModel/View/Administration/AiPromptbausteinTreeViewModel.cs +++ b/BeWo/ViewModel/View/Administration/AiPromptbausteinTreeViewModel.cs @@ -25,17 +25,18 @@ namespace BeWo.ViewModel.View.Administration ListVM = new AiPromptbausteinTreeListVM(); } - Func canAddPrompt = () => SelectedNode.IsOrdner() || SelectedNode.IsKette(); - Func canAddOrdner = () => SelectedNode.IsOrdner(); - Func canAddKette = () => SelectedNode.IsOrdner() && false; - Func canEdit = () => SelectedNode is object; - Func canCopy = () => SelectedNode.IsKette() || SelectedNode.IsOrdner(); - Func canCopySingle = () => SelectedNode is object; + Func canAddPrompt = () => (SelectedNode.IsAddablePredefinedNode() && SelectedNode.IsOrdner()) || (SelectedNode.IsNoPredefinedNode() && (SelectedNode.IsOrdner() || SelectedNode.IsKette())) ; + Func canAddOrdner = () => (SelectedNode.IsAddablePredefinedNode() && SelectedNode.IsOrdner()) || (SelectedNode.IsNoPredefinedNode() && SelectedNode.IsOrdner()); + Func canAddKette = () => false; + Func canEdit = () => SelectedNode.IsNoPredefinedNode(); + Func canCopy = () => SelectedNode.IsNoPredefinedNode() && (SelectedNode.IsKette() || SelectedNode.IsOrdner()); + Func canCopySingle = () => SelectedNode.IsNoPredefinedNode(); Func canPaste = () => HasCopiedTreeNode && !Contains(CopyTreeNode, SelectedNode) && (!CopyTreeNode.IsOrdner() || canAddOrdner()) && (!CopyTreeNode.IsKette() || canAddKette()) && - (!CopyTreeNode.IsPrompt() || canAddPrompt()); - Func canDelete = () => SelectedNode is object; + (!CopyTreeNode.IsPrompt() || canAddPrompt()) && + SelectedNode.AiActionType == CopyTreeNode.AiActionType; + Func canDelete = () => SelectedNode.IsNoPredefinedNode(); AddPromptCommand = new DelegateCommand(() => Add(AiPromptbausteinType.Prompt), canAddPrompt); AddOrdnerCommand = new DelegateCommand(() => Add(AiPromptbausteinType.Ordner), canAddOrdner); diff --git a/Shared/Extensions/CustomInterfaces/IAiPromptbausteinTreeExtension.cs b/Shared/Extensions/CustomInterfaces/IAiPromptbausteinTreeExtension.cs index 54bd8fb65..3c974a990 100644 --- a/Shared/Extensions/CustomInterfaces/IAiPromptbausteinTreeExtension.cs +++ b/Shared/Extensions/CustomInterfaces/IAiPromptbausteinTreeExtension.cs @@ -4,6 +4,7 @@ using DevExpress.Xpf.Bars.Native; using System; using System.Collections.Generic; using System.Linq; +using System.Security.Cryptography.X509Certificates; using System.Text; using System.Threading.Tasks; @@ -25,6 +26,17 @@ namespace BS.Shared.Extensions.CustomInterfaces => aiPromptbaustein.hasPrompttype(AiPromptbausteinType.Prompt); + public static bool IsPredefinedNode(this IAiPromptbaustein aiPromptbaustein) + => aiPromptbaustein.isObject() && aiPromptbaustein.Oid < 0; + + public static bool IsNoPredefinedNode(this IAiPromptbaustein aiPromptbaustein) + => aiPromptbaustein.isObject() && aiPromptbaustein.Oid >= 0; + + public static bool IsAddablePredefinedNode(this IAiPromptbaustein aiPromptbaustein) + => aiPromptbaustein.IsPredefinedNode() && !aiPromptbaustein.IsNoAddablePredefinedNode(); + + public static bool IsNoAddablePredefinedNode(this IAiPromptbaustein aiPromptbaustein) + => aiPromptbaustein.IsPredefinedNode() && aiPromptbaustein.AiActionType == AiActionType.ServiceRecord; private static bool hasPrompttype(this IAiPromptbaustein aiPromptbaustein, AiPromptbausteinType aiPromptbausteinType) => aiPromptbaustein.isObject() && aiPromptbaustein.PromptbausteinType == aiPromptbausteinType; diff --git a/Shared/Interface/IAiPromptbaustein.cs b/Shared/Interface/IAiPromptbaustein.cs index 6feb82832..01b105e41 100644 --- a/Shared/Interface/IAiPromptbaustein.cs +++ b/Shared/Interface/IAiPromptbaustein.cs @@ -8,6 +8,8 @@ namespace BS.Shared.Interface { public interface IAiPromptbaustein { + long? Oid { get; } AiPromptbausteinType PromptbausteinType { get; } + AiActionType AiActionType { get; } } }