How to add a custom button to quoted line item header?

Hello. I want to add a button to the header of quoted line items.For that I have a file named quote-data-list-header.php in custom/module/Quotes/clients/base/views/quote-data-list

BUT, the core (sugar's own) file looks like this:

$viewdefs['Quotes']['base']['view']['quote-data-list-header'] = array(
'selection' => array(
'type' => 'multi',
'actions' => array(
array(
'name' => 'group_button',
'type' => 'rowaction',
'label' => 'LBL_CREATE_GROUP_SELECTED_BUTTON_LABEL',
'tooltip' => 'LBL_CREATE_GROUP_SELECTED_BUTTON_TOOLTIP',
'acl_action' => 'edit',
),
array(
'name' => 'massdelete_button',
'type' => 'rowaction',
'label' => 'LBL_DELETE_SELECTED_LABEL',
'tooltip' => 'LBL_DELETE_SELECTED_TOOLTIP',
'acl_action' => 'delete',
),
),
),
);

No button or panel or anything. BUT ironically, there is something custom there(in the UI, not the the above file), but that is the result of a custom button from the quoted line ROW (NOT header). Short version: I want to replace this:

With a button. And that text is there because of this (in the ROW, not header)

$viewdefs['Products']['base']['view']['quote-data-group-list']=array(
'panels'=>array(
array(
'name'=>'products_quote_data_group_list',
'label'=>'LBL_PRODUCTS_QUOTE_DATA_LIST',
'fields'=>array(
array(
"name"=>'custom-pricing-button',
'label'=>'LBL_CUSTOM_PRICING_BUTTON',
'widthClass'=>'cell-large',
'type'=>'custom-pricing-button'
),
Parents
  • I have investigated a bit more and it seems the JS code for quoted-data-list-header takes it's metadata info from group-list. The initialize code looks like this (PS: this is a core file, I have not modified anything)

    initialize: function(options) {
    this._super('initialize', [options]);
    this.leftColumns = [];

    var qliListMetadata = app.metadata.getView('Products', 'quote-data-group-list');
    if (qliListMetadata && qliListMetadata.panels) {
    this.meta.panels = qliListMetadata.panels;
    }

    _.each(this.meta.panels, function(panel) {
    _.each(panel.fields, function(field) {
    if (!field.labelModule) {
    field.labelModule = 'Quotes';
    }
    }, this);
    }, this);

    this.isCreateView = this.context.get('create') || false;

    if (this.layout.isCreateView) {
    this.leftColumns.push({
    'type': 'fieldset',
    'fields': [],
    'value': false,
    'sortable': false
    });
    } else {
    this.addMultiSelectionAction();
    }

    this._fields = _.flatten(_.pluck(this.meta.panels, 'fields'));

    That _fields is rendered in the HBS file. How to leverage this, how to add a custom field (button) similar to the one I have already shown (the one in the row)

Reply
  • I have investigated a bit more and it seems the JS code for quoted-data-list-header takes it's metadata info from group-list. The initialize code looks like this (PS: this is a core file, I have not modified anything)

    initialize: function(options) {
    this._super('initialize', [options]);
    this.leftColumns = [];

    var qliListMetadata = app.metadata.getView('Products', 'quote-data-group-list');
    if (qliListMetadata && qliListMetadata.panels) {
    this.meta.panels = qliListMetadata.panels;
    }

    _.each(this.meta.panels, function(panel) {
    _.each(panel.fields, function(field) {
    if (!field.labelModule) {
    field.labelModule = 'Quotes';
    }
    }, this);
    }, this);

    this.isCreateView = this.context.get('create') || false;

    if (this.layout.isCreateView) {
    this.leftColumns.push({
    'type': 'fieldset',
    'fields': [],
    'value': false,
    'sortable': false
    });
    } else {
    this.addMultiSelectionAction();
    }

    this._fields = _.flatten(_.pluck(this.meta.panels, 'fields'));

    That _fields is rendered in the HBS file. How to leverage this, how to add a custom field (button) similar to the one I have already shown (the one in the row)

Children
No Data