Erster Entwurf: Prompts
This commit is contained in:
@@ -137,9 +137,51 @@
|
||||
Style="{StaticResource ObjectEditGroupBox}">
|
||||
<ListBox
|
||||
Padding="4,16,4,16"
|
||||
ContextMenuOpening="ListBox_ContextMenuOpening"
|
||||
ItemContainerStyle="{StaticResource PhotoListBoxItem}"
|
||||
ContextMenuService.IsEnabled="{Binding IsChecked, ElementName=EditToggleButton}"
|
||||
ItemTemplate="{StaticResource ai_promptbaustein_prompt_itemtemplate}"
|
||||
ItemsSource="{Binding SelectedFolder.SubPrompts.VMList, UpdateSourceTrigger=PropertyChanged}" />
|
||||
ItemsSource="{Binding SelectedFolder.SubPrompts.VMList, UpdateSourceTrigger=PropertyChanged}"
|
||||
SelectedItem="{Binding SelectedPrompt, Mode=TwoWay}">
|
||||
<ListBox.ContextMenu>
|
||||
<ContextMenu>
|
||||
<ContextMenu.Resources>
|
||||
<ResourceDictionary>
|
||||
<Style TargetType="{x:Type Image}">
|
||||
<Setter Property="Height" Value="24" />
|
||||
</Style>
|
||||
</ResourceDictionary>
|
||||
</ContextMenu.Resources>
|
||||
<MenuItem Command="{Binding OpenAddPromptDialogCommand}" Header="Neu">
|
||||
<MenuItem.Icon>
|
||||
<Image Source="..\..\..\Ressources\Icons\Add24.png" />
|
||||
</MenuItem.Icon>
|
||||
</MenuItem>
|
||||
<MenuItem Command="{Binding OpenEditPromptDialogCommand}" Header="Bearbeiten">
|
||||
<MenuItem.Icon>
|
||||
<Image Source="..\..\..\Ressources\Icons\Rename24.png" />
|
||||
</MenuItem.Icon>
|
||||
</MenuItem>
|
||||
<Separator />
|
||||
<MenuItem Command="{Binding CopyPromptCommand}" Header="Kopieren">
|
||||
<MenuItem.Icon>
|
||||
<Image Source="..\..\..\Ressources\Icons\Copy24.png" />
|
||||
</MenuItem.Icon>
|
||||
</MenuItem>
|
||||
<MenuItem Command="{Binding PastePromptCommand}" Header="Einfügen">
|
||||
<MenuItem.Icon>
|
||||
<Image Source="..\..\..\Ressources\Icons\Paste24.png" />
|
||||
</MenuItem.Icon>
|
||||
</MenuItem>
|
||||
<Separator />
|
||||
<MenuItem Command="{Binding DeletePromptCommand}" Header="Löschen">
|
||||
<MenuItem.Icon>
|
||||
<Image Source="..\..\..\Ressources\Icons\Delete24.png" />
|
||||
</MenuItem.Icon>
|
||||
</MenuItem>
|
||||
</ContextMenu>
|
||||
</ListBox.ContextMenu>
|
||||
</ListBox>
|
||||
</GroupBox>
|
||||
</Grid>
|
||||
</GroupBox>
|
||||
|
||||
@@ -107,5 +107,10 @@ namespace BeWo.View.Detail.AI
|
||||
{
|
||||
ViewModel.UpdateFolderCommands();
|
||||
}
|
||||
|
||||
private void ListBox_ContextMenuOpening(object sender, ContextMenuEventArgs e)
|
||||
{
|
||||
ViewModel.UpdatePromptCommands();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -77,16 +77,20 @@
|
||||
IsChecked="{Binding Node.IsOnlyForCreator}"
|
||||
IsEnabled="{Binding IsEditingMode, UpdateSourceTrigger=PropertyChanged}" />
|
||||
|
||||
<Button
|
||||
Grid.Row="6"
|
||||
Grid.Column="2"
|
||||
Width="100"
|
||||
Margin="3,19,10,3"
|
||||
HorizontalAlignment="Right"
|
||||
Command="{Binding AddCommand}"
|
||||
Visibility="{Binding IsAdd, Converter={StaticResource BoolVisibilityConverter}}">
|
||||
Speichern
|
||||
</Button>
|
||||
<StackPanel
|
||||
Grid.Row="6"
|
||||
Grid.ColumnSpan="3"
|
||||
Margin="3,19,10,3"
|
||||
HorizontalAlignment="Right"
|
||||
Orientation="Horizontal">
|
||||
<Button Width="100" Command="{Binding CancelCommand}" Visibility="Visible">
|
||||
Abbrechen
|
||||
</Button>
|
||||
<Button
|
||||
Width="100"
|
||||
Command="{Binding AcceptCommand}"
|
||||
Content="{Binding AcceptButtonText}" Visibility="Visible"/>
|
||||
</StackPanel>
|
||||
</Grid>
|
||||
</Grid>
|
||||
</UserControl>
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
|
||||
using BS.Shared;
|
||||
using BS.Shared.DataContracts;
|
||||
using BS.Shared.DataContracts.Compact;
|
||||
|
||||
namespace BeWo.ViewModel
|
||||
{
|
||||
@@ -9,9 +10,9 @@ namespace BeWo.ViewModel
|
||||
{
|
||||
private string _Title;
|
||||
private string _Description;
|
||||
private long _ParentFolderOid;
|
||||
private long _CreatorOid;
|
||||
private bool _IsPrivate;
|
||||
private long? _ParentFolderOid;
|
||||
private CompactEmployeeDC _Creator;
|
||||
private bool _IsPublic;
|
||||
private int _Position;
|
||||
private string _Prompt;
|
||||
private bool _ShowPrompt;
|
||||
@@ -36,22 +37,22 @@ namespace BeWo.ViewModel
|
||||
set => SetProperty(ref _Description, value, nameof(Description), () => DataContract.Description);
|
||||
}
|
||||
|
||||
public long ParentFolderOid
|
||||
public long? ParentFolderOid
|
||||
{
|
||||
get => _ParentFolderOid;
|
||||
set => SetProperty(ref _ParentFolderOid, value, nameof(ParentFolderOid), () => DataContract.ParentFolderOid);
|
||||
}
|
||||
|
||||
public long CreatorOid
|
||||
public CompactEmployeeDC Creator
|
||||
{
|
||||
get => _CreatorOid;
|
||||
set => SetProperty(ref _CreatorOid, value, nameof(CreatorOid), () => DataContract.CreatorOid);
|
||||
get => _Creator;
|
||||
set => SetProperty(ref _Creator, value, nameof(Creator), () => DataContract.Creator);
|
||||
}
|
||||
|
||||
public bool IsPrivate
|
||||
public bool IsPublic
|
||||
{
|
||||
get => _IsPrivate;
|
||||
set => SetProperty(ref _IsPrivate, value, nameof(IsPrivate), () => DataContract.IsPrivate);
|
||||
get => _IsPublic;
|
||||
set => SetProperty(ref _IsPublic, value, nameof(IsPublic), () => DataContract.IsPublic);
|
||||
}
|
||||
|
||||
public int Position
|
||||
@@ -90,13 +91,19 @@ namespace BeWo.ViewModel
|
||||
set => SetProperty(ref _OwnsoftRefLink, value, nameof(OwnsoftRefLink), () => DataContract.OwnsoftRefLink);
|
||||
}
|
||||
|
||||
public bool CanEdit
|
||||
{
|
||||
get => DataContract.CanEdit;
|
||||
set => DataContract.CanEdit = value;
|
||||
}
|
||||
|
||||
protected override void InitByDataContract(AiPromptbausteinPromptDC pDataContract)
|
||||
{
|
||||
_Title = pDataContract.Title;
|
||||
_Description = pDataContract.Description;
|
||||
_ParentFolderOid = pDataContract.ParentFolderOid;
|
||||
_CreatorOid = pDataContract.CreatorOid;
|
||||
_IsPrivate = pDataContract.IsPrivate;
|
||||
_Creator = pDataContract.Creator;
|
||||
_IsPublic = pDataContract.IsPublic;
|
||||
_Position = pDataContract.Position;
|
||||
_Prompt = pDataContract.Prompt;
|
||||
_ShowPrompt = pDataContract.ShowPrompt;
|
||||
@@ -110,8 +117,8 @@ namespace BeWo.ViewModel
|
||||
pDataContract.Title = _Title;
|
||||
pDataContract.Description = _Description;
|
||||
pDataContract.ParentFolderOid = _ParentFolderOid;
|
||||
pDataContract.CreatorOid = _CreatorOid;
|
||||
pDataContract.IsPrivate = _IsPrivate;
|
||||
pDataContract.Creator = _Creator;
|
||||
pDataContract.IsPublic = _IsPublic;
|
||||
pDataContract.Position = _Position;
|
||||
pDataContract.Prompt = _Prompt;
|
||||
pDataContract.ShowPrompt = _ShowPrompt;
|
||||
@@ -121,5 +128,20 @@ namespace BeWo.ViewModel
|
||||
|
||||
return pDataContract;
|
||||
}
|
||||
|
||||
public override void UpdateByDataContract(AiPromptbausteinPromptDC pDataContract)
|
||||
{
|
||||
Title = pDataContract.Title;
|
||||
Description = pDataContract.Description;
|
||||
ParentFolderOid = pDataContract.ParentFolderOid;
|
||||
Creator = pDataContract.Creator;
|
||||
IsPublic = pDataContract.IsPublic;
|
||||
Position = pDataContract.Position;
|
||||
Prompt = pDataContract.Prompt;
|
||||
ShowPrompt = pDataContract.ShowPrompt;
|
||||
ShowPromptByTenant = pDataContract.ShowPromptByTenant;
|
||||
IsOwnsoftPrompt = pDataContract.IsOwnsoftPrompt;
|
||||
OwnsoftRefLink = pDataContract.OwnsoftRefLink;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -271,7 +271,14 @@ namespace BeWo.ViewModel.ListViewModel
|
||||
return lConstr.Invoke(new object[] { pDC }) as VMType;
|
||||
}
|
||||
|
||||
public void SetSelectByIndex(int index)
|
||||
public virtual VMType CreateNewVM()
|
||||
{
|
||||
var lConstr = typeof(VMType).GetConstructor(new[] { typeof(DCType) });
|
||||
|
||||
return lConstr.Invoke(new object[] { new DCType() }) as VMType;
|
||||
}
|
||||
|
||||
public void SetSelectByIndex(int index)
|
||||
{
|
||||
if(-1 < index && index < VMList.Count){
|
||||
var x = VMList[index];
|
||||
|
||||
@@ -40,32 +40,41 @@ namespace BeWo.ViewModel.View.Administration
|
||||
public DelegateCommand PastePromptCommand { get; private set; }
|
||||
public DelegateCommand DeletePromptCommand { get; private set; }
|
||||
|
||||
public bool IsEditingMode { get; set; }
|
||||
|
||||
public AiPromptbausteinFolderVM SelectedFolder
|
||||
{
|
||||
get => _SelectedFolder;
|
||||
set => SetProperty(ref _SelectedFolder, value, nameof(SelectedFolder));
|
||||
}
|
||||
|
||||
public AiPromptbausteinComplexTreeViewModel()
|
||||
public AiPromptbausteinComplexTreeViewModel() : this(null, AiActionType.ServiceRecordConversation)
|
||||
{
|
||||
if (BeWoApp.IsInDesignMode)
|
||||
{
|
||||
AiActionType = AiActionType.ServiceRecordConversation;
|
||||
ReloadVMList();
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
public AiPromptbausteinComplexTreeViewModel(IBeWoWindowService windowService, AiActionType aiActionType)
|
||||
{
|
||||
WindowService = windowService;
|
||||
AiActionType = aiActionType;
|
||||
|
||||
OpenAddFolderDialogCommand = new DelegateCommand(OpenAddFolderDialog, canOpenAddFolderDialog, false);
|
||||
OpenEditFolderDialogCommand = new DelegateCommand(OpenEditFolderDialog, canOpenEditFolderDialog, false);
|
||||
CopyFolderCommand = new DelegateCommand(CopyFolder, canCopyFolder, false);
|
||||
PasteFolderCommand = new DelegateCommand(PasteFolder, canPasteFolder, false);
|
||||
DeleteFolderCommand = new DelegateCommand(DeleteFolder, canDeleteFolder, false);
|
||||
}
|
||||
|
||||
public AiPromptbausteinComplexTreeViewModel(IBeWoWindowService windowService, AiActionType aiActionType) : this()
|
||||
{
|
||||
WindowService = windowService;
|
||||
AiActionType = aiActionType;
|
||||
OpenAddPromptDialogCommand = new DelegateCommand(OpenAddPromptDialog, canOpenAddPromptDialog, false);
|
||||
OpenEditPromptDialogCommand = new DelegateCommand(OpenEditPromptDialog, canOpenEditPromptDialog, false);
|
||||
CopyPromptCommand = new DelegateCommand(CopyPrompt, canCopyPrompt, false);
|
||||
PastePromptCommand = new DelegateCommand(PastePrompt, canPastePrompt, false);
|
||||
DeletePromptCommand = new DelegateCommand(OpenDeletePromptDialog, canOpenDeletePromptDialog, false);
|
||||
|
||||
IsEditingMode = true;
|
||||
}
|
||||
|
||||
public override bool IsDirty
|
||||
@@ -86,6 +95,15 @@ namespace BeWo.ViewModel.View.Administration
|
||||
PasteFolderCommand.RaiseCanExecuteChanged();
|
||||
DeleteFolderCommand.RaiseCanExecuteChanged();
|
||||
}
|
||||
|
||||
public void UpdatePromptCommands()
|
||||
{
|
||||
OpenAddPromptDialogCommand.RaiseCanExecuteChanged();
|
||||
OpenEditPromptDialogCommand.RaiseCanExecuteChanged();
|
||||
CopyPromptCommand.RaiseCanExecuteChanged();
|
||||
PastePromptCommand.RaiseCanExecuteChanged();
|
||||
DeletePromptCommand.RaiseCanExecuteChanged();
|
||||
}
|
||||
|
||||
public void SaveVMList()
|
||||
{
|
||||
@@ -108,8 +126,7 @@ namespace BeWo.ViewModel.View.Administration
|
||||
void OpenAddFolderDialog()
|
||||
{
|
||||
var sel_folder = SelectedFolder;
|
||||
var new_vm = sel_folder.SubFolders.NewVM;
|
||||
sel_folder.SubFolders.NewVM = null;
|
||||
var new_vm = sel_folder.SubFolders.CreateNewVM();
|
||||
|
||||
new_vm.Creator = BeWoApp.CompactLoggedOnEmployee;
|
||||
new_vm.Parent = sel_folder;
|
||||
@@ -168,7 +185,6 @@ namespace BeWo.ViewModel.View.Administration
|
||||
{
|
||||
return SelectedFolder.CanAdd;
|
||||
}
|
||||
|
||||
bool canOpenEditFolderDialog()
|
||||
{
|
||||
return SelectedFolder.CanEdit;
|
||||
@@ -187,5 +203,84 @@ namespace BeWo.ViewModel.View.Administration
|
||||
{
|
||||
return SelectedFolder.CanEdit;
|
||||
}
|
||||
|
||||
void OpenAddPromptDialog()
|
||||
{
|
||||
var sel_folder = SelectedFolder;
|
||||
var new_vm = sel_folder.SubPrompts.CreateNewVM();
|
||||
|
||||
new_vm.Creator = BeWoApp.CompactLoggedOnEmployee;
|
||||
new_vm.ParentFolderOid = sel_folder.DataContract.Oid;
|
||||
new_vm.ShowPrompt = true;
|
||||
new_vm.ShowPromptByTenant = true;
|
||||
new_vm.CanEdit = true;
|
||||
|
||||
var vm = new AiPromptbausteinPromptViewModel(new_vm, true);
|
||||
|
||||
vm.Accept_Button_Clicked += (s, e) =>
|
||||
{
|
||||
sel_folder.SubPrompts.VMList.Add(new_vm);
|
||||
SelectedPrompt = new_vm;
|
||||
};
|
||||
|
||||
WindowService.Show(vm);
|
||||
}
|
||||
void OpenEditPromptDialog()
|
||||
{
|
||||
var sel_prompt = SelectedPrompt;
|
||||
var sel_dc = sel_prompt.CommitToDataContract();
|
||||
var edit_vm = new AiPromptbausteinPromptVM(sel_dc);
|
||||
|
||||
var vm = new AiPromptbausteinPromptViewModel(edit_vm, false);
|
||||
|
||||
vm.Accept_Button_Clicked += (s, e) =>
|
||||
{
|
||||
var edit_dc = edit_vm.CommitToDataContract();
|
||||
sel_prompt.UpdateByDataContract(edit_dc);
|
||||
};
|
||||
|
||||
WindowService.Show(vm);
|
||||
}
|
||||
void CopyPrompt()
|
||||
{
|
||||
|
||||
}
|
||||
void PastePrompt()
|
||||
{
|
||||
|
||||
}
|
||||
void OpenDeletePromptDialog()
|
||||
{
|
||||
var sel_prompt = SelectedPrompt;
|
||||
var folder = SelectedFolder;
|
||||
|
||||
var txt = "Möchten Sie den ausgewählten Prompt wirklich löschen?";
|
||||
var result = MessageBox.Show(txt, "Hinweis", MessageBoxButton.OKCancel);
|
||||
|
||||
if (result != MessageBoxResult.OK)
|
||||
return;
|
||||
|
||||
folder.SubPrompts.VMList.Remove(SelectedPrompt);
|
||||
}
|
||||
bool canOpenAddPromptDialog()
|
||||
{
|
||||
return SelectedFolder.CanAdd;
|
||||
}
|
||||
bool canOpenEditPromptDialog()
|
||||
{
|
||||
return SelectedPrompt?.CanEdit ?? false;
|
||||
}
|
||||
bool canCopyPrompt()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
bool canPastePrompt()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
bool canOpenDeletePromptDialog()
|
||||
{
|
||||
return SelectedPrompt?.CanEdit ?? false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -14,7 +14,7 @@ namespace BeWo.ViewModel.View.Administration
|
||||
{
|
||||
public class AiPromptbausteinFolderViewModel : AcceptCancelDialogViewModel
|
||||
{
|
||||
private bool _IsNew;
|
||||
private readonly bool _IsNew;
|
||||
|
||||
public AiPromptbausteinFolderViewModel(AiPromptbausteinFolderVM viewModel, bool isNew) : base()
|
||||
{
|
||||
|
||||
@@ -7,7 +7,31 @@ using System.Threading.Tasks;
|
||||
|
||||
namespace BeWo.ViewModel.View.Administration
|
||||
{
|
||||
public class AiPromptbausteinPromptViewModel : DialogViewModel
|
||||
public class AiPromptbausteinPromptViewModel : AcceptCancelDialogViewModel
|
||||
{
|
||||
private readonly bool _IsNew;
|
||||
|
||||
public AiPromptbausteinPromptViewModel(AiPromptbausteinPromptVM viewModel, bool isNew) : base()
|
||||
{
|
||||
ViewModel = viewModel;
|
||||
_IsNew = isNew;
|
||||
|
||||
if (!_IsNew)
|
||||
{
|
||||
ViewModel.PropertyChanged += (s, e) =>
|
||||
{
|
||||
AcceptCommand.RaiseCanExecuteChanged();
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
public AiPromptbausteinPromptVM ViewModel { get; set; }
|
||||
|
||||
public string AcceptButtonText => _IsNew ? "Hinzufügen" : "Speichern";
|
||||
|
||||
protected override bool canAccept()
|
||||
{
|
||||
return _IsNew || ViewModel.IsDirty;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -59,6 +59,7 @@ namespace BS.Shared.DataContracts
|
||||
Title = AiPromptbausteineTexts.OwnBibNodeTitle,
|
||||
Version = 1,
|
||||
CanAdd = true,
|
||||
IsExpanded = true,
|
||||
};
|
||||
}
|
||||
|
||||
@@ -73,7 +74,8 @@ namespace BS.Shared.DataContracts
|
||||
SubFolders = new List<AiPromptbausteinFolderDC>(),
|
||||
SubPrompts = new List<AiPromptbausteinPromptDC>(),
|
||||
Title = AiPromptbausteineTexts.SharedBibNodeTitle,
|
||||
Version = 1
|
||||
Version = 1,
|
||||
IsExpanded = true,
|
||||
};
|
||||
}
|
||||
|
||||
@@ -88,7 +90,8 @@ namespace BS.Shared.DataContracts
|
||||
SubFolders = new List<AiPromptbausteinFolderDC>(),
|
||||
SubPrompts = new List<AiPromptbausteinPromptDC>(),
|
||||
Title = AiPromptbausteineTexts.PublicBibNodeTitle,
|
||||
Version = 1
|
||||
Version = 1,
|
||||
IsExpanded = true,
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
using System;
|
||||
using BS.Shared.DataContracts.Compact;
|
||||
using System;
|
||||
using System.Runtime.Serialization;
|
||||
|
||||
namespace BS.Shared.DataContracts
|
||||
@@ -8,14 +9,16 @@ namespace BS.Shared.DataContracts
|
||||
{
|
||||
[DataMember] public string Title { get; set; }
|
||||
[DataMember] public string Description { get; set; }
|
||||
[DataMember] public long ParentFolderOid { get; set; }
|
||||
[DataMember] public long CreatorOid { get; set; }
|
||||
[DataMember] public bool IsPrivate { get; set; }
|
||||
[DataMember] public long? ParentFolderOid { get; set; }
|
||||
[DataMember] public CompactEmployeeDC Creator { get; set; }
|
||||
[DataMember] public bool IsPublic { get; set; }
|
||||
[DataMember] public int Position { get; set; }
|
||||
[DataMember] public string Prompt { get; set; }
|
||||
[DataMember] public bool ShowPrompt { get; set; }
|
||||
[DataMember] public bool ShowPromptByTenant { get; set; }
|
||||
[DataMember] public bool IsOwnsoftPrompt { get; set; }
|
||||
[DataMember] public string OwnsoftRefLink { get; set; }
|
||||
|
||||
[DataMember] public bool CanEdit { get; set; }
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user