Sugar 7 : how to remove subpanel row_action button on bwc record ?

Hello everyone !

To follow my adventures with panel-top buttons (from here : https://community.sugarcrm.com/ideas/1457#comment-1813 ), I'm struggling with a module 7 subpanel on a bwc record.

What i have :

I've created a custom module through module builder called "ag_ActesDeGestion", so it is built following version 7's intelligence. it is linked with the Contracts module (which is a legacy module) by : Contracts 1-M ag_ActesDeGestion.

So, in a Contract's record, i have a ag_ActesDeGestion subpanel. In bwc display.

What i want :

Making the row action buttons disappear from every line of this subpanel.

What i've tried :

In  custom/Extension/modules/Contracts/Ext/Layoutdefs/contracts_ag_actesdegestion_1_Contracts.php I've tried this :

<?php

// created: 2015-06-12 05:52:53

$layout_defs["Contracts"]["subpanel_setup"]['contracts_ag_actesdegestion_1'] = array (

  'order' => 100,

  'module' => 'ag_ActesDeGestion',

  'subpanel_name' => 'default',

  'sort_order' => 'asc',

  'sort_by' => 'id',

  'title_key' => 'LBL_CONTRACTS_AG_ACTESDEGESTION_1_FROM_AG_ACTESDEGESTION_TITLE',

  'get_subpanel_data' => 'contracts_ag_actesdegestion_1',

  'top_buttons' =>

  array (

    0 =>

    array (

      'widget_class' => 'SubPanelTopButtonQuickCreate',

    ),

  ),

  'list_fields' =>  array(

     'edit_button'=> array(

  'vname' => 'LBL_EDIT_BUTTON',

  'widget_class' => 'SubPanelEditButton',

  'module' => 'Contracts',

  'width' => '5%',

  'css_class'=>'disabled',

  ),

  /*'remove_button'=> array(

  'vname' => 'LBL_REMOVE',

  'widget_class' => 'SubPanelRemoveButton',

  'module' => 'Contracts',

  'width' => '5%',

  'css_class'=>'disabled',

  ),*/

  ),

);

But it does not work.

Which widget_class does they use?

Where can i find these widget classes ?

What file have i to modify ?

By advance, thanks a lot for your help and knowledges.

  • Hi

    <?php

    $viewdefs['Contracts']['base']['view']['contracts_ag_actesdegestion_1'] = array (

    //our line added

    'rowactions' => array(

            'actions' => array(

                array(

                    'type' => 'rowaction',

                    'css_class' => 'btn',

                    'tooltip' => 'LBL_PREVIEW',

                    'event' => 'list:preview:fire',

                    'icon' => 'fa-eye',

                    'acl_action' => 'view',

                    'allow_bwc' => false,

                ),

                array(

                    'type' => 'rowaction',

                    'name' => 'edit_button',

                    'icon' => 'fa-pencil',

                    'label' => 'LBL_EDIT_BUTTON',

                    'event' => 'list:editrow:fire',

                    'acl_action' => 'edit',

                    'allow_bwc' => true,

                  

                ),

                array(

                    'type' => 'unlink-action',

                    'icon' => 'fa-chain-broken',

                    'label' => 'LBL_UNLINK_BUTTON',

                     'css_class'=>'disabled',

                ),

            ),

        ),

    //our added lines ends here

      'panels' =>

                     //fields

                     //by default

      ),

      'type' => 'subpanel-list',

    );

    FYI : I have copied rowactions array from subpanel-list.php and pasted here.And added css_class for our button.

    Hope it helps.

    Thanks!.

  • Hello Ajay Kumar!

    Thanks a lot for your answer.

    I've tested it, but it does absolutely nothing.

    You understood what i wanted to do (aka remove/disable "unlink" button in subpanel), but misunderstood my situation :

    My application is in version 7.5.2.1. So, the Contracts module is a legacy module. Aka, it uses the core of Sugar 6.

    I show you below what it looks like :

    As you can see, i've opened the ag_ActesDeGestion subpanel, and you can notice the "see" and the "unlink" buttons in the row of the element.

    This is the image after trying your way, by doing the following :

    Create the folder and file in

    /custom/modules/Contracts/clients/base/views/contracts_ag_actesdegestion_1/contracts_ag_actesdegestion_1.php

    (there were no "contracts_ag_actesdegestion_1" folder in views)

    then copy/paste your code (by correcting the missing "array(" in the 'panels' seciton) :

    <?php

    $viewdefs['Contracts']['base']['view']['contracts_ag_actesdegestion_1'] = array (

    //our line added

    'rowactions' => array(

            'actions' => array(

                array(

                    'type' => 'rowaction',

                    'css_class' => 'btn',

                    'tooltip' => 'LBL_PREVIEW',

                    'event' => 'list:preview:fire',

                    'icon' => 'fa-eye',

                    'acl_action' => 'view',

                    'allow_bwc' => false,

                ),

                array(

                    'type' => 'rowaction',

                    'name' => 'edit_button',

                    'icon' => 'fa-pencil',

                    'label' => 'LBL_EDIT_BUTTON',

                    'event' => 'list:editrow:fire',

                    'acl_action' => 'edit',

                    'allow_bwc' => true,

                 

                ),

               /* array(

                    'type' => 'unlink-action',

                    'icon' => 'fa-chain-broken',

                    'label' => 'LBL_UNLINK_BUTTON',

                     'css_class'=>'disabled',

                ),*/

            ),

        ),

    //our added lines ends here

      'panels' => array(

                     //fields

                     //by default

      ),

      'type' => 'subpanel-list',

    );

    Even by commenting the button i did not want to see.

    And then, do a Quick Repair and Rebuild.

    So, it did absolutely nothing.

    And i think because Sugar 6 / legacy modules does not work as in v7. The subpanels showed in  a bwc modules are coded with v6 intelligence. So they use the same kind of things.

    I know for example that panel-top buttons are coded like this :

    'top_buttons' =>

      array (

        0 =>

        array (

          'widget_class' => 'SubPanelTopSelectButton',

          'mode' => 'MultiSelect',

        ),

        1 =>

        array (

          'widget_class' => 'SubPanelTopButtonQuickCreate',

        ),

      ),

    They are using widget_class.

    So, i would like to find which widget_class is used for row_buttons, how is the array named, and which file i have to modify.

    Thanks a lot for your time though, i really appreciate this!

    And if you have a new idea, or some clue, i'll be gratefull : )

    Thank you

  • Ok. Can you check the file in below path

    /custom/modules/ag_ActesDeGestion/metadata/subpanels/Contract_subpanel_contracts_ag_ActesDeGestion_1.php

    If this file is not there goto admin->studio->Contracts>subpanel->select "ag_ActesDeGestion".

    Then save and deploy.

    It will create one file

    you can modify this file .

    widget class for remove button same as you used - SubPanelRemoveButton

    Button Array is below,

    'remove_button' =>

      array (

        'vname' => 'LBL_REMOVE',

        'widget_class' => 'SubPanelRemoveButton',

         'module' => 'Contacts',

        'width' => '10%',

        'default' => true,

      ),

    just comment this button array.It will work.

    Thanks!.

  • Hi Gaelle,

    I just found a method that seems to work, at least for me. I did a test for Quotes where subpanel is documents.

    I create an layout def in Quotes:

    on custom/Extension/modules/Quotes/Ext/Layoutdefs/documents_quotes_Quotes.php

    In this file I select my custom subpanel definition:

    $layout_defs["Quotes"]["subpanel_setup"]['documents'] = array(

    ...

    'subpanel_name' => 'ForQuotes',

    ...

    );

    In create my special layout in modules/Documents/metadata/subpanels/ForQuotes.php

    ForQuotes is actually a copy of ForContractType where buttons code is commented.

    I've commented the code for edit_button and remove_button:

    $subpanel_layout = array(

    ...

      /*'edit_button'=>array(

      'vname' => 'LBL_EDIT_BUTTON',

      'widget_class' => 'SubPanelEditButton',

      'module' => 'Documents',

      'width' => '5%',

      ),

      'remove_button'=>array(

      'vname' => 'LBL_REMOVE',

      'widget_class' => 'SubPanelRemoveButton',

      'module' => 'Documents',

      'width' => '5%',

      ),

    ..*/

    );

    After did a QuickRepair and got Documents subpanel without edit/remove buttons.

    You can change for test purposes realtime these subpanels names (default, ForQuotes, etc) after repair playing with ext file

    custom/modules/Quotes/Ext/Layoutdefs/layoutdefs.ext.php

    Try to do the same with your module. Has to work

  • Hello Emil Maran !!!

    First of all, THANK YOU ! you understood my problem, and helped me to resolve it (but, i've had to change it a little, because it was not upgrade safe)!

    I'll add my own answer with my code. Thanks a loooot!!!
    ve a good day !

    Ha

  • So, thanks to Emil Maran and Ajay Kumar, i've sorted it out !

    So, here is a short summary of the whole story and the code i used.

    On Sugar v.7.5.2.1 :

    I have 2 modules :

    1. Contracts, which is Sugar standard, in legacy mode (aka bwc, aka displays with Sugar 6 graphics and uses widget_class and all)
    2. Actes de Gestion (ag_ActesDeGestion), which is a custom module, so uses the v7 cores and looks like a v7 module.

    They are linked with a one-to-Many relationship like this : Contracts 1-M ag_ActesDeGestion. So in Contract record, i have a ag_ActesDeGestion subpanel.

    I wanted to remove the "unlink" button on each row of the Actes de Gestion subpanel.

    So, here is the code used to make them disappear :

    In custom/modules/ag_ActesDeGestion/metadata/subpanels, create a file named "Contracts_subpanel_contracts_ag_actesdegestion_1.php"

    In it, copy/paste the code from <sugarRoot>/modules/ag_ActesDeGestion/metadata/subpanels/default.php and comment the buttons you want to remove.

    So, my code for custom/modules/ag_ActesDeGestion/metadata/subpanels/Contracts_subpanel_contracts_ag_actesdegestion_1.php is the following :

    <?php

    if(!defined('sugarEntry') || !sugarEntry) die('Not A Valid Entry Point');

    /*

    * Your installation or use of this SugarCRM file[...]

    * Copyright (C) SugarCRM Inc. All rights reserved.

    */

    $module_name='ag_ActesDeGestion';

    $subpanel_layout = array(

      'top_buttons' => array(

      array('widget_class' => 'SubPanelTopCreateButton'),

      array('widget_class' => 'SubPanelTopSelectButton', 'popup_module' => $module_name),

      ),

      'where' => '',

      'list_fields' => array(

      'name'=>array(

      'vname' => 'LBL_NAME',

      'widget_class' => 'SubPanelDetailViewLink',

      'width' => '45%',

      ),

      'date_modified'=>array(

      'vname' => 'LBL_DATE_MODIFIED',

      'width' => '45%',

      ),

    /* 'edit_button'=>array(

                'vname' => 'LBL_EDIT_BUTTON',

      'widget_class' => 'SubPanelEditButton',

      'module' => $module_name,

      'width' => '4%',

      ),

      'remove_button'=>array(

                'vname' => 'LBL_REMOVE',

      'widget_class' => 'SubPanelRemoveButton',

      'module' => $module_name,

      'width' => '5%',

      ),*/

      ),

    );

    ?>

    In

    custom/Extension/modules/Contracts/Ext/Layoutdefs/contracts_ag_actesdegestion_1_Contracts.php (a file already created by Sugar. If you don't have it, i think you can go to admin>Studio>Contracts>Subpanels>ActesDeGestion> modify the columns displayed),

    in the subpanel definition, change the subpanel_name from "default" to

    'subpanel_name' => 'Contracts_subpanel_contracts_ag_actesdegestion_1',

    Now, do a quick repair and rebuild, and Gooo ! You have what you wanted !

    This is an upgrade safe way of modifying your subpanel, by keeping in mind the problem between bwc and standard !

    Thanks to Emil Maran and Ajay Kumar, who helped me to sort it out !