Add bulk editing of roles
This commit is contained in:
@@ -20,6 +20,7 @@
|
|||||||
<RowDefinition />
|
<RowDefinition />
|
||||||
<RowDefinition Height="Auto"/>
|
<RowDefinition Height="Auto"/>
|
||||||
<RowDefinition Height="Auto" />
|
<RowDefinition Height="Auto" />
|
||||||
|
<RowDefinition Height="Auto" />
|
||||||
</Grid.RowDefinitions>
|
</Grid.RowDefinitions>
|
||||||
<DataGrid x:Name="ItemGrid" AutoGenerateColumns="false" CanUserAddRows="true" Grid.Row="0">
|
<DataGrid x:Name="ItemGrid" AutoGenerateColumns="false" CanUserAddRows="true" Grid.Row="0">
|
||||||
<DataGrid.Columns>
|
<DataGrid.Columns>
|
||||||
@@ -36,6 +37,16 @@
|
|||||||
<Button Grid.Column="0" Content="Cancel" Margin="5" Click="Cancel_OnClick" />
|
<Button Grid.Column="0" Content="Cancel" Margin="5" Click="Cancel_OnClick" />
|
||||||
<Button Grid.Column="1" Content="OK" Margin="5" Click="Ok_OnClick" />
|
<Button Grid.Column="1" Content="OK" Margin="5" Click="Ok_OnClick" />
|
||||||
</Grid>
|
</Grid>
|
||||||
|
<Grid Grid.Row="3">
|
||||||
|
<Grid.ColumnDefinitions>
|
||||||
|
<ColumnDefinition />
|
||||||
|
<ColumnDefinition />
|
||||||
|
</Grid.ColumnDefinitions>
|
||||||
|
<ComboBox Name="BulkSelect" ItemsSource="{Binding Source={StaticResource GetEnumValues}}" SelectedValue ="{Binding
|
||||||
|
RelativeSource={RelativeSource Mode=FindAncestor, AncestorType={x:Type local:RoleEditor}},
|
||||||
|
Path = BulkPromote, Mode=TwoWay}" Margin="5"/>
|
||||||
|
<Button Grid.Column="1" Content="Bulk edit" Margin ="5" Click="BulkEdit"/>
|
||||||
|
</Grid>
|
||||||
</Grid>
|
</Grid>
|
||||||
</Window>
|
</Window>
|
||||||
|
|
||||||
|
@@ -35,6 +35,7 @@ namespace Torch.Server.Views
|
|||||||
private Type _itemType;
|
private Type _itemType;
|
||||||
|
|
||||||
private Action _commitChanges;
|
private Action _commitChanges;
|
||||||
|
public MyPromoteLevel BulkPromote { get; set; } = MyPromoteLevel.Scripter;
|
||||||
|
|
||||||
public void Edit(IDictionary dict)
|
public void Edit(IDictionary dict)
|
||||||
{
|
{
|
||||||
@@ -106,5 +107,17 @@ namespace Torch.Server.Views
|
|||||||
{
|
{
|
||||||
Items.Add((IDictionaryItem)Activator.CreateInstance(_itemType));
|
Items.Add((IDictionaryItem)Activator.CreateInstance(_itemType));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void BulkEdit(object sender, RoutedEventArgs e)
|
||||||
|
{
|
||||||
|
List<ulong> l = Items.Where(i => i.Value.Equals(BulkPromote)).Select(i => (ulong)i.Key).ToList();
|
||||||
|
var w = new CollectionEditor();
|
||||||
|
w.Edit((ICollection<ulong>)l, "Bulk edit");
|
||||||
|
var r = Items.Where(j => j.Value.Equals(BulkPromote) || l.Contains((ulong)j.Key)).ToList();
|
||||||
|
foreach (var k in r)
|
||||||
|
Items.Remove(k);
|
||||||
|
foreach (var m in l)
|
||||||
|
Items.Add(new DictionaryItem<ulong, MyPromoteLevel>(m, BulkPromote));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user