public GridItemAction Render(object dataItem, GridItemAction itemAction, ViewContext viewContext)
        {
            var inheritable = dataItem as IInheritable;
            if (inheritable != null)
            {
                var localized = inheritable.IsLocalized(Site.Current);
                if (localized)
                {
                    //注释下面的代码,解决子页面本地化,父页面没有本地化时,不能进行还原操作。
                    var hasParent = Site.Current.Parent != null;
                    if (hasParent)
                    {
                        itemAction.ActionName = "Unlocalize";
                        itemAction.Title = "Unlocalize".Localize();
                        itemAction.Class = "o-icon unlocalize actionCommand";
                        itemAction.ConfirmMessage = "Are you sure you want to unlocalize this item?";
                        itemAction.Visible = true;
                    }
                    else
                    {
                        itemAction.Title = "Localize";
                        itemAction.Visible = false;
                    }
                }

            }

            return itemAction;
        }
示例#2
0
        public IEnumerable <GridItemAction> GetItemActions(ViewContext viewContext)
        {
            foreach (var gridAction in GridActions)
            {
                GridItemAction itemAction = new GridItemAction()
                {
                    ActionName     = gridAction.ActionName,
                    ControllerName = gridAction.ControllerName,
                    DisplayName    = gridAction.DisplayName,
                    ConfirmMessage = gridAction.ConfirmMessage,
                    Icon           = gridAction.Icon,
                    Title          = gridAction.Title,
                    Class          = gridAction.Class,
                    RouteValues    = new System.Web.Routing.RouteValueDictionary(gridAction.InheritRouteValues ? viewContext.RequestContext.AllRouteValues() : new RouteValueDictionary())
                };

                if (!string.IsNullOrEmpty(itemAction.ControllerName))
                {
                    itemAction.RouteValues["controller"] = itemAction.ControllerName;
                }
                if (gridAction.RouteValuesSetting != null)
                {
                    foreach (var setting in gridAction.RouteValuesSetting)
                    {
                        itemAction.RouteValues[setting.RouteValueName] = GetValue(this.DataItem, setting.PropertyName);
                    }
                }
                if (gridAction.RouteValuesGetter != null)
                {
                    itemAction.RouteValues = gridAction.RouteValuesGetter.GetValues(this.DataItem, itemAction.RouteValues, viewContext);
                }
                if (gridAction.VisibleArbiter != null)
                {
                    itemAction.Visible = gridAction.VisibleArbiter.IsVisible(DataItem, viewContext);
                }
                else
                {
                    if (!string.IsNullOrEmpty(gridAction.VisibleProperty))
                    {
                        itemAction.Visible = (bool)GetValue(DataItem, gridAction.VisibleProperty);
                    }
                }
                if (gridAction.Renderer != null)
                {
                    itemAction = gridAction.Renderer.Render(DataItem, itemAction, viewContext);
                }

                yield return(itemAction);
            }
        }
示例#3
0
文件: GridItem.cs 项目: Epitomy/CMS
        public IEnumerable<GridItemAction> GetItemActions(ViewContext viewContext)
        {
            foreach (var gridAction in GridActions)
            {
                GridItemAction itemAction = new GridItemAction()
                {
                    ActionName = gridAction.ActionName,
                    ControllerName = gridAction.ControllerName,
                    DisplayName = gridAction.DisplayName,
                    ConfirmMessage = gridAction.ConfirmMessage,
                    Icon = gridAction.Icon,
                    Title = gridAction.Title,
                    Class = gridAction.Class,
                    RouteValues = new System.Web.Routing.RouteValueDictionary(gridAction.InheritRouteValues ? viewContext.RequestContext.AllRouteValues() : new RouteValueDictionary())
                };

                if (!string.IsNullOrEmpty(itemAction.ControllerName))
                {
                    itemAction.RouteValues["controller"] = itemAction.ControllerName;
                }
                if (gridAction.RouteValuesSetting != null)
                {
                    foreach (var setting in gridAction.RouteValuesSetting)
                    {
                        itemAction.RouteValues[setting.RouteValueName] = GetValue(this.DataItem, setting.PropertyName);
                    }
                }
                if (gridAction.RouteValuesGetter != null)
                {
                    itemAction.RouteValues = gridAction.RouteValuesGetter.GetValues(this.DataItem, itemAction.RouteValues, viewContext);
                }
                if (gridAction.VisibleArbiter != null)
                {
                    itemAction.Visible = gridAction.VisibleArbiter.IsVisible(DataItem, viewContext);
                }
                else
                {
                    if (!string.IsNullOrEmpty(gridAction.VisibleProperty))
                    {
                        itemAction.Visible = (bool)GetValue(DataItem, gridAction.VisibleProperty);
                    }
                }
                if (gridAction.Renderer != null)
                {
                    itemAction = gridAction.Renderer.Render(DataItem, itemAction, viewContext);
                }

                yield return itemAction;
            }
        }