Skip to content

Instantly share code, notes, and snippets.

@skizzybiz
skizzybiz / whitelist_entry_test.js
Created April 19, 2011 19:56
broken SproutCore unit test
// This works:
module("MessageTracer.WhitelistEntry");
test("test description", function() {
var expected, result;
expected = "test";
result = "test";
return equals(result, expected, "test should equal test");
});
> e = MT.store.find(MT.WhitelistEntry, 1)
Object
> e.get('reportTemplate').get('id')
1
> t = MT.store.find(MT.ReportTemplate, 1)
Object
> t.get('whitelistEntries').length()
0
SC.ready(function() {
var records;
MT.mainPane = SC.TemplatePane.append({
layerId: 'my_app',
templateName: 'my_app'
});
records = MT.MyRecord.originals();
MT.myRecords.set('content', records);
return MT.myRecords.selectObject(records.objectAt(0));
});
@skizzybiz
skizzybiz / rails.js
Created May 3, 2011 19:23
DataSource update methods
updateRecord: function(store, storeKey) {
var data, id, recordType, request;
recordType = store.recordTypeFor(storeKey);
id = store.idFor(storeKey);
data = this.formatData(store.readDataHash(storeKey), recordType);
console.log("storeKey = " + storeKey);
console.log("store.readDataHash(" + storeKey + ") = ");
console.log(store.readDataHash(storeKey));
request = SC.Request.putUrl("" + recordType.RESOURCE_PATH + "/" + id);
MT.ReportTemplateContainerView = SC.ContainerView.extend({
contentView: SC.TemplateView.extend({
itemBinding: 'MT.reportTemplates.selectedItem',
templateName: 'report_template_show'
}),
editView: SC.TemplateView.extend({
itemBinding: 'MT.reportTemplates.selectedItem',
templateName: 'report_template_edit'
})
});
contentView: SC.SourceListView.design({
contentBinding: 'Authoring.reportTemplatesArrayController.content',
selectionBinding: 'Authoring.reportTemplatesArrayController.selection',
exampleView: SC.View.design({
classNames: 'sc-list-item-view'.w(),
childViews: 'nameLabel'.w(),
nameLabel: SC.LabelView.design({
layout: { left: 10, width: 100, height: 18 },
valueBinding: '.parentView*content.name'
})
@skizzybiz
skizzybiz / grouped_nominations.js
Created May 13, 2011 15:58
Report Approval/Nomination
Authoring.groupedNominationsController = SC.TreeController.create({
content: null,
selection: null,
treeItemIsGrouped: YES,
setNominations: function(nominations) {
var group, osVersion, osVersions, root;
root = SC.Object.create({
treeItemChildren: []
treeItemIsExpanded: YES
@skizzybiz
skizzybiz / my_page.js
Created May 16, 2011 15:07
SelectFieldView not working
// ...
stateSelect: SC.SelectFieldView.design({
layout: {
left: 120,
height: 18,
centerY: 0
},
objectsBinding: '.parentView*content.record.internalStateOptions',
nameKey: 'label',
valueKey: 'value',
sc_require('models/base_model');
Authoring.Nomination = Authoring.BaseWithTimestamps.extend({
// ...
reportTemplate: SC.Record.toOne('Authoring.ReportTemplate', {
isMaster: NO,
key: "report_template_id",
inverse: "nominations"
}),
// ...
});
@skizzybiz
skizzybiz / nomination_model.js
Created May 24, 2011 23:56
Record relations
Authoring.ReportTemplate = SC.Record.extend({
// Attributes defined ...
nominations: SC.Record.toMany('Authoring.Nomination', {
isMaster: YES,
inverse: 'reportTemplate'
}),
clone: function() {
var attributes, clone;
attributes = {};