diff --git a/BeWo/BeWo.csproj b/BeWo/BeWo.csproj index b20f66b95..758d18482 100644 --- a/BeWo/BeWo.csproj +++ b/BeWo/BeWo.csproj @@ -516,6 +516,10 @@ Designer MSBuild:Compile + + Designer + MSBuild:Compile + Designer MSBuild:Compile @@ -943,6 +947,9 @@ + + TextModuleTreeSearchView.xaml + SupportEMailControl.xaml diff --git a/BeWo/View/Detail/ServiceRecordView2.xaml b/BeWo/View/Detail/ServiceRecordView2.xaml index 16c94e9a8..2217308ac 100644 --- a/BeWo/View/Detail/ServiceRecordView2.xaml +++ b/BeWo/View/Detail/ServiceRecordView2.xaml @@ -1695,7 +1695,8 @@ - + + diff --git a/BeWo/View/Detail/ServiceRecordView2.xaml.cs b/BeWo/View/Detail/ServiceRecordView2.xaml.cs index fce726a68..f626ce0b5 100644 --- a/BeWo/View/Detail/ServiceRecordView2.xaml.cs +++ b/BeWo/View/Detail/ServiceRecordView2.xaml.cs @@ -76,8 +76,7 @@ namespace BeWo.View.Detail private ServiceRecordVM lastSelectedVM; - private readonly Dictionary> - customerContainsAssessmentCategories = new Dictionary>(); + private readonly Dictionary> customerContainsAssessmentCategories = new Dictionary>(); private bool _IgnoreGroupMultiCheck; @@ -941,14 +940,13 @@ namespace BeWo.View.Detail return (ServiceRecordVM) srListBox.SelectedItem; } - public void SetSelectedServiceRecordVM(ServiceRecordVM vm, bool isOnDelet) + public void SetSelectedServiceRecordVM(ServiceRecordVM vm, bool isOnDelete) { if (vm != null) { ServiceRecordVM existingVm = null; - - if (!isOnDelet) + if (!isOnDelete) { foreach (var serviceRecordVm in ViewModel.VMList) { @@ -980,7 +978,6 @@ namespace BeWo.View.Detail srListBox.SelectedItem = existingVm; srTableView.FocusedRow = existingVm; - } } @@ -3355,7 +3352,6 @@ namespace BeWo.View.Detail if (category?.ServiceCategoryOid != null) { - textbausteineSearchView.ServiceCategoryOid = category.ServiceCategoryOid.Value; // TextModuleTreeViewControl1.ServiceCategoryOid = category.ServiceCategoryOid; @@ -3375,9 +3371,9 @@ namespace BeWo.View.Detail private void EditTextbausteineClick(object sender, RoutedEventArgs e) { VMFactory.CreateTextModuleListVMAsync( - x => this.Dispatch(delegate + textModuleListVM => this.Dispatch(delegate { - var tbv = new TextbausteinView(x) { Background = FindResource("ApplicationBackground") as LinearGradientBrush }; + var tbv = new TextbausteinView(textModuleListVM) { Background = FindResource("ApplicationBackground") as LinearGradientBrush }; var rootGrid2 = (Grid) tbv.root.Content; @@ -3410,7 +3406,7 @@ namespace BeWo.View.Detail speichernBtn.Click += (o, args) => { tbv.Focus(); - if(x.IsDirty || x.VMList.Any(vm => vm.IsDirty)) + if(textModuleListVM.IsDirty || textModuleListVM.VMList.Any(vm => vm.IsDirty)) { tbv.Save(() => { textbausteineSearchView.ServiceCategoryOid = textbausteineSearchView.ServiceCategoryOid; }); } @@ -4499,51 +4495,65 @@ namespace BeWo.View.Detail private void ButtonBase_OnClick(object sender, RoutedEventArgs e) { - popup_textbausteine.IsOpen = true; + ServiceFacade.DoOperationsServiceAsync(s => s.GetAllTextModules(), textModules => this.Dispatch(delegate + { + popup_textbausteine.IsOpen = true; + + if(textbausteineSearchView.ServiceCategoryOid > 0) + { + var blah = textModules.Where(w => w.ServiceCategory != null && w.ServiceCategory.ServiceCategoryOid == textbausteineSearchView.ServiceCategoryOid).ToList(); + + textModules = Utils.GetParentTextModules(blah); + textModules.AddRangeIfElementsNotIn(blah); + } + + textbausteineSearchView.InitSearchView(textModules); + })); } - private void TextbausteineSearchView_OnItemSelected(object sender, EventArgs e) + private void TextModulesSearchView_OnItemSelected(object sender, EventArgs e) { - if (TabItem1_Notice.IsSelected) + if(TabItem1_Notice.IsSelected) { AddTextModuleToTextBox(e.Data.Text, dokumentationsTextBox); } - else if (TabItem2_Notice.IsSelected) + else if(TabItem2_Notice.IsSelected) { AddTextModuleToTextBox(e.Data.Text, dokumentationsTextBox2); } - else if (TabItem3_Notice.IsSelected) + else if(TabItem3_Notice.IsSelected) { AddTextModuleToTextBox(e.Data.Text, dokumentationsTextBox3); } - else if (TabItem4_Notice.IsSelected) + else if(TabItem4_Notice.IsSelected) { AddTextModuleToTextBox(e.Data.Text, dokumentationsTextBox4); } - else if (TabItem5_Notice.IsSelected) + else if(TabItem5_Notice.IsSelected) { AddTextModuleToTextBox(e.Data.Text, dokumentationsTextBox5); } - else if (TabitemRtf1Note.IsSelected) + else if(TabitemRtf1Note.IsSelected) { AddTextModuleToRichEditControl(e.Data.Text, richEditControl1); } - else if (TabitemRtf2Note.IsSelected) + else if(TabitemRtf2Note.IsSelected) { AddTextModuleToRichEditControl(e.Data.Text, richEditControl2); } - else if (TabitemRtf3Note.IsSelected) + else if(TabitemRtf3Note.IsSelected) { AddTextModuleToRichEditControl(e.Data.Text, richEditControl3); } - else if (TabitemRtf4Note.IsSelected) + else if(TabitemRtf4Note.IsSelected) { AddTextModuleToRichEditControl(e.Data.Text, richEditControl4); } - else if (TabitemRtf5Note.IsSelected) + else if(TabitemRtf5Note.IsSelected) { AddTextModuleToRichEditControl(e.Data.Text, richEditControl5); } + popup_textbausteine.IsOpen = false; } } diff --git a/BeWo/View/Detail/TextbausteinView.xaml b/BeWo/View/Detail/TextbausteinView.xaml index e35509970..c39420d94 100644 --- a/BeWo/View/Detail/TextbausteinView.xaml +++ b/BeWo/View/Detail/TextbausteinView.xaml @@ -33,7 +33,7 @@ @@ -120,7 +120,9 @@ + SelectedItem="{Binding Path=DataContext.RowData.Row.Parent, RelativeSource={RelativeSource TemplatedParent}, Mode=OneWay}" + Tag="{Binding Path=DataContext.RowData.Row, RelativeSource={RelativeSource TemplatedParent}}" + Loaded="FrameworkElement_OnLoaded"> @@ -131,7 +133,10 @@ + SelectedItem="{Binding Path=DataContext.RowData.Row.Parent, RelativeSource={RelativeSource TemplatedParent}, Mode=OneWay}" + EditValueChanged="PART_Editor_OnEditValueChanged" + Tag="{Binding Path=DataContext.RowData.Row, RelativeSource={RelativeSource TemplatedParent}, Mode=OneWay}" + Loaded="FrameworkElement_OnLoaded"> diff --git a/BeWo/View/Detail/TextbausteinView.xaml.cs b/BeWo/View/Detail/TextbausteinView.xaml.cs index 43cc15a65..df862020f 100644 --- a/BeWo/View/Detail/TextbausteinView.xaml.cs +++ b/BeWo/View/Detail/TextbausteinView.xaml.cs @@ -1,15 +1,12 @@ using System; using System.Collections.Generic; -using System.ComponentModel; using System.Globalization; using System.Linq; -using System.Runtime.CompilerServices; using System.Windows; using System.Windows.Controls; using System.Windows.Data; using System.Windows.Input; -using BeWo.Annotations; using BeWo.ServiceProxy; using BeWo.ViewModel; using BeWo.ViewModel.ListViewModel; @@ -22,7 +19,7 @@ using DevExpress.Xpf.Grid; namespace BeWo.View.Detail { - public partial class TextbausteinView : INotifyPropertyChanged + public partial class TextbausteinView { private TextModuleListVM _ViewModel; @@ -58,6 +55,11 @@ namespace BeWo.View.Detail public void Save(Action pCallBack) { var lToDos = new List>(); + + if(ViewModel.ChangedCount == 0 && ViewModel.RemovedCount == 0 && ViewModel.AddedCount == 0) + { + return; + } if (ViewModel.AddedCount > 0) { @@ -164,7 +166,7 @@ namespace BeWo.View.Detail ViewModel.NewVM.IsParent = twi.Header.Equals("Neue Textbausteinkategorie"); ViewModel.NewVM.IsExpanded = twi.Header.Equals("Neue Textbausteinkategorie"); ViewModel.NewVM.IsOnlyForEmployee = true; - ViewModel.NewVM.Name = twi.Header.ToString(); + ViewModel.NewVM.Name = GenerateNewTextModuleName(twi.Header.ToString()); if(selectedItem != null) { @@ -176,6 +178,20 @@ namespace BeWo.View.Detail } } + private string GenerateNewTextModuleName(string pName) + { + var newName = pName; + var counter = 1; + + while(ViewModel.VMList.Any(a => a.Name.Equals(newName))) + { + newName = pName + " " + counter; + counter++; + } + + return newName; + } + private void ContextMenuTextModules_Opened(object sender, RoutedEventArgs e) { if (e.OriginalSource is ContextMenu menu) @@ -245,12 +261,21 @@ namespace BeWo.View.Detail } } - public event PropertyChangedEventHandler PropertyChanged; - - [NotifyPropertyChangedInvocator] - protected virtual void OnPropertyChanged([CallerMemberName] string propertyName = null) + private void PART_Editor_OnEditValueChanged(object sender, EditValueChangedEventArgs e) { - PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName)); + var comboBoxEdit = (ComboBoxEdit) sender; + var selectedTextModule = (TextModuleVM) comboBoxEdit.Tag; + + selectedTextModule.Parent = (TextModuleVM) e.NewValue; + } + + private void FrameworkElement_OnLoaded(object sender, RoutedEventArgs e) + { + var comboBoxEdit = (ComboBoxEdit) sender; + + var textModule = (TextModuleVM) comboBoxEdit.Tag; + + comboBoxEdit.ItemsSource = ViewModel.GetTextModuleParents(textModule); } } diff --git a/BeWo/View/Search/SupportConceptTreeSearchView.xaml.cs b/BeWo/View/Search/SupportConceptTreeSearchView.xaml.cs index f088749b2..563442023 100644 --- a/BeWo/View/Search/SupportConceptTreeSearchView.xaml.cs +++ b/BeWo/View/Search/SupportConceptTreeSearchView.xaml.cs @@ -1,16 +1,13 @@ using System.Collections.Generic; -using System.Linq; using System.Windows; using System.Windows.Controls; using System.Windows.Media; + using BS.Shared.DataContracts; namespace BeWo.View.Search { - /// - /// Interaction logic for SupportConceptTreeSearchView.xaml - /// - public partial class SupportConceptTreeSearchView : UserControl + public partial class SupportConceptTreeSearchView { public static readonly DependencyProperty ResultListBackgroundProperty = DependencyProperty.Register("ResultListBackground", typeof (Brush), typeof (SupportConceptTreeSearchView), new UIPropertyMetadata(Brushes.White, (s, e) => ((SupportConceptTreeSearchView) s).listbox_result.Background = e.NewValue as Brush)); @@ -23,25 +20,22 @@ namespace BeWo.View.Search public List List { - get { return _List; } + get => _List; - set + set { _List = value; - listbox_result.DataContext = _List.Cast(); + listbox_result.DataContext = _List; } } public Brush ResultListBackground { - get { return (Brush) GetValue(ResultListBackgroundProperty); } + get => (Brush) GetValue(ResultListBackgroundProperty); - set { SetValue(ResultListBackgroundProperty, value); } + set => SetValue(ResultListBackgroundProperty, value); } - public TreeView ResultTree - { - get { return listbox_result; } - } + public TreeView ResultTree => listbox_result; } } \ No newline at end of file diff --git a/BeWo/View/Search/TextModuleSearchView.cs b/BeWo/View/Search/TextModuleSearchView.cs index 180a2827e..ccdeb6512 100644 --- a/BeWo/View/Search/TextModuleSearchView.cs +++ b/BeWo/View/Search/TextModuleSearchView.cs @@ -14,14 +14,14 @@ namespace BeWo.View.Search { public class TextModuleSearchView : GenericSearchView { - private long serviceCategoryOid; + private long _ServiceCategoryOid; public long ServiceCategoryOid { - get { return serviceCategoryOid; } + get => _ServiceCategoryOid; set { - serviceCategoryOid = value; + _ServiceCategoryOid = value; ServiceFacade.DoOperationsServiceAsync(s => s.GetTextModulesByServiceCategory(ServiceCategoryOid), r => { diff --git a/BeWo/ViewModel/ListViewModel/TextModuleListVM.cs b/BeWo/ViewModel/ListViewModel/TextModuleListVM.cs index bea5d0720..3894081d8 100644 --- a/BeWo/ViewModel/ListViewModel/TextModuleListVM.cs +++ b/BeWo/ViewModel/ListViewModel/TextModuleListVM.cs @@ -25,5 +25,10 @@ namespace BeWo.ViewModel.ListViewModel public IEnumerable PossibleCategories => _PossibleCategories; public IEnumerable PossibleTextModuleParents => _PossibleTextModuleParents; + + public IEnumerable GetTextModuleParents(TextModuleVM textModule) + { + return _PossibleTextModuleParents.Except(new List {textModule}); + } } } diff --git a/Shared/Core/Utils.cs b/Shared/Core/Utils.cs index 0ba4009b3..67b1b4d92 100644 --- a/Shared/Core/Utils.cs +++ b/Shared/Core/Utils.cs @@ -9,6 +9,8 @@ using System.IO.Compression; using System.Linq; using System.Text; using System.Xml.Serialization; +using BS.Shared.DataContracts; +using BS.Shared.Extensions; namespace BS.Shared.Core { @@ -536,6 +538,31 @@ namespace BS.Shared.Core return new Size(width, height); } + public static List GetParentTextModules(List childTextModules) + { + Parents.Clear(); + + foreach(var textModule in childTextModules) + { + GetParentTextModule(textModule); + } + + return Parents; + } + + private static readonly List Parents = new List(); + private static void GetParentTextModule(TextModuleDC textModule) + { + if(textModule.Parent != null) + { + Parents.AddIfNotIn(textModule.Parent); + + if(textModule.Parent.Parent != null) + { + GetParentTextModule(textModule.Parent.Parent); + } + } + } } public struct NullCompareResult diff --git a/Shared/DataContracts/ClientPartials/TextModuleDC.cs b/Shared/DataContracts/ClientPartials/TextModuleDC.cs index f2cbe74db..9fc982be2 100644 --- a/Shared/DataContracts/ClientPartials/TextModuleDC.cs +++ b/Shared/DataContracts/ClientPartials/TextModuleDC.cs @@ -46,5 +46,9 @@ namespace BS.Shared.DataContracts } public SolidColorBrush FilterableBrush => new SolidColorBrush(Colors.Transparent); + + public long? KeyField => TextModuleOid; + + public long? ParentField => Parent?.TextModuleOid; } } \ No newline at end of file