Skip to content

Instantly share code, notes, and snippets.

View ttdonovan's full-sized avatar

Tanner Donovan ttdonovan

  • San Francisco, CA
View GitHub Profile
// ==========================================================================
// myApp.MainMenuController
// ==========================================================================
require('core');
/** @class
(Document Your View Here)
// ==========================================================================
// CDFleet.CDMainMenu
// ==========================================================================
require('core');
/** @class
(Document your class here)
<%= text_field_view :first_name_id,
:hint => "First Name",
:enabled => true,
:bind => { :value => 'CDFleet.objectController.fname' }
%>
<% scroll_view :record_list_scroll_view, :height => 200, :width => 300 do %>
<%= list_view :record_list,
:content_value_key => 'displayString',
:bind => {
col = CDFleet.CDObject.collection();
CDFleet.objectsController.set('content', col);
col.refresh();
sv = SC.ScrollView.extend({
emptyElement: '<div style="border:1px solid green;height:100px;width:300px;"><div class="id_123abc"></div></div>',
outlets: ['listView'],
listView: SC.ListView.extend({
contentBinding: 'CDFleet.objectsController.arrangedObjects',
selectionBinding: 'CDFleet.objectsController.selection',
col = CDFleet.CDObject.collection();
CDFleet.objectsController.set('content', col);
col.refresh();
sv = SC.ScrollView.extend({
emptyElement: '<div style="border:1px solid green;"><div class="id_123abc"></div></div>',
outlets: ['listView'],
listView: SC.ListView.extend({
contentBinding: 'CDFleet.objectsController.arrangedObjects',
selectionBinding: 'CDFleet.objectsController.selection',
_buildOutlets: function (children) {
var retOutlets = []; // array of outlet objects
children.each(function(child) {
retOutlets.push(this._buildOutlet(child));
}, this); // TODO: look into which is best {}, this or {}.bind(this)
return retOutlets;
},
_buildOutlet: function (child) {
var domID = this._viewID(child.guid), // guid id for outlet
// ==========================================================================
// CDWeb.CDMainMenuView
// ==========================================================================
require('core');
/** @class
(Document Your View Here)
_currSelGuid: null, // keep track of current selection guid
// myController.addProbe(selection)
refreshRecordWhenSelected: function () {
// cannot observe selection for changes because of SC.SelectionSupport#updateSelectionAfterContentChange in sproutcore/mixins/selection_support.js
// if (!this.didChangeFor('refreshRecordWhenSelected', 'selection')) { return ; }
var sel = this.get('selection'),
record = null ;
if (sel.length == 1) {
record = sel.first() ;
CDWeb.CDData = SC.Record.extend(
/** @scope CDWeb.CDData.prototype */ {
dataSource: CDWeb.server,
resourceURL: '/cdweb/rest/data',
properties: ['type', 'display_string', 'fname', 'lname' ],
primaryKey: 'guid',
display_string: 'New Object'
diff --git a/server/couchdb_server.js b/server/couchdb_server.js
index 420f280..66a19db 100755
--- a/server/couchdb_server.js
+++ b/server/couchdb_server.js
@@ -361,7 +361,7 @@ SC.CouchdbServer = SC.Server.extend({
records.each(function(r) {
var primaryKey = r.get('primaryKey') ;
var context = {
- recordType: this._instantiateRecordType(curRecords[0].get('type'), this.prefix, null), // default rec type.
+ recordType: this._instantiateRecordType(r.get('type'), this.prefix, null), // default rec type.