Remove subpanel from a module

Hi All

How can we remove subpanel from a Module? I want to remove contacts subpanel from Accounts Module (In two ways :-One is simply hide and other is based on some condition,I want to hide contacts Subpanel from Accounts Module.I tried to hide subpanel using below modiification:

unset($layout_defs['Accounts']['subpanel_setup']['Contacts']);

But it did not work in sugarcrm 7.6 version.Please let me know how can we do this.

Parents
  • Hello Harpeet,

    One possible way to fix this is to copy

    modules/MODULE/clients/base/layouts/subpanels/subpanels.php

     

    to

     

    custom/modules/MODULE/clients/base/layouts/subpanels/subpanels.php

     

    and removes or comment out the arrays from the custom file. For example, if you wanted to get rid of the Leads subpanel, you would comment out or remove

     

        array (

          'layout' => "subpanel",

          'label' => 'LBL_LEADS_SUBPANEL_TITLE',

          'context' => array (

            'link' => 'leads',

          ),

     

    Be sure to go to Admin > Repair > Quick Repair and Rebuild to have these changes stick.

     

    Kind Regards,

     

    Jason Smith

  • Hi Justin

    I checked that and based on the solution provided I also did changes in my code and used below logic.but I am facing issue.Actually the code which iterates through each component and hide or show Submodule is not working.Can anyone please check and let me know where I am wrong/ below is the code:

    ({

    extendsFrom: 'SubpanelsLayout',

        check_field: 'description',

        hide_on_value: '',

        hide_subpanels: 'contacts',

       

         initialize: function (options)

        {

            app.view.invokeParent(this, {type: 'layout', name: 'subpanels', method: 'initialize', args:[options]});

        },

       

        showSubpanel: function(linkName) {

             var hide_subpanel = false;

            var self = this,

                //this.layout is the filter layout which subpanels is child of; we

                //use it here as it has a last_state key in its meta

                cacheKey = app.user.lastState.key('subpanels-last', this.layout);

          if (linkName) {

                app.user.lastState.set(cacheKey, linkName);

            }

            this.model.on("change", function() {

            var val = this.get(this.check_field);

              if(val == null || val == '') {

                     hide_subpanel = true;

               }

           

           _.each(this._components, function(component) {

      

                var link = component.context.get('link');

                if (!hide_subpanel && (!linkName || linkName === link)) {

      component.context.set("hidden", false);

      console.log("show");

                    component.show();

                } else {

      component.context.set("hidden", true);

      console.log("hide");

                    component.hide();

                }

            });

           

           

             });

          },

         

         

    })

  • Hi Harpreet Kaur,

    Can you please try below code in /custom/modules/Accounts/clients/base/layouts/subpanels/subpanels.js,

    ({

        extendsFrom: 'SubpanelsLayout',

       initialize: function (options) {

            this._super('initialize', [options]);

        },

         showSubpanel: function (linkName) {

            var self = this,

            //this.layout is the filter layout which subpanels is child of; we

            //use it here as it has a last_state key in its meta

            cacheKey = app.user.lastState.key('subpanels-last', this.layout);

            // wait for the model to load

            self.model.on("change", function () {

                if (linkName) {

                    app.user.lastState.set(cacheKey, linkName);

                }

                _.each(self._components, function (component) {

                    var link = component.context.get('link');

                      if(link=='contacts'){                

                         component.context.set("hidden", true);

                         component.hide();                  

                    }

                    else {

                        component.context.set("hidden", false);

                        component.show();                  

                    }               

                });

            });

        },

    })

    Thanks!.

Reply
  • Hi Harpreet Kaur,

    Can you please try below code in /custom/modules/Accounts/clients/base/layouts/subpanels/subpanels.js,

    ({

        extendsFrom: 'SubpanelsLayout',

       initialize: function (options) {

            this._super('initialize', [options]);

        },

         showSubpanel: function (linkName) {

            var self = this,

            //this.layout is the filter layout which subpanels is child of; we

            //use it here as it has a last_state key in its meta

            cacheKey = app.user.lastState.key('subpanels-last', this.layout);

            // wait for the model to load

            self.model.on("change", function () {

                if (linkName) {

                    app.user.lastState.set(cacheKey, linkName);

                }

                _.each(self._components, function (component) {

                    var link = component.context.get('link');

                      if(link=='contacts'){                

                         component.context.set("hidden", true);

                         component.hide();                  

                    }

                    else {

                        component.context.set("hidden", false);

                        component.show();                  

                    }               

                });

            });

        },

    })

    Thanks!.

Children