Quantcast
Channel: C1 CMS Foundation - Open Source on .NET
Viewing all articles
Browse latest Browse all 2540

New Post: Hide empty 'Website Items' in content perspective

$
0
0
Hi,

I thought I share...
I do not like the 'Website items' folder to appear in the content perspective when no items are present. It also always shows the '+' icon even when nothing is in it. I think this confuses users.

I have two methods for ya:

1 Quick (and a little dirty):
Add the following css at the end of styles_compiled.css if you are in control and know that later no items will be added - modify the label property according to your console Ui language
ui|treenode[label="Website Items"]
{
    display:none;
}
2 Modify method 'GetRoots' source in GeneratedDataTypesElementProvider.cs:

change
Element globalDataElement;
            if (_websiteItemsView)
            {
                globalDataElement = new Element(_providerContext.CreateElementHandle(new GeneratedDataTypesElementProviderRootEntityToken(_providerContext.ProviderName, GeneratedDataTypesElementProviderRootEntityToken.GlobalDataTypeFolderId)))
                {
                    VisualData = new ElementVisualizedData
                    {
                        Label = Texts.GlobalDataFolderLabel_OnlyGlobalData,
                        ToolTip = Texts.GlobalDataFolderToolTip_OnlyGlobalData,
                        HasChildren = true,
                        Icon = GeneratedDataTypesElementProvider.InterfaceClosed,
                        OpenedIcon = GeneratedDataTypesElementProvider.InterfaceOpen
                    }
                };
            }
            else
            {
                globalDataElement = new Element(_providerContext.CreateElementHandle(new GeneratedDataTypesElementProviderRootEntityToken(_providerContext.ProviderName, GeneratedDataTypesElementProviderRootEntityToken.GlobalDataTypeFolderId)))
                    {
                        VisualData = new ElementVisualizedData
                        {
                            Label = Texts.GlobalDataFolderLabel,
                            ToolTip = Texts.GlobalDataFolderToolTip,
                            HasChildren = GlobalDataTypeFacade.GetAllGlobalDataTypes().Any(),
                            Icon = GeneratedDataTypesElementProvider.RootClosed,
                            OpenedIcon = GeneratedDataTypesElementProvider.RootOpen
                        }
                    };
            }

            if (!_websiteItemsView)
            {
                globalDataElement.AddAction(
                    new ElementAction(new ActionHandle(new WorkflowActionToken(WorkflowFacade.GetWorkflowType("Composite.Plugins.Elements.ElementProviders.GeneratedDataTypesElementProvider.AddNewInterfaceTypeWorkflow"), _addNewInterfaceTypePermissionTypes) { Payload = _providerContext.ProviderName }))
                    {
                        VisualData = new ActionVisualizedData
                        {
                            Label = GetText("Add"),
                            ToolTip = GetText("AddToolTip"),
                            Icon = GeneratedDataTypesElementProvider.AddDataTypeIcon,
                            Disabled = false,
                            ActionLocation = new ActionLocation
                            {
                                ActionType = ActionType.Edit,
                                IsInFolder = false,
                                IsInToolbar = true,
                                ActionGroup = PrimaryActionGroup
                            }
                        }
                    });
            }

            globalDataElement.AddAction(
                new ElementAction(new ActionHandle(new ViewUnpublishedItemsActionToken()))
                {
                    VisualData = new ActionVisualizedData
                    {
                        Label = GetText("ViewUnpublishedItems"),
                        ToolTip = GetText("ViewUnpublishedItemsToolTip"),
                        Icon = GeneratedDataTypesElementProvider.ListUnpublishedItemsIcon,
                        Disabled = false,
                        ActionLocation = new ActionLocation
                        {
                            ActionType = ActionType.Other,
                            IsInFolder = false,
                            IsInToolbar = true,
                            ActionGroup = ViewActionGroup
                        }
                    }
                });


            roots.Add(globalDataElement);
To:
Element globalDataElement  = null;
            if (_websiteItemsView)
            {
                // Do we have website items available
                bool websiteItems = DataFacade.GetData<IGeneratedTypeWhiteList>().Any();

                if (websiteItems)
                {
                    globalDataElement = new Element(_providerContext.CreateElementHandle(new GeneratedDataTypesElementProviderRootEntityToken(_providerContext.ProviderName, GeneratedDataTypesElementProviderRootEntityToken.GlobalDataTypeFolderId)))
                    {
                        VisualData = new ElementVisualizedData
                        {
                            Label = Texts.GlobalDataFolderLabel_OnlyGlobalData,
                            ToolTip = Texts.GlobalDataFolderToolTip_OnlyGlobalData,
                            HasChildren = true,
                            Icon = GeneratedDataTypesElementProvider.InterfaceClosed,
                            OpenedIcon = GeneratedDataTypesElementProvider.InterfaceOpen
                        }
                    };
                }
            }
            else
            {
                globalDataElement = new Element(_providerContext.CreateElementHandle(new GeneratedDataTypesElementProviderRootEntityToken(_providerContext.ProviderName, GeneratedDataTypesElementProviderRootEntityToken.GlobalDataTypeFolderId)))
                    {
                        VisualData = new ElementVisualizedData
                        {
                            Label = Texts.GlobalDataFolderLabel,
                            ToolTip = Texts.GlobalDataFolderToolTip,
                            HasChildren = GlobalDataTypeFacade.GetAllGlobalDataTypes().Any(),
                            Icon = GeneratedDataTypesElementProvider.RootClosed,
                            OpenedIcon = GeneratedDataTypesElementProvider.RootOpen
                        }
                    };
            }

            // Defensive: Is the global data element created
            if (globalDataElement != null)
            {
                if (!_websiteItemsView)
                {
                    globalDataElement.AddAction(
                        new ElementAction(new ActionHandle(new WorkflowActionToken(WorkflowFacade.GetWorkflowType("Composite.Plugins.Elements.ElementProviders.GeneratedDataTypesElementProvider.AddNewInterfaceTypeWorkflow"), _addNewInterfaceTypePermissionTypes) { Payload = _providerContext.ProviderName }))
                        {
                            VisualData = new ActionVisualizedData
                            {
                                Label = GetText("Add"),
                                ToolTip = GetText("AddToolTip"),
                                Icon = GeneratedDataTypesElementProvider.AddDataTypeIcon,
                                Disabled = false,
                                ActionLocation = new ActionLocation
                                {
                                    ActionType = ActionType.Edit,
                                    IsInFolder = false,
                                    IsInToolbar = true,
                                    ActionGroup = PrimaryActionGroup
                                }
                            }
                        });
                }

                globalDataElement.AddAction(
                    new ElementAction(new ActionHandle(new ViewUnpublishedItemsActionToken()))
                    {
                        VisualData = new ActionVisualizedData
                        {
                            Label = GetText("ViewUnpublishedItems"),
                            ToolTip = GetText("ViewUnpublishedItemsToolTip"),
                            Icon = GeneratedDataTypesElementProvider.ListUnpublishedItemsIcon,
                            Disabled = false,
                            ActionLocation = new ActionLocation
                            {
                                ActionType = ActionType.Other,
                                IsInFolder = false,
                                IsInToolbar = true,
                                ActionGroup = ViewActionGroup
                            }
                        }
                    });

                roots.Add(globalDataElement);
            }
Hope you like it.
JamBo

Viewing all articles
Browse latest Browse all 2540

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>