I have a problem, I can't replace a hasMany
relationships. I have a zone, which has a hasMany
relationships parent. I need to change the relationships, I'm using the module ember-cli-jstree, and if I want to modify it with the plug-in dragAndDrop, I should be able to modify the data inside my store, because otherwise, there no point in moving it in my tree.
Here is my code :
let arrParent;
let newParent;
// This is an array that contain the position
arrParent = catchActualParent(node, this.get('zone'));
// This is an object which is in the good format
newParent = catchNewParent(node, this.get('zone'));
//Doesn't work
this.get('zone').objectAt(arrParent[0]).createRecord('parent', newParent).save();
Right there the problem is that it doesn't set the relationships, the object newParent
format is correct, I checked it.
Here is my model :
export default DS.Model.extend(ZoneValidations, {
numericId: Ember.computed('id', function ()
{
"use strict";
return Number(this.get('id'));
}),
alias: DS.attr('string'),
description: DS.attr('string'),
type: DS.attr('zone-type'),
doors: DS.hasMany('door'),
children: DS.hasMany('zones'),
parent: DS.hasMany('zones', {inverse: 'children'})
});
So i'm wondering if anyone as a tip about that.
TLDR: How do add an Ember.object with a relationship.
Aucun commentaire:
Enregistrer un commentaire