Skip to content

Instantly share code, notes, and snippets.

@elchele
elchele / record.js
Last active January 10, 2019 03:39
Custom record view controller, changes CSS on a given field based on number of subpanel child records linked to current record
({
/* File: ./custom/modules/Accounts/clients/base/views/record/record.js */
extendsFrom: 'RecordView',
initialize: function(options){
this._super('initialize', [options]);
this.model.on('data:sync:complete', this.styleType, this);
},
@elchele
elchele / record.js
Created January 29, 2016 21:00
Custom RecordView controller for checking if a specific related record(s) exists in a subpanel at time parent record is viewed.
({
/* File: ./custom/modules/<Module>/clients/base/views/record/record.js */
extendsFrom: 'RecordView',
initialize: function(options){
/* Check if related module has records linked to current record and meet a specific criteria (filter)
* You need the "link" field name from vardefs for the specific
* subpanel you wish to check.
*
@elchele
elchele / record.js
Created January 29, 2016 19:28
Custom RecordView controller for checking number of records in a subpanel at time parent record is viewed.
({
/* File: ./custom/modules/<Module>/clients/base/views/record/record.js */
extendsFrom: 'RecordView',
initialize: function(options){
/* Check if related module has records linked to current record
* You need the "link" field name from vardefs for the specific
* subpanel you wish to check.
*
@elchele
elchele / record.js
Created January 22, 2016 16:57
Custom record view controller for displaying an alert upon a record being accessed, if it meets a given criteria.
({
/* File: ./custom/modules/Leads/clients/base/views/record/record.js */
extendsFrom: 'RecordView',
initialize: function(options) {
this._super('initialize', [options]);
this.model.on('data:sync:complete', this.showAlert, this);
},
@elchele
elchele / record.js
Last active August 29, 2015 14:27
Custom Record view controller for removing fields not accessible via ACL.
({
/* File: ./custom/clients/base/views/record/record.js */
extendsFrom: 'RecordView',
_render: function(){
var self = this;
this._super('_render');
_.each(this.noEditFields, function(field){
@elchele
elchele / preview.js
Created July 30, 2015 20:09
Controller for Preview view, used to conditionally hide fields on preview render.
({
/* File: ./custom/modules/Accounts/clients/base/views/preview/preview.js */
extendsFrom: 'PreviewView',
_renderPreview: function(model, collection, fetch, previewId){
var self = this;
// If there are drawers there could be multiple previews, make sure we are only rendering preview for active drawer
if(app.drawer && !app.drawer.isActive(this.$el)){
@elchele
elchele / conversion-stats.js
Last active January 4, 2019 12:34
Custom pie chart for Sugar 7.x, displaying monthly lead conversion statistics.
({
/* Author: Angel Magaña -- cheleguanaco@cheleguanaco.com
* File: ./custom/clients/base/views/conversion-stats/conversion-stats.js
*
* controller for 'Monthly Lead Conversion Stats' custom pie chart
*/
plugins: ['Dashlet', 'Chart'],
className: 'conversion-stats',
@elchele
elchele / filter.js
Created July 7, 2015 17:35
Filter controller extension to change behavior to utilize OR operand
({
/* File: ./custom/modules/<Module>/clients/base/layouts/filter/filter.js */
extendsFrom: 'FilterLayout',
applyFilter: function(query, dynamicFilterDef) {
var customFilterDef = [{'$or':[{'billing_address_city':{'$starts':query}},{'name':{'$starts':query}}]}];
// TODO: getRelevantContextList needs to be refactored to handle filterpanels in drawer layouts,
// as it will return the global context instead of filtering a list view within the drawer context.
// As a result, this flag is needed to prevent filtering on the global context.
@elchele
elchele / custom-forecast-pipeline.js
Last active August 29, 2015 14:23
Correction to amounts for currency differences
({
/*
file: ./custom/modules/Forecasts/clients/base/views/forecast-pipeline/forecast-pipeline.js
*/
extendsFrom:"ForecastsForecastPipelineView",
initDashlet: function(view) {
this._super('initDashlet', [view]);
@elchele
elchele / record.js
Created May 20, 2015 03:58
Custom record view controller for setting entire record to read-only conditionally
({
/* Author: Angel Magaña -- cheleguanaco@cheleguanaco.com
* File: ./custom/modules/Opportunities/clients/base/views/record/record.js
*
* Set all fields to read-only conditionally
*/
extendsFrom: 'RecordView',
_renderHtml: function(){