-
-
Save esimonetti/664ee2f71072150f63c794a6f417a96b to your computer and use it in GitHub Desktop.
Customization for pulling external/ad-hoc data into a Sugar subpanel
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/* File: ./custom/Extension/modules/Accounts/Ext/Language/en_us.fake.lang.ext.php */ | |
$mod_strings['LBL_FAKE'] = 'Fake Subpanel'; | |
$mod_strings['LBL_FAKE_NAME'] = 'Fake Name'; | |
$mod_strings['LBL_FIELD_1'] = 'Fake Field 1'; | |
$mod_strings['LBL_FIELD_2'] = 'Fake Field 2'; | |
?> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
({ | |
/* File: ./custom/clients/base/fields/fake-name/fake-name.js */ | |
extendsFrom: 'NameField', | |
buildHref: function() { | |
//Create the URL that browser will navigate to upon clicking item in fake subpanel | |
var destinationURL = 'http://www.example.com/'; | |
return destinationURL; | |
} | |
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/* File: .custom/Extension/modules/Accounts/Ext/Vardefs/fake_link.ext.php */ | |
$dictionary['Account']['fields']['fake'] = array( | |
'name' => 'fake', | |
'type' => 'link', | |
'relationship' => 'account_fake', | |
'vname' => 'LBL_FAKE', | |
'link_type' => 'many', | |
'module' => 'Accounts', | |
'bean_name' => 'Account', | |
'source' => 'non-db', | |
); | |
?> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/* File: .custom/Extension/modules/Accounts/Ext/clients/base/layouts/subpanels/fake_panel.ext.php */ | |
$viewdefs['Accounts']['base']['layout']['subpanels']['components'][] = array ( | |
'layout' => 'subpanel', | |
'label' => 'LBL_FAKE', | |
'override_subpanel_list_view' => 'subpanel-for-fake', | |
'context' => array ( | |
'link' => 'fake', | |
), | |
); | |
?> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/* File: ./custom/clients/base/api/FakeLinkApi.php */ | |
if(!defined('sugarEntry') || !sugarEntry) die('Not A Valid Entry Point'); | |
class FakeLinkApi extends SugarApi { | |
public function registerApiRest() { | |
return array( | |
'filterRelatedRecords' => array( | |
'reqType' => 'GET', | |
'path' => array('<module>', '?', 'link', 'fake'), | |
'pathVars' => array('module', 'record', '', ''), | |
'method' => 'filterRelated', | |
'shortHelp' => 'Lists related filtered records.', | |
'longHelp' => 'include/api/help/module_record_link_link_name_filter_get_help.html', | |
), | |
); | |
} | |
public function filterRelated(ServiceBase $api, array $args) | |
{ | |
//We could pull our external data here | |
$data = array( | |
'next_offset' => '-1', | |
'records' => array( | |
//Array N/V pairing would need to match general Sugar structure and view fields | |
array( | |
'id' => 'ABCDEF0123456789', | |
'name' => 'Static', | |
'field1' => 'value1', | |
'field2' => 'value2' | |
) | |
) | |
); | |
return $data; | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
({ | |
/* File: ./custom/modules/Accounts/clients/base/views/subpanel-for-fake/subpanel-for-fake.js */ | |
extendsFrom: 'SubpanelListView', | |
initialize: function(options){ | |
this._super('initialize', [options]); | |
} | |
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/* File: ./custom/modules/Accounts/clients/base/views/subpanel-for-fake/subpanel-for-fake.php */ | |
$viewdefs['Accounts']['base']['view']['subpanel-for-fake'] = array( | |
'panels' => | |
array( | |
array( | |
'name' => 'panel_header', | |
'label' => 'LBL_PANEL_1', | |
'fields' => | |
array( | |
array( | |
'default' => true, | |
'label' => 'LBL_FAKE_NAME', | |
'enabled' => true, | |
'name' => 'name', | |
'link' => true, | |
'type' => 'fake-name', //custom widget used to create a custom route | |
), | |
array( | |
'default' => true, | |
'label' => 'LBL_FIELD_1', | |
'enabled' => true, | |
'name' => 'field1', | |
), | |
array( | |
'type' => 'varchar', | |
'default' => true, | |
'label' => 'LBL_FIELD_2', | |
'enabled' => true, | |
'name' => 'field2', | |
), | |
), | |
), | |
), | |
); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment