2023-04-13 11:51:03 +08:00
|
|
|
|
using System.Collections.ObjectModel;
|
2023-09-02 23:01:20 +08:00
|
|
|
|
using System.Linq;
|
2023-04-13 11:51:03 +08:00
|
|
|
|
using Caliburn.Micro.Core;
|
2023-09-02 23:01:20 +08:00
|
|
|
|
using MECF.Framework.Common.Account.Extends;
|
2023-04-13 11:51:03 +08:00
|
|
|
|
|
|
|
|
|
namespace MECF.Framework.UI.Client.CenterViews.Configs.Roles
|
|
|
|
|
{
|
|
|
|
|
public class RoleItem : PropertyChangedBase
|
|
|
|
|
{
|
2023-09-02 23:01:20 +08:00
|
|
|
|
#region Constructors
|
2023-04-13 11:51:03 +08:00
|
|
|
|
|
2023-09-02 23:01:20 +08:00
|
|
|
|
public RoleItem(Role role)
|
2023-04-13 11:51:03 +08:00
|
|
|
|
{
|
2023-09-02 23:01:20 +08:00
|
|
|
|
Role = role;
|
2023-04-13 11:51:03 +08:00
|
|
|
|
}
|
|
|
|
|
|
2023-09-02 23:01:20 +08:00
|
|
|
|
public RoleItem(string roleId)
|
2023-04-13 11:51:03 +08:00
|
|
|
|
{
|
2023-09-02 23:01:20 +08:00
|
|
|
|
Role = new Role(roleId, string.Empty, false, 0, string.Empty, string.Empty);
|
2023-04-13 11:51:03 +08:00
|
|
|
|
}
|
2023-09-02 23:01:20 +08:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#endregion
|
2023-04-13 11:51:03 +08:00
|
|
|
|
|
2023-09-02 23:01:20 +08:00
|
|
|
|
#region Properties
|
|
|
|
|
|
|
|
|
|
public Role Role { get; }
|
|
|
|
|
|
|
|
|
|
public string RoleId
|
2023-04-13 11:51:03 +08:00
|
|
|
|
{
|
2023-09-02 23:01:20 +08:00
|
|
|
|
get => Role.RoleId;
|
|
|
|
|
set => Role.RoleId = value;
|
2023-04-13 11:51:03 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public string RoleName
|
|
|
|
|
{
|
2023-09-02 23:01:20 +08:00
|
|
|
|
get => Role.RoleName;
|
|
|
|
|
set => Role.RoleName = value;
|
2023-04-13 11:51:03 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public int AutoLogoutTime
|
|
|
|
|
{
|
2023-09-02 23:01:20 +08:00
|
|
|
|
get => Role.LogoutTime;
|
|
|
|
|
set => Role.LogoutTime = value;
|
2023-04-13 11:51:03 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public string Description
|
|
|
|
|
{
|
2023-09-02 23:01:20 +08:00
|
|
|
|
get => Role.Description;
|
|
|
|
|
set => Role.Description = value;
|
2023-04-13 11:51:03 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public bool IsAutoLogout
|
|
|
|
|
{
|
2023-09-02 23:01:20 +08:00
|
|
|
|
get => Role.IsAutoLogout;
|
|
|
|
|
set => Role.IsAutoLogout = value;
|
2023-04-13 11:51:03 +08:00
|
|
|
|
}
|
|
|
|
|
|
2023-09-02 23:01:20 +08:00
|
|
|
|
private string _displayRoleName;
|
|
|
|
|
|
2023-04-13 11:51:03 +08:00
|
|
|
|
public string DisplayRoleName
|
|
|
|
|
{
|
2023-09-02 23:01:20 +08:00
|
|
|
|
get => _displayRoleName;
|
|
|
|
|
set
|
|
|
|
|
{
|
|
|
|
|
_displayRoleName = value;
|
|
|
|
|
NotifyOfPropertyChange();
|
|
|
|
|
}
|
2023-04-13 11:51:03 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public int DisplayAutoLogoutTime
|
|
|
|
|
{
|
|
|
|
|
get;
|
|
|
|
|
set;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public bool DisplayIsAutoLogout
|
|
|
|
|
{
|
|
|
|
|
get;
|
|
|
|
|
set;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public string DisplayDescription
|
|
|
|
|
{
|
|
|
|
|
get;
|
|
|
|
|
set;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2023-09-02 23:01:20 +08:00
|
|
|
|
private bool _isSelected;
|
2023-04-13 11:51:03 +08:00
|
|
|
|
public bool IsSelected
|
|
|
|
|
{
|
2023-09-02 23:01:20 +08:00
|
|
|
|
get => _isSelected;
|
|
|
|
|
set { _isSelected = value; NotifyOfPropertyChange(); }
|
2023-04-13 11:51:03 +08:00
|
|
|
|
}
|
|
|
|
|
|
2023-09-02 23:01:20 +08:00
|
|
|
|
private bool _roleNameTextSaved = true;
|
2023-04-13 11:51:03 +08:00
|
|
|
|
public bool RoleNameTextSaved
|
|
|
|
|
{
|
2023-09-02 23:01:20 +08:00
|
|
|
|
get => _roleNameTextSaved;
|
2023-04-13 11:51:03 +08:00
|
|
|
|
set
|
|
|
|
|
{
|
2023-09-02 23:01:20 +08:00
|
|
|
|
if (_roleNameTextSaved != value)
|
2023-04-13 11:51:03 +08:00
|
|
|
|
{
|
2023-09-02 23:01:20 +08:00
|
|
|
|
_roleNameTextSaved = value;
|
|
|
|
|
NotifyOfPropertyChange();
|
2023-04-13 11:51:03 +08:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2023-09-02 23:01:20 +08:00
|
|
|
|
private bool _timeTextSaved = true;
|
2023-04-13 11:51:03 +08:00
|
|
|
|
public bool TimeTextSaved
|
|
|
|
|
{
|
2023-09-02 23:01:20 +08:00
|
|
|
|
get => _timeTextSaved;
|
2023-04-13 11:51:03 +08:00
|
|
|
|
set
|
|
|
|
|
{
|
2023-09-02 23:01:20 +08:00
|
|
|
|
if (_timeTextSaved != value)
|
2023-04-13 11:51:03 +08:00
|
|
|
|
{
|
2023-09-02 23:01:20 +08:00
|
|
|
|
_timeTextSaved = value;
|
|
|
|
|
NotifyOfPropertyChange();
|
2023-04-13 11:51:03 +08:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2023-09-02 23:01:20 +08:00
|
|
|
|
private bool _descriptionTextSaved = true;
|
2023-04-13 11:51:03 +08:00
|
|
|
|
public bool DescriptionTextSaved
|
|
|
|
|
{
|
2023-09-02 23:01:20 +08:00
|
|
|
|
get => _descriptionTextSaved;
|
2023-04-13 11:51:03 +08:00
|
|
|
|
set
|
|
|
|
|
{
|
2023-09-02 23:01:20 +08:00
|
|
|
|
if (_descriptionTextSaved != value)
|
2023-04-13 11:51:03 +08:00
|
|
|
|
{
|
2023-09-02 23:01:20 +08:00
|
|
|
|
_descriptionTextSaved = value;
|
|
|
|
|
NotifyOfPropertyChange();
|
2023-04-13 11:51:03 +08:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2023-09-03 23:31:57 +08:00
|
|
|
|
public ObservableCollection<PermissionControlItem> MenuCollection { get; } = new();
|
2023-04-13 11:51:03 +08:00
|
|
|
|
|
2023-09-03 23:31:57 +08:00
|
|
|
|
public ObservableCollection<PermissionControlItem> RecipeCollection { get; } = new();
|
2023-04-13 11:51:03 +08:00
|
|
|
|
|
2023-09-03 23:31:57 +08:00
|
|
|
|
public ObservableCollection<PermissionControlItem> RecipeStepCollection { get; } = new();
|
2023-09-02 23:01:20 +08:00
|
|
|
|
|
2023-09-03 23:31:57 +08:00
|
|
|
|
public ObservableCollection<PermissionControlItem> ContentCollection { get; } = new();
|
2023-09-02 23:01:20 +08:00
|
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
#region Methods
|
2023-04-13 11:51:03 +08:00
|
|
|
|
|
2023-09-03 23:31:57 +08:00
|
|
|
|
public void AddMenuInfo(PermissionControlItem pInfo)
|
2023-04-13 11:51:03 +08:00
|
|
|
|
{
|
|
|
|
|
if (null == pInfo)
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
MenuCollection.Add(pInfo);
|
|
|
|
|
}
|
|
|
|
|
|
2023-09-03 23:31:57 +08:00
|
|
|
|
public void AddRecipeInfo(PermissionControlItem pInfo)
|
2023-04-13 11:51:03 +08:00
|
|
|
|
{
|
|
|
|
|
if (null == pInfo)
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
RecipeCollection.Add(pInfo);
|
|
|
|
|
}
|
|
|
|
|
|
2023-09-03 23:31:57 +08:00
|
|
|
|
public void AddStepInfo(PermissionControlItem pInfo)
|
2023-04-13 11:51:03 +08:00
|
|
|
|
{
|
|
|
|
|
if (null == pInfo)
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
RecipeStepCollection.Add(pInfo);
|
|
|
|
|
}
|
|
|
|
|
|
2023-09-03 23:31:57 +08:00
|
|
|
|
public void AddContentInfo(PermissionControlItem pInfo)
|
2023-04-13 11:51:03 +08:00
|
|
|
|
{
|
|
|
|
|
if (null == pInfo)
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
ContentCollection.Add(pInfo);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public bool IsRoleChanged()
|
|
|
|
|
{
|
2023-09-02 23:01:20 +08:00
|
|
|
|
if (DisplayRoleName != Role.RoleName)
|
2023-04-13 11:51:03 +08:00
|
|
|
|
return true;
|
|
|
|
|
|
2023-09-02 23:01:20 +08:00
|
|
|
|
if (DisplayAutoLogoutTime != Role.LogoutTime)
|
2023-04-13 11:51:03 +08:00
|
|
|
|
return true;
|
|
|
|
|
|
2023-09-02 23:01:20 +08:00
|
|
|
|
if (DisplayIsAutoLogout != Role.IsAutoLogout)
|
2023-04-13 11:51:03 +08:00
|
|
|
|
return true;
|
|
|
|
|
|
2023-09-02 23:01:20 +08:00
|
|
|
|
if (DisplayDescription != Role.Description)
|
2023-04-13 11:51:03 +08:00
|
|
|
|
return true;
|
|
|
|
|
|
2023-09-03 23:31:57 +08:00
|
|
|
|
if (MenuCollection.Any(item => item.IsChanged))
|
2023-04-13 11:51:03 +08:00
|
|
|
|
{
|
2023-09-02 23:01:20 +08:00
|
|
|
|
return true;
|
2023-04-13 11:51:03 +08:00
|
|
|
|
}
|
|
|
|
|
|
2023-09-03 23:31:57 +08:00
|
|
|
|
if (RecipeCollection.Any(item => item.IsChanged))
|
2023-04-13 11:51:03 +08:00
|
|
|
|
{
|
2023-09-02 23:01:20 +08:00
|
|
|
|
return true;
|
2023-04-13 11:51:03 +08:00
|
|
|
|
}
|
|
|
|
|
|
2023-09-03 23:31:57 +08:00
|
|
|
|
if (RecipeStepCollection.Any(item => item.IsChanged))
|
2023-04-13 11:51:03 +08:00
|
|
|
|
{
|
2023-09-02 23:01:20 +08:00
|
|
|
|
return true;
|
2023-04-13 11:51:03 +08:00
|
|
|
|
}
|
2023-09-02 23:01:20 +08:00
|
|
|
|
|
2023-09-03 23:31:57 +08:00
|
|
|
|
if (ContentCollection.Any(item => item.IsChanged))
|
2023-04-13 11:51:03 +08:00
|
|
|
|
{
|
2023-09-02 23:01:20 +08:00
|
|
|
|
return true;
|
2023-04-13 11:51:03 +08:00
|
|
|
|
}
|
2023-09-02 23:01:20 +08:00
|
|
|
|
|
2023-04-13 11:51:03 +08:00
|
|
|
|
return false;
|
|
|
|
|
}
|
2023-09-02 23:01:20 +08:00
|
|
|
|
|
|
|
|
|
#endregion
|
2023-04-13 11:51:03 +08:00
|
|
|
|
}
|
|
|
|
|
}
|