Skip to content

Instantly share code, notes, and snippets.

View mmarum-sugarcrm's full-sized avatar

Matt Marum mmarum-sugarcrm

View GitHub Profile
@mmarum-sugarcrm
mmarum-sugarcrm / case-count-by-status.hbs
Created July 6, 2015 18:48
Case Count by Status example dashlet Handlebars template
{{!
Case Count by Status example dashlet Handlebars template
We are reusing styling from the Sugar 7 Styleguide for our example dashlet.
Here we are borrowing CSS used in our Forecast Details dashlet which is suitable for display any set of name value pairs.
}}
<div class="forecast-details">
{{#each values}}
<div class="row-fluid">
@mmarum-sugarcrm
mmarum-sugarcrm / en_us.case-count-by-status.php
Created July 6, 2015 19:32
Case Count by Status English language extension
<?php
// This file will provide English strings for our new labels.
// Additional extensions could be created so that our dashlet supports other languages.
$app_strings['LBL_CASE_COUNT_BY_STATUS'] = 'Case Count By Status';
$app_strings['LBL_CASE_COUNT_BY_STATUS_DESCRIPTION'] = 'Shows the number of Cases on the Cases List view by status.';
$app_strings['LBL_CASE_COUNT_BY_STATUS_TOTAL'] = 'Total Cases:';
@mmarum-sugarcrm
mmarum-sugarcrm / case-count-by-status.js
Last active September 8, 2015 04:15
Jasmine tests for Case Count by Status dashlet
/*
* Basic Jasmine tests for Case Count by Status dashlet
*/
ddescribe("Case Count by Status", function () {
/*
* Some useful constants for our tests.
* We use them to keep track of the module, layout, and view we are testing
*/
var moduleName = 'Cases';
var viewName = 'case-count-by-status';
@mmarum-sugarcrm
mmarum-sugarcrm / test-template.js
Created September 8, 2015 04:15
Jasmine template for Sugar 7 views
/*
* Basic Jasmine test template for any Sugar 7 view
*/
ddescribe("Jasmine template for Sugar 7 views", function () {
/*
* Some useful constants for our tests.
* We use them to keep track of the module, layout, and view we are testing
*/
var moduleName = 'Accounts'; //TODO CHANGE TO AN APPROPRIATE MODULE
var viewName = "CHANGE_ME"; //TODO CHANGE TO YOUR VIEW NAME
@mmarum-sugarcrm
mmarum-sugarcrm / AccountsOnSaveHooks.php
Last active November 13, 2015 23:28
Example Sugar 7 before_save Logic Hook
<?php
/*
* Copyright 2015 SugarCRM Inc.
*/
/**
* Example of a module logic hook that we will unit test
*/
if (!defined('sugarEntry') || !sugarEntry) die('Not A Valid Entry Point');
@mmarum-sugarcrm
mmarum-sugarcrm / AccountsOnSaveHooksTest.php
Last active January 12, 2016 06:39
PHPUnit tests for example AccountsOnSave logic hooks
<?php
/*
* Copyright 2015 SugarCRM Inc.
*/
require_once 'custom/modules/Accounts/AccountsOnSaveHooks.php';
/**
* Example tests for our custom Logic Hook.
*/
@mmarum-sugarcrm
mmarum-sugarcrm / xyz_contextual-iframe.php
Created October 16, 2015 22:30
Contextual Frame Dashlet metadata
<?php
/**
* Copyright 2015 SugarCRM Inc. Licensed by SugarCRM under the Apache 2.0 license.
*/
$viewdefs['base']['view']['xyz_contextual-iframe'] = array(
//Dashlet metadata
'dashlets' => array(
array(
'label' => 'LBL_XYZ_IFRAME_DASHLET_LABEL',
'description' => 'LBL_XYZ_IFRAME_DASHLET_DESCRIPTION',
@mmarum-sugarcrm
mmarum-sugarcrm / xyz_contextual-iframe.js
Created October 16, 2015 22:40
Contextual Frame Dashlet javascript
({
/**
* Copyright 2015 SugarCRM Inc. Licensed by SugarCRM under the Apache 2.0 license.
*/
plugins: ['Dashlet'],
/**
* Record ID that is in context
*/
record: undefined,
@mmarum-sugarcrm
mmarum-sugarcrm / dashlet-config.hbs
Created October 16, 2015 22:49
Contextual Frame Dashlet templates
{{!--
Copyright 2015 SugarCRM Inc. Licensed by SugarCRM under the Apache 2.0 license.
--}}
<div class="record">
{{#each dashletConfig.config.fields}}
<div class="row-fluid panel_body">
<div class="record-cell">
<div class="record-label">{{str label}}</div>
{{field ../this model=../this.settings template=../this.action}}
</div>
@mmarum-sugarcrm
mmarum-sugarcrm / custom_button.php
Last active December 14, 2015 15:35
Adding a custom button to Sugar 7 Accounts Record view using metadata
<?php
/**
* Copyright 2015 SugarCRM Inc. Licensed by SugarCRM under the Apache 2.0 license.
*/
//Insert our custom button definition into existing Buttons array before the sidebar toggle button
array_splice($viewdefs['Accounts']['base']['view']['record']['buttons'], -1, 0, array(
array(
'name' => 'custom_button',
'type' => 'button',
'label' => 'My Custom Button',