41 lines
1.9 KiB
JavaScript
41 lines
1.9 KiB
JavaScript
"use strict";
|
|
(function () {
|
|
'use strict';
|
|
angular.module('knowledgeArticleModule')
|
|
.directive('previewKnowledgeArticle', ['events', function (events) {
|
|
return {
|
|
restrict: 'A',
|
|
templateUrl: 'views/knowledge-article/knowledge-article-details.html',
|
|
controller: 'KnowledgeArticleController',
|
|
scope: {},
|
|
link: function (scope, element, attr) {
|
|
scope.isFullVersion = false;
|
|
function editClickHandler() {
|
|
scope.handleEditClick();
|
|
}
|
|
element.on(events.CHANGE_TO_EDIT_MODE, editClickHandler);
|
|
scope.$on(events.REFRESH_KNOWLEDGE_ARTICLE, function () {
|
|
scope.getArticle(scope.article.id, true);
|
|
});
|
|
scope.$on('$destroy', function () {
|
|
if (scope.editMode || scope.state.gettingEditStatus) {
|
|
scope.editMode = false;
|
|
scope.$emit(events.TOGGLE_KNOWLEDGE_ARTICLE_EDIT_MODE);
|
|
}
|
|
element.off(events.CHANGE_TO_EDIT_MODE, editClickHandler);
|
|
});
|
|
scope.openArticleRevision = function (revision) {
|
|
scope.$emit(events.SET_PREVIEW_ITEM, { id: revision.id, type: EntityVO.TYPE_KNOWLEDGE });
|
|
};
|
|
attr.$observe('previewKnowledgeArticle', function (articleId) {
|
|
if (scope.editMode) {
|
|
scope.editMode = false;
|
|
scope.$emit(events.CANCEL_EDIT_MODE);
|
|
}
|
|
scope.getArticle(articleId, false, false); //increment view count for preview.
|
|
});
|
|
}
|
|
};
|
|
}]);
|
|
}());
|