Last active
April 26, 2022 19:14
-
-
Save AjayKumar01/86a02bf56ef96e6f0844df56dfd3fc03 to your computer and use it in GitHub Desktop.
Limiting the subpanel records based on parent module
This file contains hidden or 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
({ | |
/** | |
* Purpose:Limiting the subpanel records based on parent module | |
* Here we are limiting contacts module records based on parent module(Opporunities,Accounts and other module) * | |
* Path : sugar/custom/modules/contacts/clients/base/views/subpanel-list/subpanel-list.js | |
* Written by: Ajay Kumar | |
* Dated: 31 May 2016 | |
*/ | |
extendsFrom:'RecordlistView', | |
fallbackFieldTemplate: 'list', | |
plugins: ['ErrorDecoration', 'Editable', 'SugarLogic', 'Pagination', 'LinkedModel', 'ResizableColumns'], | |
contextEvents: { | |
"list:editall:fire": "toggleEdit", | |
"list:editrow:fire": "editClicked", | |
"list:unlinkrow:fire": "warnUnlink" | |
}, | |
initialize:function(options){ | |
this._super("initialize", [options]); | |
var parentModule=this.context.parent.get('model').module; | |
var subModule=this.context.get('model').module; | |
var collectionOptions = this.context.has('collectionOptions') ? this.context.get('collectionOptions') : {}; | |
//limiting 20 contacts for parent module opportunities | |
if((_.isEqual(parentModule,'Opportunities')) && (_.isEqual(subModule,'Contacts'))){ | |
this.context.set('collectionOptions', _.extend(collectionOptions, { | |
limit: 20 | |
})); | |
} | |
else if((_.isEqual(parentModule,'Accounts')) && (_.isEqual(subModule,'Contacts'))){ | |
//limiting 3 contacts for parent module Accounts | |
this.context.set('collectionOptions', _.extend(collectionOptions, { | |
limit: 3 | |
})); | |
} | |
else{ | |
//Sugar default | |
this.context.set('collectionOptions', _.extend(collectionOptions, { | |
limit: app.config.maxSubpanelResult | |
})); | |
} | |
} | |
}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment