Hi, I am very new to Ember.
I have an “associate” model and a “collector” model, which extends associate. Collector is also a subset of associate and no associate can be duplicated in collector.
//associate model import DS from ‘ember-data’;
export default DS.Model.extend({
associateId: DS.attr('number')
,lastName: DS.attr('string')
,firstName: DS.attr('string')
,nickname: DS.attr('string')
,phoneExtension: DS.attr('string')
});
//collector model import DS from ‘ember-data’; import associate from ‘./associate’;
export default associate.extend({
isSpanishSpeaker: DS.attr('number')
,isConciergeEligible: DS.attr('number')
,shiftName: DS.attr('string')
,isActive: DS.attr('number')
,subscriptions: DS.hasMany('call-queue')
});
I’m having trouble finding the correct “Ember way” to model this relationship.
- I want to be able to pick members from associate and add them to collector
- I want to create a pick list of associates that are not collectors
- When I add an associate to the collector set, I want the pick list in #2 to remove that associate from its list.
Finally, the action below, “addAssociateToCollectors()”, is giving me the following error: “Assertion Failed: Ember.Object.create no longer supports defining computed properties. Define computed properties using extend() or reopen() before calling create().”.
The setDiff is also not working.
//controller for my ‘add’ template for collector
export default Controller.extend({
associateToAdd: null
,availableAssociates: setDiff('model.associates', 'model.collectors') //this does not work
,actions: {
setAssociateToAdd(value) {
this.set('associateToAdd', value); //set by picklist in template
}
,addAssociateToCollectors() {
this.store.createRecord('collector', {
associateId: this.associateToAdd.id
,firstName: this.associateToAdd.firstName
,lastName: this.associateToAdd.lastName
,nickname: this.associateToAdd.nickname
,phoneExtension: this.associateToAdd.phoneExtension
,isSpanishSpeaker: 0
,isConciergeEligible: 0
,shiftName: 'Variable'
,isActive: 1
,subscriptions: null
});
}
}
});
I’d appreciate any help anyone can offer. Or, if there are docs that address this that I’m missing, please point me in the right direction.
Thank you.