Created
May 20, 2015 03:58
-
-
Save elchele/6afc297eddf20ef147cf to your computer and use it in GitHub Desktop.
Custom record view controller for setting entire record to read-only conditionally
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
({ | |
/* Author: Angel Magaña -- [email protected] | |
* File: ./custom/modules/Opportunities/clients/base/views/record/record.js | |
* | |
* Set all fields to read-only conditionally | |
*/ | |
extendsFrom: 'RecordView', | |
_renderHtml: function(){ | |
//Check the current status of selected opportunity record | |
var myCriteria = this.model.get('sales_status'); | |
//If status is 'Closed Won' do no allow any edits, by setting all fields to read-only | |
if (myCriteria === 'Closed Won') | |
{ | |
var self = this; | |
_.each(this.model.fields, function(field) { | |
//Add field to the array defining read-only fields | |
self.noEditFields.push(field.name); | |
}); | |
} | |
this._super('_renderHtml'); | |
}, | |
_dispose: function(){ | |
this._super('_dispose'); | |
} | |
}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Hi Daniel,
I found a solution, this is what works for me now:
Hope this helps,
Regards,
Angel Martinez