Created
August 30, 2008 20:46
-
-
Save mauritslamers/8140 to your computer and use it in GitHub Desktop.
This file contains 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
=== model 1 | |
// ========================================================================== | |
// Education | |
// ========================================================================== | |
require('core'); | |
require('orion_fw'); | |
/** @class | |
(Document your class here) | |
@extends SC.Record | |
@author AuthorName | |
@version 0.1 | |
*/ | |
OrionFw.Education = SC.Record.extend( | |
/** @scope Education.prototype */ { | |
// TODO: Add your own code here. | |
//dataSource: SC.Server.create({ prefix: [""], urlFormat: "?%@&%@" }), | |
//dataStore: SC.Server.create({ prefix: [""], urlFormat: "?%@&%@" }), | |
dataStore: OrionFw.server, // maybe Contacts.server? | |
dataSource: OrionFw.server, | |
//modules: SC.Record.hasMany('OrionFw.Module'), | |
/* | |
define the URL for this Record type. | |
- updates will be POSTed to '/ajaxcom/contact/update' | |
- new records will be POSTed to '/ajaxcom/contact/create' | |
- and existing records will be fetched (GET) from | |
'/ajacom/contact/show/23' (if the record has guid=23 and | |
only one record is fetched) | |
*/ | |
resourceURL: [OrionFw.standardResource + 'education'], | |
// this list of properties will be used when talking to the server | |
// backend. If you don't define this only 'guid' will be used. | |
properties: ['id','name','code'], | |
educationName: function() { | |
return [this.get('name'), this.get('code')].compact().join('-'); | |
}.property('name', 'code'), | |
modEdu: SC.Record.hasMany('OrionFw.ModEdu','educationId') | |
}); | |
=== model 2 | |
// ========================================================================== | |
// Module | |
// ========================================================================== | |
require('core'); | |
require('orion_fw'); | |
/** @class | |
(Document your class here) | |
@extends SC.Record | |
@author AuthorName | |
@version 0.1 | |
*/ | |
OrionFw.Module = SC.Record.extend( | |
/** @scope Module.prototype */ { | |
// TODO: Add your own code here. | |
//dataSource: SC.Server.create({ prefix: [""], urlFormat: "?%@&%@" }), | |
//dataStore: SC.Server.create({ prefix: [""], urlFormat: "?%@&%@" }), | |
dataStore: OrionFw.server, // maybe Contacts.server? | |
dataSource: OrionFw.server, | |
/* | |
define the URL for this Record type. | |
- updates will be POSTed to '/ajaxcom/contact/update' | |
- new records will be POSTed to '/ajaxcom/contact/create' | |
- and existing records will be fetched (GET) from | |
'/ajacom/contact/show/23' (if the record has guid=23 and | |
only one record is fetched) | |
*/ | |
resourceURL: [OrionFw.standardResource + 'module'], | |
// this list of properties will be used when talking to the server | |
// backend. If you don't define this only 'guid' will be used. | |
properties: ['id','name','nameEn','collegeyear','consecutivelessonseries','serialnumber','OSIRISId'], | |
_moduleName: null, // cached name | |
moduleName: function() { | |
if(this._moduleName == null){ | |
var tmpname = [this.get('name'), this.get('serialnumber')].compact().join(' ') + " "; | |
tmpname =[tmpname, this.get('collegeyear')].compact().join('[') + "]"; | |
this._moduleName = tmpname; | |
return tmpname; | |
} else { | |
return this._moduleName; | |
} | |
}.property('name', 'serialnumber','collegeyear'), | |
_moduleNameAndOSIRISid: null, | |
moduleNameAndOSIRISid: function() { | |
if(this._moduleNameAndOSIRISid == null){ | |
var tmpname = [this.get('name'), this.get('serialnumber')].compact().join(' ') + " "; | |
tmpname =[tmpname, this.get('collegeyear')].compact().join('[') + "] "; | |
tmpname = [tmpname, this.get('OSIRISid')].compact().join('(') + ")"; | |
this._moduleNameAndOSIRISid = tmpname; | |
return tmpname; | |
} else { | |
return this._moduleNameAndOSIRISid; | |
} | |
}.property('name', 'serialnumber','collegeyear','OSIRISid'), | |
modEdu: SC.Record.hasMany('OrionFw.ModEdu','moduleId') | |
}); | |
=== model inbetween | |
// ========================================================================== | |
// ModEdu | |
// ========================================================================== | |
require('core'); | |
require('orion_fw'); | |
/** @class | |
(Document your class here) | |
@extends SC.Record | |
@author AuthorName | |
@version 0.1 | |
*/ | |
OrionFw.ModEdu = SC.Record.extend( | |
/** @scope ModEdu.prototype */ { | |
// TODO: Add your own code here. | |
dataStore: OrionFw.server, // maybe Contacts.server? | |
dataSource: OrionFw.server, | |
/* | |
define the URL for this Record type. | |
- updates will be POSTed to '/ajaxcom/contact/update' | |
- new records will be POSTed to '/ajaxcom/contact/create' | |
- and existing records will be fetched (GET) from | |
'/ajacom/contact/show/23' (if the record has guid=23 and | |
only one record is fetched) | |
*/ | |
resourceURL: [OrionFw.standardResource + 'mod_edu'], | |
// this list of properties will be used when talking to the server | |
// backend. If you don't define this only 'guid' will be used. | |
properties: ['id','educationId','moduleId'], | |
educationIdType: 'OrionFw.Education', | |
moduleIdType: 'OrionFw.Module' | |
}); | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment