1234567891011121314151617181920212223242526272829303132333435363738394041424344454647 |
- using Comal.Classes;
- using InABox.Clients;
- using InABox.Core;
- using InABox.DynamicGrid;
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- namespace PRSDesktop;
- public class SecurityGroupUserGrid : DynamicOneToManyGrid<SecurityGroup, User>
- {
- protected override void DoReconfigure(FluentList<DynamicGridOption> options)
- {
- base.DoReconfigure(options);
- options.BeginUpdate()
- .Clear()
- .AddRange(DynamicGridOption.AddRows)
- .AddRange(DynamicGridOption.DeleteRows)
- .AddRange(DynamicGridOption.MultiSelect)
- .EndUpdate();
- }
- protected override void DoAdd(bool OpenEditorOnDirectEdit = false)
- {
- var IDs = Items.Select(x => x.ID).ToArray();
- var filters = new Filters<User>();
- filters.Add(LookupFactory.DefineFilter<User>());
- filters.Add(new Filter<User>(x => x.ID).NotInList(IDs));
- var dlg = new MultiSelectDialog<User>(filters.Combine(), null, true);
- if (dlg.ShowDialog())
- {
- SaveItems(dlg.Items());
- Refresh(false, true);
- }
- }
- protected override void OnDeleteItem(User item)
- {
- item.SecurityGroup.ID = Guid.Empty;
- Client.Save(item, "Cleared security group");
- }
- }
|