91 lines
3.0 KiB
JavaScript
91 lines
3.0 KiB
JavaScript
"use strict";
|
|
/**
|
|
* Value object for ticket item.
|
|
*
|
|
* @constructor
|
|
*/
|
|
function TicketVO() {
|
|
// simple fields
|
|
this.priority = '';
|
|
this.summary = '';
|
|
this.desc = '';
|
|
this.type = '';
|
|
this.numAttachments = '';
|
|
// complex fields
|
|
this.status = {};
|
|
this.assignee = null;
|
|
this.customer = null;
|
|
this.serviceTargets = null;
|
|
this.contact = null;
|
|
this.supportGroup = null;
|
|
this.customFields = null;
|
|
this.dynamicFields = [];
|
|
this.following = false;
|
|
this.company = null;
|
|
this.accessMappings = {};
|
|
this.locationCompany = {};
|
|
this.ownerGroup = {};
|
|
}
|
|
TicketVO.prototype = Object.create(BaseVO.prototype);
|
|
TicketVO.prototype.constructor = TicketVO;
|
|
/**
|
|
* @override
|
|
* @return {Array} properties
|
|
*/
|
|
TicketVO.prototype.getProps = function () {
|
|
return BaseVO.prototype.getProps().concat('displayId', 'modifiedDate', 'summary', 'priority', 'desc', 'numAttachments', 'status', 'assignee', 'supportGroup', 'serviceTargets', 'customer', 'contact', 'categorizations', 'customFields', 'dynamicFields', 'following', 'accessMappings', 'company', 'locationCompany', 'ownerGroup');
|
|
};
|
|
/**
|
|
* TODO: refactor this function
|
|
* @returns {boolean}
|
|
*/
|
|
TicketVO.prototype.isOngoing = function () {
|
|
return !this.isPaused() && !this.isClosed();
|
|
};
|
|
//https://jira.bmc.com/browse/DRBT2-2806
|
|
//As per the above JIRA test case, ticket to be considered paused only for below conditions.
|
|
TicketVO.prototype.isPaused = function () {
|
|
return this.status.value === 'Pending' || this.status.value === 'Waiting Approval' || this.status.value === 'Waiting';
|
|
};
|
|
TicketVO.prototype.isResolved = function () {
|
|
return this.status.value === 'Closed' || this.status.value === 'Resolved' || this.status.value === 'Completed';
|
|
};
|
|
TicketVO.prototype.isCancelled = function () {
|
|
return this.status.value === 'Cancelled' || this.status.value === 'Rejected' || this.status.value === 'Bypassed';
|
|
};
|
|
TicketVO.prototype.isClosed = function () {
|
|
return this.isResolved() || this.isCancelled();
|
|
};
|
|
/**
|
|
* @override
|
|
*/
|
|
TicketVO.prototype.postBuild = function () {
|
|
if (!_.isEmpty(this.accessMappings)) {
|
|
this.accessMappings = new AccessMappingVO().parseAccessMap(this.accessMappings, this.type);
|
|
}
|
|
else {
|
|
this.accessMappings = {
|
|
detailsEditAllowed: true,
|
|
summaryEditAllowed: true,
|
|
statusEditAllowed: true,
|
|
timelineEditAllowed: true,
|
|
relationsEditAllowed: true,
|
|
relationsDeleteAllowed: true,
|
|
priorityEditAllowed: true,
|
|
coordinatorEditAllowed: true,
|
|
tasksEditAllowed: true,
|
|
requestedforEditAllowed: true,
|
|
incidentTypeEditAllowed: true,
|
|
coordinatorSelfAssignmentAllowed: true
|
|
};
|
|
}
|
|
this.dynamicFields = _.sortBy(this.dynamicFields.map(function (item) {
|
|
item.editable = true;
|
|
item.isDynamic = true;
|
|
return new FieldVO().build(item);
|
|
}), 'displayOrder');
|
|
if (this.company === null) {
|
|
this.company = this.customer ? this.customer.company : null;
|
|
}
|
|
};
|