Textbausteine...

This commit is contained in:
Lyndon
2018-01-05 19:13:18 -04:00
parent 7fcb146d13
commit 19c596dfe1
16 changed files with 326 additions and 307 deletions

View File

@@ -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();
}));
}

View File

@@ -503,10 +503,10 @@
Height="23"/>
<Label Grid.Column="4" VerticalAlignment="Center" Content="{markup:Translate Kategorie}" />
<dxe:ComboBoxEdit x:Name="cboServiceCategory"
Grid.Column="5"
Initialized="CboServiceCategory_OnInitialized"
EditValue="{Binding Path=ServiceCategory, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}"
Margin="3" Height="23" IsTextEditable="False" Width="150" >
Grid.Column="5"
Initialized="CboServiceCategory_OnInitialized"
EditValue="{Binding Path=ServiceCategory, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}"
Margin="3" Height="23" IsTextEditable="False" Width="150" >
<dxe:ComboBoxEdit.Buttons>
<dxe:ButtonInfo GlyphKind="Cancel" Click="ButtonInfo_OnClick" Tag="{Binding}"></dxe:ButtonInfo>
</dxe:ComboBoxEdit.Buttons>

View File

@@ -23,7 +23,7 @@ namespace BeWo.View.Detail
public TextModuleListVM ViewModel
{
get { return _ViewModel; }
get => _ViewModel;
set
{

View File

@@ -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">
<view:BeWoView.Resources>
@@ -15,7 +13,7 @@
</view:BeWoView.Resources>
<GroupBox Name="root" Header="Aktuell definierte Textbausteine" Style="{StaticResource ObjectEditGroupBox}">
<Grid VerticalAlignment="Stretch">
<Grid.Resources>
<Grid.Resources>
<ContextMenu x:Key="ContextMenuTextModules" MenuItem.Click="ContextMenuTextModules_Click" Opened="ContextMenuTextModules_Opened">
<MenuItem Header="Neue Textbausteinkategorie">
<MenuItem.Icon>
@@ -29,114 +27,17 @@
</MenuItem>
</ContextMenu>
</Grid.Resources>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*" />
</Grid.ColumnDefinitions>
<Grid.RowDefinitions>
<RowDefinition Height="Auto" />
<RowDefinition Height="*" />
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
</Grid.RowDefinitions>
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="Auto" />
<ColumnDefinition Width="Auto" />
<ColumnDefinition Width="Auto" />
<ColumnDefinition Width="Auto" />
<ColumnDefinition Width="Auto" />
<ColumnDefinition Width="Auto" />
</Grid.ColumnDefinitions>
<Grid.RowDefinitions>
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
</Grid.RowDefinitions>
<Label Grid.Column="0" Grid.Row="0">Name</Label>
<TextBox Grid.Column="1" Grid.Row="0" Width="100" Text="{validation:ValidationBinding Path=NewVM.Name}"></TextBox>
<Label Grid.Column="2" Grid.Row="0">Position</Label>
<dxe:SpinEdit Grid.Column="3" Grid.Row="0" Width="100" Height="23" MinValue="0" IsFloatValue="False" Value="{Binding Path=NewVM.Position, Mode=TwoWay, Converter={StaticResource Int2DecimalConverter}, UpdateSourceTrigger=PropertyChanged}"></dxe:SpinEdit>
<Label Grid.Column="4" Grid.Row="0">Kategorie</Label>
<controls:NullItemComboBox Grid.Column="5" Grid.Row="0" Width="150" Height="23" ItemsSource="{Binding Path=PossibleCategories, Mode=OneWay}" SelectedItem="{Binding Path=NewVM.ServiceCategory}" />
<Label Grid.Column="0" Grid.Row="1">Text</Label>
<TextBox Grid.Column="1" Grid.Row="1" Grid.ColumnSpan="5" AcceptsReturn="True" MaxWidth="469" HorizontalScrollBarVisibility="Auto" VerticalScrollBarVisibility="Auto" TextWrapping="Wrap" Height="100" Margin="0,3,0,0" Text="{Binding Path=NewVM.Text, UpdateSourceTrigger=PropertyChanged}"></TextBox>
<Button Grid.Column="4" Grid.Row="2" x:Name="AddTextbausteinButton" Margin="3" HorizontalAlignment="Right" Grid.ColumnSpan="2" Click="ButtonAddTextbaustein_Click">Hinzufügen</Button>
</Grid>
<dxg:GridControl Grid.Column="0" Grid.Row="1" x:Name="DatagridTextbausteine" Margin="0,10,0,0" ItemsSource="{Binding VMList}" Visibility="Collapsed">
<dxg:GridControl.Columns>
<dxg:GridColumn FieldName="IsDeleteable" Header="" FixedWidth="True" Width="24" ReadOnly="True">
<dxg:GridColumn.CellTemplate>
<DataTemplate>
<Button Content="r" Click="DeleteButton_Click" IsEnabled="{Binding Path=DataContext.RowData.Row, Converter={StaticResource IsOnlyForEmployeeRightsConverter}, RelativeSource={RelativeSource TemplatedParent}}" FontFamily="Webdings" Width="18" Height="18" VerticalAlignment="Center" />
</DataTemplate>
</dxg:GridColumn.CellTemplate>
</dxg:GridColumn>
<dxg:GridColumn FieldName="Name" Header="Name">
<dxg:GridColumn.DisplayTemplate>
<ControlTemplate>
<dxe:TextEdit EditMode="InplaceInactive" Text="{Binding Path=DataContext.RowData.Row.Name, Mode=TwoWay, RelativeSource={RelativeSource TemplatedParent}}"
IsEnabled="{Binding Path=DataContext.RowData.Row, Converter={StaticResource IsOnlyForEmployeeRightsConverter}, RelativeSource={RelativeSource TemplatedParent}}"></dxe:TextEdit>
</ControlTemplate>
</dxg:GridColumn.DisplayTemplate>
<dxg:GridColumn.EditTemplate>
<ControlTemplate>
<dxe:TextEdit x:Name="PART_Editor" EditMode="InplaceActive" Text="{Binding Path=DataContext.RowData.Row.Name, Mode=TwoWay, RelativeSource={RelativeSource TemplatedParent}}"
IsEnabled="{Binding Path=DataContext.RowData.Row, Converter={StaticResource IsOnlyForEmployeeRightsConverter}, RelativeSource={RelativeSource TemplatedParent}}"></dxe:TextEdit>
</ControlTemplate>
</dxg:GridColumn.EditTemplate>
</dxg:GridColumn>
<dxg:GridColumn FieldName="Position" Header="Position">
<dxg:GridColumn.DisplayTemplate>
<ControlTemplate>
<dxe:SpinEdit EditMode="InplaceInactive" MinValue="0" IsFloatValue="False"
Value="{Binding Path=DataContext.RowData.Row.Position, Mode=TwoWay, RelativeSource={RelativeSource TemplatedParent}}"
IsEnabled="{Binding Path=DataContext.RowData.Row, Converter={StaticResource IsOnlyForEmployeeRightsConverter}, RelativeSource={RelativeSource TemplatedParent}}"></dxe:SpinEdit>
</ControlTemplate>
</dxg:GridColumn.DisplayTemplate>
<dxg:GridColumn.EditTemplate>
<ControlTemplate>
<dxe:SpinEdit x:Name="PART_Editor" EditMode="InplaceActive" MinValue="0" IsFloatValue="False"
Value="{Binding Path=DataContext.RowData.Row.Position, Mode=TwoWay, RelativeSource={RelativeSource TemplatedParent}}"
IsEnabled="{Binding Path=DataContext.RowData.Row, Converter={StaticResource IsOnlyForEmployeeRightsConverter}, RelativeSource={RelativeSource TemplatedParent}}"></dxe:SpinEdit>
</ControlTemplate>
</dxg:GridColumn.EditTemplate>
</dxg:GridColumn>
<dxg:GridColumn FieldName="Text" Header="Text">
<dxg:GridColumn.DisplayTemplate>
<ControlTemplate>
<dxe:TextEdit EditMode="InplaceInactive" Text="{Binding Path=DataContext.RowData.Row.Text, Mode=TwoWay, RelativeSource={RelativeSource TemplatedParent}}" />
</ControlTemplate>
</dxg:GridColumn.DisplayTemplate>
<dxg:GridColumn.EditTemplate>
<ControlTemplate>
<dxe:TextEdit x:Name="PART_Editor" EditMode="InplaceActive"
Text="{Binding Path=DataContext.RowData.Row.Text, Mode=TwoWay, RelativeSource={RelativeSource TemplatedParent}}"
IsEnabled="{Binding Path=DataContext.RowData.Row, Converter={StaticResource IsOnlyForEmployeeRightsConverter}, RelativeSource={RelativeSource TemplatedParent}}" />
</ControlTemplate>
</dxg:GridColumn.EditTemplate>
</dxg:GridColumn>
<dxg:GridColumn Header="Nur für Ersteller sichtbar" x:Name="EigenerTextbausteinSpalte">
<dxg:GridColumn.CellTemplate>
<DataTemplate>
<dxe:CheckEdit HorizontalAlignment="Center"
IsChecked="{Binding Path=DataContext.RowData.Row.IsOnlyForEmployee, Mode=TwoWay, RelativeSource={RelativeSource TemplatedParent}}"
IsEnabled="{Binding Path=DataContext.RowData.Row, ConverterParameter=IsOnlyForEmployeeCheckBox, Converter={StaticResource IsOnlyForEmployeeRightsConverter}, RelativeSource={RelativeSource TemplatedParent}}"/>
</DataTemplate>
</dxg:GridColumn.CellTemplate>
</dxg:GridColumn>
<dxg:GridColumn FieldName="ServiceCategory" Header="Kategorie">
<dxg:GridColumn.EditSettings>
<dxe:ComboBoxEditSettings ItemsSource="{Binding Path=PossibleCategories}"></dxe:ComboBoxEditSettings>
</dxg:GridColumn.EditSettings>
</dxg:GridColumn>
</dxg:GridControl.Columns>
<dxg:GridControl.View>
<dxg:TableView AutoWidth="true" ShowGroupPanel="False" ShowGroupedColumns="false" ShowTotalSummary="False" NavigationStyle="Cell" ShowingEditor="GridViewBase_OnShowingEditor" />
</dxg:GridControl.View>
</dxg:GridControl>
<dxg:TreeListControl Name="TreeListControl" Grid.Column="0" Grid.Row="1" ItemsSource="{Binding Path=VMList}" Margin="0,15,0,0" ContextMenu="{StaticResource ContextMenuTextModules}">
<Grid.RowDefinitions>
<RowDefinition Height="*" />
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
</Grid.RowDefinitions>
<dxg:TreeListControl Name="TreeListControl" Grid.Column="0" Grid.Row="0" ItemsSource="{Binding Path=VMList, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}"
Margin="0,15,0,0" ContextMenu="{StaticResource ContextMenuTextModules}"
ItemsSourceChanged="TreeListControl_OnItemsSourceChanged"
PreviewMouseDown="TreeListControl_OnPreviewMouseDown">
<dxg:TreeListControl.Columns>
<dxg:TreeListColumn FieldName="IsDeleteable" Header="" FixedWidth="True" Width="24" ReadOnly="True">
<dxg:TreeListColumn FieldName="IsDeleteable" FixedWidth="True" Width="24" ReadOnly="True" Header=" ">
<dxg:TreeListColumn.CellTemplate>
<DataTemplate>
<Button Content="r" Click="DeleteButton_Click" FontFamily="Webdings" Width="18" Height="18" VerticalAlignment="Center">
@@ -195,29 +96,54 @@
<ControlTemplate>
<dxe:ComboBoxEdit EditMode="InplaceActive" IsEnabled="{Binding Path=DataContext.RowData.Row.IsParent, Converter={StaticResource BoolReverseConverter}, RelativeSource={RelativeSource TemplatedParent}}"
ItemsSource="{Binding Path=DataContext.PossibleCategories, RelativeSource={RelativeSource FindAncestor, AncestorType=dxg:TreeListControl}}"
SelectedItem="{Binding Path=DataContext.RowData.Row.ServiceCategory, RelativeSource={RelativeSource TemplatedParent}}" />
SelectedItem="{Binding Path=DataContext.RowData.Row.ServiceCategory, RelativeSource={RelativeSource TemplatedParent}}">
<dxe:ComboBoxEdit.Buttons>
<dxe:ButtonInfo GlyphKind="Cancel" Click="RemoveServiceCategory_OnClick" Tag="{Binding}" />
</dxe:ComboBoxEdit.Buttons>
</dxe:ComboBoxEdit>
</ControlTemplate>
</dxg:TreeListColumn.DisplayTemplate>
<dxg:TreeListColumn.EditTemplate>
<ControlTemplate>
<dxe:ComboBoxEdit x:Name="PART_Editor" EditMode="InplaceActive" IsEnabled="{Binding Path=DataContext.RowData.Row.IsParent, Converter={StaticResource BoolReverseConverter}, RelativeSource={RelativeSource TemplatedParent}}"
ItemsSource="{Binding Path=DataContext.PossibleCategories, RelativeSource={RelativeSource FindAncestor, AncestorType=dxg:TreeListControl}}"
SelectedItem="{Binding Path=DataContext.RowData.Row.ServiceCategory, RelativeSource={RelativeSource TemplatedParent}}" />
SelectedItem="{Binding Path=DataContext.RowData.Row.ServiceCategory, RelativeSource={RelativeSource TemplatedParent}}">
<dxe:ComboBoxEdit.Buttons>
<dxe:ButtonInfo GlyphKind="Cancel" Click="RemoveServiceCategory_OnClick" Tag="{Binding}" />
</dxe:ComboBoxEdit.Buttons>
</dxe:ComboBoxEdit>
</ControlTemplate>
</dxg:TreeListColumn.EditTemplate>
</dxg:TreeListColumn>
<dxg:TreeListColumn FieldName="Parent" Header="Textbausteinkategorie">
<dxg:TreeListColumn.DisplayTemplate>
<ControlTemplate>
<dxe:ComboBoxEdit EditMode="InplaceActive" IsTextEditable="False"
ItemsSource="{Binding Path=DataContext.PossibleTextModuleParents, RelativeSource={RelativeSource FindAncestor, AncestorType=dxg:TreeListControl}}"
SelectedItem="{Binding Path=DataContext.RowData.Row.Parent, RelativeSource={RelativeSource TemplatedParent}}">
<dxe:ComboBoxEdit.Buttons>
<dxe:ButtonInfo GlyphKind="Cancel" Click="ButtonInfo_OnClick" Tag="{Binding}" />
</dxe:ComboBoxEdit.Buttons>
</dxe:ComboBoxEdit>
</ControlTemplate>
</dxg:TreeListColumn.DisplayTemplate>
<dxg:TreeListColumn.EditTemplate>
<ControlTemplate>
<dxe:ComboBoxEdit x:Name="PART_Editor" EditMode="InplaceActive"
<dxe:ComboBoxEdit x:Name="PART_Editor" EditMode="InplaceActive" IsTextEditable="False"
ItemsSource="{Binding Path=DataContext.PossibleTextModuleParents, RelativeSource={RelativeSource FindAncestor, AncestorType=dxg:TreeListControl}}"
SelectedItem="{Binding Path=DataContext.RowData.Row.Parent, RelativeSource={RelativeSource TemplatedParent}}"/>
SelectedItem="{Binding Path=DataContext.RowData.Row.Parent, RelativeSource={RelativeSource TemplatedParent}}">
<dxe:ComboBoxEdit.Buttons>
<dxe:ButtonInfo GlyphKind="Cancel" Click="ButtonInfo_OnClick" Tag="{Binding}" />
</dxe:ComboBoxEdit.Buttons>
</dxe:ComboBoxEdit>
</ControlTemplate>
</dxg:TreeListColumn.EditTemplate>
</dxg:TreeListColumn>
</dxg:TreeListControl.Columns>
<dxg:TreeListControl.View>
<dxg:TreeListView Name="TreeListView" AutoWidth="True" KeyFieldName="KeyField" ParentFieldName="ParentField" />
<dxg:TreeListView Name="TreeListView" AutoWidth="True" KeyFieldName="KeyField" ParentFieldName="ParentField"
ExpandStateBinding="{Binding Path=IsExpanded, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}"
/>
</dxg:TreeListControl.View>
</dxg:TreeListControl>
</Grid>

View File

@@ -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<Action<IOperationsService>>();
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<TextModuleVM>());
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<TextModuleVM> _ChildrenToDelete = new List<TextModuleVM>();
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<MenuItem>().Select(item => item))
{
if(textModule == null || !textModule.IsParent)
if(textModule != null && !textModule.IsParent)
{
menuitem.IsEnabled = false;
}
@@ -190,6 +195,63 @@ namespace BeWo.View.Detail
}
}
}
private void TreeListControl_OnItemsSourceChanged(object sender, ItemsSourceChangedEventArgs e)
{
TreeListControl.SelectedItem = null;
}
private void TreeListControl_OnPreviewMouseDown(object sender, MouseButtonEventArgs e)
{
var hitInfo = TreeListView.CalcHitInfo(e.OriginalSource as DependencyObject);
if(!hitInfo.InRowCell)
{
TreeListControl.SelectedItem = null;
}
e.Handled = false;
}
private void ButtonInfo_OnClick(object sender, RoutedEventArgs e)
{
if(sender is Button btn && btn.TemplatedParent is ButtonContainer bc)
{
if(bc.Content is ButtonInfo bi)
{
if(bi.Tag is EditGridCellData cellData)
{
var vm = (TextModuleVM) cellData.RowData.Row;
vm.Parent = null;
vm.IsParent = false;
}
}
}
}
private void RemoveServiceCategory_OnClick(object sender, RoutedEventArgs e)
{
if(sender is Button btn && btn.TemplatedParent is ButtonContainer bc)
{
if(bc.Content is ButtonInfo bi)
{
if(bi.Tag is EditGridCellData cellData)
{
var vm = (TextModuleVM) cellData.RowData.Row;
vm.ServiceCategory = null;
}
}
}
}
public event PropertyChangedEventHandler PropertyChanged;
[NotifyPropertyChangedInvocator]
protected virtual void OnPropertyChanged([CallerMemberName] string propertyName = null)
{
PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName));
}
}
public class IsOnlyForEmployeeRightsConverter : IValueConverter
@@ -198,7 +260,7 @@ namespace BeWo.View.Detail
{
var textbausteinVM = (TextModuleVM)value;
return TextbausteinView.CheckEditorRights(textbausteinVM, parameter);
return TextbausteinView.CheckEditorRights(textbausteinVM, parameter) && textbausteinVM != null && !textbausteinVM.IsParent;
}
public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)

View File

@@ -1,5 +1,6 @@
using System.Collections.Generic;
using System.Linq;
using BS.Shared.DataContracts;
namespace BeWo.ViewModel.ListViewModel

View File

@@ -25,15 +25,32 @@ namespace BeWo.ViewModel
private bool _IsParent;
private bool _IsExpanded;
private TextModuleVM _Parent;
public TextModuleVM(TextModuleDC pDataContract) : base(pDataContract, pDataContract.TextModuleOid == null) {}
public bool IsExpanded
{
get => _IsExpanded;
set
{
if(AreDifferent(_IsExpanded, value))
{
_IsExpanded = value;
StoreDirtyInformation(AreDifferent(DataContract.IsExpanded, value), nameof(IsExpanded));
FirePropertyChanged(nameof(IsExpanded));
}
}
}
public ServiceCategoryDC ServiceCategory
{
get { return _ServiceCategory; }
get => _ServiceCategory;
set
{
@@ -48,7 +65,7 @@ namespace BeWo.ViewModel
public CompactEmployeeDC Employee
{
get { return _Employee; }
get => _Employee;
set
{
@@ -63,7 +80,7 @@ namespace BeWo.ViewModel
public int Position
{
get { return _Position; }
get => _Position;
set
{
@@ -78,7 +95,7 @@ namespace BeWo.ViewModel
public string Text
{
get { return _Text; }
get => _Text;
set
{
@@ -93,7 +110,7 @@ namespace BeWo.ViewModel
public bool IsOnlyForEmployee
{
get { return _IsOnlyForEmployee; }
get => _IsOnlyForEmployee;
set
{
@@ -108,9 +125,9 @@ namespace BeWo.ViewModel
public bool IsParent
{
get { return _IsParent; }
get => _IsParent;
set
set
{
if(AreDifferent(_IsParent, value))
{
@@ -123,9 +140,9 @@ namespace BeWo.ViewModel
public TextModuleVM Parent
{
get { return _Parent; }
get => _Parent;
set
set
{
if(AreDifferent(_Parent, value) && AreDifferent(value, this))
{
@@ -145,9 +162,9 @@ namespace BeWo.ViewModel
[Validation(ValidationRule = ValidationRules.NotNullOrStringEmpty)]
public string Name
{
get { return _Name; }
get => _Name;
set
set
{
if (AreDifferent(_Name, value))
{
@@ -170,6 +187,7 @@ namespace BeWo.ViewModel
_IsOnlyForEmployee = pDataContract.IsOnlyForEmployee;
_IsParent = pDataContract.IsParent;
_Parent = pDataContract.Parent != null ? new TextModuleVM(pDataContract.Parent) : null;
_IsExpanded = pDataContract.IsExpanded;
}
else
{
@@ -184,27 +202,19 @@ namespace BeWo.ViewModel
protected override TextModuleDC MapToDataContract(TextModuleDC pDataContract, bool doCommit)
{
pDataContract.Text = _Text;
pDataContract.Position = _Position;
pDataContract.Name = _Name;
pDataContract.IsParent = _IsParent;
pDataContract.Text = _Text;
pDataContract.Position = _Position;
pDataContract.Name = _Name;
pDataContract.IsParent = _IsParent;
pDataContract.IsExpanded = _IsExpanded;
pDataContract.IsOnlyForEmployee = _IsOnlyForEmployee;
if(_Parent != null)
{
pDataContract.Parent = _Parent.CommitToDataContract();
}
pDataContract.Parent = _Parent?.CommitToDataContract();
if(_Employee != null)
{
pDataContract.Employee = _Employee;
}
pDataContract.Employee = _Employee;
if (_ServiceCategory != null)
{
pDataContract.ServiceCategory = _ServiceCategory;
}
pDataContract.ServiceCategory = _ServiceCategory;
return pDataContract;
}

View File

@@ -11,6 +11,7 @@ using BS.Shared.Core;
using BS.Shared.DataContracts;
using BS.Shared.DataContracts.Compact;
using BS.Shared.Extensions;
using DevExpress.XtraEditors.Filtering.Templates;
namespace BeWo.ViewModel

View File

@@ -12,6 +12,7 @@ namespace BeWo.Data.Entities
public static string PropertyName_IsOnlyForEmployee = "IsOnlyForEmployee";
public static string PropertyName_ParentOid = "ParentOid";
public static string PropertyName_IsParent = "IsParent";
public static string PropertyName_IsExpanded = "IsExpanded";
private string _Text;
@@ -22,6 +23,7 @@ namespace BeWo.Data.Entities
private bool _IsOnlyForEmployee;
private TextModule _Parent;
private bool _IsParent;
private bool _IsExpanded;
public TextModule()
@@ -30,9 +32,22 @@ namespace BeWo.Data.Entities
}
public virtual bool IsExpanded
{
get => _IsExpanded;
set
{
if(AreDifferent(_IsExpanded, value))
{
_IsExpanded = value;
}
}
}
public virtual ServiceCategory ServiceCategory
{
get { return _ServiceCategory; }
get => _ServiceCategory;
set
{
@@ -45,7 +60,7 @@ namespace BeWo.Data.Entities
public virtual Employee Employee
{
get { return _Employee; }
get => _Employee;
set
{
@@ -58,7 +73,7 @@ namespace BeWo.Data.Entities
public virtual bool IsOnlyForEmployee
{
get { return _IsOnlyForEmployee; }
get => _IsOnlyForEmployee;
set
{
@@ -71,9 +86,9 @@ namespace BeWo.Data.Entities
public virtual bool IsParent
{
get { return _IsParent; }
get => _IsParent;
set
set
{
if(AreDifferent(_IsParent, value))
{
@@ -84,12 +99,9 @@ namespace BeWo.Data.Entities
public virtual string Text
{
get
{
return _Text;
}
get => _Text;
set
set
{
if (AreDifferent(_Text, value))
{
@@ -100,10 +112,7 @@ namespace BeWo.Data.Entities
public virtual string Name
{
get
{
return _Name;
}
get => _Name;
set
{
@@ -116,10 +125,7 @@ namespace BeWo.Data.Entities
public virtual int Position
{
get
{
return _Position;
}
get => _Position;
set
{
@@ -132,12 +138,9 @@ namespace BeWo.Data.Entities
public virtual TextModule Parent
{
get
{
return _Parent;
}
get => _Parent;
set
set
{
if(AreDifferent(_Parent, value))
{

View File

@@ -10,6 +10,10 @@ namespace BeWo.Data.Entities
public static string PropertyName_Name = "Name";
public static string PropertyName_Employee = "Employee";
public static string PropertyName_IsOnlyForEmployee = "IsOnlyForEmployee";
public static string PropertyName_ParentOid = "ParentOid";
public static string PropertyName_IsParent = "IsParent";
public static string PropertyName_IsExpanded = "IsExpanded";
private string _Text;
private string _Name;
@@ -17,19 +21,37 @@ namespace BeWo.Data.Entities
private ServiceCategory _ServiceCategory;
private Employee _Employee;
private bool _IsOnlyForEmployee;
private TextModule _Parent;
private bool _IsParent;
private bool _IsExpanded;
public Textbaustein()
{
_Tid = TableID.Textbaustein;
}
public virtual ServiceCategory ServiceCategory
public virtual bool IsExpanded
{
get { return _ServiceCategory; }
get => _IsExpanded;
set
{
if (AreDifferent(_ServiceCategory, value))
if(AreDifferent(_IsExpanded, value))
{
_IsExpanded = value;
}
}
}
public virtual ServiceCategory ServiceCategory
{
get => _ServiceCategory;
set
{
if(AreDifferent(_ServiceCategory, value))
{
_ServiceCategory = value;
}
@@ -38,11 +60,11 @@ namespace BeWo.Data.Entities
public virtual Employee Employee
{
get { return _Employee; }
get => _Employee;
set
{
if (AreDifferent(_Employee, value))
if(AreDifferent(_Employee, value))
{
_Employee = value;
}
@@ -51,27 +73,37 @@ namespace BeWo.Data.Entities
public virtual bool IsOnlyForEmployee
{
get { return _IsOnlyForEmployee; }
get => _IsOnlyForEmployee;
set
{
if (AreDifferent(_IsOnlyForEmployee, value))
if(AreDifferent(_IsOnlyForEmployee, value))
{
_IsOnlyForEmployee = value;
}
}
}
public virtual string Text
public virtual bool IsParent
{
get
{
return _Text;
}
get => _IsParent;
set
{
if (AreDifferent(_Text, value))
if(AreDifferent(_IsParent, value))
{
_IsParent = value;
}
}
}
public virtual string Text
{
get => _Text;
set
{
if(AreDifferent(_Text, value))
{
_Text = value;
}
@@ -80,14 +112,11 @@ namespace BeWo.Data.Entities
public virtual string Name
{
get
{
return _Name;
}
get => _Name;
set
{
if (AreDifferent(_Name, value))
if(AreDifferent(_Name, value))
{
_Name = value;
}
@@ -96,18 +125,28 @@ namespace BeWo.Data.Entities
public virtual int Position
{
get
{
return _Position;
}
get => _Position;
set
{
if (AreDifferent(_Position, value))
if(AreDifferent(_Position, value))
{
_Position = value;
}
}
}
public virtual TextModule Parent
{
get => _Parent;
set
{
if(AreDifferent(_Parent, value))
{
_Parent = value;
}
}
}
}
}

View File

@@ -20,6 +20,7 @@
<property column="Name" type="String" name="Name" length="1024" />
<property column="IsOnlyForEmployee" type="Boolean" name="IsOnlyForEmployee" />
<property column="IsParent" type="Boolean" name="IsParent" />
<property column="IsExpanded" type="Boolean" name="IsExpanded" />
<many-to-one name="ServiceCategory" column="ServiceCategoryOid" class="BeWo.Data.Entities.ServiceCategory, BeWo.Data" cascade="none" fetch="join" />
<many-to-one name="Employee" column="EmployeeOid" class="BeWo.Data.Entities.Employee, BeWo.Data" cascade="none" fetch="join" />

View File

@@ -19,8 +19,11 @@
<property column="Position" name="Position" type="Int32" />
<property column="Name" type="String" name="Name" length="1024" />
<property column="IsOnlyForEmployee" type="Boolean" name="IsOnlyForEmployee" />
<property column="IsParent" type="Boolean" name="IsParent" />
<property column="IsExpanded" type="Boolean" name="IsExpanded" />
<many-to-one name="ServiceCategory" column="ServiceCategoryOid" class="BeWo.Data.Entities.ServiceCategory, BeWo.Data" cascade="none" fetch="join"/>
<many-to-one name="Employee" column="EmployeeOid" class="BeWo.Data.Entities.Employee, BeWo.Data" cascade="none" fetch="join"/>
<many-to-one name="ServiceCategory" column="ServiceCategoryOid" class="BeWo.Data.Entities.ServiceCategory, BeWo.Data" cascade="none" fetch="join" />
<many-to-one name="Employee" column="EmployeeOid" class="BeWo.Data.Entities.Employee, BeWo.Data" cascade="none" fetch="join" />
<many-to-one name="Parent" column="ParentOid" class="BeWo.Data.Entities.TextModule, BeWo.Data" cascade="none" fetch="join" />
</class>
</hibernate-mapping>

View File

@@ -0,0 +1 @@
alter table textbaustein add `IsExpanded` tinyint(4) default null;

View File

@@ -16,21 +16,13 @@ namespace BeWo.Service.DCEntityMapper
pDataContract.Name = pEntity.Name;
pDataContract.IsOnlyForEmployee = pEntity.IsOnlyForEmployee;
pDataContract.IsParent = pEntity.IsParent;
pDataContract.IsExpanded = pEntity.IsExpanded;
if(pEntity.Parent != null)
{
pDataContract.Parent = MapperFactory.TextModuleDC_TextModule.MapToNewDC(pEntity.Parent);
}
pDataContract.Parent = pEntity.Parent != null ? MapperFactory.TextModuleDC_TextModule.MapToNewDC(pEntity.Parent) : null;
if(pEntity.ServiceCategory != null)
{
pDataContract.ServiceCategory = MapperFactory.ServiceCategoryDC_ServiceCategory.MapToNewDC(pEntity.ServiceCategory);
}
pDataContract.ServiceCategory = pEntity.ServiceCategory != null ? MapperFactory.ServiceCategoryDC_ServiceCategory.MapToNewDC(pEntity.ServiceCategory) : null;
if (pEntity.Employee != null)
{
pDataContract.Employee = MapperFactory.CompactEmployeeDC_Employee.MapToNewDC(pEntity.Employee);
}
pDataContract.Employee = pEntity.Employee != null ? MapperFactory.CompactEmployeeDC_Employee.MapToNewDC(pEntity.Employee) : null;
return pDataContract;
}
@@ -45,24 +37,22 @@ namespace BeWo.Service.DCEntityMapper
pEntity.Name = pDataContract.Name;
pEntity.IsOnlyForEmployee = pDataContract.IsOnlyForEmployee;
pEntity.IsParent = pDataContract.IsParent;
pEntity.IsExpanded = pDataContract.IsExpanded;
if(pDataContract.Parent != null)
{
pEntity.Parent = DAOFactory.GenericDAO.LoadByID<TextModule>(pDataContract.Parent.TextModuleOid.Value);
pEntity.Parent = pDataContract.Parent != null ? DAOFactory.GenericDAO.LoadByID<TextModule>(pDataContract.Parent.TextModuleOid.Value) : null;
}
if (pDataContract.ServiceCategory != null)
if(pDataContract.ServiceCategory != null)
{
pEntity.ServiceCategory = pDataContract.ServiceCategory.ServiceCategoryOid.HasValue ?
DAOFactory.GenericDAO.LoadByID<ServiceCategory>(pDataContract.ServiceCategory.ServiceCategoryOid.Value) :
MapperFactory.ServiceCategoryDC_ServiceCategory.MapToNewEntity(pDataContract.ServiceCategory);
pEntity.ServiceCategory = pDataContract.ServiceCategory.ServiceCategoryOid.HasValue
? DAOFactory.GenericDAO.LoadByID<ServiceCategory>(pDataContract.ServiceCategory.ServiceCategoryOid.Value)
: MapperFactory.ServiceCategoryDC_ServiceCategory.MapToNewEntity(pDataContract.ServiceCategory);
}
else
{
pEntity.ServiceCategory = null;
}
if (pDataContract.Employee != null)
{
pEntity.Employee = DAOFactory.GenericDAO.LoadByID<Employee>(pDataContract.Employee.EmployeeOid);
}
pEntity.Employee = pDataContract.Employee != null ? DAOFactory.GenericDAO.LoadByID<Employee>(pDataContract.Employee.EmployeeOid) : null;
return pEntity;
}

View File

@@ -6,9 +6,8 @@ namespace BS.Shared.DataContracts
{
public override bool Equals(object obj)
{
if (obj is TextModuleDC)
if (obj is TextModuleDC y)
{
var y = (TextModuleDC) obj;
if (TextModuleOid == null && y.TextModuleOid == null)
{
return GetHashCode() == y.GetHashCode();
@@ -34,18 +33,18 @@ namespace BS.Shared.DataContracts
}
public ActivationTypeId ActivationType { get; set; }
public string DetailDescription { get { return Text; } }
public string FilterRelevants { get { return Name + Text; } }
public string DetailDescription => Text;
public string FilterRelevants => Name + Text;
public string IconPath { get; private set; }
public string SimpleDescription { get { return Name; } }
public string SimpleDescription => Name;
public bool SupportsActivationType { get; private set; }
public long Version
{
get { return TextModuleVersion == null ? 0 : TextModuleVersion.Value; }
set { TextModuleVersion = value; }
get => TextModuleVersion ?? 0;
set => TextModuleVersion = value;
}
public SolidColorBrush FilterableBrush { get { return new SolidColorBrush(Colors.Transparent); } }
public SolidColorBrush FilterableBrush => new SolidColorBrush(Colors.Transparent);
}
}

View File

@@ -36,5 +36,8 @@ namespace BS.Shared.DataContracts
[DataMember]
public TextModuleDC Parent { get; set; }
}
[DataMember]
public bool IsExpanded { get; set; }
}
}