}
}
+ /**
+ * Adds all IDL fields for the specified class to the set of
+ * display columns. If a field is already in the display
+ * columns, it's not added again.
+ *
+ * 'base' is the base dotpath for finding values within each
+ * object in the list. E.g. I have objects that look like
+ * foo.bar().baz() and I want to present columns for my 'bar'
+ * objects, my 'base' is 'foo.bar'. When access values via
+ * fieldValue(), the list will look up foo.bar()[field_name]().
+ * 'base' is only required when using fieldValue().
+ *
+ * To avoid ambiguity, automatically added column labels are
+ * prefixed with the class label.
+ */
+ this.addColumnsForClass = function(cls, base) {
+ var idlClass = egIDL.classes[cls];
+ angular.forEach(idlClass.fields, function(field) {
+ if (!field.label) return;
+
+ // only add virtual fields if the class is virtual
+ if (field.virtual && !idlClass.virtual) return;
+
+ var name = field.name;
+ if (base) name = base + '.' + name;
+
+ // avoid adding the field if it's already represented
+ if (self.allColumns.filter(
+ function(f) {return f.name == name })[0])
+ return;
+
+ self.allColumns.push({
+ name : name,
+ label : idlClass.label + ':' + field.label
+ });
+ });
+ }
+
this.onFirstPage = function() {
return this.offset == 0;
}
return $filter('date')(obj, 'shortDate');
case 'bool':
// let the browser translate true / false for us
- return Boolean(value == 't');
+ return Boolean(obj == 't');
default:
- return obj;
+ if (typeof obj == 'object' && obj.classname) {
+ // if we have a path to an object, display the
+ // selector value or pkey instead of the
+ // stringified object
+ var pkey = egIDL.classes[obj.classname].pkey
+ var pkey_field = egIDL.classes[obj.classname].fields.filter(
+ function(f) { return f.name == pkey })[0];
+ if (pkey_field) {
+ var dfield = pkey_field.selector || pkey;
+ return obj[dfield]();
+ } else {
+ // if we get here that means the object has no
+ // pkey / selector field. that should not happen.
+ return obj;
+ }
+
+ } else {
+ return obj;
+ }
}
}
}