[Code Style] Use prototypes in platform

WTD-1482
This commit is contained in:
Victor Woeltjen
2015-08-11 12:54:50 -07:00
parent f377c7cb71
commit b7765ff388
35 changed files with 1331 additions and 1379 deletions

View File

@@ -11,8 +11,6 @@ define(
* @property {string} name the human-readable name of this property
* @property {string} value the human-readable value of this property,
* for this specific domain object
* @constructor
* @memberof platform/core
*/
var TIME_FORMAT = "YYYY-MM-DD HH:mm:ss";
@@ -27,10 +25,23 @@ define(
* `value` properties describing that domain object (suitable for
* display.)
*
* @param {DomainObject} domainObject the domain object whose
* metadata is to be exposed
* @implements {Capability}
* @constructor
* @memberof platform/core
*/
function MetadataCapability(domainObject) {
var model = domainObject.getModel();
this.domainObject = domainObject;
}
/**
* Get metadata about this object.
* @returns {MetadataProperty[]} metadata about this object
*/
MetadataCapability.prototype.invoke = function () {
var domainObject = this.domainObject,
model = domainObject.getModel();
function hasDisplayableValue(metadataProperty) {
var t = typeof metadataProperty.value;
@@ -39,8 +50,8 @@ define(
function formatTimestamp(timestamp) {
return typeof timestamp === 'number' ?
(moment.utc(timestamp).format(TIME_FORMAT) + " UTC") :
undefined;
(moment.utc(timestamp).format(TIME_FORMAT) + " UTC") :
undefined;
}
function getProperties() {
@@ -75,20 +86,9 @@ define(
];
}
function getMetadata() {
return getProperties().concat(getCommonMetadata())
.filter(hasDisplayableValue);
}
return {
/**
* Get metadata about this object.
* @returns {MetadataProperty[]} metadata about this object
* @memberof platform/core.MetadataCapability#
*/
invoke: getMetadata
};
}
return getProperties().concat(getCommonMetadata())
.filter(hasDisplayableValue);
};
return MetadataCapability;
}