11@page " /settings/glossary"
22@using LrmCloud .Shared .DTOs .Glossary
3+ @using LrmCloud .Shared .DTOs .Organizations
34@using LrmCloud .Web .Services
45@inject GlossaryService GlossaryService
56@inject OrganizationContextService OrgContext
2021 Terms shared across ALL projects in your organization. Individual projects can override these.
2122 </RadzenText >
2223 </RadzenStack >
23- @if (_canManage )
24- {
25- <RadzenButton Variant =" Radzen.Variant.Filled" ButtonStyle =" ButtonStyle.Primary" Icon =" add" Text =" Add Term" Click =" @OpenAddDialog" Disabled =" @(_organizationId == null)" />
26- }
24+ <RadzenStack Orientation =" Radzen.Orientation.Horizontal" Gap =" 0.5rem" AlignItems =" Radzen.AlignItems.Center" >
25+ <RadzenDropDown TValue =" int?"
26+ @bind-Value =" _organizationId"
27+ Data =" @_organizations"
28+ TextProperty =" Name"
29+ ValueProperty =" Id"
30+ Placeholder =" Select organization..."
31+ Style =" min-width: 200px;"
32+ Change =" @OnOrganizationChanged" />
33+ @if (_canManage && _organizationId != null )
34+ {
35+ <RadzenButton Variant =" Radzen.Variant.Filled" ButtonStyle =" ButtonStyle.Primary" Icon =" add" Text =" Add Term" Click =" @OpenAddDialog" />
36+ }
37+ </RadzenStack >
2738</RadzenStack >
2839
2940@if (_organizationId == null )
3041{
31- <RadzenAlert AlertStyle =" AlertStyle.Warning " Shade =" Shade.Lighter" AllowClose =" false" >
32- No organization selected . Please select an organization to manage its glossary .
42+ <RadzenAlert AlertStyle =" AlertStyle.Info " Shade =" Shade.Lighter" AllowClose =" false" >
43+ Select an organization above to manage its glossary terms .
3344 </RadzenAlert >
3445}
3546else if (_isLoading )
151162
152163@code {
153164 private int ? _organizationId ;
165+ private List <OrganizationDto > _organizations = new ();
154166 private GlossaryListResponse ? _glossary ;
155167 private bool _isLoading = true ;
156168 private bool _canManage = false ;
@@ -178,9 +190,21 @@ else
178190
179191 protected override async Task OnInitializedAsync ()
180192 {
193+ // Load organizations first
194+ try
195+ {
196+ _organizations = await OrganizationService .GetOrganizationsAsync ();
197+ }
198+ catch
199+ {
200+ _organizations = new List <OrganizationDto >();
201+ }
202+
203+ // Check if there's a previously selected org
181204 await OrgContext .InitializeAsync ();
182205 _organizationId = OrgContext .SelectedOrganizationId ;
183206
207+ // If no org selected but user has orgs, don't auto-select
184208 if (_organizationId .HasValue )
185209 {
186210 await CheckPermissionsAsync ();
@@ -190,24 +214,22 @@ else
190214 {
191215 _isLoading = false ;
192216 }
193-
194- OrgContext .OnOrganizationChanged += OnOrgChanged ;
195217 }
196218
197- private async void OnOrgChanged ()
219+ private async Task OnOrganizationChanged ()
198220 {
199- _organizationId = OrgContext .SelectedOrganizationId ;
200221 if (_organizationId .HasValue )
201222 {
223+ await OrgContext .SetOrganizationAsync (_organizationId );
202224 await CheckPermissionsAsync ();
203225 await LoadGlossaryAsync ();
204226 }
205227 else
206228 {
207229 _glossary = null ;
208230 _isLoading = false ;
231+ _canManage = false ;
209232 }
210- await InvokeAsync (StateHasChanged );
211233 }
212234
213235 private async Task CheckPermissionsAsync ()
323345 return text [.. maxLength ] + " ..." ;
324346 }
325347
326- public void Dispose ()
327- {
328- OrgContext .OnOrganizationChanged -= OnOrgChanged ;
329- }
330348}
0 commit comments