Ejemplo n.º 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);
        }
Ejemplo n.º 2
0
 private static void GetFormNav(RibbonMenu quickNav)
 {
     SELECT_NAV_COMMAND_PREFIX = uniquePrefix + "QuickNav.Nav";
     if (Page.Ui != null && Page.Ui.Navigation != null)
     {
         RibbonMenuSection navSection = new RibbonMenuSection(uniquePrefix + "QuickNav.Nav", "Related", 1, RibbonDisplayMode.Menu16);
         quickNav.AddSection(navSection);
         int i = 0;
         Page.Ui.Navigation.Items.ForEach(delegate(NavigationItem nav, int index)
         {
             RibbonButton button = new RibbonButton(SELECT_NAV_COMMAND_PREFIX + nav.GetId(), i, nav.GetLabel(), "dev1.QuickNav.SelectNav", "/_imgs/FormEditorRibbon/Subgrid_16.png", "");
             navSection.AddButton(button);
             
             i++;
             return true;
         });
     }
 }
Ejemplo n.º 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

                }

            }
        }
Ejemplo n.º 4
0
        private static void GetFormTabs(RibbonMenu quickNav)
        {
            SELECT_TAB_COMMAND_PREFIX = uniquePrefix + "QuickNav.Tabs.";
            if (Page.Ui!=null && Page.Ui.FormSelector != null)
            {

                FormSelectorItem form = Page.Ui.FormSelector.GetCurrentItem();
                string formSectionName = "Form";
                if (form != null)
                {
                    formSectionName = form.GetLabel();
                }

                RibbonMenuSection tabsSection = new RibbonMenuSection(uniquePrefix + "QuickNav.Tabs", formSectionName, 1, RibbonDisplayMode.Menu16);
                quickNav.AddSection(tabsSection);
                int i = 0;
                // Get the tabs and sections on the form
                Page.Ui.Tabs.ForEach(delegate(TabItem tab, int index)
                {
                    RibbonButton button = new RibbonButton(SELECT_TAB_COMMAND_PREFIX + tab.GetName(), i, tab.GetLabel(), "dev1.QuickNav.SelectTab", "/_imgs/FormEditorRibbon/Subgrid_16.png", "");
                    tabsSection.AddButton(button);
                    i++;
                    return true;
                });
            }
        }
Ejemplo n.º 5
0
 public RibbonMenuSection AddButton(RibbonButton button)
 {
     // We use this because the standard script# array extension functions break the CRM code
     ArrayEx.Add(Buttons, button);
     return(this);
 }
Ejemplo n.º 6
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);
                    }
                    
                }

            }
        }
Ejemplo n.º 7
0
 public RibbonMenuSection AddButton(RibbonButton button)
 {
     // We use this because the standard script# array extension functions break the CRM code
     ArrayEx.Add(Buttons, button);
     return this;
 }