fully JSON based attachment configuration
Closed this issue · 2 comments
sheppard commented
Move the attachmentTypes configuration from being JavaScript hardcoded in wq/app.js to JSON embedded in the the wq configuration object.
For example,
var attachmentTypes = {
relationship: {
'predicate': 'related',
'type': 'relationshiptype',
'getTypeFilter': function(page, context) {
/* jshint unused: false */
return {'from_type': page};
},
'getChoiceList': function(type, context) {
/* jshint unused: false */
return type.to_type;
},
'getChoiceListFilter': function(type, context) {
/* jshint unused: false */
return {};
},
'getDefaults': function(type, context) {
/* jshint unused: false */
return {
'type_label': type.name,
'to_type': type.to_type
};
}
}
};
might become:
{
"pages": {
"relationship": {
"name": "relationship",
"url": "relationships",
"list": true,
"parents": {
"relationshiptype": [
"type"
]
},
"children": [],
"attachment": {
"predicate": "related",
"type": "relationshiptype",
"typeFilter": {
"from_type": "{{page}}"
},
"choiceListPage": "{{type.to_type}}",
"choiceListFilter": {},
"getDefaults": {
"type_label": "{{type.name}}",
"to_type": "{{type.to_type}}",
}
}
}
}
sheppard commented
Also, the attachmentTypes
configuration is redundant with, and should likely replace, the children
configuration. (See e.g. 849457c).
sheppard commented
This is essentially done. The children
, attachmentTypes
, parentFilters
, parents
, and choices
configurations have been merged into a single XLSForm-style field list.