AnsweredAssumed Answered

delete button on subpanel row: why does this work and is it safe to use?

Question asked by Francesca Shiekh on May 6, 2015
Latest reply on Dec 8, 2015 by Gerardo Garcia Lima
I wanted to add a delete button on a subpanel row for a custom module.
These are essentially line items on an Opportunity.

I added the rowaction it in the metadata for the subpanel:

             

mysugar/custom/modules/oppp_Opportunity_Products/clients/base/views]$ cd subpanel-for-opportunities/subpanel-for-opportunities.php

$viewdefs['oppp_Opportunity_Products']['base']['view']['subpanel-for-opportunities'] = array (
  'rowactions' => array(
    'actions' => array(
      array(
        'type' => 'rowaction',
        'css_class' => 'btn',
        'tooltip' => 'LBL_PREVIEW',
        'event' => 'list:preview:fire',
        'icon' => 'icon-eye-open',
        'acl_action' => 'view',
        'allow_bwc' => false,
      ),
      array(
        'type' => 'rowaction',
        'name' => 'edit_button',
        'icon' => 'icon-pencil',
        'label' => 'LBL_EDIT_BUTTON',
        'event' => 'list:drawereditrow:fire',
        'acl_action' => 'edit',
        'allow_bwc' => false,
      ),
      array(
        'type' => 'rowaction',
        'name' => 'delete_button',
        'icon' => 'icon-trash',
        'label' => 'LBL_DELETE_BUTTON',
        'event' => 'list:deleterow:fire',
        'acl_action' => 'delete',
        'allow_bwc' => false,
      ),
      array(
         'type' => 'unlink-action',
         'icon' => 'icon-unlink',
         'label' => 'LBL_UNLINK_BUTTON',
      ),
    ),
  ),
  'panels' =>
 <snipped>
                                                                                           

and I added the action in the subpanel-list

mysugar/custom/modules/oppp_Opportunity_Products/clients/base/views/subpanel-list/subpanel-list.js 

I was going to use the API to delete that model.id but it turns out that's unnecessary and actually causes problems.

What is puzzling me is that this works if the delteClicked function is totally empty, I came across it quite by accident... but WHY does it work? What is it doing? There is no deleteClicked in SubpanelListView so where is it getting it from?

Can anyone explain why this works an if it's safe to use?

({
  extendsFrom: 'SubpanelListView',
  initialize: function(options){
     this._super('initialize', [options]);
     this.context.on('list:drawereditrow:fire',this.drawerEditClicked, this);
     this.context.on('list:deleterow:fire',this.deleteClicked, this);
  },
  deleteClicked: function(model) {},
  drawerEditClicked: function(model){
    app.drawer.open({
       layout:'create-actions',
       context:{
         create: true,
         model: model,
         module:'oppp_Opportunity_Products',
       }
    });
  },
  _dispose: function() {
    this._super('_dispose');
  },
});
                                                         


thanks,
FrancescaS

Outcomes