* @param entity
* @param action
* @param prefix
+ * @param required
*/
- function populateFields(fields, entity, action, prefix) {
+ function populateFields(fields, entity, action, prefix, required) {
_.each(getFieldsCache[entity+action].values, function(field) {
var name = prefix + field.name,
pos = fields.length;
fields[pos].children = [];
populateFields(fields[pos].children, joins[name], 'get', name + '.');
}
- if (!prefix && field['api.required'] && field['api.required'] !== '0') {
+ if (!prefix && required && field['api.required'] && field['api.required'] !== '0') {
required.push(field.name);
}
});
return response;
}
+ /**
+ * TODO: This works given the current code structure but would cause race conditions if called many times per second
+ * @param entity string
+ * @returns $.Deferred
+ */
function getActions(entity) {
if (getActionsCache[entity]) {
return $.Deferred().resolve(getActionsCache[entity]);
function onChangeEntityOrAction(changedElement) {
var required = [];
fields = [];
+ joins = [];
getFieldData = {};
// Special case for getfields
if (action === 'getfields') {
}, {})
};
showFields(['api_action']);
+ renderJoinSelector();
return;
}
getMetadata(entity, action).done(function(data) {
}
onChangeAction(action);
getFieldData = data.values;
- populateFields(fields, entity, action, '');
+ populateFields(fields, entity, action, '', required);
showFields(required);
renderJoinSelector();
if (_.includes(['get', 'getsingle', 'getvalue', 'getstat'], action)) {