1 // ========================================================================== 2 // Papercube.Author 3 // 4 // License: PaperCube is open source software released under 5 // the MIT License (see license.js) 6 // ========================================================================== 7 8 require('core'); 9 10 /** @class 11 12 Author model. 13 14 @extends SC.Record 15 @author Peter Bergstrom 16 @version 1.0 17 @copyright 2008-2009 Peter Bergström. 18 */ 19 Papercube.Author = SC.Record.extend( 20 /** @scope Papercube.Author.prototype */ { 21 22 /** 23 Cached paper count. 24 25 @property {Integer} 26 */ 27 _cached_paperCount: null, 28 29 /** 30 Computed property returning paper count. 31 32 @property {Integer} 33 @isReadOnly 34 */ 35 paperCount: function() 36 { 37 if(!this._cached_paperCount) 38 { 39 var papers = this.get('papers'); 40 if(papers && papers.length) 41 { 42 this._cached_paperCount = papers.length; 43 } 44 else 45 { 46 this._cached_paperCount = 0; 47 } 48 } 49 return this._cached_paperCount; 50 }.property(), 51 52 /** 53 Computed property returning a author's name as different property, 'label' 54 55 @property {String} 56 @isReadOnly 57 */ 58 label: function() 59 { 60 return this.get('name'); 61 }.property() 62 63 64 }) ; 65