SmartIT_Extensions/BMC/smart-it-full-helix/scripts/app/person/person-profile-vo.js

84 lines
2.7 KiB
JavaScript

"use strict";
/**
* Value object for person.
*
* @constructor
*/
function PersonProfileVO() {
this.firstName = '';
this.lastName = '';
this.fullName = '';
this.department = '';
this.email = '';
this.company = null;
this.phone = '';
this.site = null;
this.organization = '';
this.loginId = '';
this.available = '';
this.jid = '';
this.cell = '';
this.fax = '';
this.jobTitle = '';
this.customFields = null;
this.following = false;
this.type = EntityVO.TYPE_PERSON;
this.isVIP = false;
//attributes for IT Agent
this.isSupportStaff = false;
this.enabled = false;
this.introduction = '';
this.linkedIn = '';
this.twitter = '';
this.availableForAssignment = false;
this.deskLocation = '';
this.manager = null;
this.costCenter = '';
this.openTickets = 0;
this.accessMappings = {};
this.supportGroups = [];
this.personId = '';
}
/**
* Setup inheritance chain.
*/
PersonProfileVO.prototype = Object.create(BaseVO.prototype);
PersonProfileVO.prototype.constructor = PersonProfileVO;
/**
* @override
* @returns {Array}
*/
PersonProfileVO.prototype.getProps = function () {
return BaseVO.prototype.getProps().concat('firstName', 'lastName', 'fullName', 'department', 'email', 'company', 'phone', 'thumbnailMime', 'thumbnail', 'site', 'organization', 'loginId', 'available', 'jid', 'cell', 'fax', 'jobTitle', 'customFields', 'isSupportStaff', 'enabled', 'introduction', 'linkedIn', 'twitter', 'availableForAssignment', 'deskLocation', 'manager', 'costCenter', 'openTickets', 'accessMappings', 'supportGroups', 'following', 'type', 'isVIP', 'personId');
};
PersonProfileVO.prototype.getFullName = function () {
return this.firstName + ' ' + this.lastName;
};
PersonProfileVO.prototype.getSiteAddress = function () {
var siteAddress = this.site && this.site.address || {};
if (siteAddress.address) {
return siteAddress.address;
}
return siteAddress.street + ', ' + siteAddress.city + ', ' + siteAddress.state + ' '
+ (siteAddress.zip ? siteAddress.zip : '') + ', ' + siteAddress.country;
};
/**
* @override
*/
PersonProfileVO.prototype.postBuild = function () {
if (!_.isEmpty(this.accessMappings)) {
var accessMappings = {};
for (var i = 0; i < this.accessMappings.length; i++) {
accessMappings[this.accessMappings[i].id + 'EditAllowed'] = (this.accessMappings[i].permission === 'write');
}
this.accessMappings = accessMappings;
}
else {
this.accessMappings = {
detailsEditAllowed: true,
timelineEditAllowed: true,
relationsEditAllowed: true
};
}
};