120 lines
4.5 KiB
JavaScript
120 lines
4.5 KiB
JavaScript
"use strict";
|
|
/**
|
|
* Value object for asset.
|
|
*
|
|
* @constructor
|
|
*/
|
|
function AssetVO() {
|
|
this.name = '';
|
|
this.desc = '';
|
|
this.company = null;
|
|
this.product = null;
|
|
this.reconciliationId = '';
|
|
this.classId = '';
|
|
this.assetId = '';
|
|
this.instanceId = '';
|
|
this.site = {};
|
|
this.status = null;
|
|
this.assetExtension = null;
|
|
this.thumbnail = '';
|
|
this.thumbnailMime = '';
|
|
this.type = '';
|
|
this.subType = '';
|
|
this.lifecycleDates = null;
|
|
this.financial = null;
|
|
this.needsReconciliation = false;
|
|
this.floor = '';
|
|
this.room = '';
|
|
this.systemRole = '';
|
|
this.serialNumber = '';
|
|
this.partNumber = '';
|
|
this.tagNumber = '';
|
|
this.supplier = null;
|
|
this.manufacturer = '';
|
|
this.impact = null;
|
|
this.urgency = null;
|
|
this.priority = null;
|
|
this.invoiceNumber = '';
|
|
this.orderId = '';
|
|
this.submitter = null;
|
|
this.lastModifiedBy = null;
|
|
this.supplier = null;
|
|
this.version = null;
|
|
this.owner = null;
|
|
this.ticketType = EntityVO.TYPE_ASSET;
|
|
this.extensionAttrs = {};
|
|
this.domainAttrs = {};
|
|
this.productAttrs = {};
|
|
this.accessMappings = {};
|
|
this.poiInfo = {};
|
|
this.following = false;
|
|
this.assetType = "";
|
|
this.customFields = {};
|
|
this.bcmDeviceId = null;
|
|
}
|
|
// inherit BaseVO
|
|
AssetVO.prototype = new BaseVO();
|
|
// correct the constructor pointer
|
|
AssetVO.prototype.constructor = AssetVO;
|
|
AssetVO.prototype.getProps = function () {
|
|
return BaseVO.prototype.getProps().concat('name', 'desc', 'company', 'product', 'reconciliationId', 'classId', 'assetId', 'instanceId', 'site', 'status', 'assetExtension', 'thumbnail', 'thumbnailMime', 'type', 'subType', 'lifecycleDates', 'financial', 'needsReconciliation', 'floor', 'room', 'systemRole', 'serialNumber', 'partNumber', 'tagNumber', 'supplier', 'manufacturer', 'impact', 'urgency', 'priority', 'invoiceNumber', 'orderId', 'submitter', 'supplier', 'version', 'lastModifiedBy', 'owner', 'accessMappings', 'following', 'poiInfo', 'assetType', 'customFields', 'bcmDeviceId');
|
|
};
|
|
AssetVO.prototype.getSiteAddress = function () {
|
|
var siteAddress = this.site && this.site.address || {};
|
|
return siteAddress.street + ', ' + siteAddress.city + ', ' + siteAddress.state + ' '
|
|
+ (siteAddress.zip ? siteAddress.zip : '') + ', ' + siteAddress.country;
|
|
};
|
|
AssetVO.prototype.postBuild = function () {
|
|
_.forOwn(this.lifecycleDates, _.bind(function (value, prop) {
|
|
//datePropObj = moment(value).format('ll');
|
|
this.lifecycleDates[prop] = value;
|
|
}, this));
|
|
if (this.orderId) {
|
|
this.financial.orderId = this.orderId;
|
|
}
|
|
if (this.invoiceNumber) {
|
|
this.financial.invoiceNumber = this.invoiceNumber;
|
|
}
|
|
if (!_.isEmpty(this.accessMappings)) {
|
|
var accessMappings = {};
|
|
for (var i = 0; i < this.accessMappings.length; i++) {
|
|
if (this.accessMappings[i].id === 'financial') {
|
|
accessMappings.financialReadAllowed = (this.accessMappings[i].permission === 'write' || this.accessMappings[i].permission === 'read');
|
|
accessMappings.financialEditAllowed = (this.accessMappings[i].permission === 'write');
|
|
}
|
|
else {
|
|
accessMappings[this.accessMappings[i].id + 'EditAllowed'] = (this.accessMappings[i].permission === 'write');
|
|
}
|
|
}
|
|
this.accessMappings = accessMappings;
|
|
}
|
|
else {
|
|
this.accessMappings = {
|
|
detailsEditAllowed: true,
|
|
statusEditAllowed: true,
|
|
timelineEditAllowed: true,
|
|
relationsEditAllowed: true,
|
|
financialReadAllowed: true,
|
|
financialEditAllowed: true,
|
|
inventoryEditAllowed: true,
|
|
assetrelationsEditAllowed: true
|
|
};
|
|
}
|
|
this.isPoi = !_.isEmpty(this.poiInfo);
|
|
if (this.isPoi) {
|
|
this.isPoiOnly = !this.reconciliationId;
|
|
this.poiAttributes = _.toPairs(_.omit(this.poiInfo, ['name', 'desc', 'type', 'status', 'owner', 'id', 'thumbnail', 'thumbnailMime', 'qrcode', 'tag', 'source', 'floorMapId']));
|
|
this.poiLink = '../myitapp/#/resource/' + this.poiInfo.id;
|
|
this.poiId = this.poiInfo.id;
|
|
if (this.isPoiOnly) {
|
|
this.name = this.poiInfo.name;
|
|
this.reconciliationId = this.poiInfo.id;
|
|
this.classId = 'POI';
|
|
if (this.poiInfo.thumbnail && this.poiInfo.thumbnailMime) {
|
|
this.thumbnail = this.poiInfo.thumbnail;
|
|
this.thumbnailMime = this.poiInfo.thumbnailMime;
|
|
}
|
|
}
|
|
}
|
|
};
|