201 lines
5.1 KiB
C#
201 lines
5.1 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.Collections.ObjectModel;
|
|
using System.Linq;
|
|
using System.Windows;
|
|
using BeWo.ViewModel.ListViewModel;
|
|
using BS.Shared;
|
|
using BS.Shared.DataContracts.Compact;
|
|
using BS.Shared.DataContracts.Feature.AI;
|
|
|
|
namespace BeWo.ViewModel
|
|
{
|
|
public class AiPromptbausteinFolderVM : AbstractDCMapperVM<AiPromptbausteinFolderDC>
|
|
{
|
|
private string _Title;
|
|
private string _Description;
|
|
private long? _ParentFolderOid;
|
|
private CompactEmployeeDC _Creator;
|
|
private bool _IsPublic;
|
|
private int _Position;
|
|
private bool _IsExpanded;
|
|
private AiActionType _ActionType;
|
|
private AiPromptbausteinFolderListVM _SubFolders;
|
|
private AiPromptbausteinPromptListVM _SubPrompts;
|
|
|
|
public AiPromptbausteinFolderVM(AiPromptbausteinFolderDC dc) : base(dc, dc.Oid)
|
|
{
|
|
|
|
}
|
|
|
|
public string Title
|
|
{
|
|
get => _Title;
|
|
set
|
|
{
|
|
var success = SetProperty(ref _Title, value, nameof(Title), () => DataContract.Title);
|
|
if (!success)
|
|
return;
|
|
|
|
FirePropertyChanged(nameof(Displayname));
|
|
}
|
|
}
|
|
|
|
public string Description
|
|
{
|
|
get => _Description;
|
|
set => SetProperty(ref _Description, value, nameof(Description), () => DataContract.Description);
|
|
}
|
|
|
|
public long? ParentFolderOid
|
|
{
|
|
get => _ParentFolderOid;
|
|
set => SetProperty(ref _ParentFolderOid, value, nameof(ParentFolderOid), () => DataContract.ParentFolderOid);
|
|
}
|
|
|
|
public CompactEmployeeDC Creator
|
|
{
|
|
get => DataContract.Creator;
|
|
set => SetProperty(ref _Creator, value, nameof(Creator), () => DataContract.Creator);
|
|
}
|
|
|
|
public bool IsPublic
|
|
{
|
|
get => _IsPublic;
|
|
set => SetProperty(ref _IsPublic, value, nameof(IsPublic), () => DataContract.IsPublic);
|
|
}
|
|
|
|
public int Position
|
|
{
|
|
get => _Position;
|
|
set => SetProperty(ref _Position, value, nameof(Position), () => DataContract.Position);
|
|
}
|
|
|
|
public bool IsExpanded
|
|
{
|
|
get => _IsExpanded;
|
|
set => SetProperty(ref _IsExpanded, value, nameof(IsExpanded));
|
|
}
|
|
|
|
public AiActionType ActionType
|
|
{
|
|
get => _ActionType;
|
|
set => SetProperty(ref _ActionType, value, nameof(ActionType), () => DataContract.ActionType);
|
|
}
|
|
|
|
public AiPromptbausteinFolderListVM SubFolders
|
|
{
|
|
get => _SubFolders;
|
|
set => SetProperty(ref _SubFolders, value, nameof(SubFolders));
|
|
}
|
|
|
|
public AiPromptbausteinPromptListVM SubPrompts
|
|
{
|
|
get => _SubPrompts;
|
|
set
|
|
{
|
|
var success = SetProperty(ref _SubPrompts, value, nameof(SubPrompts));
|
|
if (!success)
|
|
return;
|
|
|
|
_SubPrompts.VMList.ListChanged += (s, e) => FirePropertyChanged(nameof(Displayname));
|
|
}
|
|
}
|
|
|
|
public List<AiPromptbausteinPromptVM> Prompts
|
|
{
|
|
get
|
|
{
|
|
var res = new List<AiPromptbausteinPromptVM>();
|
|
|
|
res.AddRange(SubPrompts.VMList);
|
|
|
|
foreach (var folder in SubFolders.VMList)
|
|
{
|
|
res.AddRange(folder.Prompts);
|
|
}
|
|
|
|
return res;
|
|
}
|
|
}
|
|
|
|
public bool CanAddFolder
|
|
{
|
|
get => DataContract.CanAddFolder;
|
|
set => DataContract.CanAddFolder = value;
|
|
}
|
|
public bool CanAddPrompt
|
|
{
|
|
get => DataContract.CanAddPrompt;
|
|
set => DataContract.CanAddPrompt = value;
|
|
}
|
|
public bool CanEdit
|
|
{
|
|
get => DataContract.CanEdit;
|
|
set => DataContract.CanEdit = value;
|
|
}
|
|
|
|
public bool IsNewFeature
|
|
{
|
|
get => DataContract.IsNewFeature;
|
|
}
|
|
public bool IsEnabled
|
|
{
|
|
get => !IsNewFeature;
|
|
}
|
|
|
|
public AiPromptbausteinFolderVM Parent { get; set; }
|
|
|
|
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 (SubPrompts?.VMList != null && SubPrompts.VMList.Count > 0)
|
|
{
|
|
return $"{Title} ({SubPrompts.Count})";
|
|
}
|
|
|
|
return Title;
|
|
}
|
|
}
|
|
|
|
protected override void InitByDataContract(AiPromptbausteinFolderDC pDataContract)
|
|
{
|
|
_Title = pDataContract.Title;
|
|
_Description = pDataContract.Description;
|
|
_ParentFolderOid = pDataContract.ParentFolderOid;
|
|
_Creator = pDataContract.Creator;
|
|
_IsPublic = pDataContract.IsPublic;
|
|
_Position = pDataContract.Position;
|
|
_IsExpanded = pDataContract.IsExpanded;
|
|
_ActionType = pDataContract.ActionType;
|
|
_SubFolders = new AiPromptbausteinFolderListVM(pDataContract.SubFolders, this);
|
|
_SubPrompts = new AiPromptbausteinPromptListVM(pDataContract.SubPrompts);
|
|
_SubPrompts.VMList.ListChanged += (s, e) => FirePropertyChanged(nameof(Displayname));
|
|
}
|
|
|
|
protected override AiPromptbausteinFolderDC MapToDataContract(AiPromptbausteinFolderDC pDataContract, bool doCommit)
|
|
{
|
|
pDataContract.Title = _Title;
|
|
pDataContract.Description = _Description;
|
|
pDataContract.ParentFolderOid = _ParentFolderOid;
|
|
pDataContract.Creator = _Creator;
|
|
pDataContract.IsPublic = _IsPublic;
|
|
pDataContract.Position = _Position;
|
|
pDataContract.ActionType = _ActionType;
|
|
pDataContract.SubFolders = _SubFolders.CopyToDCList(doCommit);
|
|
pDataContract.SubPrompts = _SubPrompts.CopyToDCList(doCommit);
|
|
|
|
return pDataContract;
|
|
}
|
|
|
|
public override void UpdateByDataContract(AiPromptbausteinFolderDC pDataContract)
|
|
{
|
|
Title = pDataContract.Title;
|
|
Description = pDataContract.Description;
|
|
IsPublic = pDataContract.IsPublic;
|
|
}
|
|
}
|
|
} |