|
| 1 | +@using Blazorise.Components |
| 2 | +@using Volo.Abp.BlazoriseUI.Components |
| 3 | +@using Volo.Abp.PermissionManagement.Localization |
| 4 | +@inherits Volo.Abp.AspNetCore.Components.AbpComponentBase |
| 5 | +@inject AbpBlazorMessageLocalizerHelper<AbpPermissionManagementResource> LH |
| 6 | + |
| 7 | +<Modal @ref="Modal" Closing="@ClosingModal"> |
| 8 | + <ModalContent Size="ModalSize.ExtraLarge" Centered="true"> |
| 9 | + <ModalHeader> |
| 10 | + <ModalTitle>@L["ResourcePermissions"] - @ResourceDisplayName</ModalTitle> |
| 11 | + <CloseButton Clicked="CloseModal" /> |
| 12 | + </ModalHeader> |
| 13 | + <ModalBody Overflow="Overflow.Hidden"> |
| 14 | + @if(HasAnyResourcePermission && HasAnyResourceProviderKeyLookupService) |
| 15 | + { |
| 16 | + <div class="d-grid gap-2 mb-2 d-md-flex justify-content-md-end"> |
| 17 | + <Button Color="Color.Primary" size="Size.Small" Clicked="OpenCreateModalAsync">@L["AddResourcePermission"]</Button> |
| 18 | + </div> |
| 19 | + <DataGrid TItem="ResourcePermissionGrantInfoDto" |
| 20 | + Data="ResourcePermissionList.Permissions" |
| 21 | + TotalItems="ResourcePermissionList.Permissions.Count" |
| 22 | + ShowPager="true" |
| 23 | + PageSize="PageSize"> |
| 24 | + <DataGridColumns> |
| 25 | + <DataGridColumn |
| 26 | + Width="150px" |
| 27 | + Sortable="false" |
| 28 | + TItem="ResourcePermissionGrantInfoDto" |
| 29 | + Field="@nameof(ResourcePermissionGrantInfoDto.ProviderName)" |
| 30 | + Caption="@L["Actions"]"> |
| 31 | + <DisplayTemplate> |
| 32 | + <Dropdown> |
| 33 | + <DropdownToggle Color="Color.Primary"> |
| 34 | + @L["Actions"] |
| 35 | + </DropdownToggle> |
| 36 | + <DropdownMenu> |
| 37 | + <DropdownItem Clicked="() => OpenEditModalAsync(context)"> |
| 38 | + @L["Edit"] |
| 39 | + </DropdownItem> |
| 40 | + <DropdownItem Clicked="() => DeleteResourcePermissionAsync(context)"> |
| 41 | + @L["Delete"] |
| 42 | + </DropdownItem> |
| 43 | + </DropdownMenu> |
| 44 | + </Dropdown> |
| 45 | + </DisplayTemplate> |
| 46 | + </DataGridColumn> |
| 47 | + <DataGridColumn TItem="ResourcePermissionGrantInfoDto" Field="@nameof(ResourcePermissionGrantInfoDto.ProviderName)" Caption="@L["ResourcePermissionTarget"]" Sortable="false"> |
| 48 | + <DisplayTemplate> |
| 49 | + @{ |
| 50 | + <Tooltip Text="@context.ProviderNameDisplayName" Placement="TooltipPlacement.Right" Style="float: left;"> |
| 51 | + <span class="d-inline-block bg-light rounded-pill px-2 me-1 ms-1 mb-1">@context.ProviderName</span> |
| 52 | + </Tooltip> |
| 53 | + @context.ProviderDisplayName |
| 54 | + } |
| 55 | + </DisplayTemplate> |
| 56 | + </DataGridColumn> |
| 57 | + <DataGridColumn TItem="ResourcePermissionGrantInfoDto" Field="@nameof(ResourcePermissionGrantInfoDto.Permissions)" Caption="@L["ResourcePermissionPermissions"]" Sortable="false"> |
| 58 | + <DisplayTemplate> |
| 59 | + @{ |
| 60 | + foreach (var permission in context.Permissions) |
| 61 | + { |
| 62 | + <span class="d-inline-block bg-light rounded-pill px-2 me-1 mb-1">@permission.DisplayName</span> |
| 63 | + } |
| 64 | + } |
| 65 | + </DisplayTemplate> |
| 66 | + </DataGridColumn> |
| 67 | + </DataGridColumns> |
| 68 | + <EmptyTemplate> |
| 69 | + @L["NoDataAvailableInDatatable"] |
| 70 | + </EmptyTemplate> |
| 71 | + </DataGrid> |
| 72 | + } |
| 73 | + else |
| 74 | + { |
| 75 | + <div class="alert alert-warning" role="alert"> |
| 76 | + @if (!HasAnyResourcePermission) |
| 77 | + { |
| 78 | + @L["NoResourcePermissionFound"] |
| 79 | + } |
| 80 | + else if(!HasAnyResourceProviderKeyLookupService) |
| 81 | + { |
| 82 | + @L["NoResourceProviderKeyLookupServiceFound"] |
| 83 | + } |
| 84 | + </div> |
| 85 | + } |
| 86 | + </ModalBody> |
| 87 | + <ModalFooter> |
| 88 | + <Button Color="Color.Primary" Outline Clicked="CloseModal">@L["Close"]</Button> |
| 89 | + </ModalFooter> |
| 90 | + </ModalContent> |
| 91 | +</Modal> |
| 92 | + |
| 93 | +<Modal @ref="CreateModal" Closing="@ClosingCreateModal"> |
| 94 | + <ModalContent Centered="true"> |
| 95 | + <Form> |
| 96 | + <ModalHeader> |
| 97 | + <ModalTitle>@L["AddResourcePermission"]</ModalTitle> |
| 98 | + <CloseButton Clicked="CloseCreateModalAsync" /> |
| 99 | + </ModalHeader> |
| 100 | + <ModalBody> |
| 101 | + <Validations @ref="@CreateValidationsRef" Model="@CreateEntity" ValidateOnLoad="false"> |
| 102 | + <div class="mb-3"> |
| 103 | + <RadioGroup TValue="string" |
| 104 | + CheckedValue="@CurrentLookupService" |
| 105 | + CheckedValueChanged="@OnLookupServiceCheckedValueChanged"> |
| 106 | + @foreach(var keyLookupService in ResourceProviderKeyLookupServices) |
| 107 | + { |
| 108 | + <Radio Value="@(keyLookupService.Name)">@keyLookupService.DisplayName</Radio> |
| 109 | + } |
| 110 | + </RadioGroup> |
| 111 | + <Autocomplete @ref="ProviderKeyAutocompleteRef" |
| 112 | + TItem="SearchProviderKeyInfo" |
| 113 | + TValue="string" |
| 114 | + Data="@ProviderKeys" |
| 115 | + ReadData="@SearchProviderKeyAsync" |
| 116 | + TotalItems="ProviderKeys.Count" |
| 117 | + TextField="@((item) => item.ProviderDisplayName)" |
| 118 | + ValueField="@((item) => item.ProviderKey)" |
| 119 | + SelectedValue="@ProviderKey" |
| 120 | + SelectedText="@ProviderDisplayName" |
| 121 | + SelectedValueChanged="SelectedProviderKeyAsync" |
| 122 | + class="mt-1"> |
| 123 | + </Autocomplete> |
| 124 | + <Validation @ref="ProviderKeyValidationRef" Validator="ValidateProviderKey"> |
| 125 | + <TextEdit Style="display: none;"> |
| 126 | + <Feedback> |
| 127 | + <ValidationError></ValidationError> |
| 128 | + </Feedback> |
| 129 | + </TextEdit> |
| 130 | + </Validation> |
| 131 | + </div> |
| 132 | + <div class="mb-3"> |
| 133 | + <h4>@L["ResourcePermissionPermissions"]</h4> |
| 134 | + <Switch TValue="bool" Checked="CreateEntity.Permissions.All(x => x.IsGranted)" CheckedChanged="GrantAllAsync">@L["GrantAllResourcePermissions"]</Switch> |
| 135 | + <div class="mt-2"> |
| 136 | + @foreach (var permission in CreateEntity.Permissions) |
| 137 | + { |
| 138 | + <Check TValue="bool" Checked="@permission.IsGranted" CheckedChanged="@((c) => OnPermissionCheckedChanged(permission, c))">@permission.DisplayName</Check> |
| 139 | + } |
| 140 | + </div> |
| 141 | + </div> |
| 142 | + </Validations> |
| 143 | + </ModalBody> |
| 144 | + <ModalFooter> |
| 145 | + <Button Color="Color.Primary" Outline Clicked="CloseCreateModalAsync">@L["Cancel"]</Button> |
| 146 | + <SubmitButton Clicked="@CreateResourcePermissionAsync" /> |
| 147 | + </ModalFooter> |
| 148 | + </Form> |
| 149 | + </ModalContent> |
| 150 | +</Modal> |
| 151 | + |
| 152 | +<Modal @ref="EditModal" Closing="@ClosingEditModal"> |
| 153 | + <ModalContent Centered="true"> |
| 154 | + <Form> |
| 155 | + <ModalHeader> |
| 156 | + <ModalTitle>@L["UpdateResourcePermission"]</ModalTitle> |
| 157 | + <CloseButton Clicked="CloseEditModalAsync" /> |
| 158 | + </ModalHeader> |
| 159 | + <ModalBody> |
| 160 | + <Validations @ref="@EditValidationsRef" Model="@EditEntity" ValidateOnLoad="false"> |
| 161 | + <div class="mb-3"> |
| 162 | + <h4>@L["ResourcePermissionPermissions"]</h4> |
| 163 | + <Switch TValue="bool" Checked="EditEntity.Permissions.All(x => x.IsGranted)" CheckedChanged="GrantAllAsync">@L["GrantAllResourcePermissions"]</Switch> |
| 164 | + <div class="mt-2"> |
| 165 | + @foreach (var permission in EditEntity.Permissions) |
| 166 | + { |
| 167 | + <Check TValue="bool" Checked="@permission.IsGranted" CheckedChanged="@((c) => OnPermissionCheckedChanged(permission, c))">@permission.DisplayName</Check> |
| 168 | + } |
| 169 | + </div> |
| 170 | + </div> |
| 171 | + </Validations> |
| 172 | + </ModalBody> |
| 173 | + <ModalFooter> |
| 174 | + <Button Color="Color.Primary" Outline Clicked="CloseEditModalAsync">@L["Cancel"]</Button> |
| 175 | + <SubmitButton Clicked="@UpdateResourcePermissionAsync" /> |
| 176 | + </ModalFooter> |
| 177 | + </Form> |
| 178 | + </ModalContent> |
| 179 | +</Modal> |
0 commit comments