publish-deny-modal-directive.js 1.15 KB
Newer Older
lepdou committed
1 2 3 4 5 6 7 8 9
directive_module.directive('publishdenymodal', publishDenyDirective);

function publishDenyDirective(AppUtil, EventManager) {
    return {
        restrict: 'E',
        templateUrl: '../../views/component/publish-deny-modal.html',
        transclude: true,
        replace: true,
        scope: {
10
            env: "="
lepdou committed
11 12 13 14 15 16 17 18 19 20 21 22 23 24
        },
        link: function (scope) {
            var MODAL_ID = "#publishDenyModal";

            EventManager.subscribe(EventManager.EventType.PUBLISH_DENY, function (context) {
                scope.toReleaseNamespace = context.namespace;
                scope.mergeAndPublish = !!context.mergeAndPublish;
                AppUtil.showModal(MODAL_ID);
            });

            scope.emergencyPublish = emergencyPublish;

            function emergencyPublish() {
                AppUtil.hideModal(MODAL_ID);
25 26 27 28 29 30

                EventManager.emit(EventManager.EventType.EMERGENCY_PUBLISH,
                                  {
                                      mergeAndPublish: scope.mergeAndPublish,
                                      namespace: scope.toReleaseNamespace
                                  });
lepdou committed
31 32 33 34 35 36 37

            }
        }
    }
}