63 lines
1.8 KiB
JavaScript
63 lines
1.8 KiB
JavaScript
"use strict";
|
|
/**
|
|
* Created by Sun Chu on 6/2/14.
|
|
*/
|
|
/**
|
|
* Value object for service request template item.
|
|
*
|
|
* @constructor
|
|
*/
|
|
function ServicerequestTemplateVO() {
|
|
// simple fields
|
|
this.name = '';
|
|
this.type = '';
|
|
this.desc = '';
|
|
// complex fields
|
|
this.company = null;
|
|
this.templateObject = null;
|
|
this.modifiedDate = null;
|
|
// derived fields
|
|
this.categorizations = [];
|
|
this.createDateLabel = '';
|
|
this.modifiedDateLabel = '';
|
|
this.turnaroundTimeUnits = '';
|
|
this.turnaroundTime = '';
|
|
this.cost = '';
|
|
this.isAttributeHidden = {};
|
|
}
|
|
/**
|
|
* Setup inheritance chain.
|
|
*/
|
|
ServicerequestTemplateVO.prototype = Object.create(BaseVO.prototype);
|
|
ServicerequestTemplateVO.prototype.constructor = ServicerequestTemplateVO;
|
|
/**
|
|
* @override
|
|
* @return {Array}
|
|
*/
|
|
ServicerequestTemplateVO.prototype.getProps = function () {
|
|
return BaseVO.prototype.getProps().concat('name', 'type', 'desc', 'company', 'templateObject', 'modifiedDate');
|
|
};
|
|
/**
|
|
* @override
|
|
*/
|
|
ServicerequestTemplateVO.prototype.postBuild = function () {
|
|
var template = this.templateObject;
|
|
if (template) {
|
|
this.price = template.price;
|
|
this.currency = template.currency;
|
|
this.turnaroundTime = template.turnaroundTime;
|
|
this.turnaroundTimeUnits = template.turnaroundTimeUnits;
|
|
this.summary = template.summary;
|
|
if (template.hideAttributes) {
|
|
var self = this;
|
|
_.each(template.hideAttributes, function (hideAttribute) {
|
|
self.isAttributeHidden[hideAttribute] = true;
|
|
});
|
|
}
|
|
}
|
|
this.type = 'servicerequestTemplate';
|
|
// transform date to human readable string
|
|
this.createDateLabel = moment(this.createDate).calendar({ sameElse: 'lll' });
|
|
this.modifiedDateLabel = moment(this.modifiedDate).calendar({ sameElse: 'lll' });
|
|
};
|