1+ @using SimpleIdServer .IdServer .Website .Stores .IdentityProvisioningStore ;
2+ @inherits Fluxor .Blazor .Web .Components .FluxorComponent
3+ @inject IState <SearchIdentityProvisioningMappingRuleState > searchIdentityProvisioningMappingRulesState
4+ @inject ContextMenuService contextMenuService
5+ @inject IDispatcher dispatcher
6+ @inject DialogService dialogService
7+
8+
9+ <RadzenButton class =" mb-1" Click =" @(args => AddMappingRule())" Icon =" add" Text =" Add mapping rule" ButtonStyle =" ButtonStyle.Primary" Size =" ButtonSize.Medium" ></RadzenButton >
10+
11+ <RadzenDataGrid AllowFiltering =" true"
12+ AllowColumnResize =" true"
13+ AllowAlternatingRows =" false"
14+ FilterMode =" FilterMode.Simple"
15+ FilterCaseSensitivity =" FilterCaseSensitivity.CaseInsensitive"
16+ AllowSorting =" true"
17+ AllowPaging =" false"
18+ PagerHorizontalAlign =" HorizontalAlign.Left"
19+ ShowPagingSummary =" true"
20+ IsLoading =" @searchIdentityProvisioningMappingRulesState.Value.IsLoading"
21+ Count =" @searchIdentityProvisioningMappingRulesState.Value.Count"
22+ Data =" @searchIdentityProvisioningMappingRulesState.Value.MappingRules"
23+ RowRender =" @RowRender"
24+ TItem =" SelectableIdentityProvisioningMappingRule"
25+ ColumnWidth =" 300px" >
26+ <Columns >
27+ <RadzenDataGridColumn TItem =" SelectableIdentityProvisioningMappingRule" Filterable =" false" Sortable =" false" Width =" 80px" TextAlign =" TextAlign.Center" >
28+ <HeaderTemplate >
29+ <RadzenCheckBox @bind-Value =@selectAll Change =" @(args => ToggleAll(args))" TValue =" bool" />
30+ </HeaderTemplate >
31+ <Template Context =" data" >
32+ <RadzenCheckBox @bind-Value =@data.IsSelected Change =" @(args => ToggleChanged(args, data))" TValue =" bool" />
33+ </Template >
34+ </RadzenDataGridColumn >
35+ <RadzenDataGridColumn TItem =" SelectableIdentityProvisioningMappingRule" Property =" Value.From" Filterable =" false" Sortable =" false" Title =" From" Width =" 80px" />
36+ <RadzenDataGridColumn TItem =" SelectableIdentityProvisioningMappingRule" Filterable =" false" Sortable =" false" Title =" Type" Width =" 80px" >
37+ <Template Context =" data" >
38+ <RadzenBadge IsPill =true Text =" @Enum.GetName(typeof(MappingRuleTypes), data.Value.MapperType)" BadgeStyle =" BadgeStyle.Primary" ></RadzenBadge >
39+ </Template >
40+ </RadzenDataGridColumn >
41+ <RadzenDataGridColumn TItem =" SelectableIdentityProvisioningMappingRule" Property =" Value.TargetUserAttribute" Filterable =" false" Sortable =" false" Title =" Attribute" Width =" 80px" />
42+ <RadzenDataGridColumn TItem =" SelectableIdentityProvisioningMappingRule" Property =" Value.TargetUserProperty" Filterable =" false" Sortable =" false" Title =" Property" Width =" 80px" />
43+ <RadzenDataGridColumn TItem =" SelectableIdentityProvisioningMappingRule" Filterable =" false" Sortable =" false" Width =" 80px" TextAlign =" TextAlign.Center" >
44+ <Template Context =" data" >
45+ <RadzenButton Icon =" more_vert" Click =" @(args => ShowMoreContextMenu(data, args))" />
46+ </Template >
47+ </RadzenDataGridColumn >
48+ </Columns >
49+ </RadzenDataGrid >
50+
51+ @code {
52+ [Parameter ]
53+ public Domains .IdentityProvisioning IdProvisioning { get ; set ; }
54+ bool selectAll = false ;
55+
56+ void ToggleAll (bool isSelected )
57+ {
58+ var act = new SelectAllIdentityProvisioningMappingRulesAction { IsSelected = isSelected };
59+ dispatcher .Dispatch (act );
60+ }
61+
62+ void ToggleChanged (bool isSelected , SelectableIdentityProvisioningMappingRule mappingRule )
63+ {
64+ var act = new SelectIdentityProvisioningMappingRuleAction { IsSelected = isSelected , Id = mappingRule .Value .Id };
65+ dispatcher .Dispatch (act );
66+ }
67+
68+ void RowRender (RowRenderEventArgs < SelectableIdentityProvisioningMappingRule > row )
69+ {
70+ const string className = " class" ;
71+ if (row .Data .IsNew )
72+ row .Attributes .Add (className , " new" );
73+ else if (row .Data .IsSelected )
74+ row .Attributes .Add (className , " active" );
75+ else if (row .Attributes .ContainsKey (className ))
76+ row .Attributes .Remove (className );
77+ }
78+
79+ void ShowMoreContextMenu (SelectableIdentityProvisioningMappingRule idProvisioning , MouseEventArgs args )
80+ {
81+ contextMenuService .Open (args , new List <ContextMenuItem >
82+ {
83+ new ContextMenuItem { Text = " Delete" , Value = 1 }
84+ }, (a ) =>
85+ {
86+ if (a .Value .Equals (1 ))
87+ {
88+ var mappingRuleIds = searchIdentityProvisioningMappingRulesState .Value .MappingRules ? .Where (c => c .IsSelected ).Select (c => c .Value .Id )? .ToList ();
89+ if (! mappingRuleIds .Contains (idProvisioning .Value .Id )) mappingRuleIds .Add (idProvisioning .Value .Id );
90+ var act = new RemoveSelectedIdentityProvisioningMappingRulesAction { MappingRuleIds = mappingRuleIds , Id = IdProvisioning .Id };
91+ dispatcher .Dispatch (act );
92+ contextMenuService .Close ();
93+ }
94+ });
95+ }
96+
97+ async void AddMappingRule ()
98+ {
99+ await dialogService .OpenAsync <AddIdProvisioningMapperDialog >(" Add mapping rule" , new Dictionary <string , object > { { " IdProvisioningId" , IdProvisioning .Id } }, new DialogOptions
100+ {
101+ Width = " 700px" ,
102+ Height = " 512px" ,
103+ Resizable = true ,
104+ Draggable = true
105+ });
106+ }
107+ }
0 commit comments