71 lines
2.3 KiB
JavaScript
71 lines
2.3 KiB
JavaScript
"use strict";
|
|
/**
|
|
* Created by Igor Samulenko on 3/5/14.
|
|
*/
|
|
//TODO: should inherit from ticket-template-vo.js
|
|
//TODO: however backend data for incident, workorder and task template are not consistent, waiting for backend data
|
|
/**
|
|
* Value object for incident template item.
|
|
*
|
|
* @constructor
|
|
*/
|
|
function IncidentTemplateVO() {
|
|
// simple fields
|
|
this.name = '';
|
|
this.type = '';
|
|
this.desc = '';
|
|
this.notes = '';
|
|
this.summary = '';
|
|
// complex fields
|
|
this.company = null;
|
|
this.templateObject = null;
|
|
this.modifiedDate = null;
|
|
// derived fields
|
|
this.status = '';
|
|
this.priority = '';
|
|
this.assignedGroup = '';
|
|
this.categorizations = [];
|
|
this.resCategorizations = [];
|
|
this.allCategories = [];
|
|
this.templateCategory = '';
|
|
this.createDateLabel = '';
|
|
this.modifiedDateLabel = '';
|
|
this.tier1 = '';
|
|
this.tier2 = '';
|
|
this.tier3 = '';
|
|
}
|
|
/**
|
|
* Setup inheritance chain.
|
|
*/
|
|
IncidentTemplateVO.prototype = Object.create(BaseVO.prototype);
|
|
IncidentTemplateVO.prototype.constructor = IncidentTemplateVO;
|
|
/**
|
|
* @override
|
|
* @return {Array}
|
|
*/
|
|
IncidentTemplateVO.prototype.getProps = function () {
|
|
return BaseVO.prototype.getProps().concat('name', 'type', 'desc', 'notes', 'summary', 'company', 'templateObject', 'modifiedDate');
|
|
};
|
|
/**
|
|
* @override
|
|
*/
|
|
IncidentTemplateVO.prototype.postBuild = function () {
|
|
var template = this.templateObject;
|
|
if (template) {
|
|
this.status = template.status ? template.status.value : '';
|
|
var i, tiers = template.templateCategorizations[0].tiers, tierSize = _.size(tiers), tierValues = _.values(tiers);
|
|
this.priority = template.priority ? template.priority : '';
|
|
this.assignedGroup = template.assignedGroup.name;
|
|
this.templateCategory = tiers.incidentTemplateCategoryTier1;
|
|
this.categorizations = template.categorizations;
|
|
this.resCategorizations = template.resCategorizations;
|
|
for (i = 1; i <= tierSize; i++) {
|
|
this['tier' + i] = tierValues[i - 1];
|
|
}
|
|
}
|
|
this.type = 'incidentTemplate';
|
|
// transform date to human readable string
|
|
this.createDateLabel = moment(this.createDate).calendar({ sameElse: 'lll' });
|
|
this.modifiedDateLabel = moment(this.modifiedDate).calendar({ sameElse: 'lll' });
|
|
};
|