';
// Check special character
pattern = /(?=.*[!@#$%^&*])/;
if (pattern.test(vm.newPassword)) {
vm.newPasswordTooltip += '
';
} else {
vm.newPasswordTooltip += '
';
}
vm.newPasswordTooltip += globalResources.M.AtLeastOneSpecialCharacter + '
';
}
function changePassword() {
$http.post('/api/Users/ChangePassword', { password: vm.newPassword })
.success(function () {
$modalInstance.dismiss('cancel');
});
}
function cancel() {
$modalInstance.dismiss('cancel');
}
}
})();;
(function () {
'use strict';
angular.module(modules.chapterModule)
.controller(controllers.searchController, searchController);
searchController.$inject = ['$scope', '$http', '$state', '$stateParams', '$timeout', '$document',
'favoriteService', 'folderService', 'tabStateService', 'resizeService', 'stringValidationService', 'metaDataService', 'documentService', '$q'];
function searchController($scope, $http, $state, $stateParams, $timeout, $document,
favoriteService, folderService, tabStateService, resizeService, stringValidationService, metaDataService, documentService, $q) {
var vm = this;
vm.handbookRequests = handbookRequests;
$scope.translation = globalResources;
vm.commonGridSettingKey = gridSettingKeys.commonVisibilitySettings;
vm.enabledMetadataSearch = true;
vm.enabledAdvanceSearch = true;
vm.isMetadataSearch = (HandbookConfiguration.MetadataEnabled.toLowerCase() == 'true' ? true : false) && vm.enabledMetadataSearch;
vm.doSearchDataMining = (HandbookConfiguration.DoSearchDataMining.toLowerCase() == 'true' ? true : false);
vm.enabledCompendiaSearch = (HandbookConfiguration.CompendiaSearch == 'True' ? true : false);
vm.searchInFolders = HandbookConfiguration.SearchInFolders.toUpperCase() == 'TRUE' ? true : false;
var showCompendiaSearch = vm.enabledCompendiaSearch;
var showFolderSearch = vm.searchInFolders;
vm.searchLogLevel = parseInt(HandbookConfiguration.SearchLogLevel);
$scope.searchTypes = [
{ id: 1, name: $scope.translation.TitleSearch },
{ id: 2, name: $scope.translation.ContentSearch }
];
if (vm.enabledAdvanceSearch) {
$scope.searchTypes.push({ id: 3, name: $scope.translation.AdvanceSearch });
}
if (vm.isMetadataSearch) {
$scope.searchTypes.push({ id: 4, name: $scope.translation.MetadataSearch });
}
$scope.keywords = {};
vm.today = new Date();
vm.keyword = $stateParams.keyword;
vm.searchInContents = $stateParams.searchInContents == true || $stateParams.searchInContents == 'true';
//vm.documentTemplate = $stateParams.template;
vm.folderId = $stateParams.folderId;
vm.fromDate = $stateParams.fromDate != null ? new Date(parseInt($stateParams.fromDate)) : null;
vm.toDate = $stateParams.toDate != null ? new Date(parseInt($stateParams.toDate)) : null;
vm.fromDateDisplayed = $stateParams.fromDate != null ? new Date(parseInt($stateParams.fromDate)) : null;
vm.toDateDisplayed = $stateParams.toDate != null ? new Date(parseInt($stateParams.toDate)) : null;
vm.registerItemId = $stateParams.registerItemId;
vm.registerItemValueId = $stateParams.registerItemValueId;
vm.type = $stateParams.type;
vm.hasExpired = $stateParams.hasExpired == 1;
vm.version = $stateParams.version != null ? parseInt($stateParams.version) : null;
vm.documentType = $stateParams.documentType != null ? parseInt($stateParams.documentType) : null;
vm.documents = {};
vm.folders = {};
vm.compendiaDocuments = [];
vm.totalHits = 0;
vm.totalFound = 0;
vm.showLoadMore = false;
vm.loadMoreClickedCounter = 0;
vm.searchFilter = '';
vm.folderName = '';
vm.searchType = E.searchType.Maximum;
vm.searchFilters = '';
vm.showMoreLink = globalResources.Showmore;
vm.selectedItem = {
selectedMetadata: null,
selectedTag: null
};
vm.foldersGridSetting = [];
vm.initMetadata = {
metadatas: [],
tags: []
};
vm.startMetadata = 0;
vm.startTag = 0;
vm.onRowClick = onRowClick;
vm.loadByMaxSearchSize = loadByMaxSearchSize;
vm.showLoadMoreLink = showLoadMoreLink;
$scope.selectNodeHead = selectNodeHead;
$scope.selectNodeLabel = selectNodeLabel;
$scope.clearSelectedNode = clearSelectedNode;
$scope.clearFromDate = clearFromDate;
$scope.clearToDate = clearToDate;
$scope.changeSearchType = changeSearchType;
$scope.search = search;
vm.openCompendiaDocument = openCompendiaDocument;
vm.defaultExportFileName = globalResources.SearchResult;
vm.openDocument = openDocument;
vm.folderClick = folderClick;
vm.isClickDocument = false;
initialize();
$scope.$on('$stateChangeStart',
function (event, toState, toParams, fromState, fromParams, options) {
if (vm.isClickDocument
|| vm.searchLogLevel != SEARCH_LOG_LEVEL.LOG_DOCUMENT_SELECTED_AND_0_HIT_AND_NO_SELECTION
|| fromState.name != "searchDocuments" || vm.documents.length == 0 || vm.documents.length == undefined
|| vm.documents == null) {
vm.isClickDocument = false;
return;
}
else {
insertLogWords(-2, user.userId, vm.keyword, $scope.selectedSearchType.id);
}
vm.isClickDocument = false;
});
function folderClick(id) {
favoriteService.setFavoriteNodeState({ isFavorited: false });
$state.go(handbookActions.FolderAction, { folderId: id });
};
function initialize() {
//check and resize the view
if (vm.isMetadataSearch) {
getRegisterItems();
}
if (vm.searchInFolders) {
buildFoldersGridSetting();
}
loadFolderTree();
resizeService.resizeView();
getGridSetting(gridSettingKeys.commonVisibilitySettings);
getColumnsDefinition(gridSettingKeys.commonVisibilitySettings);
vm.getFolderInformation = getFolderInformation();
vm.commonColumnsDefinition = angular.copy(optionalColumnsDenifinition);
//TODO Why do we use these 2 lines?
/*$scope.commonGridColumnDefinition = commonColumnsDefinition;
$scope.optionalColumns = optionalColumnsDenifinition;*/
if (vm.enabledCompendiaSearch) {
var mandatatoryRequests = [
searchCompendiaDocuments(vm.keyword),
getSearchResult(E.searchType.Maximum)
];
$q.all(mandatatoryRequests).then(function (response) {
$timeout(function () {
calculateHeightForDocumentGrids();
}, 500);
});
} else {
getSearchResult(E.searchType.Maximum, true);
}
activeButtonGroup(parseInt(vm.type), true);
vm.filter = {
keyword: vm.keyword,
searchInContents: vm.searchInContents,
searchType: E.searchType.Maximum,
folderId: vm.folderId,
fromDate: vm.fromDate,
toDate: vm.toDate,
hasExpired: vm.hasExpired,
registerItemId: vm.registerItemValueId != null ? null : vm.registerItemId,
registerItemValueId: vm.registerItemValueId,
version: vm.version,
documentType: vm.documentType
};
vm.exportParams = {
folderId: vm.folderId,
isRecursive: false,
groupBy: E.exportDocumentGroupsByColumn.none,
filter: vm.filter
};
vm.exportParams.columns = getDocumentColumnsForExporting(gridSettingKeys.commonVisibilitySettings);
};
function buildFoldersGridSetting() {
vm.foldersGridSetting.push({ id: 'name', name: globalResources.Folder, width: 50, coldefault: true, icon: 'icon' });
vm.foldersGridSetting.push({ id: 'location', name: globalResources.CommonGridColumns.Location, width: 50, coldefault: true });
vm.columnNotRemove = 'name';
}
function openDocument(id) {
vm.isClickDocument = true;
insertLogWords(id, user.userId, vm.keyword, $scope.selectedSearchType.id);
}
$scope.$on(broadcastType.gridSettingTarget, function (e, target, gridSettingKey) {
if (gridSettingKey == gridSettingKeys.commonVisibilitySettings) {
vm.exportParams.columns = getDocumentColumnsForExporting(gridSettingKeys.commonVisibilitySettings);
}
});
$document.bind('click', function (event) {
var isClickedElementChildOfPopup = $('.folder-search')
.find(event.target)
.length > 0;
if (isClickedElementChildOfPopup)
return;
$scope.showFolderTree = false;
});
$scope.$on('ngRepeatFinished', function (ngRepeatFinishedEvent) {
adjustContentPosition();
});
function adjustContentPosition() {
var tabState = tabStateService.getState(tabStateType.searchTabState);
$timeout(function () {
tabStateService.adjustContentPosition(tabState, tabStateType.searchTabState);
}, 0, false);
}
function getRegisterItems() {
if (vm.isMetadataSearch) {
metaDataService.getRegisterAndRegisterItems().then(function (data) {
if (data) {
vm.initMetadata.metadatas = data;
}
});
}
};
$scope.$watch('vm.selectedItem.selectedMetadata', function (selectedMetadata) {
if (vm.isMetadataSearch) {
if (vm.startTag != 1) {
vm.selectedItem.selectedTag = null;
if (selectedMetadata != null && selectedMetadata != undefined) {
getMetadataTags(selectedMetadata.registerItemId);
}
} else {
vm.startTag = 0;
}
}
});
function getMetadataTags(registerItemId) {
if (vm.isMetadataSearch) {
metaDataService.getMetadataTags(registerItemId).then(function (data) {
if (data) {
vm.initMetadata.tags = data;
}
});
}
};
function selectNodeHead(node) {
if (!node.isLoaded) {
$http.get(handbookRequests.GetSubfoldersRequest, { params: { 'folderId': node.id } })
.success(function (data, status, headers, config) {
node.children = data;
node.isLoaded = true;
})
.error(function (data, status, headers, config) {
node.isLoaded = true;
});
}
};
function selectNodeLabel(node) {
$scope.selectedNode = node;
$scope.showFolderTree = false;
};
function clearSelectedNode() {
$scope.selectedNode = null;
}
function clearFromDate() {
$scope.fromDate = null;
}
function clearToDate() {
$scope.toDate = null;
}
function activeButtonGroup(type, notCalculateHeigthGrid) {
angular.element('#search-title-id').addClass('btn-disabled');
angular.element('#search-content-id').addClass('btn-disabled');
angular.element('#search-advance-id').addClass('btn-disabled');
angular.element('#search-metadata-id').addClass('btn-disabled');
if (type == 1) {
angular.element('#search-title-id').removeClass('btn-disabled');
$scope.selectedSearchType = $scope.searchTypes[0];
} else if (type == 2) {
angular.element('#search-content-id').removeClass('btn-disabled');
$scope.selectedSearchType = $scope.searchTypes[1];
} else if (type == 3) {
angular.element('#search-advance-id').removeClass('btn-disabled');
$scope.selectedSearchType = $scope.searchTypes[2];
} else if (type == 4) {
angular.element('#search-metadata-id').removeClass('btn-disabled');
$scope.selectedSearchType = $scope.searchTypes[3];
}
var showMoreItem = (type == 3 || type == 4);
if (!notCalculateHeigthGrid) {
calculateHeightForDocumentGrids();
}
}
function changeSearchType(type) {
if (type == 1) {
$scope.isAdvanceSearch = false;
$scope.isMetadataSearch = false;
$scope.searchPlaceHolder = $scope.translation.TitleSearch;
$scope.selectedSearchType = $scope.searchTypes[0];
} else if (type == 2) {
$scope.isAdvanceSearch = false;
$scope.isMetadataSearch = false;
$scope.searchPlaceHolder = $scope.translation.ContentSearch;
$scope.selectedSearchType = $scope.searchTypes[1];
}
else if (type == 3 && vm.enabledAdvanceSearch) {
$scope.isAdvanceSearch = true;
$scope.isMetadataSearch = false;
$scope.searchPlaceHolder = $scope.translation.AdvanceSearch;
$scope.selectedSearchType = $scope.searchTypes[2];
} else if (type == 4 && vm.enabledMetadataSearch) {
$scope.isAdvanceSearch = false;
$scope.isMetadataSearch = true;
$scope.searchPlaceHolder = $scope.translation.MetadataSearch;
$scope.selectedSearchType = $scope.searchTypes[3];
}
$timeout(function () {
activeButtonGroup(type);
}, 500);
}
function search() {
if ($scope.selectedSearchType.id == 1) {
searchTitle();
} else if ($scope.selectedSearchType.id == 2) {
searchContent();
} else if ($scope.selectedSearchType.id == 3) {
searchAdvance();
} else if ($scope.selectedSearchType.id == 4) {
searchMetadata();
}
var searchCondition = ((vm.keyword != null && vm.keyword != "")
|| vm.folderId > 0
|| vm.fromDate != null
|| vm.toDate != null
|| (vm.registerItemId != null && vm.registerItemId != undefined && vm.registerItemId != 0))
&& stringValidationService.notContainSpecialCharacter(vm.keyword);
if (!searchCondition) {
return;
}
$state.go(handbookActions.SearchResultAction, {
keyword: vm.keyword,
searchInContents: vm.searchInContents ? 1 : 0,
folderId: vm.folderId,
fromDate: vm.fromDate,
toDate: vm.toDate,
hasExpired: vm.hasExpired ? 1 : 0,
registerItemId: vm.registerItemId,
registerItemValueId: vm.registerItemValueId,
type: $scope.selectedSearchType.id
});
}
function openCompendiaDocument(link) {
window.open(link);
}
function searchTitle() {
if (!$scope.keyword) {
return;
}
vm.keyword = $scope.keyword;
vm.searchInContents = false;
vm.folderId = null;
vm.fromDate = null;
vm.toDate = null;
vm.hasExpired = false;
vm.registerItemId = null;
vm.registerItemValueId = null;
}
function searchContent() {
if (!$scope.keyword) {
return;
}
vm.keyword = $scope.keyword;
vm.searchInContents = true;
vm.folderId = null;
vm.fromDate = null;
vm.toDate = null;
vm.hasExpired = false;
vm.registerItemId = null;
vm.registerItemValueId = null;
}
function searchAdvance() {
vm.keyword = $scope.keyword;
vm.searchInContents = true;
vm.folderId = $scope.selectedNode != null ? $scope.selectedNode.id : null;
vm.folderName = $scope.selectedNode != null ? $scope.selectedNode.name : null;
vm.fromDate = ($scope.fromDate != null && ($scope.toDate == null || $scope.fromDate <= $scope.toDate)) ? $scope.fromDate.getTime() : null;
vm.toDate = ($scope.toDate != null && $scope.toDate <= vm.today) ? $scope.toDate.getTime() : null;
vm.hasExpired = $scope.hasExpired;
vm.registerItemId = null;
vm.registerItemValueId = null;
}
function searchMetadata() {
vm.keyword = $scope.keyword;
vm.searchInContents = true;
vm.folderId = $scope.selectedNode != null ? $scope.selectedNode.id : null;
vm.folderName = $scope.selectedNode != null ? $scope.selectedNode.name : null;
vm.fromDate = null;
vm.toDate = null;
vm.hasExpired = false;
vm.registerItemId = vm.selectedItem.selectedMetadata != null ? vm.selectedItem.selectedMetadata.registerItemId : null;
vm.registerItemValueId = vm.selectedItem.selectedTag != null ? vm.selectedItem.selectedTag.registerItemValueId : null;
}
function getSearchResult(searchType, reCalculateHeigth) {
var searchCondition = ((vm.keyword != null && vm.keyword != "")
|| vm.folderId > 0
|| vm.fromDate != null
|| vm.toDate != null
|| (vm.registerItemId != null && vm.registerItemId != undefined && vm.registerItemId != 0))
&& stringValidationService.notContainSpecialCharacter(vm.keyword);
if (searchCondition) {
vm.searchConditionTrue = true;
vm.totalHits = specialCharacter.questionMark;
vm.totalFound = specialCharacter.questionMark;
if (vm.fromDate != null && typeof vm.fromDate != 'string') {
vm.fromDate = vm.fromDate.toUTCString().replace('UTC', 'GMT');
}
if (vm.toDate != null && typeof vm.toDate != 'string') {
vm.toDate = vm.toDate.toUTCString().replace('UTC', 'GMT');
}
if (vm.registerItemId) {
vm.searchInContents = true;
}
var searchRequestParams = {
keyword: vm.keyword,
searchInContents: vm.searchInContents,
searchType: searchType,
folderId: vm.folderId,
fromDate: vm.fromDate,
toDate: vm.toDate,
hasExpired: vm.hasExpired,
registerItemId: vm.registerItemValueId != null ? null : vm.registerItemId,
registerItemValueId: vm.registerItemValueId,
version: vm.version,
documentType: vm.documentType,
searchFilters: vm.searchParams,
showLoading: true
};
vm.searchType = searchType;
tabStateService.setCurrentStateType(tabStateType.searchTabState);
return $http.get(handbookRequests.SearchRequest, { params: searchRequestParams })
.then(function (response, status, headers, config) {
if (response.data.documents != null && (response.data.documents.length > 0)) {
updateAttachmentsForDocuments(response.data.documents);
documentService.getAgreeFilesForDocuments(response.data.documents);
vm.documents = response.data.documents;
vm.totalHits = vm.documents.length;
vm.totalFound = response.data.totalCount;
var showMoreItem = (vm.type == 3 || vm.type == 4);
} else {
vm.totalHits = 0;
vm.totalFound = 0;
if (vm.searchLogLevel == SEARCH_LOG_LEVEL.LOG_DOCUMENT_SELECTED_AND_0_HIT
|| vm.searchLogLevel == SEARCH_LOG_LEVEL.LOG_DOCUMENT_SELECTED_AND_0_HIT_AND_NO_SELECTION) {
insertLogWords(-1, user.userId, vm.keyword, $scope.selectedSearchType.id);
}
}
if (response.data.folders != null && response.data.folders.length > 0) {
vm.folders = response.data.folders;
angular.forEach(vm.folders, function (node) {
node.icon = getFolderClass(node.type)
});
vm.totalFolderHits = vm.folders.length;
}
showFolderSearch = (showFolderSearch && vm.folders.length > 0);
if (reCalculateHeigth) {
$timeout(function () {
calculateHeightForDocumentGrids();
}, 500);
}
});
} else {
vm.searchConditionTrue = false;
}
}
function getFolderClass(nodeType) {
switch (nodeType.toString()) {
case E.nodeTypes.Folder:
return 'folder-5-icon';
case E.nodeTypes.TopFolder:
return 'folder-6-icon';
case E.nodeTypes.DepartmentFolder:
return 'folder-7-icon';
case E.nodeTypes.RegionalFolder:
return 'folder-8-icon';
default:
return 'folder-5-icon';
}
};
function searchCompendiaDocuments(keyword) {
var searchUrl = null;
if (vm.type == 1) {
searchUrl = handbookRequests.CompendiaDocument_TitleSearch;
} else if (vm.type == 2) {
searchUrl = handbookRequests.CompendiaDocument_ContentSearch;
}
if (searchUrl == null) {
vm.compendiaDocuments = [];
return;
}
return $http.get(searchUrl, { params: { keyword: keyword, showLoading: true } })
.success(function (data) {
vm.compendiaDocuments = data;
showCompendiaSearch = (showCompendiaSearch && vm.compendiaDocuments.length > 0);
});
}
function getFolderInformation() {
if (vm.folderId != undefined && vm.folderId != 0) {
var folder = folderService.getFolder();
if (folder == undefined) {
folderService.getFolderById(vm.folderId).then(function (response) {
vm.folderName = response.data.name;
$scope.selectedNode = response.data;
});
}
else {
vm.folderName = folder.name;
$scope.selectedNode = folder;
}
}
};
function getSearchFilter() {
var filter = '';
if (vm.keyword != null && vm.keyword != '') {
filter = vm.keyword;
}
var folderIdNotNull = vm.folderId != 0 && vm.folderId != null,
fromDateNotNull = vm.fromDateDisplayed != null,
toDateNotNull = vm.toDateDisplayed != null,
registerItemIdNotNull = vm.selectedItem.selectedMetadata != null,
registerItemValueIdNotNull = vm.selectedItem.selectedTag != null,
startOption = specialCharacter.space + specialCharacter.openParenthesis,
endOption = specialCharacter.closeParenthesis,
seperator = specialCharacter.comma + specialCharacter.space,
colon = specialCharacter.space + specialCharacter.colon + specialCharacter.space;
if ($scope.selectedSearchType.id == 3) {
if (folderIdNotNull || fromDateNotNull || toDateNotNull || registerItemIdNotNull) {
if (folderIdNotNull) {
filter += startOption + globalResources.Chapter + colon + vm.folderName;
}
else {
filter += startOption;
}
if (fromDateNotNull && folderIdNotNull) {
filter += seperator + globalResources.From + colon + getDateStringFromInput(vm.fromDateDisplayed);
}
else if (fromDateNotNull) {
filter += globalResources.From + colon + getDateStringFromInput(vm.fromDateDisplayed);
}
if ((toDateNotNull && folderIdNotNull) || (toDateNotNull && fromDateNotNull)) {
filter += seperator + globalResources.To + colon + getDateStringFromInput(vm.toDateDisplayed) + endOption;
}
else if (toDateNotNull) {
filter += globalResources.To + colon + getDateStringFromInput(vm.toDateDisplayed) + endOption;
}
else {
filter += endOption;
}
}
} else if ($scope.selectedSearchType.id == 4) {
if (folderIdNotNull || registerItemIdNotNull) {
if (folderIdNotNull) {
filter += startOption + globalResources.Chapter + colon + vm.folderName;
}
else {
filter += startOption;
}
if (registerItemIdNotNull) {
filter += seperator + globalResources.Metadata + colon + vm.selectedItem.selectedMetadata.name;
}
if (registerItemValueIdNotNull) {
filter += seperator + globalResources.Tag + colon + vm.selectedItem.selectedTag.registerValue + endOption;
}
else {
filter += endOption;
}
}
}
return filter;
};
function loadFolderTree() {
$http.get(handbookRequests.GetFoldersRequest, { params: { 'id': null, 'showDocumentInTree': false } })
.success(function (data, status, headers, config) {
$scope.folderTree = data;
loadSearchType();
});
}
function loadSearchType() {
if (vm.type == 3) {
$scope.searchPlaceHolder = $scope.translation.AdvanceSearch;
$scope.selectedSearchType = $scope.searchTypes[2];
$scope.keyword = vm.keyword;
$scope.fromDate = vm.fromDateDisplayed;
$scope.toDate = vm.toDateDisplayed;
$scope.hasExpired = vm.hasExpired;
for (var i = 0; i < $scope.folderTree.length; i++) {
if (vm.folderId == $scope.folderTree[i].id) {
$scope.selectedNode = $scope.folderTree[i];
vm.folderName = $scope.selectedNode != null ? $scope.selectedNode.name : null;
break;
}
}
$scope.isAdvanceSearch = true;
$scope.isMetadataSearch = false;
} else if (vm.type == 2) {
$scope.searchPlaceHolder = $scope.translation.ContentSearch;
$scope.selectedSearchType = $scope.searchTypes[1];
$scope.keyword = vm.keyword;
$scope.isAdvanceSearch = false;
$scope.isMetadataSearch = false;
} else if (vm.type == 1) {
$scope.searchPlaceHolder = $scope.translation.TitleSearch;
$scope.selectedSearchType = $scope.searchTypes[0];
$scope.keyword = vm.keyword;
$scope.isAdvanceSearch = false;
$scope.isMetadataSearch = false;
} else if (vm.type == 4) {
$scope.searchPlaceHolder = $scope.translation.MetadataSearch;
$scope.keyword = vm.keyword;
$scope.selectedSearchType = $scope.searchTypes[3];
$scope.isAdvanceSearch = false;
$scope.isMetadataSearch = true;
for (var i = 0; i < $scope.folderTree.length; i++) {
if (vm.folderId == $scope.folderTree[i].id) {
$scope.selectedNode = $scope.folderTree[i];
vm.folderName = $scope.selectedNode != null ? $scope.selectedNode.name : null;
break;
}
}
initMetadataSearch();
}
$timeout(function () {
vm.searchFilter = getSearchFilter();
}, 700);
}
function initMetadataSearch() {
if (vm.registerItemId && vm.registerItemId != 0) {
getRegisterItems();
getMetadataTags(vm.registerItemId);
$timeout(function () {
if (vm.registerItemId && vm.registerItemId != 0) {
for (var i = 0; i < vm.initMetadata.metadatas.length; i++) {
var metadata = vm.initMetadata.metadatas[i];
if (vm.registerItemId == metadata.registerItemId) {
vm.selectedItem.selectedMetadata = metadata;
break;
}
}
if (vm.registerItemValueId && vm.registerItemValueId != 0) {
for (var i = 0; i < vm.initMetadata.tags.length; i++) {
var tag = vm.initMetadata.tags[i];
if (vm.registerItemValueId == tag.registerItemValueId) {
vm.selectedItem.selectedTag = tag;
break;
}
}
}
vm.startMetadata = 1;
vm.startTag = 1;
}
}, 500);
}
};
function onRowClick($event) {
favoriteService.setFavoriteNodeState({
isFavorited: false
});
documentService.goToDocument($event);
};
function loadByMaxSearchSize() {
vm.loadMoreClickedCounter = 1;
getSearchResult(E.searchType.Maximum);
};
function showLoadMoreLink(row) {
var _isShow = vm.documents.length < vm.totalFound && vm.loadMoreClickedCounter == 0;
var _isLastIndex = row.rowIndex == vm.documents.length - 1;
if (_isShow && _isLastIndex) {
return true;
}
return false;
};
function getDateStringFromInput(date) {
return date.getDate() + '.' + (date.getMonth() + 1) + '.' + date.getFullYear();
}
function updateAttachmentsForDocuments(documents) {
var documentIds = [];
for (var i = 0; i < documents.length; i++) {
if (documents[i].hasAttachment) {
documentIds.push(documents[i].id);
}
}
if (documentIds.length > 0) {
$http
.get('/api/Documents/GetAttachmentsForDocuments', { params: { documentIds: documentIds } })
.success(function (data) {
if (data && data.length > 0) {
data.forEach(function (x) {
x.itemId = x.extraId ? x.extraId : x.itemId;
});
}
for (var i = 0; i < documents.length; i++) {
if (documents[i].hasAttachment) {
documents[i].attachments = [];
for (var j = 0; j < data.length; j++) {
if (data[j].documentId == documents[i].id) {
documents[i].attachments.push(data[j]);
}
}
}
}
});
}
}
function calculateRemainingHeightForDocumentGrids() {
var heightOfTopBar = $('#handbook-nav').outerHeight(true);
var heightOfBreadcrumbs = $('.search-result-page > .clearfix').outerHeight(true);
var heightOfSearchButtons = $('.search-result-page > .button-group').outerHeight(true);
var heightOfSearchForm = $('.search-result-page > .form-button').outerHeight(true);
var heightOfAdvancedSearchForm = $scope.isAdvanceSearch ? $('.search-result-page .search-result-search-more').outerHeight(true) : 0;
var heightOfHandbookDocumentsTitle = $('.search-result-page .search-document-title-hit').outerHeight(true);
var heightOfCompendiaDocumentsTitle = !showCompendiaSearch
? 0 : $('.search-result-page .compendia-title-hit').outerHeight(true);
var heightOfFolderSearchTitle = !showFolderSearch
? 0 : $('.search-result-page .search-folder-title-hit').outerHeight(true);
return $(window).height() - heightOfTopBar - heightOfBreadcrumbs
- heightOfSearchButtons - heightOfSearchForm - heightOfAdvancedSearchForm
- heightOfHandbookDocumentsTitle
- heightOfCompendiaDocumentsTitle
- heightOfFolderSearchTitle;
}
$scope.$on('refeshHeightOfSearch', function (e, target) {
calculateHeightForDocumentGrids();
});
function calculateHeightForDocumentGrids() {
var heightOfShowAllLink = 25;
var documentHeight = 33;
var folderHeight = 33;
var remainingHeight = calculateRemainingHeightForDocumentGrids() - 30 - (showFolderSearch ? 30 : 0) - (showCompendiaSearch ? 30 : 0);// If 3 headers grid existed = 90
var realHeightOfCompendia = 0; // real height of Compendia Document Grid
var realHeightOfDocument; // Real height of Handbook Document Grid
var heightOfCompendia = vm.compendiaDocuments.length ? vm.compendiaDocuments.length * documentHeight : 0; // Height of Compendia Document Grid
var heightOfDocument = 0; // Height of Handbook Document Grid
var realHeightOfFolder = 0;
var heightOfFolder = vm.folders.length ? (vm.folders.length) * folderHeight : 0;
var calRemainingHeight = 0;
var percentHandbook = (showFolderSearch && showCompendiaSearch) ? 0.4 : 0.6;
var percentCompendia = !showCompendiaSearch ? 0 : (!showFolderSearch ? 1 - percentHandbook : 0.3);
var percentFolder = 1 - percentHandbook - percentCompendia;
if (!showFolderSearch && !showCompendiaSearch) {
heightOfDocument = remainingHeight ;
} else {
realHeightOfCompendia = showCompendiaSearch ? (vm.compendiaDocuments.length * documentHeight) : 0;
realHeightOfDocument = vm.documents.length ? (vm.documents.length) * documentHeight : documentHeight;
realHeightOfFolder = showFolderSearch ? (vm.folders.length) * folderHeight : 0;
if ((realHeightOfCompendia + realHeightOfDocument + realHeightOfFolder) > remainingHeight) {
var calHeigthCompendia = showCompendiaSearch ? (percentCompendia * remainingHeight - documentHeight) : 0;
heightOfCompendia = (calHeigthCompendia > realHeightOfCompendia) ? realHeightOfCompendia : calHeigthCompendia;
var calHeigthFolder = showFolderSearch ? (percentFolder * remainingHeight - folderHeight) : 0;
heightOfFolder = (calHeigthFolder > realHeightOfFolder) ? realHeightOfFolder : calHeigthFolder;
calRemainingHeight = remainingHeight - heightOfCompendia - heightOfFolder;
if (calRemainingHeight > realHeightOfDocument) {
heightOfDocument = realHeightOfDocument;
calRemainingHeight = remainingHeight - heightOfDocument - heightOfFolder - heightOfCompendia;
if (heightOfFolder < realHeightOfFolder && showFolderSearch) {
heightOfFolder = heightOfFolder + calRemainingHeight;
} else if (heightOfCompendia < realHeightOfCompendia && showCompendiaSearch) {
heightOfCompendia = heightOfCompendia + calRemainingHeight;
}
} else {
heightOfDocument = calRemainingHeight;
}
} else {
heightOfCompendia = realHeightOfCompendia;
heightOfDocument = realHeightOfDocument;
heightOfFolder = realHeightOfFolder;
}
}
if ((heightOfDocument < realHeightOfDocument)) {
heightOfDocument = heightOfDocument - heightOfShowAllLink;
}
$('.handbook-folders #gridController tbody').css('max-height', heightOfFolder);
$('.compendia-documents .content-wrapper').css('max-height', heightOfCompendia);
$('.handbook-documents #gridController tbody').css('max-height', heightOfDocument);
}
$(window).on('resize', function () {
calculateHeightForDocumentGrids()
});
function insertLogWords(documentId, employeeId, searchKey, searchType) {
if (!vm.doSearchDataMining) {
return;
}
vm.searchFilters = window.location.search;
if (vm.searchFilters && vm.searchFilters != '') {
if (documentId == -2) {
searchKey = decodeURI(vm.searchFilters.match("keyword=(.*)&search")[1]);
searchType = vm.searchFilters.substring(vm.searchFilters.length - 1);
}
return $http.post('/api/Search/LogSearchWords',
{
documentId: documentId,
employeeId: employeeId,
searchKey: searchKey,
searchType: searchType,
searchFilters: vm.searchFilters
}).then(function (data, status, headers, config) {
return true;
});
}
}
};
})();;
(function () {
var model = angular.module('managementModule', ['ngDraggable']);
model.controller(controllers.manageFavoritesController, ['$scope', '$http', '$state', '$modal', '$modalInstance', 'broadcastService', 'items',
function ($scope, $http, $state, $modal, $modalInstance, broadcastService, items) {
$scope.translation = globalResources;
$scope.folders = [];
$scope.forcedAndDepartmentFolders = [];
$scope.originalFoldersData = [];
$scope.documents = [];
$scope.originalDocumentsData = [];
$scope.emailSubsribed = [];
$scope.manageFavoriteTabs = manageFavoriteTabs;
$scope.currentTab = manageFavoriteTabs.folder;
$scope.isChanged = false;
$scope.isSortByAlphabet = true;
$scope.runOnce = false;
$scope.simpleSubscription = HandbookConfiguration.SimpleSubscription.toUpperCase() == 'TRUE' ? true : false;
initDataSource();
$scope.loadEmailSubscribedFolder = function () {
$http.get(handbookRequests.GetUserEmailSubscriptionsForFoldersAndDocuments)
.then(function (result) {
result.data.forEach(function (item) {
if (checkFolder(item.type)) {
if (item.isRecursiveFolder) {
item.subscriptionName = $scope.translation.FolderAndSubFolders;
} else {
item.subscriptionName = $scope.translation.FolderOnly;
}
}
});
$scope.emailSubsribed = result.data;
})
};
function checkFolder(type){
if(type == E.nodeTypes.Folder || type == E.nodeTypes.TopFolder || type == E.nodeTypes.DepartmentFolder || type == E.nodeTypes.RegionalFolder){
return true;
}
return false;
}
$scope.removeFolderFromFavorite = function (folder) {
var requestUrl = handbookRequests.RemoveFavoriteFolder + '/' + folder.id;
confirmAndDeleteItem(folder, requestUrl, $scope.folders, $scope.originalFoldersData, true);
};
$scope.removeDocumentFromFavorite = function (document) {
var requestUrl = handbookRequests.RemoveFavoriteDocument + '/' + document.id;
confirmAndDeleteItem(document, requestUrl, $scope.documents, $scope.originalDocumentsData, true);
};
$scope.removeEmailSubscribed = function (folder) {
var requestUrl = '';
if (checkFolder(folder.type)) {
if (folder.isRecursiveFolder) {
requestUrl = handbookRequests.RemoveEmailSubscription + '/' + folder.id;
} else {
requestUrl = handbookRequests.RemoveOnlyFolderFromEmailSubscription + '/' + folder.id;
}
} else {
requestUrl = handbookRequests.RemoveEmailSubscriptionDocument + '/' + folder.id;
}
confirmAndDeleteItem(folder, requestUrl, $scope.emailSubsribed, null, false);
};
$scope.onDragSuccess = function (data, evt) {
$scope.runOnce = false;
};
$scope.onDropComplete = function (index, obj, evt) {
if (!$scope.runOnce) { // to prevent this evt run twice
$scope.isChanged = true;
var dataSource = getSourceByItemType(obj.type);
removeBorderAndUpdateOrder(index, evt.element, obj, dataSource, false, false);
}
}
$scope.onDropCompleteForLastItem = function (index, obj, evt) {
$scope.isChanged = true;
var dataSource = getSourceByItemType(obj.type);
removeBorderAndUpdateOrder(index, evt.element, obj, dataSource, false, true);
}
$scope.onDropCompleteForTopItem = function (index, obj, evt) {
$scope.isChanged = true;
var dataSource = getSourceByItemType(obj.type);
removeBorderAndUpdateOrder(index, evt.element, obj, dataSource, true, false);
}
$scope.setCurrentTab = function (tab) {
$scope.currentTab = tab;
};
$scope.addCurrentActiveClass = function (id) {
removeOldActiveDragItem();
angular.element(prefix.hashbangPrefix + id).addClass(cssClass.currentDrag);
};
$scope.sortAlphabet = function () {
if (!$scope.isSortByAlphabet) {
$scope.isChanged = true;
var source = getSourceByCurrentTab(false);
setOrderByAlphabet(source);
}
};
$scope.cancel = function () {
$scope.folders = angular.copy($scope.originalFoldersData);
$scope.documents = angular.copy($scope.originalDocumentsData);
closeAndUpdateFavoriteTree();
};
$scope.saveAndClose = function () {
if ($scope.isChanged) {
var documents = reArrangeAndGetChangedSortOrderItems($scope.documents, $scope.originalDocumentsData);
var folders = reArrangeAndGetChangedSortOrderItems($scope.folders, $scope.originalFoldersData);
var updatedItems = documents.concat(folders);
$http.post(handbookRequests.UpdateFavoritesSortOrder, updatedItems)
.then(function () {
$scope.isChanged = false;
updateOriginalData();
closeAndUpdateFavoriteTree();
});
}
else {
$modalInstance.close();
}
};
function initDataSource() {
for (var index = 0; index < items.length; index++) {
if (isFolder(items[index].type)) {
if (!items[index].isForced && items[index].type != E.nodeTypes.DepartmentFolder) {
$scope.folders.splice(index, 0, items[index]);
$scope.originalFoldersData.splice(index, 0, angular.copy(items[index]));
}
else {
$scope.forcedAndDepartmentFolders.splice(index, 0, items[index]);
}
}
else {
$scope.documents.splice(index, 0, items[index]);
$scope.originalDocumentsData.splice(index, 0, angular.copy(items[index]));
}
if (items[index].sort > 0) {
$scope.isSortByAlphabet = false;
}
}
};
function isFolder(type) {
return type > E.nodeTypes.ShortcutDocument;
};
function confirmAndDeleteItem(object, requestUrl, dataSource, originalDataSource, isUpdateFavoriteTree) {
var modalInstance = $modal.open({
templateUrl: paths.ConfirmationView,
controller: controllers.confirmController,
resolve: {
item: function () {
return object.name;
}
}
});
modalInstance.result.then(function (isConfirm) {
if (isConfirm) {
$http.post(requestUrl)
.then(function () {
//remove item in manage window
dataSource.splice($.inArray(object, dataSource), 1);
//remove item in original data
if (originalDataSource != null) {
removeItemFromList(object.id, originalDataSource);
}
//remove item in favorite tree
if (isUpdateFavoriteTree) {
broadcastToUpdateFavoriteTree(object);
}
});
}
});
};
function removeItemFromList(id, dataSource) {
for (var index = 0; index < dataSource.length; index++) {
if (dataSource[index].id == id) {
dataSource.splice(index, 1);
break;
}
}
};
function removeOldActiveDragItem() {
var oldActive = angular.element.find(elementClass.currentDrag);
if (oldActive.length > 0) {
oldActive.forEach(function (element) {
var css = element.className.replace(' ' + cssClass.currentDrag, '');
element.className = css;
});
}
};
function broadcastToUpdateFavoriteTree(item) {
var target = {
data: {
id: item.id,
name: item.name,
type: item.type,
isDocument: !isFolder(item.type)
},
requestType: requestType.removeRequest
};
broadcastService(broadcastType.favoriteTarget, target);
};
function removeBorderAndUpdateOrder(index, element, object, dataSource, isTop, isBottom) {
element.removeClass(cssClass.dragEnter);
if (isTop || isBottom) {
removeItemFromList(object.id, dataSource);
if (isTop) {
dataSource.splice(0, 0, object);
}
else {
dataSource.splice(dataSource.length, 0, object);
}
}
else {
var moveObjectIndex = dataSource.indexOf(object);
if (index != moveObjectIndex) {
removeItemFromList(object.id, dataSource);
}
if (index > moveObjectIndex) {
dataSource.splice(index, 0, object); //move down
}
if (index < moveObjectIndex) {
dataSource.splice(index + 1, 0, object); //move up
}
}
$scope.runOnce = true;
removeOldActiveDragItem();
};
function getSourceByItemType(type) {
if (isFolder(type)) {
return $scope.folders;
} else {
return $scope.documents;
}
};
function getSourceByCurrentTab(isOriginalSource) {
if ($scope.currentTab == manageFavoriteTabs.folder) {
if (isOriginalSource) {
return $scope.originalFoldersData;
}
else {
return $scope.folders;
}
}
else if ($scope.currentTab == manageFavoriteTabs.document) {
if (isOriginalSource) {
return $scope.originalDocumentsData;
}
else {
return $scope.documents;
}
}
};
function reArrangeAndGetChangedSortOrderItems(dataSource, originalDataSource) {
var changedItems = [];
for (var index = 0; index < dataSource.length; index++) {
dataSource[index].sort = index;
if (dataSource[index].sort != originalDataSource[index].sort || dataSource[index].id != originalDataSource[index].id) {
changedItems.splice(changedItems.length, 0, dataSource[index]);
}
}
return changedItems;
};
function setOrderByAlphabet(dataSource) {
dataSource.sort(function (item1, item2) {
if (item1.name.toLowerCase() > item2.name.toLowerCase())
return 1;
else
return -1;
return 0;
});
for (var index = 0; index < dataSource.length; index++) {
dataSource[index].sort = 0;
}
};
function closeAndUpdateFavoriteTree() {
var source = $scope.documents.concat($scope.folders).concat($scope.forcedAndDepartmentFolders);
$modalInstance.close(source);
};
function updateOriginalData() {
$scope.originalFoldersData = angular.copy($scope.folders);
$scope.originalDocumentsData = angular.copy($scope.documents);
};
}]);
model.controller(controllers.confirmController, ['$scope', 'item', '$modalInstance', function ($scope, item, $modalInstance) {
$scope.translation = globalResources;
$scope.confirmMessage = String.format(globalResources.DeleteConfirmMessage, '"' + item + '"');
$scope.confirm = function () {
$modalInstance.close(true);
};
$scope.cancel = function () {
$modalInstance.close(false);
};
}]);
})();;
(function () {
'use strict';
angular.module('angularTreeview')
.controller('frontpageTreeview', treeViewController);
treeViewController.$inject = ['$scope', '$http', '$state', '$modal', '$location', '$timeout', 'favoriteService', 'treeNavigationService', 'localStorageService', 'documentService'];
function treeViewController($scope, $http, $state, $modal, $location, $timeout, favoriteService, treeNavigationService, localStorageService, documentService) {
$scope.showTreeFavorites = false;
$scope.showTreeDocument = false;
$scope.showTreeMyMostRead = false;
$scope.showTreeMyLastVisited = false;
$scope.showToggleSearchPanel = false;
$scope.documentList = {};
$scope.favoritesList = {};
$scope.myMostReadList = {};
$scope.myLastVisitedList = {};
var currentRecursiveIndex = 0;
var parents = [];
var previousRequest = { itemId: 0, itemType: '' };
var initOpeningDocumentGroupAsDefault = false;
$scope.init = function () {
if (HandbookConfiguration.OpenDocumentGroupAsDefault == "True") {
initOpeningDocumentGroupAsDefault = true;
$scope.loadWhenSelectMenu("Document");
}
};
$scope.clearSelect = function () {
if (HandbookConfiguration.IsAuthenticated == "True" && HandbookConfiguration.IsAnonymous != "True") {
if ($scope["favoritesTree"].currentNode) {
var currentItem = getItemById($scope["favoritesTree"].currentNode.id, $scope.favoritesList);
if (currentItem) {
currentItem.selected = undefined;
}
}
if ($scope["myMostReadTree"].currentNode && $scope["myMostReadTree"].currentNode.selected) {
$scope["myMostReadTree"].currentNode.selected = undefined;
}
if ($scope["myLastVisitedTree"].currentNode && $scope["myLastVisitedTree"].currentNode.selected) {
$scope["myLastVisitedTree"].currentNode.selected = undefined;
}
}
if ($scope["documentTree"].currentNode && $scope["documentTree"].currentNode.selected) {
$scope["documentTree"].currentNode.selected = undefined;
}
};
$scope.selectNodeHead = function (node) {
//check if type of selected node is in [1, 2, 3, 4] = [Document, LinkDocument, FileDocument, ShortcutDocument] refer to enum NodeType, we dont call request
if (!node.isLoaded && node.type > 4) {
switch (node.TreeFlag) {
case "Document":
$http.get(handbookRequests.GetFoldersRequest, { params: { 'Id': node.id } })
.success(function (data, status, headers, config) {
node.children = data;
node.isLoaded = true;
var isScroll = !$scope.showTreeFavorites && !$scope.showTreeMyMostRead && !$scope.showTreeMyLastVisited;
treeNavigationService.onChildrenLoaded(node, isScroll);
})
.error(function (data, status, headers, config) {
node.isLoaded = true;
});
break;
case "Favorites":
$http.get(handbookRequests.GetFoldersRequest, { params: { 'Id': node.id } })
.success(function (data, status, headers, config) {
node.children = data;
node.isLoaded = true;
})
.error(function (data, status, headers, config) {
node.isLoaded = true;
});
break;
}
}
};
$scope.IsFolderNode = function (node) {
return node.type == E.nodeTypes.Folder || node.type == E.nodeTypes.TopFolder || node.type == E.nodeTypes.DepartmentFolder || node.type == E.nodeTypes.RegionalFolder;
}
$scope.selectNodeLabel = function (node) {
angular.element('.selected:not(#' + node.id + '-label)').removeClass('selected');
$scope.clearSelect();
if (node.isFavorited != undefined && node.isFavorited == true) {
favoriteService.setFavoriteNodeState({ isFavorited: true, id: node.id, type: node.type });
} else {
favoriteService.setFavoriteNodeState({ isFavorited: false, id: node.id, type: node.type });
}
if (node.treeId == 'documentTree') {
//If we click on document tree we don't call Autohighlight function
treeNavigationService.setIsDocumentTree(true);
//Need to set timeout for set item selected
$timeout(function () {
if ($scope.IsFolderNode(node)) {
angular.element('#' + node.id + '-label-f').addClass('selected');
} else {
angular.element('#' + node.id + '-' + node.virtualHandbookId + '-label').addClass('selected');
}
});
}
if ($scope.IsFolderNode(node)) {
$state.go(handbookActions.FolderAction, { folderId: node.id });
} else {
documentService.goToDocument(node.id, node.defaultFieldView);
}
};
$scope.loadWhenSelectMenu = function (menuType) {
$scope.showHideMenuLeft(menuType);
switch (menuType) {
case "Document":
$scope.showTreeDocument = !$scope.showTreeDocument;
if ($scope.showTreeDocument) {
var node = angular.element('#treeDocuments .selected');
if (node && node.length > 0) {
$timeout(function () {
treeNavigationService.scrollToVisibleView(node);
});
}
}
if ($scope.showTreeDocument && $scope.documentList.length == undefined) {
$http.get(handbookRequests.GetFoldersRequest).
success(function (data, status, headers, config) {
$scope.documentList = data;
treeNavigationService.navigateToItemLocation(true);
if (isNaN(HandbookConfiguration.OpenDocumentGroupTopFolderAsDefault) == false && initOpeningDocumentGroupAsDefault) {
initOpeningDocumentGroupAsDefault = false;
if ($scope.documentList && $scope.documentList.length > 0) {
var node = null;
for (var i = 0; i < $scope.documentList.length; i++) {
if ($scope.documentList[i].id == parseInt(HandbookConfiguration.OpenDocumentGroupTopFolderAsDefault)) {
node = $scope.documentList[i];
break;
}
}
if (node != null) {
node.TreeFlag = "Document";
node.collapsed = true;
$scope.selectNodeHead(node);
}
}
}
});
}
break;
case "Favorites":
$scope.showTreeFavorites = !$scope.showTreeFavorites;
if ($scope.showTreeFavorites && $scope.favoritesList.length == undefined) {
$http.get(handbookRequests.GetFavoritesRequest).
success(function (data, status, headers, config) {
getFavoritesData(data);
});
}
break;
case "MyMostRead":
$scope.showTreeMyMostRead = !$scope.showTreeMyMostRead;
if ($scope.showTreeMyMostRead && $scope.myMostReadList.length == undefined) {
$http.get(handbookRequests.GetMostViewedDocumentsRequest).
success(function (data, status, headers, config) {
$scope.myMostReadList = data;
});
}
break;
case "MyLastVisited":
$scope.showTreeMyLastVisited = !$scope.showTreeMyLastVisited;
if ($scope.showTreeMyLastVisited && $scope.myLastVisitedList.length == undefined) {
$http.get(handbookRequests.GetRecentDocumentsRequest).
success(function (data, status, headers, config) {
$scope.myLastVisitedList = data;
});
}
break;
case "ToggleSearchPanel":
$scope.showToggleSearchPanel = true;
break;
}
};
$scope.showHideMenuLeft = function (menuType) {
$scope.showTreeFavorites = (menuType != "Favorites") ? false : $scope.showTreeFavorites;
$scope.showTreeMyMostRead = (menuType != "MyMostRead") ? false : $scope.showTreeMyMostRead;
$scope.showTreeMyLastVisited = (menuType != "MyLastVisited") ? false : $scope.showTreeMyLastVisited;
$scope.showTreeDocument = (menuType != "Document") ? false : $scope.showTreeDocument;
$scope.showToggleSearchPanel = (menuType != "ToggleSearchPanel") ? false : $scope.showToggleSearchPanel;
};
$scope.$on(broadcastType.onTreeNavigation, function (e, target) {
treeNavigationService.changeRoute();
var element = $location.path().split('/');
var requestParams = {
itemId: element[2],
itemType: element[1]
};
if (previousRequest.itemId == requestParams.itemId && requestParams.itemType == requestParams.itemType) {
return;
}
previousRequest = angular.copy(requestParams);
if (target.parents != null && target.parents.length > 0) {
navigateToCurrentItem(target.parents);
}
});
$scope.$on(broadcastType.collapseExpandSidebar, function (e, target) {
//Get flag to check user click on tree
//If click on document tree we will not call Autohighlight
var isDocumentTree = treeNavigationService.getIsDocumentTree();
if (target.navigateSideBar && !isDocumentTree) {
treeNavigationService.changeRoute();
navigateToCurrentItem(null);
} else {
treeNavigationService.setIsDocumentTree(false);
}
});
$scope.$on(broadcastType.onOpeningSidebarMenu, function (e, target) {
$scope.loadWhenSelectMenu(target.menu);
});
function navigateToCurrentItem(parents) {
if ($scope.showTreeDocument == false) {
if (!$scope.showTreeFavorites && !$scope.showTreeMyMostRead && !$scope.showTreeMyLastVisited) {
$scope.showTreeDocument = true;
$scope.showHideMenuLeft('Document');
}
if ($scope.documentList.length == undefined) {
$http.get(handbookRequests.GetFoldersRequest).
success(function (data, status, headers, config) {
$scope.documentList = data;
makeRecursiveParentRequest(parents);
});
} else {
makeRecursiveParentRequest(parents);
}
} else {
makeRecursiveParentRequest(parents);
}
};
function makeRecursiveParentRequest(parents) {
treeNavigationService.setDocumentsTree($scope["documentTree"]);
var isScroll = !$scope.showTreeFavorites && !$scope.showTreeMyMostRead && !$scope.showTreeMyLastVisited;
if (parents == null || parents.length == 0) {
var element = $location.path().split('/');
treeNavigationService.setNodeType($location.path().indexOf('document/') >= 0 ? treeNodeTypes.document : treeNodeTypes.folder);
var requestParams = {
itemId: element[2],
itemType: element[1]
};
if (requestParams.itemId) {
$http.get(handbookRequests.GetParentFoldersRequest, { params: requestParams })
.then(function (response, status, headers, config) {
var _parents = buildBreadcrumbs(response.data);
treeNavigationService.navigateToCurrentItem($scope.documentList, _parents, isScroll);
});
}
} else {
treeNavigationService.navigateToCurrentItem($scope.documentList, parents, isScroll);
}
}
function buildBreadcrumbs(data) {
var result = [];
var totalItem = data.length;
//move root to result array
for (var i = 0; i < data.length; i++) {
if (data[i].parentFolderId == null) {
result.push(data[i]);
data.splice(i, 1);
break;
}
}
//fill in the rest
var currentItem = 0;
while (result.length != totalItem && currentItem <= result.length) {
for (var i = 0; i < data.length; i++) {
if (result[currentItem].id == data[i].parentFolderId) {
result.push(data[i]);
data.splice(i, 1);
break;
}
}
currentItem++;
}
return result;
};
$scope.popupModal = function () {
var modalInstance = $modal.open({
templateUrl: paths.ManageFavoritesView,
controller: controllers.manageFavoritesController,
size: 'lg',
backdrop: 'static',
resolve: {
items: function () {
var data = angular.copy($scope.favoritesList);
return data;
}
}
});
modalInstance.result.then(function (items) {
if (items != undefined) {
$scope.favoritesList = items;
}
});
};
$scope.$on(broadcastType.documentOpenedTarget, function (e, target) {
if ($scope.myLastVisitedList.length != undefined) {
updateLastVisitedList(target);
}
});
$scope.$on(broadcastType.favoriteTarget, function (e, target) {
$scope.refreshFavorites();
});
function addOrRemoveFavoriteItem(target) {
if (target.requestType == requestType.addRequest) {
target.data.isFavorited = true;
if (target.data.type > E.nodeTypes.ShortcutDocument) {
var lastDocumentIndex = getLastFavoriteDocumentIndex();
$scope.favoritesList.splice(lastDocumentIndex, 0, target.data);
}
else {
$scope.favoritesList.splice(0, 0, target.data);
}
}
else {
if (target.data.isDocument) {
removeDocumentInfavoritesList(target);
} else {
removeFolderInfavoritesList(target)
}
// Remove favorite state
favoriteService.setFavoriteNodeState({
isFavorited: false, id: target.data.id, type: 0
});
}
};
function removeFolderInfavoritesList(target) {
for (var index = 0; index < $scope.favoritesList.length; index++) {
if ($scope.favoritesList[index].id == target.data.id && $scope.IsFolderNode($scope.favoritesList[index])) {
$scope.favoritesList.splice(index, 1);
break;
}
}
};
function removeDocumentInfavoritesList(target) {
for (var index = 0; index < $scope.favoritesList.length; index++) {
if ($scope.favoritesList[index].id == target.data.id && isDocumentNode($scope.favoritesList[index].type)) {
$scope.favoritesList.splice(index, 1);
break;
}
}
};
function isDocumentNode(type) {
return type == E.nodeTypes.Document || type == E.nodeTypes.LinkDocument || type == E.nodeTypes.FileDocument || type == E.nodeTypes.ShortcutDocument;
};
function getFavoritesData(data) {
for (var i = 0; i < data.length; i++) {
data[i].isFavorited = true;
}
$scope.favoritesList = data;
};
function getLastFavoriteDocumentIndex() {
var lastDocumentIndex = 0;
for (var index = 0; index < $scope.favoritesList.length; index++) {
if ($scope.favoritesList[index].type > E.nodeTypes.ShortcutDocument) {
lastDocumentIndex = index;
break;
}
}
return lastDocumentIndex;
};
function updateLastVisitedList(target) {
// Flag: Check my last visited tree is selected
var isSelectedTree = ($scope["myLastVisitedTree"].currentNode && $scope["myLastVisitedTree"].currentNode.selected);
//Update currentNode.selected = undefined if my last visited tree is selected
if (isSelectedTree) {
$scope["myLastVisitedTree"].currentNode.selected = undefined;
}
for (var index = 0; index < $scope.myLastVisitedList.length; index++) {
if ($scope.myLastVisitedList[index].id == target.id) {
$scope.myLastVisitedList.splice(index, 1);
break;
}
}
if ($scope.myLastVisitedList.length == HandbookConfiguration.RecentItemsCount) {
$scope.myLastVisitedList.splice($scope.myLastVisitedList.length - 1, 1);
}
$scope.myLastVisitedList.splice(0, 0, target);
//if my last visited tree is selected
if (isSelectedTree) {
$scope["myLastVisitedTree"].currentNode = $scope.myLastVisitedList[0];
$scope["myLastVisitedTree"].currentNode.selected = cssClass.selected;
}
};
function getItemById(id, source) {
for (var index = 0; index < source.length; index++) {
if (source[index].id == id) {
return source[index];
break;
}
}
return null;
};
$scope.refreshFavorites = function () {
$http.get(handbookRequests.GetFavoritesRequest).
success(function (data, status, headers, config) {
getFavoritesData(data);
});
};
$scope.refreshDocument = function () {
$http.get(handbookRequests.GetFoldersRequest).
success(function (data, status, headers, config) {
$scope.documentList = data;
treeNavigationService.navigateToItemLocation(true);
});
};
};
})();
;
(function () {
'use strict';
angular.module(modules.printingModule, [])
.controller(controllers.printingController, printController);
printController.$inject = ['$scope'];
function printController($scope) {
$scope.init = function () {
getGridSetting();
$scope.columnsSetting = commonGridSetting;
window.print();
};
};
})();;
(function () {
'use strict';
angular.module('handbookApp', [
'ui.bootstrap', 'angularTreeview', 'ui.router', 'ngGrid', 'ui.tree',
'placeholderShim', 'cfp.hotkeys', 'ngClipboard', 'dibari.angular-ellipsis', 'modelOptions', 'ngSanitize',
'accountModule', 'documentModule', 'customeDirectivesModule', 'PubSubModule', 'homeModule', 'chapterModule', 'configModule',
'documentFieldsModule', 'tabModule', 'managementModule', 'newsListModule', 'feedbackModule',
'advanceSearchModule', 'metadataSearchModule', 'smart-table', 'infinite-scroll', 'hearingFeedbackModule', 'NewsCategoryModule', 'documentHearingFieldsModule', 'compareWithEarlierVersionModule', 'fieldsContentWholeDocumentModule', 'rwdImageMaps', 'vs-repeat', 'documentCompareWithEarlierVersionModule'
]).provider('workersPool', function workersPoolProvider() {
var self = this;
window.workersPool = {};
window.workersPool['document-worker.js'] = new Worker('/workers/document-worker.js');
window.workersPool['meta-data-document-worker.js'] = new Worker('/workers/meta-data-document-worker.js');
this.$get = [function workersPoolFactory() {
return window.workersPool;
}];
});
angular.module('printingApp', ['printingModule']);
})();;
(function () {
var model = angular.module('feedbackModule', []);
model.controller(controllers.feedbackController, ['$scope', '$http', '$modal', 'feedBackService', '$modalInstance', 'model', '$sce',
function ($scope, $http, $modal, feedBackService, $modalInstance, model, $sce) {
vm = this;
$scope.globalResources = angular.copy(globalResources);
$scope.globalResources.Feedback_Message = $sce.trustAsHtml(globalResources.Feedback_Message);
$scope.globalResources.Feedback_Message1 = $sce.trustAsHtml(globalResources.Feedback_Message1);
$scope.globalResources.FeedBackCheckLabel = $sce.trustAsHtml(globalResources.FeedBackCheckLabel);
$scope.globalResources.FeedBackCheckLabelA = $sce.trustAsHtml(globalResources.FeedBackCheckLabelA);
$scope.globalResources.FeedBackCheckLabelB = $sce.trustAsHtml(globalResources.FeedBackCheckLabelB);
$scope.globalResources.FeedBackCheckLabelC = $sce.trustAsHtml(globalResources.FeedBackCheckLabelC);
$scope.globalResources.FeedBackCheckLabelD = $sce.trustAsHtml(globalResources.FeedBackCheckLabelD);
$scope.globalResources.FeedBackCheckLabelE = $sce.trustAsHtml(globalResources.FeedBackCheckLabelE);
$scope.globalResources.FeedBackCheckLabelF = $sce.trustAsHtml(globalResources.FeedBackCheckLabelF);
$scope.globalResources.FeedBackCheckLabelG = $sce.trustAsHtml(globalResources.FeedBackCheckLabelG);
$scope.globalResources.FeedBackCheckLabelH = $sce.trustAsHtml(globalResources.FeedBackCheckLabelH);
$scope.feedBackLabels = [
{ value: 1, text: $scope.globalResources.FeedBackCheckLabelA, positive: true, result: 0 },
{ value: 2, text: $scope.globalResources.FeedBackCheckLabelB, positive: true, result: 0 },
{ value: 1, text: $scope.globalResources.FeedBackCheckLabelD, positive: false, result: 0 },
{ value: 2, text: $scope.globalResources.FeedBackCheckLabelE, positive: false, result: 0 },
{ value: 4, text: $scope.globalResources.FeedBackCheckLabelF, positive: false, result: 0 },
{ value: 8, text: $scope.globalResources.FeedBackCheckLabelG, positive: false, result: 0 },
{ value: 16, text: $scope.globalResources.FeedBackCheckLabelH, positive: false, result: 0 }
];
if (HandbookConfiguration.RecipientsForFeedbackMail == E.RecipientsForFeedbackMail.OwnerOnly) {
$scope.isOwnerOnly = true;
}
vm.enableExtendedFeedback = HandbookConfiguration.EnableExtendedFeedback == 'True' ? true : false;
$scope.enableExtendedFeedback = vm.enableExtendedFeedback;
$scope.currentData = {
positive: model.positive,
feedbackMessage: '',
feedBack: 0,
sendAlsoToApprover: false
};
$scope.sendFeedback = function () {
if (vm.enableExtendedFeedback) {
const selectedOption = getSelectedFeedBack();
if (selectedOption) {
$scope.currentData.feedbackMessage = selectedOption + $scope.currentData.feedbackMessage;
}
if (!validFeedBack()) {
alert(globalResources.PleaseEnterFeedback);
return false;
}
}
return feedBackService
.sendFeedback(model.entityId, $scope.currentData)
.then(function (response) {
if (response) {
$modalInstance.close(true);
resetCurrentData();
alert(globalResources.ThanksForYourFeedback);
}
});
};
$scope.close = function () {
$modalInstance.close(true);
};
$scope.calculateFeedBack = function () {
var count = 0;
var feedBackLabels = $scope.feedBackLabels || [];
for (var i = 0; i < feedBackLabels.length; i++) {
var x = feedBackLabels[i];
if (parseInt(x.result) > 0) {
count = count + parseInt(x.result);
}
}
$scope.currentData.feedBack = count;
}
function validFeedBack() {
if ($scope.currentData.positive != null && ($scope.currentData.feedbackMessage || $scope.currentData.feedBack)) {
return true;
}
return false;
}
function resetCurrentData() {
$scope.currentData.positive = null;
$scope.currentData.feedbackMessage = '';
$scope.currentData.feedBack = 0;
$scope.currentData.sendAlsoToApprover = false;
}
function getSelectedFeedBack() {
var value = '';
var feedBackLabels = $scope.feedBackLabels || [];
for (var i = 0; i < feedBackLabels.length; i++) {
var x = feedBackLabels[i];
if (parseInt(x.result) > 0) {
value = value + x.text + '\n';
}
}
return value;
}
}]);
})();;
(function () {
'use strict';
angular.module('handbookApp')
.config(['$stateProvider', '$urlRouterProvider', '$locationProvider', routesConfig]);
function routesConfig($stateProvider, $urlRouterProvider, $locationProvider) {
$locationProvider.hashPrefix('!');
$locationProvider.html5Mode(true);
var internalPaths = window.paths;
var templateUrlFieldView = internalPaths.DocumentFields;
var controllerFieldView = 'DocumentFieldsController';
if (parseInt(HandbookConfiguration.DocumentViewOption) == 2) {
templateUrlFieldView = '/Document/fieldsContentWholeDocument';
controllerFieldView = 'FieldsContentWholeDocumentController';
}
// Now set up the states
$stateProvider
.state('tab', {
url: '/tab',
templateUrl: internalPaths.FrontpageHome,
controller: 'homeController',
controllerAs: 'vm',
data: {
title: globalResources.Home,
description: globalResources.HomeMetaDescription
}
})
.state(handbookActions.DocumentAction, {
url: handbookActionParameters.DocumentActionParameters,
templateUrl: internalPaths.DocumentHome,
controller: 'DocumentController',
controllerAs: 'vm',
data: {
title: globalResources.Document,
description: globalResources.DocumentMetaDescription
}
})
.state(handbookActions.DocumentFromFieldViewAction, {
url: handbookActionParameters.DocumentFromFieldViewActionParameters,
templateUrl: internalPaths.DocumentHome,
controller: 'DocumentController',
controllerAs: 'vm',
data: {
title: globalResources.Document,
description: globalResources.DocumentMetaDescription
}
})
.state(handbookActions.HearingAction, {
url: '/document/:documentId/hearing',
templateUrl: '/Document/HearingFeedback',
controller: 'HearingFeedbackController',
controllerAs: 'vm',
data: {
title: globalResources.Document,
description: globalResources.DocumentMetaDescription
}
})
.state('hearingFieldsContent', {
url: '/document/:documentId/hearingfields/:fieldId',
templateUrl: '/Document/HearingFieldsContent',
controller: 'DocumentHearingFieldsController',
controllerAs: 'vm',
data: {
title: globalResources.Document,
description: globalResources.DocumentMetaDescription
}
})
.state('hearingCompareWithEarlierVersion', {
url: '/documenthearing/:documentId/compareWithEarlierVersion',
templateUrl: '/Document/CompareWithEarlierVersion',
controller: 'CompareWithEarlierVersionController',
controllerAs: 'vm',
data: {
title: globalResources.Document,
description: globalResources.DocumentMetaDescription
}
})
.state('compareWithEarlierVersion', {
url: '/document/:documentId/compareWithEarlierVersion',
templateUrl: '/Document/DocumentCompareWithEarlierVersion',
controller: 'DocumentCompareWithEarlierVersionController',
controllerAs: 'vm',
data: {
title: globalResources.Document,
description: globalResources.DocumentMetaDescription
}
})
.state(handbookActions.FolderAction, {
url: handbookActionParameters.FolderActionParameters,
templateUrl: internalPaths.ChapterHome,
controller: 'chapterController',
controllerAs: 'vm',
data: {
title: globalResources.Folder,
description: globalResources.FolderMetaDescription
}
})
.state(handbookActions.HomeAction, {
url: handbookActionParameters.HomeActionParameters,
templateUrl: internalPaths.FrontpageHome,
controller: 'homeController',
controllerAs: 'vm',
data: {
title: globalResources.Home,
description: globalResources.HomeMetaDescription
}
})
.state(handbookActions.SearchResultAction, {
url: handbookActionParameters.SearchResultActionParameters,
templateUrl: internalPaths.ChapterSearch,
controller: 'searchController',
controllerAs: 'vm',
data: {
title: globalResources.Search,
description: globalResources.SearchMetaDescription
}
})
.state(handbookActions.DocumentFieldsAction, {
url: '/document/:documentId/fields/:fieldId',
templateUrl: templateUrlFieldView,
controller: controllerFieldView,
controllerAs: 'vm',
data: {
title: globalResources.Document,
description: globalResources.DocumentMetaDescription
}
})
.state(handbookActions.StartpageNews, {
url: handbookActionParameters.StartpageNewsParameters,
templateUrl: internalPaths.NewsDetais,
controller: 'NewsDetailsController',
controllerAs: 'vm',
data: {
title: globalResources.Home,
description: globalResources.HomeMetaDescription
}
}).state(handbookActions.UnsupportBrowser, {
url: '/unsupportedBrowser',
templateUrl: '/app/components/home/templates/unsupportedBrowser.html',
controller: 'homeController',
controllerAs: 'vm',
data: {
title: globalResources.Home,
description: globalResources.HomeMetaDescription
}
}).state(handbookActions.MyReadingReceiptsReport, {
url: "/myReadingReceipts/params?folderId&recursive",
templateUrl: '/app/components/home/templates/reportsView.html',
controller: 'reportsViewController',
controllerAs: 'vm',
data: {
title: globalResources.Home,
description: globalResources.HomeMetaDescription
}
}).state(handbookActions.NewsListAction, {
url: '/newsList/:pageIndex',
params: {
pageIndex: 1
},
templateUrl: '/app/components/home/view/newsList.html',
controller: 'NewsListController',
controllerAs: 'vm',
data: {
title: globalResources.Home,
description: globalResources.HomeMetaDescription
}
}).state(handbookActions.NewsCategoryAction, {
url: '/newscategory/:categoryId',
templateUrl: '/app/components/home/view/newsCategory.html',
controller: 'NewsCategoryController',
controllerAs: 'vm',
params: {
categoryId: '',
pageIndex: '1'
},
data: {
title: globalResources.Home,
description: globalResources.HomeMetaDescription
}
}).state('embedDocument', {
url: '/embed/document/:documentId',
templateUrl: internalPaths.DocumentHome,
controller: 'DocumentController',
controllerAs: 'vm',
data: {
title: '',
description: ''
}
}).state('embedDocumentField', {
url: '/embed/document/:documentId/field/:fieldId/:type',
templateUrl: internalPaths.DocumentFields,
controller: 'DocumentFieldsController',
controllerAs: 'vm',
params: {
type: 0
},
data: {
title: '',
description: ''
}
}).state('embedDocumentField1', {
url: '/embed/document/:documentId/field/:fieldId',
templateUrl: internalPaths.DocumentFields,
controller: 'DocumentFieldsController',
controllerAs: 'vm',
params: {
type: 0
},
data: {
title: '',
description: ''
}
}).state('annualCycleDetail', {
url: '/annualCycle/:id',
templateUrl: '/app/components/annualCycle/annualCycleDetail.html',
controller: 'annualCycleDetailController',
controllerAs: 'vm',
params: {
id: ''
},
data: {
title: globalResources.AnnualCycle,
description: ''
}
});
$urlRouterProvider.otherwise(handbookActionParameters.HomeActionParameters);
};
angular.module('handbookApp').run(['$rootScope', '$location', '$timeout', 'anchorService', 'documentService', 'broadcastService',
function ($rootScope, $location, $timeout, anchorService, documentService, broadcastService) {
$rootScope.$on('$locationChangeSuccess', function () {
$rootScope.actualLocation = $location.absUrl();
});
$rootScope.$on('$locationChangeStart', function (event, next, current) {
if (next && next.indexOf('fields') > 0) {
$location.$$absUrl = decodeURIComponent($location.$$absUrl);
var indexHash = $location.$$absUrl.indexOf('#');
if (indexHash > 0 && !$location.$$hash) {
var length = $location.$$absUrl.length - (indexHash + 1);
$location.$$hash = $location.$$absUrl.substr(indexHash + 1, length);
}
$location.$$url = decodeURIComponent($location.$$url);
}
});
$rootScope.$watch(function () { return $location.absUrl() }, function (newLocation, oldLocation) {
var isBackButton = false;
if ($rootScope.actualLocation === newLocation) {
isBackButton = true;
}
if ($location.hash() == null || $location.hash() == '') {
$timeout(function () {
var documentContent = angular.element('#document-content-identifier'),
folderContent = angular.element('#folder-content-identifier'),
newsContent = angular.element('#wrapper');
var anchorOject = anchorService.getAnchorObject();
var position = (anchorOject != null && isBackButton) ? anchorOject.position : 0;
if (documentContent && documentContent.length > 0) {
documentContent[0].scrollTop = position;
} else if (folderContent && folderContent.length > 0) {
folderContent[0].scrollTop = position;
} else if (newsContent && newsContent.length > 0) {
newsContent[0].scrollTop = position;
}
anchorService.setAnchorObject(0);
}, 100);
}
if (isBackButton) {
if (angular.element('#handbook-nav:visible').length == 0) {
documentService.showNormal();
broadcastService(broadcastType.toggleDocumentFullscreen, {});
}
}
if (!newLocation.includes(oldLocation) && !oldLocation.includes(newLocation)) {
angular.element('#treeDocuments span').removeClass('selected');
}
});
$rootScope.$on('$stateChangeSuccess', function (event, toState) {
// Sets the layout name, which can be used to display different layouts (header, footer etc.)
// based on which page the user is located
$rootScope.layout = toState.layout;
$rootScope.title = globalResources.Handbook + " - " + toState.data.title;
$rootScope.metaDescription = toState.data.description;
});
}]);
})();;
(function () {
var model = angular.module('metadataSearchModule', []);
model.controller(controllers.metadataController, ['$scope', '$state', '$http', '$document', 'folderService', '$modalInstance', 'quickSearchKeyword', 'metaDataService', 'broadcastService',
function ($scope, $state, $http, $document, folderService, $modalInstance, quickSearchKeyword, metaDataService, broadcastService) {
$scope.translation = globalResources;
$scope.currentData = {
advanceSearchKeyword: quickSearchKeyword,
folderName: '',
selectedFolderId: 0,
};
$scope.selectedItem = {
selectedMetadata: null,
selectedTag: null
};
$scope.initMetadata = {
metadatas: [],
tags: []
};
$scope.folderTree = [];
$scope.filterOptionNeededMessage = globalResources.FilterOptionNeededMessage;
$scope.showTreeDocument = false;
$scope.key_showRemoveIcon = false;
$scope.folder_showRemoveIcon = false;
$scope.initMetadataSearchData = initMetadataSearchData;
$scope.onMetadataSearch = onMetadataSearch;
$scope.close = close;
$scope.loadFolderTree = loadFolderTree;
$scope.hidePopupOnLostFocus = hidePopupOnLostFocus;
$scope.selectNodeHead = selectNodeHead;
$scope.selectNodeLabel = selectNodeLabel;
$scope.hideTooltip = hideTooltip;
$scope.clear_advKeyword = clear_advKeyword;
$scope.clear_advFolder = clear_advFolder;
function initMetadataSearchData() {
setTimeout(function () {
$('#adv_keyword').focus();
}, 1000);
//Init chapter base on url
var id = $state.params.folderId;
if (id != undefined && id > 0 && $state.current.name == 'folder') {
folderService.getFolderById(id).then(function (response) {
$scope.currentData.folderName = response.data.name;
$scope.currentData.selectedFolderId = response.data.id;
});;
}
$scope.key_showRemoveIcon = ($scope.currentData.advanceSearchKeyword != undefined && $scope.currentData.advanceSearchKeyword.length > 0);
getRegisterItems();
};
function getRegisterItems() {
metaDataService.getRegisterAndRegisterItems().then(function (data) {
if (data) {
$scope.initMetadata.metadatas = data;
}
});
};
$scope.$watch('selectedItem.selectedMetadata', function (selectedMetadata) {
$scope.selectedItem.selectedTag = null;
if (selectedMetadata != null && selectedMetadata != undefined) {
getMetadataTags(selectedMetadata.registerItemId);
}
});
function getMetadataTags(registerItemId) {
metaDataService.getMetadataTags(registerItemId).then(function (data) {
if (data) {
$scope.initMetadata.tags = data;
}
});
};
function onMetadataSearch() {
if ($scope.currentData.selectedFolderId != 0 || $scope.selectedItem.selectedRegister != null || $scope.currentData.advanceSearchKeyword != '') {
$scope.filterOptionNeededMessage = '';
$state.go(handbookActions.SearchResultAction, {
keyword: $scope.currentData.advanceSearchKeyword,
searchInContents: 1,
folderId: $scope.currentData.selectedFolderId,
registerItemId: $scope.selectedItem.selectedMetadata != null ? $scope.selectedItem.selectedMetadata.registerItemId : null,
registerItemValueId: $scope.selectedItem.selectedTag != null ? $scope.selectedItem.selectedTag.registerItemValueId : null,
type: 4
});
$modalInstance.close(true);
broadcastService(broadcastType.resetQuickSearchKeyword, null);
}
else {
$scope.filterOptionNeededMessage = globalResources.FilterOptionNeededMessage;
}
};
$document.bind('click', function (event) {
var isClickedElementChildOfPopup = $('.folder-search')
.find(event.target)
.length > 0;
if (isClickedElementChildOfPopup)
return;
$scope.showTreeDocument = false;
});
function close() {
$modalInstance.close(true);
}
function loadFolderTree() {
$scope.showTreeDocument = !$scope.showTreeDocument;
if ($scope.showTreeDocument) {
if ($scope.folderTree.length == undefined || $scope.folderTree.length == 0) {
$http.get(handbookRequests.GetFoldersRequest)
.success(function (data, status, headers, config) {
$scope.folderTree = data;
});
}
}
};
function hidePopupOnLostFocus() {
$scope.showTreeDocument = false;
};
function selectNodeHead(node) {
if (!node.isLoaded) {
$http.get(handbookRequests.GetSubfoldersRequest, { params: { 'folderId': node.id } })
.success(function (data, status, headers, config) {
node.children = data;
node.isLoaded = true;
})
.error(function (data, status, headers, config) {
node.isLoaded = true;
});
}
};
function selectNodeLabel(node) {
$scope.currentData.folderName = node.name;
$scope.currentData.selectedFolderId = node.id;
$scope.folder_showRemoveIcon = ($scope.currentData.selectedFolderId != undefined && $scope.currentData.selectedFolderId > 0);
folderService.setFolder(node);
hidePopupOnLostFocus();
hideTooltip();
};
function hideTooltip() {
if (angular.element('#btnAdvanceSearch').scope().tt_isOpen) {
angular.element('#btnAdvanceSearch').scope().tt_isOpen = false;
}
$scope.key_showRemoveIcon = ($scope.currentData.advanceSearchKeyword != undefined && $scope.currentData.advanceSearchKeyword.length > 0);
};
function clear_advKeyword() {
$scope.currentData.advanceSearchKeyword = '';
$scope.key_showRemoveIcon = false;
};
function clear_advFolder() {
$scope.currentData.folderName = '';
$scope.currentData.selectedFolderId = 0;
$scope.folder_showRemoveIcon = false;
};
}]);
})();;
(function () {
'use strict';
angular.module(modules.homeModule)
.controller('reportsViewController', reportsViewController);
reportsViewController.$inject = ['$state', '$stateParams', '$http'];
function reportsViewController($state, $stateParams, $http) {
var vm = this;
vm.filter = {
folderId: $stateParams.folderId != null ? $stateParams.folderId : null,
includeSubfolders: $stateParams.recursive
};
initialize();
function initialize() {
var screenHeight = window.innerHeight;
angular.element('#frameReport').height(screenHeight - 50);
vm.reportPage = '/Reports/Viewer.aspx?folderId=' + vm.filter.folderId + '&recursive=' + vm.filter.includeSubfolders;
};
$(window).on('resize', function () {
var screenHeight = window.innerHeight;
angular.element('#frameReport').height(screenHeight - 50);
});
};
})();;
(function () {
'use strict';
angular.module('servicesModule')
.controller('AddMembersController', controller);
controller.$inject = ['$modalInstance', '$http', '$scope', 'existedEmployees', 'titlePage', 'roleId', 'excludedQuitDepartmentId', 'folderId'];
function controller($modalInstance, $http, $scope, existedEmployees, titlePage, roleId, excludedQuitDepartmentId, folderId) {
var vm = this;
vm.translation = globalResources;
var infiniteScrollLoadsize = (HandbookConfiguration.InfiniteScrollLoadSize == "0" || HandbookConfiguration.InfiniteScrollLoadSize == 0) ?
0 :
parseInt(HandbookConfiguration.InfiniteScrollLoadSize);
vm.titlePage = titlePage;
vm.search = {
recursive: false,
pageSize: infiniteScrollLoadsize,
pageIndex: 0,
firstName: '',
lastName: '',
roleId: null,
excludedQuitDepartmentId: excludedQuitDepartmentId,
folderId: folderId
};
vm.selectedRole = {};
vm.getDepartment = getDepartment;
vm.saveChanges = saveChanges;
vm.cancel = cancel;
vm.existedEmployees = existedEmployees;
vm.excludedEmployees = [];
vm.nextPage = nextPage;
vm.searchEmployee = searchEmployee;
vm.onSelectRow = onSelectRow;
vm.checkAll = checkAll;
vm.onKeyUp = onKeyUp;
initialize();
function initialize() {
if (vm.existedEmployees) {
vm.existedEmployees.forEach(function (item) {
vm.excludedEmployees.push(item.id);
});
}
vm.total = 0;
vm.times = 0;
vm.currentRowIndex = 0;
vm.selectedEmployees = [];
vm.selectedEmployeesCount = 0;
$http.get('/api/Users/GetSecurityGroups', {})
.success(function (data, status, headers, config) {
vm.roles = data;
})
var promise = $http.post('/api/Users/GetEmployees',
{
recursive: vm.search.recursive,
pageSize: vm.search.pageSize,
pageIndex: vm.search.pageIndex,
departmentId: vm.search.departmentId,
firstName: vm.search.firstName,
lastName: vm.search.lastName,
roleId: vm.search.roleId,
excludedEmployeeId: vm.excludedEmployees,
excludedQuitDepartmentId: vm.search.excludedQuitDepartmentId,
folderId: vm.search.folderId
});
promise.success(function (data, status, headers, config) {
vm.employees = data;
});
};
$scope.$watch('vm.employees', function (data, oldData) { // This handler for initialize data.
var response = gridUtilities.lookupData(data, vm.rowCollection, vm.originalCollection, infiniteScrollLoadsize, vm.total, vm.currentRowIndex);
vm.total = response.total;
vm.currentRowIndex = response.currentIndex;
vm.rowCollection = response.data;
}, true);
function nextPage(tableState) {
if (infiniteScrollLoadsize == 0) {
vm.rowCollection = vm.employees;
vm.originalCollection = angular.copy(vm.rowCollection);
} else {
//if we reset (like after a search or an order)
if (tableState.pagination.start === 0) {
if (vm.rowCollection == null || vm.rowCollection.length == 0) {
getAPage(true);
$scope.$apply();
}
} else {
//we load more
getAPage(false);
$scope.$apply();
}
}
};
function getAPage(first) {
vm.search.pageIndex += 1;
vm.search.roleId = vm.selectedRole != null ? vm.selectedRole.id : null;
var promise = $http.post('/api/Users/GetEmployees',
{
recursive: vm.search.recursive,
pageSize: vm.search.pageSize,
pageIndex: vm.search.pageIndex,
departmentId: vm.search.departmentId,
firstName: vm.search.firstName,
lastName: vm.search.lastName,
roleId: vm.search.roleId,
excludedEmployeeId: vm.excludedEmployees,
folderId: vm.search.folderId
});
promise.success(function (data, status, headers, config) {
if (first) {
vm.rowCollection = data;
} else {
vm.rowCollection = vm.rowCollection.concat(data);
}
vm.originalCollection = angular.copy(vm.rowCollection);
});
}
function searchEmployee() {
vm.search.pageIndex = 1;
vm.search.roleId = vm.selectedRole != null ? vm.selectedRole.id : null;
var promise = $http.post('/api/Users/GetEmployees',
{
recursive: vm.search.recursive,
pageSize: vm.search.pageSize,
pageIndex: vm.search.pageIndex,
departmentId: vm.search.departmentId,
firstName: vm.search.firstName,
lastName: vm.search.lastName,
roleId: vm.search.roleId,
excludedEmployeeId: vm.excludedEmployees,
excludedQuitDepartmentId: vm.search.excludedQuitDepartmentId,
folderId: vm.search.folderId
});
promise.success(function (data, status, headers, config) {
vm.selectedEmployees = [];
vm.selectedEmployeesCount = 0;
vm.rowCollection = data;
vm.originalCollection = angular.copy(vm.rowCollection);
});
};
function onSelectRow(row) {
if (row.selected == true) {
vm.selectedEmployees.push(row);
if (row != null) {
vm.selectedEmployeesCount += 1;
}
} else {
if (row != null) {
if (vm.selectedEmployeesCount > 0) {
vm.selectedEmployeesCount -= 1;
}
}
vm.selectedEmployees.splice($.inArray(row, vm.selectedEmployees), 1);
}
};
function checkAll() {
vm.selectedEmployees = [];
vm.selectedEmployeesCount = 0;
if (vm.isAllSelected) {
vm.rowCollection.forEach(function (item) {
item.selected = true;
vm.selectedEmployees.push(item);
vm.selectedEmployeesCount += 1;
});
} else {
vm.rowCollection.forEach(function (item) {
item.selected = false;
});
}
};
function onKeyUp(e) {
if (e.which == 13) {
searchEmployee();
}
}
function getDepartment(department) {
if (department) {
vm.search.departmentId = department.id;
} else {
vm.search.departmentId = null;
}
}
function saveChanges() {
if (vm.selectedEmployees && vm.selectedEmployees.length != 0) {
$modalInstance.close(vm.selectedEmployees);
}
}
function cancel() {
$modalInstance.dismiss('cancel');
}
};
})();;
(function () {
'use strict';
angular.module(modules.chapterModule)
.controller('SendDocumentToHearingEmailController', controller);
controller.$inject = ['$modalInstance', 'objectEmailContent'];
function controller($modalInstance, objectEmailContent) {
var vm = this;
vm.translation = globalResources;
vm.email = {
subject: '',
body: ''
};
vm.saveChanges = saveChanges;
vm.cancel = cancel;
initialize();
function initialize() {
vm.email.subject = vm.translation.SubjectSendToHearingCreate;
var extraInfo = objectEmailContent.allowForwarding ? vm.translation.ExtraInfoSendToHearingCreate : '';
vm.email.body = String.format(vm.translation.BodySendToHearingCreate, objectEmailContent.documentName, objectEmailContent.dueDate, objectEmailContent.url, objectEmailContent.documentResponsible, extraInfo);
};
function saveChanges() {
if (vm.email.subject && vm.email.body) {
$modalInstance.close(vm.email);
}
}
function cancel() {
$modalInstance.dismiss('cancel');
}
};
})();;
(function () {
'use strict';
angular.module('documentHearingFieldsModule', [])
.controller("DocumentHearingFieldsController", documentHearingFieldsController);
documentHearingFieldsController.$inject = ['$http', '$sce', '$timeout', '$location', '$scope', '$rootScope', '$state', '$anchorScroll',
'documentService', 'anchorService', 'documentContentsSearchService', 'resizeService', '$stateParams', 'folderService'];
function documentHearingFieldsController($http, $sce, $timeout, $location, $scope, $rootScope, $state, $anchorScroll,
documentService, anchorService, documentContentsSearchService, resizeService, $stateParams, folderService) {
var vm = this;
vm.documentInformation = {};
vm.originalData = {};
vm.fieldId = -1;
vm.currentData = {};
vm.oldData = {};
vm.highlights = {
highlightText: '',
currentIndex: 0,
totalFound: 0
};
vm.loginUserId = user.userId;
var urlParams = $location.url().split('/');
vm.isEmbedUrl = false;
vm.typeHideHeader = false;
vm.documentId = $stateParams.documentId;
if (urlParams != null && urlParams.length > 0) {
vm.isEmbedUrl = urlParams[1] == 'embed';
if (vm.isEmbedUrl) {
vm.fieldId = urlParams[5];
vm.typeHideHeader = urlParams.length == 7 ? (urlParams[6] == '1') : false;
vm.documentId = urlParams[3];
}
}
vm.isShowMetadata = HandbookConfiguration.MetadataEnabled == 'True' ? true : false;
vm.isShowMetatagTab = HandbookConfiguration.ShowMetatagTab.toUpperCase() == 'TRUE' ? true : false;
vm.publishedVersion = HandbookConfiguration.PublishedVersion.toUpperCase() == 'TRUE' ? true : false;
vm.showContent = showContent;
vm.clearActive = clearActive;
vm.searchAndHighlightText = searchAndHighlightText;
vm.navForward = navForward;
vm.navBackward = navBackward;
vm.focusItem = focusItem;
vm.goBackDocumentHearing = goBackDocumentHearing;
vm.editCommentField = editCommentField;
vm.saveCommentField = saveCommentField;
vm.editCommentDraf = editCommentDraf;
vm.deleteCommentField = deleteCommentField;
vm.goBackDocumentHearing = goBackDocumentHearing;
vm.printPDF = printPDF;
vm.getNextSearchResultByEnter = getNextSearchResultByEnter;
vm.isFloatTitle = $(window).height() > HandbookConfiguration.DocumentTitleScreenHeight ? true : false;
initialize();
function initialize() {
processEmbedUrl();
//check and resize the view
resizeService.resizeView();
getDocument();
};
function processEmbedUrl() {
if (vm.isEmbedUrl) {
if (vm.typeHideHeader) {
angular.element('#documentHeader1Container').hide();
angular.element('#fieldTitle').hide();
}
}
}
function getDocument() {
if (vm.isShowMetadata && vm.isShowMetatagTab) {
getMetadataTab();
}
vm.currentDataPromise =
$http.get(handbookRequests.GetDocumentInformationForHearingRequest, { params: { 'documentId': vm.documentId } })
.then(function (result) {
createTooltipsRelatedDocument(result.data);
vm.oldData = result.data;
if (vm.oldData.description) {
vm.oldData.description = $sce.trustAsHtml(vm.oldData.description.replace(new RegExp(String.fromCharCode(13) + String.fromCharCode(10), 'g'), '
'));
}
vm.oldData.nodeType = convertToNodeType(vm.oldData.type);
if (vm.oldData.fieldContents != null) {
vm.oldData.fieldContents.forEach(function (fieldContent) {
if (!vm.oldData.fieldId) {
vm.oldData.fieldId = fieldContent.fieldId;
}
if (fieldContent.content) {
fieldContent.content = $sce.trustAsHtml(fieldContent.content);
}
if (fieldContent.description) {
fieldContent.description = $sce.trustAsHtml(fieldContent.description);
}
});
updateFields();
}
if (vm.isShowMetadata && vm.isShowMetatagTab) {
vm.oldData.metadatas = angular.copy(vm.metadataList);
formatMetadata();
}
angular.copy(vm.oldData, vm.originalData);
runServicesAfterInit();
vm.oldData.documentInformation = angular.copy(vm.oldData);
vm.oldData.confirmInformation = vm.currentData.confirmInformation;
vm.oldData.fieldId = $stateParams.fieldId;
buildDocumentObjectFromCurrentDocument(vm.oldData);
getHearingData();
$rootScope.title = globalResources.Handbook + " - " + result.data.documentName;
return vm.currentData;
})
.catch(function (result) {
vm.errorMessage = result.data;
vm.showError = true;
// Update currentData so favorite button work
vm.currentData.documentId = vm.documentId;
runErrorServicesAfterInit();
});
};
function runErrorServicesAfterInit() {
tabStateService.closeOpenedTabIfNoPrivilege(tabStateType.documentTabState);
}
function getMetadataTab() {
$http.get(handbookRequests.GetDocumentMetadataRequest, { params: { 'documentId': $stateParams.documentId } })
.then(function (result) {
vm.metadataList = result.data;
});
};
function formatMetadata() {
if (vm.isShowMetadata && vm.oldData.metadatas && vm.oldData.metadatas.length > 0 && vm.isShowMetatagTab) {
vm.oldData.metadatas.forEach(function (item) {
item.nameDisplay = $sce.trustAsHtml(item.registerName + ' - ' + item.registerItemName + ' - ' + item.registerValue);
});
}
}
function updateFields() {
if (vm.oldData.relatedAttachments && vm.oldData.relatedAttachments.length > 0) {
vm.oldData.relatedAttachments.forEach(function (x) {
x.itemId = x.extraId ? x.extraId : x.itemId;
});
}
var relatedDocumentAll = angular.copy(vm.oldData.relatedDocuments);
var relatedAttachmentAll = angular.copy(vm.oldData.relatedAttachments);
vm.oldData.isShowTopBoxContent = false;
for (var i = 0; i < vm.oldData.fieldContents.length; i++) {
var fieldContent = vm.oldData.fieldContents[i];
if (fieldContent.relatedAttachments && fieldContent.relatedAttachments.length > 0) {
fieldContent.relatedAttachments.forEach(function (x) {
x.itemId = x.extraId ? x.extraId : x.itemId;
});
}
if (checkShowFieldName(fieldContent)) {
vm.oldData.isShowTopBoxContent = true;
}
var relatedDocuments = fieldContent.relatedDocuments;
relatedDocumentAll = relatedDocumentAll.concat(relatedDocuments);
var relatedAttachments = fieldContent.relatedAttachments;
relatedAttachmentAll = relatedAttachmentAll.concat(relatedAttachments);
var relatedImageGroups = groupBy(fieldContent.images, function (item) {
return [item.verticalAlign];
});
var relatedBottomImages = [];
var relatedTopImages = [];
relatedImageGroups.forEach(function (item) {
if (item.key == parseInt(E.VerticalAlign.Top)) {
relatedTopImages = relatedTopImages.concat(item.value.data);
} else {
if (item.key == parseInt(E.VerticalAlign.Bottom)) {
relatedBottomImages = relatedBottomImages.concat(item.value.data);
}
}
});
fieldContent.relatedTopImages = relatedTopImages;
fieldContent.relatedBottomImages = relatedBottomImages;
}
};
function getHearingData() {
$http.get(handbookRequests.GetHearingForFeedbackRequest, {
params: {
'entityId': vm.oldData.entityId
}
})
.then(function (response, status, headers, config) {
if (response.data && response.data.id != null && response.data.id > 0) {
vm.hearing = response.data;
if (vm.hearing.description && vm.hearing.description != '') {
vm.hearing.description = $sce.trustAsHtml(vm.hearing.description.replace(/[\r\n\t]/g, "
"));
}
checkMemberHearing();
if (vm.oldData.approvalStatus == 3) {
vm.showComment = (!vm.hearing.public && vm.isMemberHearing) || vm.hearing.public;
} else {
vm.showComment = false;
vm.hearingClose = true;
}
if (vm.hearingClose) {
vm.closeHearings = vm.hearing.hearingMembers;
pubSub.publish(broadcastType.gridDataChanges, { id: 'closeHearing', data: vm.closeHearings }, { isForced: true });
} else {
vm.hearings = vm.hearing.hearingMembers;
}
vm.preHearingMembers = vm.hearing.preHearingMembers;
if (!vm.hearingCommentAfterResponse && !vm.isMyAssessment) {
vm.showComment = false;
}
adjustmentHearingComments(vm.hearing.hearingComments, vm.hearing.preHearingComments);
}
});
};
function checkShowFieldName(fieldContent) {
if (fieldContent.fieldName != '' && fieldContent.fieldName != undefined && fieldContent.isVisible && !fieldContent.isHideByBooklet) {
return true;
}
return false;
}
function adjustmentHearingComments(dataComments, preDataComments) {
var commentDocuments = [];
var commentFields = [];
if (dataComments.length > 0) {
dataComments.forEach(function (item) {
if (item.fieldId == null) {
commentDocuments.push(angular.copy(item));
} else {
commentFields.push(angular.copy(item));
}
});
}
vm.commentDocuments = commentDocuments;
var preCommentDocuments = [];
var preCommentFields = [];
if (preDataComments.length > 0) {
preDataComments.forEach(function (item) {
if (item.fieldId == null) {
preCommentDocuments.push(angular.copy(item));
} else {
preCommentFields.push(angular.copy(item));
}
})
}
vm.preCommentDocuments = preCommentDocuments;
if ((commentFields != null && commentFields.length > 0) || (preCommentFields != null && preCommentFields.length > 0)) {
for (var i = 0; i < vm.documentInformation.fieldContents.length; i++) {
var fieldContent = vm.documentInformation.fieldContents[i];
fieldContent.commentDocumentText = '';
if (commentFields != null && commentFields.length > 0) {
var comments = [];
commentFields.forEach(function (item) {
if (fieldContent.fieldId == item.fieldId) {
comments.push(angular.copy(item));
}
});
fieldContent.comments = comments;
}
if (preCommentFields != null && preCommentFields.length > 0) {
var preComments = [];
preCommentFields.forEach(function (item) {
if (fieldContent.fieldId == item.fieldId) {
preComments.push(angular.copy(item));
}
});
fieldContent.preComments = preComments;
}
if (fieldContent.fieldId == $stateParams.fieldId) {
vm.documentInformation.fieldContent = angular.copy(fieldContent);
}
}
} else {
for (var i = 0; i < vm.documentInformation.fieldContents.length; i++) {
var fieldContent = vm.documentInformation.fieldContents[i];
if (fieldContent.fieldId == $stateParams.fieldId) {
vm.documentInformation.fieldContent = angular.copy(fieldContent);
}
}
}
};
function convertToNodeType(documentType) {
switch (documentType.toString()) {
case E.documentTypes.Document:
return E.nodeTypes.Document;
case E.documentTypes.LinkDocument:
return E.nodeTypes.LinkDocument;
case E.documentTypes.FileDocument:
return E.nodeTypes.FileDocument;
case E.documentTypes.ShortcutDocument:
return E.nodeTypes.ShortcutDocument;
}
}
function setIconForDocument(data) {
data = data == null ? vm.currentData : data;
var icon = '';
switch (data.levelType.toString()) {
case E.HandbookLevelTypes.Enterprise:
icon = paths.DocumentLevelTypeEnterprise;
break;
case E.HandbookLevelTypes.Regional:
icon = paths.DocumentLevelTypeRegional;
break;
case E.HandbookLevelTypes.Local:
icon = paths.DocumentLevelTypeLocal;
break;
default:
icon = paths.DocumentLevelTypeEnterprise;
break;
}
data.docIcon = icon;
}
function buildDocumentObjectFromCurrentDocument(currentDocument) {
if (currentDocument) {
vm.documentInformation = angular.copy(currentDocument.documentInformation);
vm.currentData = angular.copy(currentDocument.documentInformation);
setIconForDocument(vm.documentInformation);
if (vm.currentData.description) {
vm.currentData.description = $sce.trustAsHtml(vm.currentData.description.toString());
}
if (vm.isShowMetadata && vm.currentData.metadatas && vm.currentData.metadatas.length > 0 && vm.isShowMetatagTab) {
vm.currentData.metadatas.forEach(function (item) {
item.nameDisplay = $sce.trustAsHtml(item.nameDisplay.toString());
});
}
if (vm.documentInformation) {
for (var i = 0; i < vm.documentInformation.fieldContents.length; i++) {
if (vm.documentInformation.fieldContents[i].fieldId == currentDocument.fieldId) {
vm.fieldId = currentDocument.fieldId;
vm.currentData.confirmInformation = currentDocument.confirmInformation;
vm.documentInformation.fieldContents[i].activeField = 'active';
if (vm.documentInformation.fieldContents[i].fieldName) {
vm.documentInformation.fieldName = $sce.trustAsHtml(vm.documentInformation.fieldContents[i].fieldName.toString());
}
if (vm.documentInformation.fieldContents[i].content) {
vm.documentInformation.content = $sce.trustAsHtml(vm.documentInformation.fieldContents[i].content.toString());
}
vm.documentInformation.relatedDocuments = vm.documentInformation.fieldContents[i].relatedDocuments;
vm.documentInformation.relatedAttachments = vm.documentInformation.fieldContents[i].relatedAttachments;
vm.documentInformation.relatedTopImages = vm.documentInformation.fieldContents[i].relatedTopImages;
vm.documentInformation.relatedBottomImages = vm.documentInformation.fieldContents[i].relatedBottomImages;
vm.documentInformation.fieldContent = vm.documentInformation.fieldContents[i];
}
else {
vm.documentInformation.fieldContents[i].activeField = '';
}
}
}
}
};
function showContent(fieldItem) {
vm.clearActive();
fieldItem.activeField = 'active';
if (fieldItem.fieldName) {
vm.documentInformation.fieldName = $sce.trustAsHtml(fieldItem.fieldName);
}
if (fieldItem.content) {
vm.documentInformation.content = $sce.trustAsHtml(fieldItem.content.toString());
} else {
vm.documentInformation.content = '';
}
vm.documentInformation.fieldContent = angular.copy(fieldItem);
vm.documentInformation.relatedDocuments = fieldItem.relatedDocuments;
vm.documentInformation.relatedAttachments = fieldItem.relatedAttachments;
vm.documentInformation.relatedTopImages = fieldItem.relatedTopImages;
vm.documentInformation.relatedBottomImages = fieldItem.relatedBottomImages;
vm.fieldId = fieldItem.fieldId;
angular.copy(vm.documentInformation, vm.originalData);
updateLocalAnchors();
};
function clearActive() {
for (var i = 0; i < vm.documentInformation.fieldContents.length; i++) {
vm.documentInformation.fieldContents[i].activeField = '';
}
};
function searchAndHighlightText() {
highlightTextInContent();
documentContentsSearchService.searchAndHighlightText(vm.highlights);
};
function navForward() {
documentContentsSearchService.navForward(vm.highlights);
};
function navBackward() {
documentContentsSearchService.navBackward(vm.highlights);
};
function highlightTextInContent() {
if (vm.documentInformation.content != undefined) {
angular.copy(vm.originalData, vm.documentInformation);
vm.documentInformation.content = documentContentsSearchService.searchAndHighlight(vm.documentInformation.content, vm.highlights.highlightText);
}
};
function updateLocalAnchors() {
$timeout(function () {
var domContent = angular.element('div.contentWithLayout');
anchorService.updateLocalAnchors(domContent, true);
scrollToAnchorIfExists();
});
}
function scrollToAnchorIfExists() {
var hash = $location.hash();
if (hash != '') {
$anchorScroll();
}
}
function runServicesAfterInit() {
updateLocalAnchors();
}
function checkMemberHearing() {
if (vm.hearing.hearingMembers.length > 0) {
vm.hearing.hearingMembers.forEach(function (item) {
if (item.employeeId == vm.loginUserId) {
vm.isMyAssessment = !item.hearingResponse && vm.currentData.approvalStatus == 3;
vm.isMemberHearing = true;
}
})
}
};
function focusItem(itemId) {
setTimeout(function () {
angular.element('#' + itemId).show();
angular.element('#' + itemId).focus();
}, 0);
};
function goBackDocumentHearing() {
$state.go(handbookActions.HearingAction, { documentId: vm.documentId });
}
function saveCommentField(fieldContent, isDraft) {
var request = {
entityId: vm.oldData.entityId,
hearingsId: vm.hearing.id,
comment: fieldContent.commentDocumentText,
isDraft: isDraft,
fieldId: fieldContent.fieldId
};
$http.post(handbookRequests.CreateHearingCommentRequest, request)
.success(function (data, status, headers, config) {
updateCommentsInformation(fieldContent, data);
fieldContent.comments = data;
fieldContent.commentDocumentText = '';
})
.error(function (data, status, headers, config) {
vm.hearingClose = true;
});
};
function editCommentField(comment, fieldContent, isDraft) {
var request = {
entityId: vm.oldData.entityId,
id: comment.id,
hearingsId: vm.hearing.id,
comment: comment.commentDocumentText,
isDraft: isDraft,
fieldId: fieldContent.fieldId
};
$http.post(handbookRequests.UpdateHearingCommentRequest, request)
.success(function (data, status, headers, config) {
updateCommentsInformation(fieldContent, data);
fieldContent.comments = data;
})
.error(function (data, status, headers, config) {
vm.hearingClose = true;
});
};
function updateCommentsInformation(fieldContent, data) {
for (var i = 0; i < vm.documentInformation.fieldContents.length; i++) {
if (vm.documentInformation.fieldContents[i].fieldId == fieldContent.fieldId) {
vm.documentInformation.fieldContents[i].comments = data;
break;
}
}
}
function deleteCommentField(comment, comments) {
var isConfirm = confirm(globalResources.DeleteHearingCommentConfirmMessage);
if (isConfirm) {
var request = {
entityId: vm.currentData.entityId,
id: comment.id
};
$http.post(handbookRequests.DeleteHearingCommentRequest, request)
.success(function (data, status, headers, config) {
comments.splice($.inArray(comment, comments), 1);
for (var i = 0; i < vm.documentInformation.fieldContents.length; i++) {
if (vm.documentInformation.fieldContents[i].fieldId == vm.documentInformation.fieldContent.fieldId) {
vm.documentInformation.fieldContents[i].comments.splice($.inArray(comment, vm.documentInformation.fieldContents.comments), 1);
break;
}
}
})
.error(function (data, status, headers, config) {
vm.hearingClose = true;
});
}
};
function editCommentDraf(comment) {
comment.showCommentDocument = true;
vm.focusItem('txtUpdateComment');
comment.commentDocumentText = comment.comment.replace(new RegExp('
', 'g'), '\n');
}
function printPDF() {
window.open(String.format("/Printing/PrintHearingFeedback?documentId={0}", vm.documentId));
};
function anchorClick(hash) {
if (vm.documentInformation.fieldContents.length == 1)
return;
var existedAnchor = false;
var domContent = angular.element('div.contentWithLayout');
angular.forEach(domContent.find('a[name]'), function (tag) {
if (hash.hash.indexOf(tag.attributes.name.value) != -1) {
existedAnchor = true;
}
});
if (existedAnchor)
return;
var field = null;
for (var i = 0; i < vm.documentInformation.fieldContents.length; i++) {
var fieldContent = vm.documentInformation.fieldContents[i];
if (fieldContent.fieldId == vm.fieldId || !fieldContent.content) {
continue;
}
var div = document.createElement('div');
div.innerHTML = fieldContent.content;
domContent = angular.element(div);
angular.forEach(domContent.find('a[name]'), function (tag) {
if (hash.hash.indexOf(tag.attributes.name.value) != -1) {
existedAnchor = true;
}
});
if (existedAnchor) {
field = fieldContent;
break;
}
}
if (field != null) {
showContent(field);
}
}
function getNextSearchResultByEnter(keyEvent) {
if (keyEvent.which == 13) {
navForward();
}
}
$scope.$on('anchorclick', function (e, target) {
anchorClick(target);
});
};
})();;
(function () {
'use strict';
angular.module('compareWithEarlierVersionModule', [])
.controller('CompareWithEarlierVersionController', controller);
controller.$inject = ['$http', '$state', '$sce', '$q', 'documentService'];
function controller($http, $state, $sce, $q, documentService) {
var vm = this;
vm.DocumentTitleResult = '';
vm.translation = globalResources
vm.DocumentTitleResult = '';
vm.currentDocumentId = $state.params.documentId;
vm.childDocumentId = $state.params.documentId;
vm.parentDocumentId = 0;
vm.originalData = {};
vm.fromVersions = [];
vm.toVersions = [];
vm.input = {
fromVersion: null,
toVersion: null
};
vm.enableDocumentExtention = HandbookConfiguration.EnableDocumentExtention == 'True' ? true : false;
vm.showCompareParentExtension = false;
vm.showCompareChildrenExtension = false;
initialize();
vm.printDocumentComparison = printDocumentComparison;
vm.changeFromVersion = changeFromVersion;
vm.changeToVersion = changeToVersion;
vm.viewCompareParentDocument = viewCompareParentDocument;
vm.viewCompareChildDocument = viewCompareChildDocument;
function initialize() {
if (vm.enableDocumentExtention) {
vm.parentDocumentId = 0;
var promises = [];
promises.push(documentService.getParentIdExtendDocument(vm.currentDocumentId));
promises.push(documentService.checkDocumentHaveToCompareById(vm.currentDocumentId));
$q.all(promises).then(function (result) {
var resultGetParentId = parseInt(result[0]);
if (resultGetParentId && resultGetParentId > 0) {
vm.parentDocumentId = resultGetParentId;
}
var resultCheckDocumentHaveToCompareById = result[1] == 'true' ? true : false;
if (!resultCheckDocumentHaveToCompareById) {
vm.currentDocumentId = vm.parentDocumentId;
}
vm.showCompareParentExtension = vm.parentDocumentId > 0;
vm.showCompareChildrenExtension = resultCheckDocumentHaveToCompareById;
generateComparisonResult(null, 0);
});
}
else {
generateComparisonResult(null, 0);
}
}
function generateComparisonResult(selectedVersion, isType) {
var params = {
params: {
documentId: vm.currentDocumentId,
fromVersion: vm.input.fromVersion,
toVersion: vm.input.toVersion,
showLoading: true
}
};
$http
.get('/api/Documents/GenerateComparisonResult', params)
.success(function (data) {
vm.data = data;
if (isType == 0) { // initialize
vm.originalData = angular.copy(vm.data);
getDataForComboVersions(selectedVersion, isType);
vm.input.fromVersion = parseInt(data.earlierVersionNumber);
vm.input.toVersion = parseInt(data.latestVersionNumber);
} else {
getDataForComboVersions(selectedVersion, isType);
}
vm.DocumentTitleResult = $sce.trustAsHtml(String.format('{0} - {1} - {2}: {3} - {4} {5} {6} {7}', globalResources.ComparisonResult,
data.comparisonNameResult, globalResources.DocId, vm.currentDocumentId,
globalResources.CommonGridColumns.Version, data.earlierVersionNumber, globalResources.And, data.latestVersionNumber));
vm.data.earlierVersionHtml = $sce.trustAsHtml(data.earlierVersionHtml);
vm.data.latestVersionHtml = $sce.trustAsHtml(data.latestVersionHtml);
vm.data.comparisonResult = $sce.trustAsHtml(data.comparisonResult);
})
.error(function (data, status, headers, config) {
vm.errorMessage = getErrorMessage(status);
});
}
function getDataForComboVersions(selectedVersion, isType) {
if (selectedVersion == null && isType > 0)
return;
var latestVersion = parseInt(vm.originalData.latestVersionNumber);
var fromVersions = [];
var toVersions = [];
switch (isType) {
case 0:// initialize
selectedVersion = latestVersion - 1;
for (var i = 0; i <= selectedVersion; i++) {
fromVersions.push({ id: i, name: i });
}
for (var j = selectedVersion + 1; j <= latestVersion; j++) {
toVersions.push({ id: j, name: j });
}
vm.fromVersions = angular.copy(fromVersions);
vm.toVersions = angular.copy(toVersions);
break;
case 1: // From version
for (var j = selectedVersion + 1; j <= latestVersion; j++) {
toVersions.push({ id: j, name: j });
}
vm.toVersions = angular.copy(toVersions);
break;
case 2: // to version
selectedVersion = selectedVersion - 1;
for (var i = 0; i <= selectedVersion; i++) {
fromVersions.push({ id: i, name: i });
}
vm.fromVersions = angular.copy(fromVersions);
break;
default:
}
}
function changeFromVersion() {
generateComparisonResult(vm.input.fromVersion, 1);
}
function changeToVersion() {
generateComparisonResult(vm.input.toVersion, 2);
}
$(window).on('resize', function () {
angular.element('.comparison-result').removeAttr('style');
angular.element('#resizeBar').removeAttr('style');
angular.element('.comparison-versions').removeAttr('style');
});
function printDocumentComparison() {
window.open(String.format('/Printing/PrintCompareWithEarlierVersion?documentId={0}&fromVersion={1}&toVersion={2}', vm.currentDocumentId, vm.input.fromVersion, vm.input.toVersion));
}
function viewCompareParentDocument() {
if (vm.currentDocumentId != vm.parentDocumentId) {
vm.currentDocumentId = vm.parentDocumentId;
generateComparisonResult(null, 0);
}
}
function viewCompareChildDocument() {
if (vm.currentDocumentId != vm.childDocumentId) {
vm.currentDocumentId = vm.childDocumentId;
generateComparisonResult(null, 0);
}
}
}
})();;
(function () {
'use strict';
angular.module('documentCompareWithEarlierVersionModule', [])
.controller('DocumentCompareWithEarlierVersionController', controller);
controller.$inject = ['$http', '$state', '$sce', '$scope', '$q', 'documentService'];
function controller($http, $state, $sce, $scope, $q, documentService) {
var vm = this;
vm.translation = globalResources
vm.DocumentTitleResult = '';
vm.currentDocumentId = $state.params.documentId;
vm.childDocumentId = $state.params.documentId;
vm.parentDocumentId = 0;
vm.originalData = {};
vm.fromVersions = [];
vm.toVersions = [];
vm.input = {
fromVersion: null,
toVersion: null
};
vm.advancedCompare = HandbookConfiguration.AdvancedCompare == 'True' ? true : false;
vm.enableDocumentExtention = HandbookConfiguration.EnableDocumentExtention == 'True' ? true : false;
vm.showCompareParentExtension = false;
vm.showCompareChildrenExtension = false;
initialize();
vm.printDocumentComparison = printDocumentComparison;
vm.changeFromVersion = changeFromVersion;
vm.changeToVersion = changeToVersion;
vm.viewCompareParentDocument = viewCompareParentDocument;
vm.viewCompareChildDocument = viewCompareChildDocument;
function initialize() {
window.addEventListener('resize', initCompareScrollEvent, true /*Capture event*/);
$scope.$on('$destroy', function () {
window.removeEventListener('resize', initCompareScrollEvent);
});
function initCompareScrollEvent() {
if (vm.advancedCompare) {
angular.element('.comparison-result').removeAttr('style');
angular.element('#resizeBar').removeAttr('style');
angular.element('.comparison-versions').removeAttr('style');
}
}
if (vm.enableDocumentExtention) {
vm.parentDocumentId = 0;
var promises = [];
promises.push(documentService.getParentIdExtendDocument(vm.currentDocumentId));
promises.push(documentService.checkDocumentHaveToCompareById(vm.currentDocumentId));
$q.all(promises).then(function (result) {
var resultGetParentId = parseInt(result[0]);
if (resultGetParentId && resultGetParentId > 0) {
vm.parentDocumentId = resultGetParentId;
}
var resultCheckDocumentHaveToCompareById = result[1] == 'true' ? true : false;
if (!resultCheckDocumentHaveToCompareById) {
vm.currentDocumentId = vm.parentDocumentId;
}
vm.showCompareParentExtension = vm.parentDocumentId > 0;
vm.showCompareChildrenExtension = resultCheckDocumentHaveToCompareById;
generateComparisonResult(null, 0);
});
}
else {
generateComparisonResult(null, 0);
}
}
function generateComparisonResult(selectedVersion, isType) {
var params = {
params: {
documentId: vm.currentDocumentId,
fromVersion: vm.input.fromVersion,
toVersion: vm.input.toVersion
}
};
$http
.get('/api/Documents/GenerateDocumentComparisonResult', params)
.success(function (data) {
vm.data = data;
if (vm.advancedCompare) {
if (isType == 0) { // initialize
vm.originalData = angular.copy(vm.data);
getDataForComboVersions(selectedVersion, isType);
vm.input.fromVersion = parseInt(data.earlierVersionNumber);
vm.input.toVersion = parseInt(data.latestVersionNumber);
} else {
getDataForComboVersions(selectedVersion, isType);
}
}
vm.DocumentTitleResult = $sce.trustAsHtml(String.format('{0} - {1} - {2}: {3} - {4} {5} {6} {7}', globalResources.ComparisonResult,
data.comparisonNameResult, globalResources.DocId, vm.currentDocumentId,
globalResources.CommonGridColumns.Version, data.earlierVersionNumber, globalResources.And, data.latestVersionNumber));
vm.data.earlierVersionHtml = $sce.trustAsHtml(data.earlierVersionHtml);
vm.data.latestVersionHtml = $sce.trustAsHtml(data.latestVersionHtml);
vm.data.comparisonResult = $sce.trustAsHtml(data.comparisonResult);
})
.error(function (data, status, headers, config) {
vm.errorMessage = getErrorMessage(status);
});
}
function getDataForComboVersions(selectedVersion, isType) {
if (selectedVersion == null && isType > 0)
return;
var latestVersion = parseInt(vm.originalData.latestVersionNumber);
var fromVersions = [];
var toVersions = [];
switch (isType) {
case 0:// initialize
selectedVersion = latestVersion - 1;
for (var i = 0; i <= selectedVersion; i++) {
fromVersions.push({ id: i, name: i });
}
for (var j = selectedVersion + 1; j <= latestVersion; j++) {
toVersions.push({ id: j, name: j });
}
vm.fromVersions = angular.copy(fromVersions);
vm.toVersions = angular.copy(toVersions);
break;
case 1: // From version
for (var j = selectedVersion + 1; j <= latestVersion; j++) {
toVersions.push({ id: j, name: j });
}
vm.toVersions = angular.copy(toVersions);
break;
case 2: // to version
selectedVersion = selectedVersion - 1;
for (var i = 0; i <= selectedVersion; i++) {
fromVersions.push({ id: i, name: i });
}
vm.fromVersions = angular.copy(fromVersions);
break;
default:
}
}
function changeFromVersion() {
generateComparisonResult(vm.input.fromVersion, 1);
}
function changeToVersion() {
generateComparisonResult(vm.input.toVersion, 2);
}
function printDocumentComparison() {
if (vm.advancedCompare) {
window.open(String.format('/Printing/PrintDocumentComparisonResultForLatestApproved?documentId={0}&fromVersion={1}&toVersion={2}', $state.params.documentId, vm.input.fromVersion, vm.input.toVersion));
} else {
window.open(String.format('/Printing/PrintDocumentComparisonResultForLatestApproved?documentId={0}', vm.currentDocumentId));
}
}
function viewCompareParentDocument() {
if (vm.currentDocumentId != vm.parentDocumentId) {
vm.currentDocumentId = vm.parentDocumentId;
vm.input.fromVersion = null;
vm.input.toVersion = null;
generateComparisonResult(null, 0);
}
}
function viewCompareChildDocument() {
if (vm.currentDocumentId != vm.childDocumentId) {
vm.currentDocumentId = vm.childDocumentId;
vm.input.fromVersion = null;
vm.input.toVersion = null;
generateComparisonResult(null, 0);
}
}
}
})();;
(function () {
'use strict';
angular.module('fieldsContentWholeDocumentModule', [])
.controller("FieldsContentWholeDocumentController", FieldsContentWholeDocumentController);
FieldsContentWholeDocumentController.$inject = ['$http','$state', '$sce', '$timeout', '$location', '$scope', '$rootScope', '$anchorScroll',
'documentService', 'anchorService', 'documentContentsSearchService', 'resizeService', '$stateParams', 'pubSub', 'folderService', 'treeNavigationService', '$q', 'tabStateService'];
function FieldsContentWholeDocumentController($http, $state, $sce, $timeout, $location, $scope, $rootScope, $anchorScroll,
documentService, anchorService, documentContentsSearchService, resizeService, $stateParams, pubSub, folderService, treeNavigationService, $q, tabStateService) {
var ignoreRichText = (HandbookConfiguration.LazyLoadRichText == 'True') ? true : false;
var vm = this;
//vm.documentInformation = {};
vm.originalData = {};
vm.fieldId = -1;
vm.currentData = {};
vm.highlights = {
highlightText: '',
currentIndex: 0,
totalFound: 0
};
vm.FolderLinks = [];
vm.menuFields = [];
var isIE = detectIE();
var urlParams = $location.url().split('/');
var isFieldActive;
vm.isEmbedUrl = false;
vm.typeHideHeader = false;
vm.documentId = $stateParams.documentId;
vm.hideGoToDocumentFields = true;
vm.addFavoriteRequest = handbookRequests.AddFavoriteDocument;
vm.removeFavoriteRequest = handbookRequests.RemoveFavoriteDocument;
if (urlParams != null && urlParams.length > 0) {
vm.isEmbedUrl = urlParams[1] == 'embed';
if (vm.isEmbedUrl) {
vm.fieldId = urlParams[5];
vm.typeHideHeader = urlParams.length == 7 ? (urlParams[6] == '1') : false;
vm.documentId = urlParams[3];
}
}
vm.urlDocument = window.location.origin + '/document/' + vm.documentId + '?preview=true';
vm.showDocumentLinkToBackend = HandbookConfiguration.ShowDocumentLinkToBackend == 'True' ? true : false;
vm.simpleSubscription = HandbookConfiguration.SimpleSubscription.toUpperCase() == 'TRUE' ? true : false;
vm.isShowMetadata = HandbookConfiguration.MetadataEnabled == 'True' ? true : false;
vm.isShowMetatagTab = HandbookConfiguration.ShowMetatagTab.toUpperCase() == 'TRUE' ? true : false;
vm.publishedVersion = HandbookConfiguration.PublishedVersion.toUpperCase() == 'TRUE' ? true : false;
vm.showContent = showContent;
vm.searchAndHighlightText = searchAndHighlightText;
vm.navForward = navForward;
vm.navBackward = navBackward;
vm.printDocumentField = printDocumentField;
vm.fullScreen = fullScreen;
vm.isFloatTitle = $(window).height() > HandbookConfiguration.DocumentTitleScreenHeight ? true : false;
vm.linkToDocumentManagement = linkToDocumentManagement;
vm.getNextSearchResultByEnter = getNextSearchResultByEnter;
vm.documentViewOption = parseInt(HandbookConfiguration.DocumentViewOption);
vm.isToggleSidebarFields = true;
vm.showSidebarFields = showSidebarFields;
vm.hideSidebarFields = hideSidebarFields;
vm.setStickyTitle = setStickyTitle;
vm.compareDocument = compareDocument;
vm.hideCompareButton = false;
initialize();
function initialize() {
window.location.replace('/document/' + $stateParams.documentId + '#' + $stateParams.fieldId)
};
function processEmbedUrl() {
if (vm.isEmbedUrl) {
if (vm.typeHideHeader) {
angular.element('#documentHeader1Container').hide();
angular.element('#fieldTitle').hide();
}
}
}
function linkToDocumentManagement() {
var backendUrl = HandbookConfiguration.BackendURL;
var lastChar = backendUrl.charAt(backendUrl.length - 1);
var commonAdd = lastChar == '/' ? '' : '/';
if (vm.backendIsDb4) {
var url = backendUrl + '&documentId=' + vm.documentId;
url = url.replace('gk=2', 'gk=1');
window.open(url, '_blank');
} else {
window.open(backendUrl + commonAdd + 'document/' + vm.documentId, '_blank');
}
};
function getDocument() {
if (vm.isShowMetadata && vm.isShowMetatagTab) {
getMetadataTab();
}
var params = {
params: {
'documentId': vm.documentId,
'ignoreRichText': ignoreRichText,
showLoading: true
}
};
vm.currentDataPromise =
$http.get(handbookRequests.GetDocumentInformationRequest, params)
.then(function (result) {
var fieldIdTemp = vm.isEmbedUrl ? vm.fieldId : $stateParams.fieldId;
vm.isFavoriteNodeSelected = true;
createTooltipsRelatedDocument(result.data);
vm.currentData = result.data;
if (vm.currentData.description) {
vm.currentData.description = $sce.trustAsHtml(vm.currentData.description.replace(new RegExp(String.fromCharCode(13) + String.fromCharCode(10), 'g'), '
'));
}
vm.currentData.nodeType = convertToNodeType(vm.currentData.type);
var fieldContentTemp = null;
if (vm.currentData.fieldContents != null) {
var richTextRequests = [];
vm.currentData.fieldContents.forEach(function (fieldContent) {
if (fieldContent.fieldId == fieldIdTemp) {
fieldContentTemp = fieldContent;
}
if (fieldContent.description) {
fieldContent.description = $sce.trustAsHtml(fieldContent.description);
}
vm.menuFields.push("Id" + fieldContent.fieldId);
if (ignoreRichText && fieldContent.fieldType == 6 && fieldContent.fieldContentId) {
var params = {
params: {
id: fieldContent.fieldContentId
}
}
var getRichText = $http.get('/api/documents/getRichText', params).then(function (response) {
if (response.data && response.data.content) {
fieldContent.content = $sce.trustAsHtml(response.data.content);
fieldContent.isVisible = true;
}
});
richTextRequests.push(getRichText);
} else {
if (fieldContent.content) {
fieldContent.content = $sce.trustAsHtml(fieldContent.content);
}
}
});
if (ignoreRichText) {
$q.all(richTextRequests).then(function () {
angular.copy(vm.currentData, vm.originalData);
$timeout(function () {
showContent(fieldIdTemp, fieldContentTemp);
});
$timeout(function () {
runServicesAfterInit();
}, 2000);
});
}
updateFields();
if (vm.currentData.relatedDocuments.length > 0) {
vm.menuFields.push("IdrelatedDocument");
}
if (vm.currentData.relatedAttachments.length > 0) {
vm.menuFields.push("Idattachment");
}
}
if (vm.isShowMetadata && vm.isShowMetatagTab) {
vm.currentData.metadatas = angular.copy(vm.metadataList);
formatMetadata();
}
documentService.setDocuments(null); // clear service
vm.showDocumentLinkToBackend = vm.showDocumentLinkToBackend &&
(vm.currentData.hasEditPermission || vm.currentData.hasApprovalPermission);
$rootScope.title = globalResources.Handbook + " - " + result.data.documentName;
angular.copy(vm.currentData, vm.originalData);
vm.currentData.fieldId = fieldIdTemp;
if(!ignoreRichText || !vm.currentData.fieldContents){
$timeout(function () {
showContent(fieldIdTemp, fieldContentTemp);
});
$timeout(function () {
runServicesAfterInit();
}, 2000);
}
setTimeout(function () { stickyTitle(); }, 0);
updateAfterCurrentDataChanged();
vm.isCompare = (HandbookConfiguration.EnableCompare.toUpperCase() == 'TRUE' && vm.currentData.version > 0) ? true : false;
if (vm.currentData.type == E.documentTypes.LinkDocument || vm.currentData.type == E.documentTypes.FileDocument) {
vm.hideCompareButton = true;
}
return vm.currentData;
})
.catch(function (result) {
vm.errorMessage = result.data;
vm.showError = true;
// Update currentData so favorite button work
vm.currentData.documentId = vm.documentId;
});
};
function scrollAffectFieldSelected() {
var lastId,
topMenuDocument = $("#document-top-menu-identifier"),
topMenuDocumentHeight = topMenuDocument.outerHeight(),
idCurrent = '';
for (var i = 0; i < vm.menuFields.length; i++) {
var item = "#" + vm.menuFields[i];
if ($(item).length) {
var top = $(item).offset().top;
if ((top < topMenuDocumentHeight + 250) && (top > 0)) {
idCurrent = vm.menuFields[i];
break;
}
}
}
if ((lastId !== idCurrent) && (idCurrent != '')) {
lastId = idCurrent;
angular.forEach(vm.currentData.fieldContents, function (fieldContent) {
fieldContent.activeField = '';
});
switch (lastId) {
case 'Idattachment':
vm.activeAttachments = true;
break;
case 'IdrelatedDocument':
vm.activeRelatedDocuemnts = true;
break;
default:
var fieldId = lastId.substring(2);
for (var i = 0; i < vm.currentData.fieldContents.length; i++) {
if (vm.currentData.fieldContents[i].fieldId == parseInt(fieldId)) {
$scope.$apply(function () {
vm.currentData.fieldContents[i].activeField = 'active';
});
break;
}
}
}
}
}
function setStickyTitle() {
setTimeout(function () { stickyTitle(); }, 0);
}
function stickyTitle(height) {
var title = document.querySelector('#documentTitle');
var titlePosition = title.getBoundingClientRect();
var content = document.querySelector('#document-content-identifier');
if (!content) {
return;
}
var contentPosition = content.getBoundingClientRect();
var placeholder = $("#placeholderTitleId")
if (placeholder.length > 0) {
placeholder.remove();
}
placeholder = document.createElement('div');
placeholder.id = "placeholderTitleId";
placeholder.style.height = titlePosition.height + 'px';
var isAdded = false;
var heightToFloat = 0, currentPosition = 0;
heightToFloat = contentPosition.top + 50;
var heightScroll = height ? height : $('#document-content-identifier').height();
if ($(window).height() > HandbookConfiguration.DocumentTitleScreenHeight) {
removeStickyTitle();
$('#document-content-identifier').scroll(function () {
var scrollTop = $('#document-content-identifier').scrollTop();
var isfullScreen = $('#document-content-identifier').hasClass('fullScreen-height');
currentPosition = isfullScreen ? scrollTop : contentPosition.top + scrollTop;
if (currentPosition >= heightToFloat && !isAdded) {
title.classList.add('sticky');
document.querySelector('#document-content-identifier').classList.add('scrolling');
title.parentNode.insertBefore(placeholder, title);
isAdded = true;
var contentWidth = $('#document-content-identifier').width() + 10;
if (!isfullScreen) {
$('#documentTitle').css('top', contentPosition.top);
$('#documentTitle').css('width', contentWidth);
$('#documentTitle').css('background-color', 'white');
} else {
$('#documentTitle').css('width', contentWidth);
$('#documentTitle').css('background-color', 'white');
}
heightScroll = !isfullScreen ? heightScroll : screen.availHeight - 100;
$('#document-content-identifier').css('margin-top', '85px');
$('#document-content-identifier').css('height', heightScroll -85);
} else if (currentPosition < heightToFloat && isAdded) {
title.classList.remove('sticky');
document.querySelector('#document-content-identifier').classList.remove('scrolling');
$('#documentTitle').css('top', '');
$('#documentTitle').css('width', '');
$('#documentTitle').css('background-color', '');
$('#documentTitle').css('margin-left', '');
title.parentNode.removeChild(placeholder);
isAdded = false;
$('#document-content-identifier').css('margin-top', '0px');
$('#document-content-identifier').css('height', heightScroll);
} else {
//$('#document-content-identifier').css('height', heightScroll);
}
if (!isFieldActive) {
scrollAffectFieldSelected();
}
});
}
else {
$('#document-content-identifier').scroll(function () {
var isfullScreen = $('#document-content-identifier').hasClass('fullScreen-height');
currentPosition = isfullScreen ? $('#document-content-identifier').scrollTop() : contentPosition.top + $('#document-content-identifier').scrollTop();
if (!isFieldActive) {
scrollAffectFieldSelected();
}
});
}
}
function runInitforIE(height) {
if ($(window).height() > HandbookConfiguration.DocumentTitleScreenHeight) {
var title = document.querySelector('#documentTitle');
var titlePosition = title.getBoundingClientRect();
var content = document.querySelector('#document-content-identifier');
var contentPosition = content.getBoundingClientRect();
var placeholder = $("#placeholderTitleId")
if (placeholder.length > 0) {
placeholder.remove();
}
placeholder = document.createElement('div');
placeholder.id = "placeholderTitleId";
var heightToFloat = 0, currentPosition = 0;
heightToFloat = contentPosition.top + 50;
var heightScroll = height ? height: $('#document-content-identifier').height();
var scrollTop = $('#document-content-identifier').scrollTop();
var isfullScreen = $('#document-content-identifier').hasClass('fullScreen-height');
currentPosition = isfullScreen ? scrollTop : contentPosition.top + scrollTop;
if (currentPosition >= heightToFloat) {
title.classList.add('sticky');
document.querySelector('#document-content-identifier').classList.add('scrolling');
title.parentNode.insertBefore(placeholder, title);
var contentWidth = $('#document-content-identifier').width() + 10;
if (!isfullScreen) {
$('#documentTitle').css('top', contentPosition.top);
$('#documentTitle').css('width', contentWidth);
$('#documentTitle').css('background-color', 'white');
} else {
$('#documentTitle').css('width', contentWidth);
$('#documentTitle').css('background-color', 'white');
}
heightScroll = !isfullScreen ? heightScroll : screen.availHeight - 100;
$('#document-content-identifier').css('margin-top', '90px');
$('#document-content-identifier').css('height', heightScroll - 90);
}
}
}
function removeStickyTitle() {
var title = document.querySelector('#documentTitle');
title.classList.remove('sticky');
$('#documentTitle').css('top', '');
$('#documentTitle').css('width', '');
$('#documentTitle').css('background-color', '');
$('#documentTitle').css('margin-left', '');
var placeholder = document.querySelector('#placeholderTitleId');
if (placeholder != null) {
title.parentNode.removeChild(placeholder);
}
document.querySelector('#document-content-identifier').classList.remove('scrolling');
$('#document-content-identifier').unbind('scroll');
}
function getMetadataTab() {
$http.get(handbookRequests.GetDocumentMetadataRequest, { params: { 'documentId': $stateParams.documentId } })
.then(function (result) {
vm.metadataList = result.data;
});
};
function formatMetadata() {
if (vm.isShowMetadata && vm.currentData.metadatas && vm.currentData.metadatas.length > 0 && vm.isShowMetatagTab) {
vm.currentData.metadatas.forEach(function (item) {
item.nameDisplay = $sce.trustAsHtml(item.registerName + ' - ' + item.registerItemName + ' - ' + item.registerValue);
});
}
}
function updateFields() {
var relatedDocumentAll = angular.copy(vm.currentData.relatedDocuments);
var relatedAttachmentAll = angular.copy(vm.currentData.relatedAttachments);
vm.currentData.isShowTopBoxContent = false;
for (var i = 0; i < vm.currentData.fieldContents.length; i++) {
var fieldContent = vm.currentData.fieldContents[i];
if (checkShowFieldName(fieldContent)) {
vm.currentData.isShowTopBoxContent = true;
}
var relatedDocuments = fieldContent.relatedDocuments;
relatedDocumentAll = relatedDocumentAll.concat(relatedDocuments);
var relatedAttachments = fieldContent.relatedAttachments;
relatedAttachmentAll = relatedAttachmentAll.concat(relatedAttachments);
var relatedImageGroups = groupBy(fieldContent.images, function (item) {
return [item.verticalAlign];
});
var relatedBottomImages = [];
var relatedTopImages = [];
relatedImageGroups.forEach(function (item) {
if (item.key == parseInt(E.VerticalAlign.Top)) {
relatedTopImages = relatedTopImages.concat(item.value.data);
} else {
if (item.key == parseInt(E.VerticalAlign.Bottom)) {
relatedBottomImages = relatedBottomImages.concat(item.value.data);
}
}
});
fieldContent.relatedTopImages = relatedTopImages;
fieldContent.relatedBottomImages = relatedBottomImages;
}
};
function checkShowFieldName(fieldContent) {
if (fieldContent.fieldName != '' && fieldContent.fieldName != undefined && fieldContent.isVisible && !fieldContent.isHideByBooklet) {
return true;
}
return false;
}
function convertToNodeType(documentType) {
switch (documentType.toString()) {
case E.documentTypes.Document:
return E.nodeTypes.Document;
case E.documentTypes.LinkDocument:
return E.nodeTypes.LinkDocument;
case E.documentTypes.FileDocument:
return E.nodeTypes.FileDocument;
case E.documentTypes.ShortcutDocument:
return E.nodeTypes.ShortcutDocument;
}
}
function setIconForDocument(data) {
data = data == null ? vm.currentData : data;
var icon = '';
switch (data.levelType.toString()) {
case E.HandbookLevelTypes.Enterprise:
icon = paths.DocumentLevelTypeEnterprise;
break;
case E.HandbookLevelTypes.Regional:
icon = paths.DocumentLevelTypeRegional;
break;
case E.HandbookLevelTypes.Local:
icon = paths.DocumentLevelTypeLocal;
break;
default:
icon = paths.DocumentLevelTypeEnterprise;
break;
}
data.docIcon = icon;
}
function updateAfterCurrentDataChanged() {
setIconForDocument(vm.currentData);
}
function buildDocumentObjectFromCurrentDocument(currentDocument) {
if (currentDocument) {
vm.currentData = angular.copy(currentDocument.documentInformation);
angular.copy(currentDocument.documentInformation, vm.originalData);
updateAfterCurrentDataChanged();
if (vm.currentData.description) {
vm.currentData.description = $sce.trustAsHtml(vm.currentData.description.toString());
}
var fieldContent = '';
for (var i = 0; i < vm.currentData.fieldContents.length; i++) {
if (vm.currentData.fieldContents[i].fieldId == currentDocument.fieldId) {
vm.fieldId = currentDocument.fieldId;
fieldContent = vm.currentData.fieldContents[i];
$timeout(function () {
showContent(vm.fieldId, fieldContent);
});
}
}
setTimeout(function () { stickyTitle(); }, 0);
}
};
function clearActive() {
vm.activeRelatedDocuments = false;
vm.activeAttachments = false;
for (var i = 0; i < vm.currentData.fieldContents.length; i++) {
vm.currentData.fieldContents[i].activeField = '';
}
};
function showContent(id, fieldContent) {
isFieldActive = true;
animationChangeBackgroundColor(id);
clearActive();
if (fieldContent) {
fieldContent.activeField = 'active';
} else {
if (String(id).indexOf('IdrelatedDocument') > -1)
vm.activeRelatedDocuments = true;
else
vm.activeAttachments = true;
}
setTimeout(function () {
isFieldActive = false;
}, 2000);
};
function animationChangeBackgroundColor(id) {
id = String(id);
var indexHash = id.indexOf('#');
if (indexHash > 0) {
id = id.substr(0, indexHash);
}
var hash = '#p' + id;
var elementId = '#Id' + id;
if (id.indexOf('IdrelatedDocument') > -1 || id.indexOf('Idattachment') > -1) {
hash = '#' + id;
elementId = '#' + id;
}
var $parentDiv = $('.document-detail');
$parentDiv.animate({ scrollTop: $(hash).position().top }, 'slow');
var $element = $(elementId);
$element.animate({ backgroundColor: '#D7D7D7' }, 1500);
$timeout(function () {
$element.css("background-color", "");
}, 2000);
}
function searchAndHighlightText() {
highlightTextInContent();
documentContentsSearchService.searchAndHighlightText(vm.highlights);
};
function navForward() {
documentContentsSearchService.navForward(vm.highlights);
};
function navBackward() {
documentContentsSearchService.navBackward(vm.highlights);
};
function printDocumentField() {
window.open(String.format(handbookRequests.PrintHtmlFieldRequest, vm.documentInformation.documentId, vm.fieldId));
};
function highlightTextInContent() {
if (vm.currentData.fieldContents != undefined) {
var viewMode = angular.copy(vm.currentData.viewMode);
angular.copy(vm.originalData, vm.currentData);
vm.currentData.viewMode = viewMode;
vm.currentData.fieldContents.forEach(function (fieldContent) {
fieldContent.content = documentContentsSearchService.searchAndHighlight(fieldContent.content, vm.highlights.highlightText);
fieldContent.description = $sce.trustAsHtml(fieldContent.description.toString());
});
}
};
function updateLocalAnchors() {
$timeout(function () {
var domContent = angular.element('div.contentWithLayout');
anchorService.updateLocalAnchors(domContent, true);
scrollToAnchorIfExists();
});
}
function scrollToAnchorIfExists() {
var hash = $location.hash();
if (hash != '') {
$anchorScroll();
}
}
function runServicesAfterInit() {
updateLocalAnchors();
}
function fullScreen() {
if (vm.isFullScreen) {
documentService.showFullscreen();
} else {
documentService.showNormal();
tabStateService.adjustContentHeightPosition(tabStateType.documentTabState);
$('#document-content-identifier').css('margin-top', '0px');
}
vm.isFullScreen = !vm.isFullScreen;
setTimeout(function () {
var height = $('#document-content-identifier').height();
stickyTitle(height);
if (isIE) {
runInitforIE(height);
}
}, 500);
}
function fullScreenInit() {
if (angular.element('#handbook-nav:visible').length == 0) {
documentService.showFullscreen();
vm.isFullScreen = false;
} else {
documentService.showNormal();
vm.isFullScreen = true;
}
}
function getNextSearchResultByEnter(keyEvent) {
if (keyEvent.which == 13) {
navForward();
}
}
$scope.$on(broadcastType.toggleDocumentFullscreen, function (e, target) {
fullScreen();
});
function showSidebarFields() {
vm.isToggleSidebarFields = true;
}
function hideSidebarFields() {
vm.isToggleSidebarFields = false;
}
function compareDocument() {
window.open(String.format('/document/{0}/compareWithEarlierVersion', vm.documentId), '_blank');
}
};
})();;