SmartIT_Extensions/BMC/smart-it-full-helix/scripts/app/layout-configuration/status-bar-component/status-bar-directive.js

56 lines
2.6 KiB
JavaScript

"use strict";
/**
* Created by etang
*/
(function () {
'use strict';
angular.module('layoutConfigModule')
.directive('statusBar', ['customFieldLinkFunction', 'screenConfigurationModel',
function (customFieldLinkFunction, screenConfigurationModel) {
return {
restrict: 'E',
replace: true,
scope: {
ticket: '=',
metadata: '=',
editStatus: '&',
isDraft: '=',
isEditable: '=?',
data: '=?',
isCopyChange: '=?',
isNew: '=?'
},
templateUrl: 'views/layout-configuration/status-bar-component/status-bar.html',
controller: 'StatusBarController',
link: function (scope, element, attr) {
if (!attr.isEditable) {
scope.handleEditableFlagManually = true;
}
if (scope.$parent.isNew) {
scope.accessible = true;
scope.fieldLengthForSm6 = true;
scope.fieldLengthForSm4 = true;
}
else {
if (element.closest(".layout-renderer__child-column")[0]) {
scope.fieldLengthForSm6 = _.includes(element.closest(".layout-renderer__child-column")[0].className, 'col-sm-6');
scope.fieldLengthForSm4 = _.includes(element.closest(".layout-renderer__child-column")[0].className, 'col-sm-4');
}
}
var screenName = screenConfigurationModel.getScreenNameByTicketType(scope.ticket.type);
var screenPanels = screenConfigurationModel.screensCacheByName[screenName]
? screenConfigurationModel.screensCacheByName[screenName].panels : [];
var screenPanel = _.find(screenPanels, { name: 'statusBarPanel' });
if (screenPanel && screenPanel.fields) {
var statusField = _.find(screenPanel.fields, { name: 'status' });
scope.accessible = statusField.isAccessible();
if (scope.handleEditableFlagManually) {
scope.isEditable = statusField.isEditable(scope.ticket.accessMappings);
}
}
customFieldLinkFunction(scope);
}
};
}]);
}());