Skip to content

Instantly share code, notes, and snippets.

@csprocket777
csprocket777 / ember-data.dependent-relations.js
Last active March 23, 2016 21:47 — forked from cyk/ember-data.dependent-relations.js
Dependent Relationships in Ember Data (for Ember Data v1.13.x) (removed dirty related record dirties parent)
/**
Ember Data: Dependent Relationships (Ember Data v1.13.x)
This package extends Ember Data to support creating relationships
where a model's dirty state depends not only on its own attributes
but on the dirty state of models in dependent relationships as well.
```javascript
App.Thing = DS.Model.extend({
name : DS.attr('string'),
/**
Ember Data: Dependent Relationships
This package extends Ember Data to support creating relationships
where a model's dirty state depends not only on its own attributes
but on the dirty state of models in dependent relationships as well.
```javascript
App.Thing = DS.Model.extend({
name : DS.attr('string'),
@csprocket777
csprocket777 / gist:d75420e2df3887830d9e
Created June 30, 2014 23:04
Laravel Polymorphic relationship search
// MODEL SETUPS
class Record extends Eloquent{
protected $fillable = array(
"record_form",
"systemVersion",
"creator"
);
public function recordFieldValues(){
return $this->hasMany('RecordFieldValue', 'record_id', 'id');
var adapter = DS.RESTAdapter.extend({
host: window.apiHost,
ajax: function(url, method, hash){
hash = hash || {};
hash.crossDomain = true;
return this._super(url, method, hash);
},
findQuery: function(store, type, id) {
var allOfType = store.all(type);
@csprocket777
csprocket777 / list-item-view.js
Last active August 29, 2015 14:00
Hack solution to updating Ember.Select with computed property created using defineProperty()
export default Ember.View.extend({
didInsertElement: function(){
var self = this;
setTimeout(function(){
self.get('controller.model').fixBindingsHack();
}, 100);
}
});
@csprocket777
csprocket777 / gist:5756f286095475363743
Created May 1, 2014 19:34
Using defineProperty to create a computed property that drives an Ember.Select
setupExistingParams: function(){
Ember.defineProperty(this, 'record_phase', Ember.computed('record_workflow_segment_step_params.[]', function(key, value){
if( this.get('step_type').toString() !== "1" ){
return undefined;
}
var param = this.get('record_workflow_segment_step_params').findBy('name', 'record_phase');
if( !Ember.isNone( value ) )
{
@csprocket777
csprocket777 / BrocFile.js
Created April 22, 2014 17:03
Broccoli Compile Error
var filterTemplates = require('broccoli-template');
var uglifyJavaScript = require('broccoli-uglify-js');
var compileES6 = require('broccoli-es6-concatenator');
// var compileLess = require('broccoli-less');
var compileSass = require('broccoli-sass');
var pickFiles = require('broccoli-static-compiler');
var mergeTrees = require('broccoli-merge-trees');
var findBowerTrees = require('broccoli-bower');
var env = require('broccoli-env').getEnv();
@csprocket777
csprocket777 / base-model.js
Last active August 29, 2015 13:57
Ember-Data belongsTo / hasMany isDirty workaround. NOTE: These are used in an Ember-App-Kit application setup.
export default DS.Model.extend({
modelIsDirty: DS.attr('boolean', {default: false}),
relationshipWatchList: [],
relationshipWatcherSetup: function(){
this.get('relationshipWatchList').forEach(function(item,index,enumerable){
this.addObserver(item, this, "changeObserver");
}, this);
}.on('init'),
changeObserver: function(){
@csprocket777
csprocket777 / Main Application File
Created July 19, 2013 16:58
Ember Unit Testing help.
Env = Ember.Application.create({
LOG_TRANSITIONS:true,
LOG_BINDING: true,
ready:function(){
console.log( Env.browsers );
},
supportedVideoFormats: ["mp4","ogg"],
contentLocation: "content/",
@csprocket777
csprocket777 / gist:5880537
Created June 27, 2013 21:25
EmberJS Handlebars helper
Ember.Handlebars.registerBoundHelper('videoJS', function(lo, options){
console.log(lo);
});
<script type="text/x-handlebars" data-template-name="lo">
{{videoJS lo}}
</script>