58 lines
2.7 KiB
JavaScript
58 lines
2.7 KiB
JavaScript
"use strict";
|
|
(function () {
|
|
'use strict';
|
|
angular.module('changeModule')
|
|
.directive('risks', ['screenConfigurationModel', 'tabIds', 'events', '$rootScope',
|
|
function (screenConfigurationModel, tabIds, events, $rootScope) {
|
|
return {
|
|
restrict: 'E',
|
|
replace: true,
|
|
templateUrl: 'views/change/risks.html',
|
|
scope: {
|
|
context: '=',
|
|
risksCustomFields: '=',
|
|
screenLayout: '=',
|
|
metadata: '=',
|
|
editMode: '=',
|
|
isNew: '='
|
|
},
|
|
link: function (scope) {
|
|
scope.$on(events.WIDGET_VALUE_CHANGE, function (event, data) {
|
|
$rootScope.$broadcast(events.WIDGET_VALUE_CHANGE_FROM_WIZARD, data);
|
|
});
|
|
scope.$on(events.FIELD_VALUE_CHANGE, function (event, data) {
|
|
$rootScope.$broadcast(events.FIELD_VALUE_CHANGE_FROM_WIZARD, data);
|
|
});
|
|
scope.tabIds = tabIds;
|
|
var screenPanels = scope.screenLayout && screenConfigurationModel.screensCacheByName[scope.screenLayout.name]
|
|
? screenConfigurationModel.screensCacheByName[scope.screenLayout.name].panels : [];
|
|
scope.riskSection = _.find(screenPanels, { name: 'riskPanel' });
|
|
scope.panelChildrenCount = function (screenPanelName) {
|
|
var screenPanel = _.find(screenPanels, { name: screenPanelName });
|
|
if (screenPanel && screenPanel.fields) {
|
|
return screenPanel.fields.length;
|
|
}
|
|
return 0;
|
|
};
|
|
scope.$watch(tabIds.wizard.risks + '.$invalid', function (invalid) {
|
|
if (typeof invalid !== 'undefined') {
|
|
scope.$emit(events.CHANGE_WIZARD_FORM_STATE, {
|
|
name: scope.tabIds.wizard.risks,
|
|
invalid: invalid
|
|
});
|
|
}
|
|
});
|
|
scope.$watch(tabIds.wizard.risks + '.$dirty', function (dirty) {
|
|
if (typeof dirty !== 'undefined') {
|
|
scope.$emit(events.CHANGE_WIZARD_FORM_STATE, {
|
|
name: scope.tabIds.wizard.risks,
|
|
dirty: dirty
|
|
});
|
|
}
|
|
});
|
|
}
|
|
};
|
|
}
|
|
]);
|
|
})();
|