foam-framework / foam2

FOAM: Feature-Oriented Active Modeller, Version 2
Apache License 2.0
73 stars 63 forks source link

Properties have a default view of TextField, but TextField asserts that values are primitive #85

Open adamvy-google opened 8 years ago

adamvy-google commented 8 years ago

That means you don't get reasonable default behaviour with an untyped property set to an object.

We should maybe set the view of an untyped property to something that only renders a text field if primitive and renders a read only label, or a detail view if set to an object.

adamvy-google commented 8 years ago

The follow example demonstrates:

foam.CLASS({
  name: 'Abc',
  properties: [ 'a' ]
});

foam.CLASS({
  name: 'Def',
  properties: [ 'b' ]
});

foam.u2.DetailView.create({
  data: Abc.create({
    a: Def.create({
      b: 'hello'
    })
  })
}).write();

If you run this code you get the following error: "Assertion Failed: Attribute value must be a primitive type."

But this error does not really make clear what you did wrong. It's not obvious to a new user that an untyped property tries to render as a text field, and therefore will fail if set to an object.