Last active
September 20, 2017 06:27
-
-
Save felipekoblinger/f189538e9dd79bb8b547676a30997659 to your computer and use it in GitHub Desktop.
Relationship Ember Rapid Form
This file contains hidden or 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
import Ember from 'ember'; | |
export default Ember.Controller.extend({ | |
appName: 'Ember Twiddle' | |
}); |
This file contains hidden or 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
import DS from 'ember-data'; | |
import DependentRelationships from '../mixins/dependent-relationships'; | |
import { validator, buildValidations } from 'ember-cp-validations'; | |
import InputErrors from 'ember-rapid-forms/mixins/input-errors'; | |
import Helper from 'ember-rapid-forms/mixins/ember-cp-validations-helper'; | |
const { attr, hasMany } = DS; | |
const Validations = buildValidations({ | |
name: validator('presence', true) | |
}); | |
export default DS.Model.extend(Validations, InputErrors, Helper, { | |
cpf_number: attr('string'), | |
name: attr('string'), | |
email: attr('string'), | |
notes: attr('string'), | |
birthday: attr('date'), | |
phones: hasMany('customer_phone', { async: false, cascadeDelete: true }) | |
}); |
This file contains hidden or 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
import DS from 'ember-data'; | |
import { validator, buildValidations } from 'ember-cp-validations'; | |
import InputErrors from 'ember-rapid-forms/mixins/input-errors'; | |
import Helper from 'ember-rapid-forms/mixins/ember-cp-validations-helper'; | |
const { attr, belongsTo } = DS; | |
const Validations = buildValidations({ | |
number: validator('presence', true) | |
}); | |
export default DS.Model.extend(Validations, InputErrors, Helper, { | |
type: attr('string'), | |
number: attr('string'), | |
customer: belongsTo('customer') | |
}); |
This file contains hidden or 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
import Ember from 'ember'; | |
export default Ember.Route.extend({ | |
model() { | |
return this.store.createRecord('customer', { | |
phones: [this.store.createRecord('customer_phone')] | |
}); | |
} | |
}); |
This file contains hidden or 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
{ | |
"version": "0.12.1", | |
"EmberENV": { | |
"FEATURES": {} | |
}, | |
"options": { | |
"use_pods": false, | |
"enable-testing": false | |
}, | |
"dependencies": { | |
"jquery": "https://cdnjs.cloudflare.com/ajax/libs/jquery/1.11.3/jquery.js", | |
"ember": "2.12.0", | |
"ember-template-compiler": "2.12.0", | |
"ember-testing": "2.12.0" | |
}, | |
"addons": { | |
"ember-data": "alpha", | |
"ember-truth-helpers": "^1.3.0", | |
"ember-rapid-forms": "^1.0.0-beta14", | |
"ember-cp-validations": "^3.4.1" | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment