Permalink
Browse files

fix(entity): uses association type instead of collection

  • Loading branch information...
bas080
bas080 committed Jul 15, 2016
1 parent 7a6b8ab commit c1be8bc5d013fcbbf968b87d1ae469acefcdf67d
Showing with 24 additions and 7 deletions.
  1. +14 −0 doc/types.md
  2. +1 −0 src/component/framework/bootstrap/association.html
  3. +9 −7 src/entity-schema.js
@@ -322,3 +322,17 @@ This is how you define buttons.
actionsElement
];
```

## `association`
> bootstrap
Association type plays nice with aurelia-orm's association select.

```js
let tagElement = {
type: 'association',
multiple: true // defaults to false
};
```
@@ -4,6 +4,7 @@
<form-group role="group" element.bind="element" message.bind="message">
<association-select
attributes.bind = "element.attributes"
multiple.bind = "element.multiple"
value.bind = "value"
property.bind = "element.property"
repository.bind = "element.repository"
@@ -10,11 +10,12 @@ import extend from 'extend';
* @returns {object[]} a schema consisting out of element objects
*/
export function entitySchema(entity) {
let metadata = entity.getMeta();
let types = metadata.fetch('types') || {};
let associations = metadata.fetch('associations');
let data = metadata.fetch('data') || {};
let schema = [];
let metadata = entity.getMeta();
let types = metadata.fetch('types') || {};
let associations = metadata.fetch('associations');
let data = metadata.fetch('data') || {};
let schema = [];
let entityManager = entity.getRepository().entityManager

for (let key of Object.keys(entity)) {
/* should be fixed in orm */
@@ -35,8 +36,9 @@ export function entitySchema(entity) {
}

if (associations[key] && associations[key].type === 'collection') {
element.type = 'collection';
element.schema = entitySchema(entityManager.getEntity(key));
element.type = 'association';
element.multiple = true;
element.schema = entitySchema(entityManager.getEntity(key));
}

schema.push(element);

0 comments on commit c1be8bc

Please sign in to comment.