Navigation Menu

Skip to content

Commit

Permalink
enhance forms plugin so that it can deal with nested properties on ob…
Browse files Browse the repository at this point in the history
…ject types #383
  • Loading branch information
jstrachan committed Jul 8, 2013
1 parent abc3667 commit f3a6fa0
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 4 deletions.
3 changes: 2 additions & 1 deletion hawtio-web/src/main/webapp/app/dozer/js/helpers.ts
Expand Up @@ -118,9 +118,10 @@ module Dozer {
function copyAttributes(object: any, element: Element) {
var attributeMap = element.attributes;
for (var i = 0; i < attributeMap.length; i++) {
// TODO hacky work around for compiler issue ;)
//var attr = attributeMap.item(i);
var attMap: any = attributeMap;
var attr = attMap.item(i);
//var attr = attributeMap.item(i);
if (attr) {
var name = attr.localName;
var value = attr.value;
Expand Down
14 changes: 11 additions & 3 deletions hawtio-web/src/main/webapp/app/forms/js/simpleFormDirective.ts
Expand Up @@ -196,10 +196,18 @@ module Forms {
if (!propSchema) {
propSchema = Forms.lookupDefinition(propTypeName, fullSchema);
}
if (propSchema && Forms.isObjectType(propSchema)) {
console.log("type name " + propTypeName + " has nested object type " + JSON.stringify(propSchema, null, " "));

angular.forEach(propSchema.properties, (childProp, childId) => {
var nestedProperties = null;
if (!propSchema && "object" === propTypeName && property.properties) {
// if we've no type name but have nested properties on an object type use those
nestedProperties = property.properties;
} else if (propSchema && Forms.isObjectType(propSchema)) {
// otherwise use the nested properties from the related schema type
console.log("type name " + propTypeName + " has nested object type " + JSON.stringify(propSchema, null, " "));
nestedProperties = propSchema.properties;
}
if (nestedProperties) {
angular.forEach(nestedProperties, (childProp, childId) => {
var newId = id + "." + childId;
addProperty(newId, childProp);
});
Expand Down

0 comments on commit f3a6fa0

Please sign in to comment.