AnsweredAssumed Answered

Custom Buttons in list-headerpane to add in manifest Package

Question asked by Jackie Justin on May 19, 2019

I have modified my Accounts module list-headerpane.php and added Two Buttons to it. 

\custom\modules\Accounts\clients\base\views\list-headerpane\list-headerpane.php

 

<?php
$viewdefs['Accounts'] = array(
'base' => array(
'view' => array(
'list-headerpane' => array(
'template' => 'headerpane',
'buttons' => array(
array(
'name' => 'create_button',
'type' => 'button',
'label' => 'LBL_CREATE_BUTTON_LABEL',
'css_class' => 'btn-primary',
'acl_action' => 'create',
'route' => array(
'action'=>'create'
)
),
array(
'name' => 'call_my_API',
'type' => 'button',
'label' => 'LBL_CALL_MY_API',
'css_class' => 'btn-success',
'events' => array(
'click' => 'button:call_my_api_button:click',
),
),

array(
'name' => 'call_my_Second_API',
'type' => 'button',
'label' => 'LBL_CALL_MY_SECOND_API',
'css_class' => 'btn-success',
'events' => array(
'click' => 'button:call_my_second_api_button:click',
),
),
array(
'name' => 'sidebar_toggle',
'type' => 'sidebartoggle',
),
),
),
),
),
);

The issue is we have to create Two Installable modules for each API call.

list_headerpane.js has currently both button handler defined in the initializer function. 

 

 

({
extendsFrom: 'HeaderpaneView',

initialize: function (options) {
this._super('initialize', [options]);
options.meta = _.extend(
{},
app.metadata.getView(null, 'list-headerpane'),
app.metadata.getView(options.module, 'list-headerpane'),
options.meta
);

// Register click event listener on button
this.context.on('button:call_my_api_button:click', this.call_my_api_button, this);

this.context.on('button:call_my_second_api_button:click', this.call_my_api_button, this);
},

 

call_my_api_button: function () {

// handle first Button 

}

call_my_second_api_button: function () {

// handle Second Button 

}

 


Is there any method in SugarCRM Manifest that i add the list-headerpane.php and list-headerpane.js changes to two packages so that after installing both, the buttons show and it does not override one another. 

Outcomes