127 lines
4.7 KiB
JavaScript
127 lines
4.7 KiB
JavaScript
"use strict";
|
|
/**
|
|
* Value object for screen config.
|
|
*
|
|
* @author Igor Samulenko
|
|
* @constructor
|
|
*/
|
|
function ScreenConfigurationVO() {
|
|
// simple fields
|
|
this.id = '';
|
|
this.name = '';
|
|
this.title = '';
|
|
this.datasource = '';
|
|
// complex fields
|
|
this.panels = [];
|
|
// flags
|
|
this.opened = false;
|
|
// derived fields
|
|
this.hoveredPanelId = '';
|
|
}
|
|
/**
|
|
* Setup inheritance chain.
|
|
*/
|
|
ScreenConfigurationVO.prototype = Object.create(BaseVO.prototype);
|
|
ScreenConfigurationVO.prototype.constructor = ScreenConfigurationVO;
|
|
/**
|
|
* @override
|
|
* @return {Array}
|
|
*/
|
|
ScreenConfigurationVO.prototype.getProps = function () {
|
|
return ['id', 'name', 'title', 'datasource', 'panels'];
|
|
};
|
|
/**
|
|
* @override
|
|
*/
|
|
ScreenConfigurationVO.prototype.postBuild = function () {
|
|
this.panels = this.panels.map(function (item) {
|
|
return new PanelVO().build(item);
|
|
});
|
|
var screenId = this.id;
|
|
var screenTitle = this.title;
|
|
var screenDataSource = this.datasource;
|
|
var screenName = this.name;
|
|
this.panels.forEach(function (panel) {
|
|
panel.parentScreenId = screenId;
|
|
panel.parentScreenTitle = screenTitle;
|
|
panel.parentScreenName = screenName;
|
|
panel.dataSource = screenDataSource;
|
|
});
|
|
};
|
|
/**
|
|
* Get fields from all panels belonging to screen
|
|
*
|
|
* @returns {Array} fields
|
|
*/
|
|
ScreenConfigurationVO.prototype.getFields = function () {
|
|
var result = [];
|
|
this.panels.forEach(function (panel) {
|
|
panel.fields.forEach(function (field) {
|
|
field.panelId = panel.id;
|
|
result.push(field);
|
|
});
|
|
//result = result.concat(panel.fields);
|
|
});
|
|
return result;
|
|
};
|
|
/**
|
|
* Finds specific panel by name
|
|
*
|
|
* @param panelName
|
|
* @returns {PanelVO} panel
|
|
*/
|
|
ScreenConfigurationVO.prototype.getPanelByName = function (panelName) {
|
|
return _.find(this.panels, { name: panelName });
|
|
};
|
|
ScreenConfigurationVO.prototype.INCIDENT_DETAILS_SCREEN = 'incidentDetailsScreen';
|
|
ScreenConfigurationVO.prototype.WORK_ORDER_DETAILS_SCREEN = 'workOrderDetailsScreen';
|
|
ScreenConfigurationVO.prototype.TASK_DETAILS_SCREEN = 'taskDetailsScreen';
|
|
ScreenConfigurationVO.prototype.PERSON_DETAILS_SCREEN = 'personDetailsScreen';
|
|
ScreenConfigurationVO.prototype.CHANGE_REQUEST_SCREEN = 'changeRequestScreen';
|
|
ScreenConfigurationVO.prototype.PROBLEM_DETAILS_SCREEN = 'problemScreen';
|
|
ScreenConfigurationVO.prototype.KNOWN_ERROR_DETAILS_SCREEN = 'knownErrorScreen';
|
|
ScreenConfigurationVO.prototype.ASSET_SCREEN = 'assetScreen';
|
|
ScreenConfigurationVO.prototype.INCIDENT_VIEW_SCREEN = 'incidentViewScreen';
|
|
ScreenConfigurationVO.prototype.WORK_ORDER_VIEW_SCREEN = 'workOrderViewScreen';
|
|
ScreenConfigurationVO.prototype.TASK_VIEW_SCREEN = 'taskViewScreen';
|
|
ScreenConfigurationVO.prototype.CHANGE_VIEW_SCREEN = 'changeViewScreen';
|
|
ScreenConfigurationVO.prototype.CREATE_INCIDENT_SCREEN = 'createIncidentScreen';
|
|
ScreenConfigurationVO.prototype.CREATE_WORK_ORDER_SCREEN = 'createWorkOrderScreen';
|
|
ScreenConfigurationVO.prototype.CREATE_TASK_SCREEN = 'createTaskScreen';
|
|
ScreenConfigurationVO.prototype.CREATE_CHANGE_SCREEN = 'createChangeScreen';
|
|
// Order of this array is used to position new screens on screen configuration list
|
|
ScreenConfigurationVO.prototype.V2_COMPATIBLE_SCREENS = [
|
|
ScreenConfigurationVO.prototype.INCIDENT_VIEW_SCREEN,
|
|
ScreenConfigurationVO.prototype.CREATE_INCIDENT_SCREEN,
|
|
ScreenConfigurationVO.prototype.CHANGE_VIEW_SCREEN,
|
|
ScreenConfigurationVO.prototype.CREATE_CHANGE_SCREEN,
|
|
ScreenConfigurationVO.prototype.WORK_ORDER_VIEW_SCREEN,
|
|
ScreenConfigurationVO.prototype.CREATE_WORK_ORDER_SCREEN,
|
|
ScreenConfigurationVO.prototype.TASK_VIEW_SCREEN,
|
|
ScreenConfigurationVO.prototype.CREATE_TASK_SCREEN
|
|
];
|
|
ScreenConfigurationVO.prototype.CREATE_SCREENS = [
|
|
ScreenConfigurationVO.prototype.CREATE_CHANGE_SCREEN,
|
|
ScreenConfigurationVO.prototype.CREATE_INCIDENT_SCREEN,
|
|
ScreenConfigurationVO.prototype.CREATE_WORK_ORDER_SCREEN,
|
|
ScreenConfigurationVO.prototype.CREATE_TASK_SCREEN
|
|
];
|
|
ScreenConfigurationVO.prototype.isV2Compatible = function (screenName) {
|
|
if (!screenName) {
|
|
screenName = this.name;
|
|
}
|
|
return this.V2_COMPATIBLE_SCREENS.indexOf(screenName) !== -1;
|
|
};
|
|
ScreenConfigurationVO.prototype.isCreateScreen = function (screenName) {
|
|
if (!screenName) {
|
|
screenName = this.name;
|
|
}
|
|
return (ScreenConfigurationVO.prototype.CREATE_SCREENS.indexOf(screenName) !== -1);
|
|
};
|
|
ScreenConfigurationVO.prototype.getScreenOrderNumber = function () {
|
|
return ScreenConfigurationVO.prototype.V2_COMPATIBLE_SCREENS.indexOf(this.name);
|
|
};
|
|
ScreenConfigurationVO.prototype.isTicketEnabledForProviderActionExpression = function (type) {
|
|
return type === EntityVO.TYPE_INCIDENT || type === EntityVO.TYPE_CHANGE || type === EntityVO.TYPE_WORKORDER || type === EntityVO.TYPE_TASK;
|
|
};
|