Permalink
Browse files

feat(components): association type and component

  • Loading branch information...
bas080
bas080 committed Jun 30, 2016
1 parent 3dd5846 commit 9ba164ab4d02fe53be64911ec0cbf8ff8d9063e3
Showing with 22 additions and 0 deletions.
  1. +16 −0 src/component/framework/bootstrap/association.html
  2. +6 −0 src/entity-schema.js
@@ -0,0 +1,16 @@
<template>
<require from="./../../../attributes"></require>
<require from="./form-group"></require>
<form-group role="group" element.bind="element" message.bind="message">
<association-select
attributes.bind = "element.attributes"
value.bind = "value"
property.bind = "element.property"
repository.bind = "element.repository"
resource = "element.resource"
association.bind = "element.association"
manyAssociation.bind = "element.manyAssociation"
criteria.bind = "element.criteria"></association-select>
<span class="help-block">${messages[element.key]}</span>
</form-group>
</template>
@@ -1,3 +1,5 @@
import extend from 'extend';

/**
* Takes an entity and uses it's metadata to generate a form-schema. Entities
* behave like normal objects in the way one can get and set the values on
@@ -11,15 +13,19 @@ 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 = [];

for (let key of Object.keys(entity)) {
if (key === '__validationReporter__') {continue;} /* should be fixed in orm */

let element = {
key: key,
type: types[key]
};

element = extend(true, element, data[key].form || {});

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

0 comments on commit 9ba164a

Please sign in to comment.