Sic.Framework-Nanjing-Baishi/MECF.Framework.UI.Client/CenterViews/Configs/Roles/RoleItem.cs

224 lines
5.1 KiB
C#
Raw Normal View History

2023-04-13 11:51:03 +08:00
using System.Collections.ObjectModel;
using System.Linq;
2023-04-13 11:51:03 +08:00
using Caliburn.Micro.Core;
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
{
#region Constructors
2023-04-13 11:51:03 +08:00
public RoleItem(Role role)
2023-04-13 11:51:03 +08:00
{
Role = role;
2023-04-13 11:51:03 +08:00
}
public RoleItem(string roleId)
2023-04-13 11:51:03 +08:00
{
Role = new Role(roleId, string.Empty, false, 0, string.Empty, string.Empty);
2023-04-13 11:51:03 +08:00
}
#endregion
2023-04-13 11:51:03 +08:00
#region Properties
public Role Role { get; }
public string RoleId
2023-04-13 11:51:03 +08:00
{
get => Role.RoleId;
set => Role.RoleId = value;
2023-04-13 11:51:03 +08:00
}
public string RoleName
{
get => Role.RoleName;
set => Role.RoleName = value;
2023-04-13 11:51:03 +08:00
}
public int AutoLogoutTime
{
get => Role.LogoutTime;
set => Role.LogoutTime = value;
2023-04-13 11:51:03 +08:00
}
public string Description
{
get => Role.Description;
set => Role.Description = value;
2023-04-13 11:51:03 +08:00
}
public bool IsAutoLogout
{
get => Role.IsAutoLogout;
set => Role.IsAutoLogout = value;
2023-04-13 11:51:03 +08:00
}
private string _displayRoleName;
2023-04-13 11:51:03 +08:00
public string DisplayRoleName
{
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;
}
private bool _isSelected;
2023-04-13 11:51:03 +08:00
public bool IsSelected
{
get => _isSelected;
set { _isSelected = value; NotifyOfPropertyChange(); }
2023-04-13 11:51:03 +08:00
}
private bool _roleNameTextSaved = true;
2023-04-13 11:51:03 +08:00
public bool RoleNameTextSaved
{
get => _roleNameTextSaved;
2023-04-13 11:51:03 +08:00
set
{
if (_roleNameTextSaved != value)
2023-04-13 11:51:03 +08:00
{
_roleNameTextSaved = value;
NotifyOfPropertyChange();
2023-04-13 11:51:03 +08:00
}
}
}
private bool _timeTextSaved = true;
2023-04-13 11:51:03 +08:00
public bool TimeTextSaved
{
get => _timeTextSaved;
2023-04-13 11:51:03 +08:00
set
{
if (_timeTextSaved != value)
2023-04-13 11:51:03 +08:00
{
_timeTextSaved = value;
NotifyOfPropertyChange();
2023-04-13 11:51:03 +08:00
}
}
}
private bool _descriptionTextSaved = true;
2023-04-13 11:51:03 +08:00
public bool DescriptionTextSaved
{
get => _descriptionTextSaved;
2023-04-13 11:51:03 +08:00
set
{
if (_descriptionTextSaved != value)
2023-04-13 11:51:03 +08:00
{
_descriptionTextSaved = value;
NotifyOfPropertyChange();
2023-04-13 11:51:03 +08:00
}
}
}
public ObservableCollection<PermissionControlItem> MenuCollection { get; } = new();
2023-04-13 11:51:03 +08:00
public ObservableCollection<PermissionControlItem> RecipeCollection { get; } = new();
2023-04-13 11:51:03 +08:00
public ObservableCollection<PermissionControlItem> RecipeStepCollection { get; } = new();
public ObservableCollection<PermissionControlItem> ContentCollection { get; } = new();
#endregion
#region Methods
2023-04-13 11:51:03 +08:00
public void AddMenuInfo(PermissionControlItem pInfo)
2023-04-13 11:51:03 +08:00
{
if (null == pInfo)
return;
MenuCollection.Add(pInfo);
}
public void AddRecipeInfo(PermissionControlItem pInfo)
2023-04-13 11:51:03 +08:00
{
if (null == pInfo)
return;
RecipeCollection.Add(pInfo);
}
public void AddStepInfo(PermissionControlItem pInfo)
2023-04-13 11:51:03 +08:00
{
if (null == pInfo)
return;
RecipeStepCollection.Add(pInfo);
}
public void AddContentInfo(PermissionControlItem pInfo)
2023-04-13 11:51:03 +08:00
{
if (null == pInfo)
return;
ContentCollection.Add(pInfo);
}
public bool IsRoleChanged()
{
if (DisplayRoleName != Role.RoleName)
2023-04-13 11:51:03 +08:00
return true;
if (DisplayAutoLogoutTime != Role.LogoutTime)
2023-04-13 11:51:03 +08:00
return true;
if (DisplayIsAutoLogout != Role.IsAutoLogout)
2023-04-13 11:51:03 +08:00
return true;
if (DisplayDescription != Role.Description)
2023-04-13 11:51:03 +08:00
return true;
if (MenuCollection.Any(item => item.IsChanged))
2023-04-13 11:51:03 +08:00
{
return true;
2023-04-13 11:51:03 +08:00
}
if (RecipeCollection.Any(item => item.IsChanged))
2023-04-13 11:51:03 +08:00
{
return true;
2023-04-13 11:51:03 +08:00
}
if (RecipeStepCollection.Any(item => item.IsChanged))
2023-04-13 11:51:03 +08:00
{
return true;
2023-04-13 11:51:03 +08:00
}
if (ContentCollection.Any(item => item.IsChanged))
2023-04-13 11:51:03 +08:00
{
return true;
2023-04-13 11:51:03 +08:00
}
2023-04-13 11:51:03 +08:00
return false;
}
#endregion
2023-04-13 11:51:03 +08:00
}
}