Beispiel #1
0
        public static void Populate(CommandProperties commandProperties)
        {
            _resources           = (Dictionary <string, string>)Script.Literal("window.top._quickNav__resources");
            _userPriviledgeNames = (Dictionary <string, string>)Script.Literal("window.top._quickNav__userPriviledgeNames");
            _siteMap             = (SiteMap)Script.Literal("window.top._quickNav__siteMap");

            uniquePrefix = "dev1_" + DateTime.Now.GetTime().ToString() + "|";
            bool isOnForm = (Page.Ui != null);

            LoadResources();

            RibbonMenu        quickNav   = new RibbonMenu("dev1.QuickNav");
            RibbonMenuSection topSection = new RibbonMenuSection("dev1.SiteMapMenuSection", "", 2, RibbonDisplayMode.Menu16);

            quickNav.AddSection(topSection);

            // Only show Sitemap in web client
            if (Page.Context.Client.GetClient() == ClientType.Web)
            {
                if (isOnForm)
                {
                    RibbonFlyoutAnchor siteMapMenuFlyout = new RibbonFlyoutAnchor(uniquePrefix + "SiteMapButton", 1, ReplaceResourceToken("$Site_Map"), "Mscrm.Enabled", "/_imgs/FormEditorRibbon/Subgrid_16.png", null);
                    topSection.AddButton((RibbonButton)(object)siteMapMenuFlyout);

                    siteMapMenuFlyout.Menu = new RibbonMenu("dev1.SiteMapButton.Menu");

                    RibbonMenuSection siteMapMenuFlyoutSection = new RibbonMenuSection(uniquePrefix + "SiteMapButton.Menu.Section", "", 1, RibbonDisplayMode.Menu16);
                    siteMapMenuFlyout.Menu.AddSection(siteMapMenuFlyoutSection);
                    GetSiteMap(siteMapMenuFlyoutSection);
                }
                else
                {
                    GetSiteMap(topSection);
                }
            }

            // Add Advanced Find
            RibbonButton advFind = new RibbonButton("dev1.OpenAdvancedFind.Button", 1, ReplaceResourceToken("$Advanced_Find"), "dev1.OpenAdvancedFind", "/_imgs/ribbon/AdvancedFind_16.png", null);

            topSection.AddButton(advFind);

            GetFormTabs(quickNav);

            GetFormNav(quickNav);

            commandProperties.PopulationXML = quickNav.SerialiseToRibbonXml();

            // Store for next time
            Script.Literal("window.top._quickNav__resources={0}", _resources);
            Script.Literal("window.top._quickNav__userPriviledgeNames={0}", _userPriviledgeNames);
            Script.Literal("window.top._quickNav__siteMap={0}", _siteMap);
        }
Beispiel #2
0
        public static void GetSiteMap(RibbonMenuSection siteMapSection)
        {
            GetUserPrivs();

            //jQuery.FromHtml("<style>.commandBar-NavButton{background-color:red}</style>").AppendTo("head");



            int sequence = 1;

            foreach (Area area in _siteMap.areas)
            {
                string areaIconUrl = "/_imgs/FormEditorRibbon/Subgrid_16.png";
                if (!String.IsNullOrEmpty(area.icon))
                {
                    areaIconUrl = DecodeImageUrl(area.icon);
                }
                RibbonFlyoutAnchor areaFlyout = new RibbonFlyoutAnchor(uniquePrefix + area.id + ".Flyout", sequence++, ReplaceResourceToken(area.title), "Mscrm.Enabled", areaIconUrl, null);
                areaFlyout.Menu = new RibbonMenu(area.id + ".Flyout.Menu");
                //areaFlyout.Image16by16Class = @"commandBar-NavButton";

                //menu.AddSection(areaSection);
                siteMapSection.AddButton((RibbonButton)(object)areaFlyout);
                RibbonMenuSection areaSection = null;

                foreach (Group group in area.groups)
                {
                    RibbonMenuSection subAreaMenuSection = null;
                    RibbonMenu        subAreaParentMenu  = null;



                    if (group.title != null)
                    {
                        areaSection = new RibbonMenuSection(uniquePrefix + area.id + "|" + group.id + ".Section", ReplaceResourceToken(group.title), sequence++, RibbonDisplayMode.Menu16);

                        subAreaParentMenu  = areaFlyout.Menu;
                        subAreaMenuSection = areaSection;
                    }
                    else
                    {
                        if (areaSection == null)
                        {
                            // Create default areaSection because we don't have group titles
                            areaSection = new RibbonMenuSection(uniquePrefix + area.id + ".Section", ReplaceResourceToken(area.title), sequence++, RibbonDisplayMode.Menu16);

                            subAreaParentMenu = areaFlyout.Menu;
                        }
                        subAreaMenuSection = areaSection;
                    }

                    int subAreaSequence = 1;

                    foreach (SubArea subArea in group.subareas)
                    {
                        string subAreaIconUrl = "/_imgs/FormEditorRibbon/Subgrid_16.png";
                        if (!String.IsNullOrEmpty(subArea.icon))
                        {
                            subAreaIconUrl = DecodeImageUrl(subArea.icon);
                        }
                        else if (!string.IsNullOrEmpty(subArea.entity) && subArea.objecttypecode != 4703 && subArea.objecttypecode != 9603)
                        {
                            subAreaIconUrl = "/_imgs/ico_16_" + subArea.objecttypecode.ToString() + ".gif";
                        }


                        bool hasAccess = true;
                        // Check Privs
                        if (subArea.privileges != null && subArea.privileges.Count > 0)
                        {
                            foreach (string priv in subArea.privileges)
                            {
                                hasAccess = hasAccess && _userPriviledgeNames.ContainsKey(priv.ToLowerCase());
                                if (!hasAccess)
                                {
                                    break;
                                }
                            }
                        }
                        if (hasAccess)
                        {
                            RibbonButton button = new RibbonButton(uniquePrefix + area.id + "|" + group.id + "|" + subArea.id, subAreaSequence++, ReplaceResourceToken(subArea.title), "dev1.QuickNav.SelectSiteMapNav", subAreaIconUrl, "");
                            subAreaMenuSection.AddButton(button);
                        }
                    }
                    // Add submenu to menu if it has at least one item
                    if (subAreaMenuSection.Buttons.Count > 0)
                    {
                        subAreaParentMenu.AddSection(subAreaMenuSection);
                    }
                }
            }
        }
Beispiel #3
0
        public static void GetSiteMap(RibbonMenuSection siteMapSection)
        {
            GetUserPrivs();



            int sequence = 1;

            foreach (Area area in _siteMap.areas)
            {
                string areaIconUrl = "/_imgs/FormEditorRibbon/Subgrid_16.png";
                if (!String.IsNullOrEmpty(area.icon))
                {
                    areaIconUrl = DecodeImageUrl(area.icon);
                }
                RibbonFlyoutAnchor areaFlyout = new RibbonFlyoutAnchor(uniquePrefix + area.id + ".Flyout", sequence++, ReplaceResourceToken(area.title), "Mscrm.Enabled", areaIconUrl, null);
                areaFlyout.Menu = new RibbonMenu(area.id + ".Flyout.Menu");

                //menu.AddSection(areaSection);
                siteMapSection.AddButton((RibbonButton)(object)areaFlyout);
                RibbonMenuSection areaSection = null;

                foreach (Group group in area.groups)
                {
                    RibbonMenuSection subAreaMenuSection = null;



                    if (group.title != null)
                    {
                        //string groupIconUrl = "/_imgs/FormEditorRibbon/Subgrid_16.png";
                        //if (!String.IsNullOrEmpty(group.icon))
                        //    groupIconUrl = group.icon;
                        //RibbonFlyoutAnchor groupButton = new RibbonFlyoutAnchor(uniquePrefix + area.id + "|" + group.id, sequence++, ReplaceResourceToken(group.title), "Mscrm.Enabled", groupIconUrl, null);
                        //areaSection.AddButton((RibbonButton)(object)groupButton);
                        //groupButton.Menu = new RibbonMenu(group.id + "Menu");
                        //// Add Group Menu
                        //RibbonMenuSection groupButtonMenuSection = new RibbonMenuSection(uniquePrefix + area.id + "." + group.id + ".Section", "", sequence++, RibbonDisplayMode.Menu16);
                        //groupButton.Menu.AddSection(groupButtonMenuSection);

                        //subAreaMenuSection = groupButtonMenuSection;

                        areaSection = new RibbonMenuSection(uniquePrefix + area.id + "|" + group.id + ".Section", ReplaceResourceToken(group.title), sequence++, RibbonDisplayMode.Menu16);
                        areaFlyout.Menu.AddSection(areaSection);
                        subAreaMenuSection = areaSection;
                    }
                    else
                    {
                        if (areaSection == null)
                        {
                            // Create default areaSection because we don't have group titles
                            areaSection = new RibbonMenuSection(uniquePrefix + area.id + ".Section", ReplaceResourceToken(area.title), sequence++, RibbonDisplayMode.Menu16);
                            areaFlyout.Menu.AddSection(areaSection);
                        }
                        subAreaMenuSection = areaSection;
                    }

                    int subAreaSequence = 1;

                    foreach (SubArea subArea in group.subareas)
                    {
                        string subAreaIconUrl = "/_imgs/FormEditorRibbon/Subgrid_16.png";
                        if (!String.IsNullOrEmpty(subArea.icon))
                        {
                            subAreaIconUrl = DecodeImageUrl(subArea.icon);
                        }
                        else if (!string.IsNullOrEmpty(subArea.entity) && subArea.objecttypecode != 4703 && subArea.objecttypecode != 9603)
                        {
                            subAreaIconUrl = "/_imgs/ico_16_" + subArea.objecttypecode.ToString() + ".gif";
                        }


                        bool hasAccess = true;
                        // Check Privs
                        if (subArea.privileges != null && subArea.privileges.Count > 0)
                        {
                            foreach (string priv in subArea.privileges)
                            {
                                hasAccess = hasAccess && _userPriviledgeNames.ContainsKey(priv.ToLowerCase());
                                if (!hasAccess)
                                {
                                    break;
                                }
                            }
                        }
                        if (hasAccess)
                        {
                            RibbonButton button = new RibbonButton(uniquePrefix + area.id + "|" + group.id + "|" + subArea.id, subAreaSequence++, ReplaceResourceToken(subArea.title), "dev1.QuickNav.SelectSiteMapNav", subAreaIconUrl, "");
                            subAreaMenuSection.AddButton(button);
                        }
                    }
                    // Add devider
                }
            }
        }