using System;
using System.Collections.Generic;
using Abp;
using Abp.Application.Navigation;
using Abp.Authorization;
using Abp.Collections.Extensions;
using Abp.Localization;
namespace IwbZero.Navigation
{
///
/// Represents an item in a .
///
public class IwbMenuItemDefinition : IIwbHasMenuItemDefinitions
//: IHasMenuItemDefinitions
{
///
/// Unique name of the menu item in the application.
/// Can be used to find this menu item later.
///
public string Name { get; }
///
/// Display name of the menu item. Required.
///
public string DisplayName { get; set; }
///
/// Display name of the menu item. Required.
///
public ILocalizableString LocalizableDisplayName { get; set; }
///
/// The Display order of the menu. Optional.
///
public int Order { get; set; }
///
/// Icon of the menu item if exists. Optional.
///
public string Icon { get; set; }
///
/// The URL to navigate when this menu item is selected. Optional.
///
public string Url { get; set; }
///
/// A permission name. Only users that has this permission can see this menu item.
/// Optional.
///
//[Obsolete("Use PermissionDependency instead.")]
public string RequiredPermissionName { get; set; }
///
/// A permission dependency. Only users that can satisfy this permission dependency can see this menu item.
/// Optional.
///
public IPermissionDependency PermissionDependency { get; set; }
/////
///// A feature dependency.
///// Optional.
/////
//public IFeatureDependency FeatureDependency { get; set; }
///
/// This can be set to true if only authenticated users should see this menu item.
///
public bool RequiresAuthentication { get; set; }
///
/// Returns true if this menu item has no child .
///
public bool IsLeaf => Items.IsNullOrEmpty();
///
/// Target of the menu item. Can be "_blank", "_self", "_parent", "_top" or a frame name.
///
public string Target { get; set; }
///
/// Can be used to store a custom object related to this menu item. Optional.
///
public object CustomData { get; set; }
///
/// Can be used to enable/disable a menu item.
///
public bool IsEnabled { get; set; }
///
/// Can be used to show/hide a menu item.
///
public bool IsVisible { get; set; }
///
/// Sub items of this menu item. Optional.
///
public List Items { get; }
///
///
///
///
///
///
/// This parameter is obsolete. Use instead!
///
///
///
///
///
///
public IwbMenuItemDefinition(
string name,
string displayName,
string icon = null,
string url = null,
bool requiresAuthentication = false,
string requiredPermissionName = null,
int order = 0,
object customData = null,
ILocalizableString localizableDisplayName = null,
//IFeatureDependency featureDependency = null,
string target = null,
bool isEnabled = true,
bool isVisible = true,
IPermissionDependency permissionDependency = null)
{
Check.NotNull(name, nameof(name));
if (string.IsNullOrEmpty(displayName))
Check.NotNull(localizableDisplayName, nameof(localizableDisplayName));
Name = name;
DisplayName = displayName;
LocalizableDisplayName = localizableDisplayName;
Icon = icon;
Url = url;
RequiresAuthentication = requiresAuthentication;
RequiredPermissionName = requiredPermissionName;
Order = order;
CustomData = customData;
//FeatureDependency = featureDependency;
Target = target;
IsEnabled = isEnabled;
IsVisible = isVisible;
PermissionDependency = permissionDependency;
Items = new List();
}
///
/// Adds a to .
///
/// to be added
/// This object
public IwbMenuItemDefinition AddItem(IwbMenuItemDefinition menuItem)
{
Items.Add(menuItem);
return this;
}
}
}