Skip to content

Commit

Permalink
Merge pull request #13 from EasyAbp/part8
Browse files Browse the repository at this point in the history
Implementation: Part 8 (Filters & Localization)
  • Loading branch information
gdlcf88 authored Jun 30, 2024
2 parents fdf9c66 + cc5bc35 commit d5ce956
Show file tree
Hide file tree
Showing 8 changed files with 93 additions and 167 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -23,4 +23,6 @@ public class ProcessGetListInput : PagedAndSortedResultRequestDto
public string? StateSummaryText { get; set; }

public string? StateDetailsText { get; set; }

public string? UserName { get; set; }
}
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ public override async Task<ProcessStateHistoryDto> GetAsync(Guid id)
if (!await HasManagementPermissionAsync())
{
var process = await ProcessRepository.GetAsync(history.ProcessId);
var groupKeys = await GetUserGroupKeys();
var groupKeys = await GetUserGroupKeys(CurrentUser.GetId());

if (!groupKeys.Contains(process.GroupKey))
{
Expand All @@ -55,7 +55,7 @@ public override async Task<PagedResultDto<ProcessStateHistoryDto>> GetListAsync(
if (!await HasManagementPermissionAsync())
{
var process = await ProcessRepository.GetAsync(input.ProcessId);
var groupKeys = await GetUserGroupKeys();
var groupKeys = await GetUserGroupKeys(CurrentUser.GetId());

if (!groupKeys.Contains(process.GroupKey))
{
Expand Down Expand Up @@ -109,8 +109,8 @@ protected virtual async Task<bool> HasManagementPermissionAsync()
return await AuthorizationService.IsGrantedAsync(ProcessManagementPermissions.Process.Manage);
}

protected virtual async Task<List<string>> GetUserGroupKeys()
protected virtual async Task<List<string>> GetUserGroupKeys(Guid userId)
{
return await UserGroupManager.GetUserGroupKeysAsync(CurrentUser.GetId());
return await UserGroupManager.GetUserGroupKeysAsync(userId);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ public override async Task<ProcessDto> GetAsync(Guid id)

if (!await HasManagementPermissionAsync())
{
var groupKeys = await GetUserGroupKeys();
var groupKeys = await GetUserGroupKeys(CurrentUser.GetId());

if (!groupKeys.Contains(entity.GroupKey))
{
Expand All @@ -48,11 +48,18 @@ public override async Task<ProcessDto> GetAsync(Guid id)

protected override async Task<IQueryable<Process>> CreateFilteredQueryAsync(ProcessGetListInput input)
{
var queryable = (await base.CreateFilteredQueryAsync(input));
var queryable = await base.CreateFilteredQueryAsync(input);

if (!await HasManagementPermissionAsync())
var hasUserNameInput = !input.UserName.IsNullOrWhiteSpace();

if (hasUserNameInput && input.UserName != CurrentUser.UserName && !await HasManagementPermissionAsync())
{
throw new AbpAuthorizationException();
}

if (hasUserNameInput)
{
var groupKeys = await GetUserGroupKeys();
var groupKeys = await GetUserGroupKeys(CurrentUser.GetId());
queryable = queryable.Where(x => groupKeys.Contains(x.GroupKey));
}

Expand All @@ -76,9 +83,9 @@ protected virtual async Task<bool> HasManagementPermissionAsync()
return await AuthorizationService.IsGrantedAsync(ProcessManagementPermissions.Process.Manage);
}

protected virtual async Task<List<string>> GetUserGroupKeys()
protected virtual async Task<List<string>> GetUserGroupKeys(Guid userId)
{
return await UserGroupManager.GetUserGroupKeysAsync(CurrentUser.GetId());
return await UserGroupManager.GetUserGroupKeysAsync(userId);
}

protected override ProcessDto MapToGetOutputDto(Process entity)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,55 +1,24 @@
{
"culture": "en",
"texts": {
"Menu:Process": "Process",
"Menu:ProcessManagement": "Process management",
"More": "More",
"Permission:ProcessManagement": "Process management",
"Permission:Process": "Process",
"Notifications": "Notifications",
"Permission:Manage": "Manage",
"Menu:Process": "MenuProcess",
"Permission:Process": "Process",
"Permission:ProcessManagement": "Process management",
"Process": "Process",
"ProcessProcessName": "ProcessProcessName",
"ProcessCorrelationId": "ProcessCorrelationId",
"ProcessGroupKey": "ProcessGroupKey",
"ProcessStateUpdateTime": "ProcessStateUpdateTime",
"ProcessStateName": "ProcessStateName",
"ProcessActionName": "ProcessActionName",
"ProcessStateFlag": "ProcessStateFlag",
"ProcessCreationTime": "ProcessCreationTime",
"ProcessStateSummaryText": "ProcessStateSummaryText",
"ProcessStateDetailsText": "ProcessStateDetailsText",
"CreateProcess": "CreateProcess",
"EditProcess": "EditProcess",
"ProcessDeletionConfirmationMessage": "Are you sure to delete the process {0}?",
"SuccessfullyDeleted": "Successfully deleted",
"TableFilter": "TableFilter",
"Menu:ProcessStateHistory": "MenuProcessStateHistory",
"ProcessStateHistory": "ProcessStateHistory",
"ProcessStateHistoryProcessId": "ProcessStateHistoryProcessId",
"ProcessStateHistoryStateName": "ProcessStateHistoryStateName",
"ProcessStateHistoryActionName": "ProcessStateHistoryActionName",
"ProcessStateHistoryStateFlag": "ProcessStateHistoryStateFlag",
"ProcessStateHistoryStateSummaryText": "ProcessStateHistoryStateSummaryText",
"ProcessStateHistoryStateDetailsText": "ProcessStateHistoryStateDetailsText",
"ProcessStateHistoryStateUpdateTime": "ProcessStateHistoryStateUpdateTime",
"CreateProcessStateHistory": "CreateProcessStateHistory",
"EditProcessStateHistory": "EditProcessStateHistory",
"ProcessStateHistoryDeletionConfirmationMessage": "Are you sure to delete the processStateHistory {0}?",
"Menu:Notification": "MenuNotification",
"Notification": "Notification",
"NotificationUserId": "NotificationUserId",
"NotificationProcessId": "NotificationProcessId",
"NotificationReadTime": "NotificationReadTime",
"NotificationDismissedTime": "NotificationDismissedTime",
"NotificationProcessName": "NotificationProcessName",
"NotificationCorrelationId": "NotificationCorrelationId",
"NotificationGroupKey": "NotificationGroupKey",
"NotificationStateUpdateTime": "NotificationStateUpdateTime",
"NotificationStateName": "NotificationStateName",
"NotificationActionName": "NotificationActionName",
"NotificationStateFlag": "NotificationStateFlag",
"NotificationStateSummaryText": "NotificationStateSummaryText",
"CreateNotification": "CreateNotification",
"EditNotification": "EditNotification",
"NotificationDeletionConfirmationMessage": "Are you sure to delete the notification {0}?"
"ProcessActionName": "Action",
"ProcessCorrelationId": "Correlation ID",
"ProcessCreationTime": "Created",
"ProcessGroupKey": "User group key",
"ProcessProcessName": "Process",
"ProcessStateDetailsText": "Details",
"ProcessStateName": "State",
"ProcessStateSummaryText": "Summary",
"ProcessStateUpdateTime": "Updated",
"ProcessUserName": "Username",
"TableFilter": "TableFilter"
}
}
Original file line number Diff line number Diff line change
@@ -1,55 +1,24 @@
{
"culture": "zh-Hans",
"texts": {
"More": "More",
"Permission:ProcessManagement": "Process management",
"Permission:Process": "Process",
"Permission:Manage": "Manage",
"Menu:Process": "MenuProcess",
"Process": "Process",
"ProcessProcessName": "ProcessProcessName",
"ProcessCorrelationId": "ProcessCorrelationId",
"ProcessGroupKey": "ProcessGroupKey",
"ProcessStateUpdateTime": "ProcessStateUpdateTime",
"ProcessStateName": "ProcessStateName",
"ProcessActionName": "ProcessActionName",
"ProcessStateFlag": "ProcessStateFlag",
"ProcessCreationTime": "ProcessCreationTime",
"ProcessStateSummaryText": "ProcessStateSummaryText",
"ProcessStateDetailsText": "ProcessStateDetailsText",
"CreateProcess": "CreateProcess",
"EditProcess": "EditProcess",
"ProcessDeletionConfirmationMessage": "Are you sure to delete the process {0}?",
"SuccessfullyDeleted": "Successfully deleted",
"TableFilter": "TableFilter",
"Menu:ProcessStateHistory": "MenuProcessStateHistory",
"ProcessStateHistory": "ProcessStateHistory",
"ProcessStateHistoryProcessId": "ProcessStateHistoryProcessId",
"ProcessStateHistoryStateName": "ProcessStateHistoryStateName",
"ProcessStateHistoryActionName": "ProcessStateHistoryActionName",
"ProcessStateHistoryStateFlag": "ProcessStateHistoryStateFlag",
"ProcessStateHistoryStateSummaryText": "ProcessStateHistoryStateSummaryText",
"ProcessStateHistoryStateDetailsText": "ProcessStateHistoryStateDetailsText",
"ProcessStateHistoryStateUpdateTime": "ProcessStateHistoryStateUpdateTime",
"CreateProcessStateHistory": "CreateProcessStateHistory",
"EditProcessStateHistory": "EditProcessStateHistory",
"ProcessStateHistoryDeletionConfirmationMessage": "Are you sure to delete the processStateHistory {0}?",
"Menu:Notification": "MenuNotification",
"Notification": "Notification",
"NotificationUserId": "NotificationUserId",
"NotificationProcessId": "NotificationProcessId",
"NotificationReadTime": "NotificationReadTime",
"NotificationDismissedTime": "NotificationDismissedTime",
"NotificationProcessName": "NotificationProcessName",
"NotificationCorrelationId": "NotificationCorrelationId",
"NotificationGroupKey": "NotificationGroupKey",
"NotificationStateUpdateTime": "NotificationStateUpdateTime",
"NotificationStateName": "NotificationStateName",
"NotificationActionName": "NotificationActionName",
"NotificationStateFlag": "NotificationStateFlag",
"NotificationStateSummaryText": "NotificationStateSummaryText",
"CreateNotification": "CreateNotification",
"EditNotification": "EditNotification",
"NotificationDeletionConfirmationMessage": "Are you sure to delete the notification {0}?"
"Menu:Process": "流程",
"Menu:ProcessManagement": "流程管理",
"More": "更多",
"Notifications": "通知",
"Permission:Manage": "管理",
"Permission:Process": "流程",
"Permission:ProcessManagement": "流程管理",
"Process": "流程",
"ProcessActionName": "动作",
"ProcessCorrelationId": "标识 ID",
"ProcessCreationTime": "创建时间",
"ProcessGroupKey": "用户组",
"ProcessProcessName": "流程",
"ProcessStateDetailsText": "详情",
"ProcessStateName": "状态",
"ProcessStateSummaryText": "概述",
"ProcessStateUpdateTime": "更新时间",
"ProcessUserName": "用户名",
"TableFilter": "筛选器"
}
}
Original file line number Diff line number Diff line change
@@ -1,55 +1,24 @@
{
"culture": "zh-Hant",
"texts": {
"More": "More",
"Permission:ProcessManagement": "Process management",
"Permission:Process": "Process",
"Permission:Manage": "Manage",
"Menu:Process": "MenuProcess",
"Process": "Process",
"ProcessProcessName": "ProcessProcessName",
"ProcessCorrelationId": "ProcessCorrelationId",
"ProcessGroupKey": "ProcessGroupKey",
"ProcessStateUpdateTime": "ProcessStateUpdateTime",
"ProcessStateName": "ProcessStateName",
"ProcessActionName": "ProcessActionName",
"ProcessStateFlag": "ProcessStateFlag",
"ProcessCreationTime": "ProcessCreationTime",
"ProcessStateSummaryText": "ProcessStateSummaryText",
"ProcessStateDetailsText": "ProcessStateDetailsText",
"CreateProcess": "CreateProcess",
"EditProcess": "EditProcess",
"ProcessDeletionConfirmationMessage": "Are you sure to delete the process {0}?",
"SuccessfullyDeleted": "Successfully deleted",
"TableFilter": "TableFilter",
"Menu:ProcessStateHistory": "MenuProcessStateHistory",
"ProcessStateHistory": "ProcessStateHistory",
"ProcessStateHistoryProcessId": "ProcessStateHistoryProcessId",
"ProcessStateHistoryStateName": "ProcessStateHistoryStateName",
"ProcessStateHistoryActionName": "ProcessStateHistoryActionName",
"ProcessStateHistoryStateFlag": "ProcessStateHistoryStateFlag",
"ProcessStateHistoryStateSummaryText": "ProcessStateHistoryStateSummaryText",
"ProcessStateHistoryStateDetailsText": "ProcessStateHistoryStateDetailsText",
"ProcessStateHistoryStateUpdateTime": "ProcessStateHistoryStateUpdateTime",
"CreateProcessStateHistory": "CreateProcessStateHistory",
"EditProcessStateHistory": "EditProcessStateHistory",
"ProcessStateHistoryDeletionConfirmationMessage": "Are you sure to delete the processStateHistory {0}?",
"Menu:Notification": "MenuNotification",
"Notification": "Notification",
"NotificationUserId": "NotificationUserId",
"NotificationProcessId": "NotificationProcessId",
"NotificationReadTime": "NotificationReadTime",
"NotificationDismissedTime": "NotificationDismissedTime",
"NotificationProcessName": "NotificationProcessName",
"NotificationCorrelationId": "NotificationCorrelationId",
"NotificationGroupKey": "NotificationGroupKey",
"NotificationStateUpdateTime": "NotificationStateUpdateTime",
"NotificationStateName": "NotificationStateName",
"NotificationActionName": "NotificationActionName",
"NotificationStateFlag": "NotificationStateFlag",
"NotificationStateSummaryText": "NotificationStateSummaryText",
"CreateNotification": "CreateNotification",
"EditNotification": "EditNotification",
"NotificationDeletionConfirmationMessage": "Are you sure to delete the notification {0}?"
"Menu:Process": "流程",
"Menu:ProcessManagement": "流程管理",
"More": "更多",
"Notifications": "通知",
"Permission:Manage": "管理",
"Permission:Process": "流程",
"Permission:ProcessManagement": "流程管理",
"Process": "流程",
"ProcessActionName": "動作",
"ProcessCorrelationId": "標識 ID",
"ProcessCreationTime": "建立時間",
"ProcessGroupKey": "使用者群組",
"ProcessProcessName": "流程",
"ProcessStateDetailsText": "詳情",
"ProcessStateName": "狀態",
"ProcessStateSummaryText": "概述",
"ProcessStateUpdateTime": "更新時間",
"ProcessUserName": "使用者名",
"TableFilter": "篩選器"
}
}
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
using System.Linq;
using System.Threading.Tasks;
using EasyAbp.ProcessManagement.Localization;
using EasyAbp.ProcessManagement.Permissions;
Expand All @@ -18,16 +19,21 @@ public async Task ConfigureMenuAsync(MenuConfigurationContext context)
private async Task ConfigureMainMenuAsync(MenuConfigurationContext context)
{
var l = context.GetLocalizer<ProcessManagementResource>();
//Add main menu items.
context.Menu.GetAdministration().AddItem(new ApplicationMenuItem(ProcessManagementMenus.Prefix,
displayName: "ProcessManagement", icon: "fa fa-list", url: "~/ProcessManagement"));

var processManagementMenuItem = new ApplicationMenuItem(ProcessManagementMenus.Prefix,
displayName: l["Menu:ProcessManagement"], icon: "fa fa-tasks", url: "~/ProcessManagement");

if (await context.IsGrantedAsync(ProcessManagementPermissions.Process.Manage))
{
context.Menu.GetAdministration().AddItem(
processManagementMenuItem.AddItem(
new ApplicationMenuItem(ProcessManagementMenus.Process, l["Menu:Process"],
"/ProcessManagement/Processes/Process")
);
}

if (processManagementMenuItem.Items.Any())
{
context.Menu.GetAdministration().AddItem(processManagementMenuItem);
}
}
}
Original file line number Diff line number Diff line change
@@ -1,17 +1,21 @@
using System;
using System.Threading.Tasks;
using System.ComponentModel.DataAnnotations;
using EasyAbp.ProcessManagement.Processes;
using Volo.Abp.AspNetCore.Mvc.UI.Bootstrap.TagHelpers.Form;

namespace EasyAbp.ProcessManagement.Web.Pages.ProcessManagement.Processes.Process;

public class IndexModel : ProcessManagementPageModel
{
public ProcessFilterInput ProcessFilter { get; set; }
public ProcessFilterInput ProcessFilter { get; set; } = new();

public virtual async Task OnGetAsync()
{
if (ProcessFilter.UserName.IsNullOrWhiteSpace())
{
ProcessFilter.UserName = CurrentUser.UserName;
}

await Task.CompletedTask;
}
}
Expand All @@ -26,6 +30,10 @@ public class ProcessFilterInput
[Display(Name = "ProcessCorrelationId")]
public string? CorrelationId { get; set; }

[FormControlSize(AbpFormControlSize.Small)]
[Display(Name = "ProcessUserName")]
public string? UserName { get; set; }

[FormControlSize(AbpFormControlSize.Small)]
[Display(Name = "ProcessGroupKey")]
public string? GroupKey { get; set; }
Expand All @@ -42,10 +50,6 @@ public class ProcessFilterInput
[Display(Name = "ProcessActionName")]
public string? ActionName { get; set; }

[FormControlSize(AbpFormControlSize.Small)]
[Display(Name = "ProcessStateFlag")]
public ProcessStateFlag? StateFlag { get; set; }

[FormControlSize(AbpFormControlSize.Small)]
[Display(Name = "ProcessStateSummaryText")]
public string? StateSummaryText { get; set; }
Expand Down

0 comments on commit d5ce956

Please sign in to comment.