diff --git a/BeWo/View/Detail/ServiceRecordView2.xaml.cs b/BeWo/View/Detail/ServiceRecordView2.xaml.cs
index b67d79740..fce726a68 100644
--- a/BeWo/View/Detail/ServiceRecordView2.xaml.cs
+++ b/BeWo/View/Detail/ServiceRecordView2.xaml.cs
@@ -3379,50 +3379,28 @@ namespace BeWo.View.Detail
{
var tbv = new TextbausteinView(x) { Background = FindResource("ApplicationBackground") as LinearGradientBrush };
- var rootGrid2 = (Grid)tbv.root.Content;
- var zielGrid = (Grid)rootGrid2.Children[0];
- var cb = new CheckBox
- {
- Content = "Nur für mich sichtbar",
- Margin = new Thickness(3),
- HorizontalAlignment = HorizontalAlignment.Left,
- VerticalAlignment = VerticalAlignment.Center
- };
-
- if (BeWoApp.LoggedOnUser.HasRight(UserRightType.TextbausteineNurEigeneBearbeiten) && !BeWoApp.LoggedOnUser.HasRight(UserRightType.TextbausteineAlleBearbeiten))
- {
- cb.IsEnabled = false;
- }
-
- var IsOnlyForEmployeeBinding = new Binding("NewVM.IsOnlyForEmployee") { Source = tbv.ViewModel, UpdateSourceTrigger = UpdateSourceTrigger.PropertyChanged };
- BindingOperations.SetBinding(cb, ToggleButton.IsCheckedProperty, IsOnlyForEmployeeBinding);
-
- Grid.SetColumn(cb, 0);
- Grid.SetRow(cb, 2);
- Grid.SetColumnSpan(cb, 4);
-
- zielGrid.Children.Add(cb);
+ var rootGrid2 = (Grid) tbv.root.Content;
var stackPanel = new StackPanel { Orientation = Orientation.Horizontal, HorizontalAlignment = HorizontalAlignment.Right };
var speichernBtn = new Button
{
- Content = "Speichern und schließen",
+ Content = "Speichern",
HorizontalAlignment = HorizontalAlignment.Right,
Margin = new Thickness(3),
VerticalAlignment = VerticalAlignment.Center
};
- var abbrechenBtn = new Button
+ var schliessenBtn = new Button
{
- Content = "Abbrechen",
+ Content = "Schließen",
HorizontalAlignment = HorizontalAlignment.Right,
Margin = new Thickness(3),
VerticalAlignment = VerticalAlignment.Center
};
stackPanel.Children.Add(speichernBtn);
- stackPanel.Children.Add(abbrechenBtn);
+ stackPanel.Children.Add(schliessenBtn);
Grid.SetRow(stackPanel, 2);
rootGrid2.Children.Add(stackPanel);
@@ -3432,13 +3410,13 @@ namespace BeWo.View.Detail
speichernBtn.Click += (o, args) =>
{
tbv.Focus();
- if (x.IsDirty || x.VMList.Any(vm => vm.IsDirty))
+ if(x.IsDirty || x.VMList.Any(vm => vm.IsDirty))
+ {
tbv.Save(() => { textbausteineSearchView.ServiceCategoryOid = textbausteineSearchView.ServiceCategoryOid; });
-
- window.Close();
+ }
};
- abbrechenBtn.Click += (o, args) =>
+ schliessenBtn.Click += (o, args) =>
{
tbv.Focus();
tbv.DoSaveCheck();
@@ -3446,6 +3424,8 @@ namespace BeWo.View.Detail
window.Close();
};
+ window.WindowStartupLocation = WindowStartupLocation.CenterScreen;
+
window.Show();
}));
}
diff --git a/BeWo/View/Detail/SupportConceptView.xaml b/BeWo/View/Detail/SupportConceptView.xaml
index 95eef130c..765c92b28 100644
--- a/BeWo/View/Detail/SupportConceptView.xaml
+++ b/BeWo/View/Detail/SupportConceptView.xaml
@@ -503,10 +503,10 @@
Height="23"/>
+ Grid.Column="5"
+ Initialized="CboServiceCategory_OnInitialized"
+ EditValue="{Binding Path=ServiceCategory, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}"
+ Margin="3" Height="23" IsTextEditable="False" Width="150" >
diff --git a/BeWo/View/Detail/TextModuleView.xaml.cs b/BeWo/View/Detail/TextModuleView.xaml.cs
index e7709110d..528cee8cc 100644
--- a/BeWo/View/Detail/TextModuleView.xaml.cs
+++ b/BeWo/View/Detail/TextModuleView.xaml.cs
@@ -23,7 +23,7 @@ namespace BeWo.View.Detail
public TextModuleListVM ViewModel
{
- get { return _ViewModel; }
+ get => _ViewModel;
set
{
diff --git a/BeWo/View/Detail/TextbausteinView.xaml b/BeWo/View/Detail/TextbausteinView.xaml
index 3bcde7389..e35509970 100644
--- a/BeWo/View/Detail/TextbausteinView.xaml
+++ b/BeWo/View/Detail/TextbausteinView.xaml
@@ -4,9 +4,7 @@
xmlns:view="clr-namespace:BeWo.View"
xmlns:dxe="http://schemas.devexpress.com/winfx/2008/xaml/editors"
xmlns:dxg="http://schemas.devexpress.com/winfx/2008/xaml/grid"
- xmlns:validation="clr-namespace:BeWo.Validation"
xmlns:detail="clr-namespace:BeWo.View.Detail"
- xmlns:controls="clr-namespace:BeWo.Controls;assembly=BeWo.Controls"
Height="Auto" Width="Auto" HorizontalAlignment="Stretch"
VerticalAlignment="Stretch" Focusable="True">
@@ -15,7 +13,7 @@
-
+
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
-
+
+ SelectedItem="{Binding Path=DataContext.RowData.Row.ServiceCategory, RelativeSource={RelativeSource TemplatedParent}}">
+
+
+
+
+
+
+
+
+
+
+
+
+
-
+ SelectedItem="{Binding Path=DataContext.RowData.Row.Parent, RelativeSource={RelativeSource TemplatedParent}}">
+
+
+
+
-
+
diff --git a/BeWo/View/Detail/TextbausteinView.xaml.cs b/BeWo/View/Detail/TextbausteinView.xaml.cs
index 49e08cc96..43cc15a65 100644
--- a/BeWo/View/Detail/TextbausteinView.xaml.cs
+++ b/BeWo/View/Detail/TextbausteinView.xaml.cs
@@ -1,26 +1,28 @@
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.Core;
-using BeWo.Core.Service;
+using BeWo.Annotations;
using BeWo.ServiceProxy;
-using BeWo.Validation;
using BeWo.ViewModel;
using BeWo.ViewModel.ListViewModel;
using BS.Shared;
using BS.Shared.Extensions;
+using DevExpress.Xpf.Editors;
using DevExpress.Xpf.Grid;
namespace BeWo.View.Detail
{
- public partial class TextbausteinView
+ public partial class TextbausteinView : INotifyPropertyChanged
{
private TextModuleListVM _ViewModel;
@@ -37,41 +39,20 @@ namespace BeWo.View.Detail
public override bool IsDirty => ViewModel != null && ViewModel.IsDirty;
- internal override DependencyObject ValidationOnSaveRootElement => AddTextbausteinButton;
-
- private bool isInAdministrationView;
+ private readonly bool _IsInAdministrationView;
public TextbausteinView(TextModuleListVM pViewModel, bool pIsInAdministrationView = false)
{
InitializeComponent();
- isInAdministrationView = pIsInAdministrationView;
-
- EigenerTextbausteinSpalte.Visible = !isInAdministrationView;
+ _IsInAdministrationView = pIsInAdministrationView;
ViewModel = pViewModel;
}
protected override void Save()
{
- var lToDos = new List>();
-
- if (ViewModel.AddedCount > 0)
- {
- lToDos.Add(s => s.InsertNewTextModules(ViewModel.CommitAdded()));
- }
-
- if (ViewModel.RemovedCount > 0)
- {
- lToDos.Add(s => s.DeleteTextModules(ViewModel.GetRemoved().ToDictionary(dc => dc.TextModuleOid.Value, dc => dc.TextModuleVersion.Value)));
- }
-
- if (ViewModel.ChangedCount > 0)
- {
- lToDos.Add(s => s.UpdateTextModules(ViewModel.CommitChanged()));
- }
-
- ServiceFacade.DoMultipleOperationsServicesAsync(lToDos, ReloadViewModel);
+ Save(null);
}
public void Save(Action pCallBack)
@@ -93,39 +74,63 @@ namespace BeWo.View.Detail
lToDos.Add(s => s.UpdateTextModules(ViewModel.CommitChanged()));
}
- ServiceFacade.DoMultipleOperationsServicesAsync(lToDos, pCallBack);
+ ServiceFacade.DoMultipleOperationsServicesAsync(lToDos, () =>
+ {
+ pCallBack?.Invoke();
+ ReloadViewModel();
+ });
}
private void ReloadViewModel()
{
- Cache.GetInstance().ClearServiceCategoryDescriptions();
VMFactory.CreateTextModuleListVMAsync(r => this.Dispatch(delegate
{
+ TreeListControl.BeginDataUpdate();
+
ViewModel = r;
- }), isInAdministrationView);
+
+ TreeListControl.EndDataUpdate();
+
+ TreeListControl.SelectedItems.Clear();
+
+ }), _IsInAdministrationView);
}
private void DeleteButton_Click(object sender, RoutedEventArgs e)
{
- ViewModel.VMList.Remove(DatagridTextbausteine.GetCurrentValue());
- BeWoWpfUtils.RefreshDXGrid(DatagridTextbausteine);
- }
+ var focusedNode = TreeListView.FocusedNode;
+ var selectedTextModule = (TextModuleVM) focusedNode.Content;
- private void ButtonAddTextbaustein_Click(object sender, RoutedEventArgs e)
- {
- if (ValidationTrigger.Validate(this))
+ _ChildrenToDelete.Add(selectedTextModule);
+
+ if(selectedTextModule.IsParent)
{
- ViewModel.AddNewVMToList();
+ if(ViewModel.VMList.Any(textModule => selectedTextModule.Equals(textModule.Parent)))
+ {
+ if(MessageBox.Show("Die Textbausteinkategorie enthält weitere Textbausteine und/oder Textbausteinkategorien. Wenn Sie fortfahren, werden alle Unterelemente von \"" + selectedTextModule.Name + "\" gelöscht.", "Textbausteine löschen", MessageBoxButton.OKCancel, MessageBoxImage.Question) == MessageBoxResult.Cancel)
+ {
+ _ChildrenToDelete.Clear();
+ return;
+ }
+ }
+
+ RetrieveChildTextModulesFromParent(selectedTextModule);
}
+
+ ViewModel.VMList.RemoveRange(_ChildrenToDelete);
+ _ChildrenToDelete.Clear();
}
- private void GridViewBase_OnShowingEditor(object sender, ShowingEditorEventArgs e)
+ private readonly List _ChildrenToDelete = new List();
+
+ private void RetrieveChildTextModulesFromParent(TextModuleVM parent)
{
- if (e.Column.Header.Equals("Kategorie"))
- {
- var textbausteinVM = (TextModuleVM)e.Row;
+ var children = ViewModel.VMList.Where(w => w.Parent != null && w.Parent.Equals(parent));
- e.Cancel = !CheckEditorRights(textbausteinVM, null);
+ foreach(var child in children)
+ {
+ _ChildrenToDelete.Add(child);
+ RetrieveChildTextModulesFromParent(child);
}
}
@@ -150,8 +155,6 @@ namespace BeWo.View.Detail
return false;
}
- // TODO: Merken, ob die Textmodulkategorie aufgeklappt ist.
- // TODO: Speichern und Schließen statt der bisherigen Lösung.
private void ContextMenuTextModules_Click(object sender, RoutedEventArgs e)
{
if(e.OriginalSource is MenuItem twi)
@@ -159,7 +162,9 @@ namespace BeWo.View.Detail
var selectedItem = TreeListControl.SelectedItem as TextModuleVM;
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();
if(selectedItem != null)
{
@@ -179,7 +184,7 @@ namespace BeWo.View.Detail
foreach (var menuitem in menu.Items.OfType