Skip to content
This repository has been archived by the owner on Nov 25, 2020. It is now read-only.

Commit

Permalink
feat(components): association type and component
Browse files Browse the repository at this point in the history
  • Loading branch information
bas080 committed Jun 30, 2016
1 parent 3dd5846 commit 9ba164a
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 0 deletions.
16 changes: 16 additions & 0 deletions src/component/framework/bootstrap/association.html
@@ -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>
6 changes: 6 additions & 0 deletions src/entity-schema.js
@@ -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
Expand All @@ -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));
Expand Down

0 comments on commit 9ba164a

Please sign in to comment.