AnsweredAssumed Answered

move button from main dropdown to panel header / Version 7.5 Professional

Question asked by tsp tsp on Aug 17, 2015
Hello I want to move the button for the historycal summary (accounts) from the dropdown list to the panel heder, so that it is a standalone button that can directly be cklicked when the accounts view is open. Implementing it like this in \custom\modules\Accounts\clients\base\views\record\record.php 


<?php
$viewdefs['Accounts']['base']['view']['record'] = array (
  'buttons' =>
  array (
    0 =>
    array (
      'type' => 'button',
      'name' => 'cancel_button',
      'label' => 'LBL_CANCEL_BUTTON_LABEL',
      'css_class' => 'btn-invisible btn-link',
      'showOn' => 'edit',
    ),
    1 =>
    array (
      'type' => 'rowaction',
      'event' => 'button:save_button:click',
      'name' => 'save_button',
      'label' => 'LBL_SAVE_BUTTON_LABEL',
      'css_class' => 'btn btn-primary',
      'showOn' => 'edit',
      'acl_action' => 'edit',
    ),
    2 =>
    array (
      'type' => 'actiondropdown',
      'name' => 'main_dropdown',
      'primary' => true,
      'showOn' => 'view',
      'buttons' =>
      array (
      [...]

//OLD POSTION:
        /**15 =>
        array (
          'type' => 'rowaction',
          'event' => 'button:historical_summary_button:click',
          'name' => 'historical_summary_button',
          'label' => 'LBL_HISTORICAL_SUMMARY',
          'acl_action' => 'view',
        ),*/

          18 =>
        
[...]
      ),
    ),
    3 =>
    array (
      'name' => 'sidebar_toggle',
      'type' => 'sidebartoggle',
    ),
  ),
  'panels' =>
  array (
    0 =>
    array (
      'name' => 'panel_header',
      'label' => 'LBL_PANEL_HEADER',
      'header' => true,
      'fields' =>
      array (
        0 =>
        array (
          'name' => 'picture',
          'type' => 'avatar',
          'width' => 42,
          'height' => 42,
          'dismiss_label' => true,
          'readonly' => true,
        ),

        [...]
//NEW POSITON
        4 =>
        array (
          'name' => 'historical_summary_button',
          'label' => 'LBL_HISTORY_LINK',
          'type' => 'button',
          'event' => 'button:historical_summary_button:click',
          'readonly' => true,
          'dismiss_label' => true,
        ),
        
      ),
    ),
    1 =>
    array (
      'name' => 'panel_body',
[...]
    ),
    2 =>
    array (
      'name' => 'panel_hidden',
  [...]
    ),
  ),
  'templateMeta' =>
  array (
    'useTabs' => true,
  ),
);



generates:

<span class="record-cell" data-type="button" data-name="historical_summary_button">   <span class="table-cell-wrapper">
<span class="index" data-fieldname="historical_summary_button" data-index="">
<span sfuuid="726" class="nodata">
Keine Daten [i.e. "no data", ]
</span>
</span>
   </span>
</span>

How is this button correctly to be built within the panel header?

\custom\modules\Accounts\clients\base\views\record\record.js includes:

    initialize : function(options) {
        this._super('initialize', [ options ]);
[...]
        this.context.on('button:historical_summary_button:click', this.historicalSummaryClicked, this);
    },

\jssource\src_files\include\javascript\sugar7\plugins\HistoricalSummary.js includes:


(function(app) {
    app.events.on('app:init', function() {
        app.plugins.register('HistoricalSummary', ['view'], {
            /**
             * @inheritdoc
             *
             * Bind the historical summary button handler.
             */
            onAttach: function(component, plugin) {
                this.on('init', function() {
                    this.context.on('button:historical_summary_button:click', this.historicalSummaryClicked, this);
                });
            },

            /**
             * Handles the click event, and open the historical-summary-list view
             */
            historicalSummaryClicked: function() {
                var context = this.context.getChildContext({
                    module: 'History'
                });
                app.drawer.open({
                    layout: 'history-summary',
                    context: context
                });
            },
        });
    });
})(SUGAR.App);

Thank you in advance!

Outcomes