Last active
January 10, 2019 03:39
-
-
Save elchele/6f3254f2a83856557ab5 to your computer and use it in GitHub Desktop.
Custom record view controller, changes CSS on a given field based on number of subpanel child records linked to current record
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
({ | |
/* 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); | |
}, | |
styleType: function(){ | |
/* 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. | |
* | |
* This example will check the 'Calls' subpanel. | |
*/ | |
var subpanelRecs = this.model.getRelatedCollection('calls'); | |
subpanelRecs.fetch({ | |
relate: true, | |
success: function(data){ | |
if (data.models.length === 0) | |
{ | |
this.$('div[data-name=account_type]').addClass('yellow'); | |
} | |
} | |
}); | |
}, | |
_dispose: function(){ | |
this._super('_dispose'); | |
} | |
}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment