"use strict"; /** * Value object for layout configuration. * * @author Abhranil Naha * @constructor */ function LayoutConfigurationVO() { // simple fields this.id = ''; this.name = ''; this.layout = ''; // complex fields this.panels = []; } var notConfigurablePanels = ['statusSection', 'changeBannerSection', 'summarySection']; var notExpandableSections = ['titleSection']; function markNotConfigurablePanels(panels) { panels.forEach(function (panel) { if (notConfigurablePanels.indexOf(panel.name) !== -1) { panel.notConfigurable = true; } }); } function markNotExpandablePanels(panels) { panels.forEach(function (panel) { if (notExpandableSections.indexOf(panel.name) !== -1) { panel.notExpandable = true; } }); } /** * Setup inheritance chain. */ LayoutConfigurationVO.prototype = Object.create(BaseVO.prototype); LayoutConfigurationVO.prototype.constructor = LayoutConfigurationVO; /** * @override * @return {Array} */ LayoutConfigurationVO.prototype.getProps = function () { return ['id', 'name', 'layout', 'panels']; }; /** * @override */ LayoutConfigurationVO.prototype.postBuild = function () { markNotConfigurablePanels(this.panels); markNotExpandablePanels(this.panels); }; LayoutConfigurationVO.prototype.getRawLayout = function () { var layoutCopy = _.cloneDeep(this); layoutCopy.panels.forEach(function (panel) { if (!angular.isUndefined(panel.notConfigurable)) { delete panel.notConfigurable; } if (!angular.isUndefined(panel.notExpandable)) { delete panel.notExpandable; } if (!angular.isUndefined(panel.emptyPanel)) { delete panel.emptyPanel; } }); return layoutCopy; }; LayoutConfigurationVO.prototype.specialHandlingSections = [].concat(notExpandableSections); /** * Checks whether current layout is Change Request screen layout, which has special logic around its sections * @return {boolean} */ LayoutConfigurationVO.prototype.isCreateChangeLayout = function () { return this.name === ScreenConfigurationVO.prototype.CREATE_CHANGE_SCREEN; };