SmartIT_Extensions/BMC/smart-it-full-helix/scripts/app/common/vo/global-search-item-vo.js

69 lines
2.5 KiB
JavaScript

"use strict";
/**
* Value object for metadata.
*
* @constructor
*/
function GlobalSearchItemVO() {
this.additionalInformation = {};
this.category = '';
this.desc = '';
this.displayId = '';
this.id = '';
this.relevancy = 0;
this.title = '';
this.type = '';
this.templateName = '';
this.visited = false;
this.subType = '';
this.internalUse = '';
}
// inherit BaseVO
GlobalSearchItemVO.prototype = new BaseVO();
// correct the constructor pointer
GlobalSearchItemVO.prototype.constructor = GlobalSearchItemVO;
GlobalSearchItemVO.prototype.getProps = function () {
var keys = Object.keys(new GlobalSearchItemVO());
return BaseVO.prototype.getProps().concat(keys);
};
GlobalSearchItemVO.prototype.getRating = function (isHKM) {
return isHKM ? Math.round(this.additionalInformation.rating) : (Math.round((this.additionalInformation.useCount / ((+this.additionalInformation.useCount) + (+this.additionalInformation.notUsefulCount))) * 100) || 0);
};
GlobalSearchItemVO.prototype.getNumberOfViews = function () {
if (!_.isUndefined(this.additionalInformation.viewCount) && (this.additionalInformation.viewCount !== null)) {
return this.additionalInformation.viewCount;
}
else {
return -1;
}
};
GlobalSearchItemVO.prototype.getNumberOfLinkedItems = function () {
if (!_.isUndefined(this.additionalInformation.linkedItems) && (this.additionalInformation.linkedItems !== null)) {
return this.additionalInformation.linkedItems;
}
else {
return -1;
}
};
GlobalSearchItemVO.prototype.getLastModifyDate = function () {
return this.additionalInformation.modifiedDate;
};
GlobalSearchItemVO.prototype.getStatus = function () {
return this.additionalInformation.status.value;
};
GlobalSearchItemVO.prototype.getAssigneeFullName = function () {
return this.additionalInformation.assignee && this.additionalInformation.assignee.fullName;
};
GlobalSearchItemVO.prototype.isDecisionTree = function () {
return this.templateName === 'Decision Tree';
};
GlobalSearchItemVO.prototype.isArticleActive = function () {
var fieldObj = this.realObject || this.additionalInformation;
return this.type === EntityVO.TYPE_KNOWLEDGE
? ["Cancelled", "Retire Approval", "Retired", "Closed Version"].indexOf(fieldObj && fieldObj.status && fieldObj.status.value) === -1
: true;
};
GlobalSearchItemVO.prototype.postBuild = function () {
this.subType = this.additionalInformation.isAutomatic ? "-auto" : "";
};