';
// 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("handbookApp")
.controller(controllers.searchController, searchController);
searchController.$inject = ['$scope', '$http', '$state', '$stateParams', '$timeout', '$document',
'favoriteService', 'folderService', 'tabStateService', 'resizeService', 'stringValidationService',
'metaDataService', 'documentService', '$location', '$q', 'configService', 'broadcastService', '$filter'];
function searchController($scope, $http, $state, $stateParams, $timeout, $document,
favoriteService, folderService, tabStateService, resizeService, stringValidationService,
metaDataService, documentService, $location, $q, configService, broadcastService, $filter) {
var vm = this;
vm.handbookRequests = handbookRequests;
$scope.translation = globalResources;
vm.commonGridSettingKey = gridSettingKeys.commonVisibilitySettings;
vm.enabledMetadataSearch = true;
vm.enabledAdvanceSearch = true;
vm.isMetadataSearch = configService.getBool(HandbookConfiguration.MetadataEnabled) && vm.enabledMetadataSearch;
vm.doSearchDataMining = configService.getBool(HandbookConfiguration.DoSearchDataMining);
vm.enabledCompendiaSearch = configService.getBool(HandbookConfiguration.CompendiaSearch);
vm.searchInFolders = configService.getBool(HandbookConfiguration.SearchInFolders);
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.folderId = $stateParams.folderId;
vm.fromDate = $stateParams.fromDate != null ? new Date(parseInt($stateParams.fromDate)) : null;
vm.fromDateBK = angular.copy(vm.fromDate);
vm.toDate = $stateParams.toDate != null ? new Date(parseInt($stateParams.toDate)) : null;
vm.toDateBK = angular.copy(vm.toDate);
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.advancedSearchLocationType = vm.folderId == null ? 1 : (isNaN(vm.folderId) ? 2 : 1);
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.setSearchLocationType = setSearchLocationType;
$scope.search = search;
$scope.isProcessNode = isProcessNode;
vm.openCompendiaDocument = openCompendiaDocument;
vm.defaultExportFileName = globalResources.SearchResult;
vm.openDocument = openDocument;
vm.folderClick = folderClick;
vm.onVARClick = onVARClick;
vm.isClickDocument = false;
vm.areaGridSetting = [];
vm.processes = {};
vm.processAreas = {};
vm.processesInterconnected = {};
vm.areasRecords = 0;
vm.processRecords = 0;
vm.goToProcess = goToProcess;
vm.goToProcessArea = goToProcessArea;
vm.goToProcessInterconnected = goToProcessInterconnected;
vm.enableProcess = configService.getBool(HandbookConfiguration.EnableProcess);
vm.enableVAR = configService.getBool(HandbookConfiguration.EnableVAR);
vm.enableInterconnectedProcess = configService.getBool(HandbookConfiguration.InterconnectedProcess);
vm.maxHeight = 635;
vm.getGetRegisterItemByAreaOrFolder = getGetRegisterItemByAreaOrFolder;
vm.metaDataAll = [];
vm.VAROffset = 0;
vm.VARsGridSetting = [
{ id: 'title', name: window.resources.L.Common.title, width: 33, coldefault: true },
{ id: 'status', name: window.resources.L.Common.changeType, width: 33, coldefault: true },
{ id: 'updatedDate', name: window.resources.L.Common.lastUpdated, width: 33, coldefault: true }
];
vm.varRecords = [];
vm.exportParams = {};
vm.exportRequestUrl = '';
vm.exportDocumentParams = {};
vm.searchProcessParams = {};
vm.exportProcessParams = {};
vm.exportProcessInterconnectedParams = {};
vm.tabNameToExport = { processTab: 'processTab', interconnectedTab: 'interconnectedTab', documentTab: 'documentTab', areaTab: 'areaTab', folderTab: 'folderTab' };
vm.handleChangeTabForExportList = handleChangeTabForExportList;
vm.enableExportButton = false;
initialize();
function initialize() {
//check and resize the view
if (vm.isMetadataSearch) {
getRegisterItems();
}
if (vm.searchInFolders) {
buildFoldersGridSetting();
}
buildAreaGridSetting();
loadFolderTree();
if (vm.enableProcess) {
loadAreaTree();
}
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;*/
generateExportParams();
if (vm.enabledCompendiaSearch) {
var mandatatoryRequests = [
searchCompendiaDocuments(vm.keyword),
getSearchResult(E.searchType.Maximum)
];
$q.all(mandatatoryRequests).then(function (response) {
$timeout(function () {
handleNavigate();
}, 500);
getExportParams();
});
} else {
var mandatatoryRequests = [getSearchResult(E.searchType.Maximum, true)];
$q.all(mandatatoryRequests).then(function (response) {
getExportParams();
});
}
activeButtonGroup(parseInt(vm.type), true);
activeLocationTypeButtonGroup(vm.advancedSearchLocationType);
if (vm.folderId) {
getGetRegisterItemByAreaOrFolder(vm.folderId);
}
watchVARGridScroll();
};
$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 goToProcess(processNumber) {
$state.go('process-detail', { processNumber: processNumber });
}
function goToProcessArea(areaId) {
$state.go('process-area-detail', { areaId: areaId });
}
function goToProcessInterconnected(processInterconnectedNumber) {
$state.go('process-interconnected', { processNumber: processInterconnectedNumber });
}
function handleNavigate() {
var url = angular.copy($location.$$url);
if (!url)
return;
url = url.toLowerCase();
if (url.indexOf('tab?') == -1) {
return;
}
if (vm.processes.length > 0 && url.indexOf('searchProcesses') > -1) {
triggerTabClicked('#seachProcesses', false);
}
if (vm.documents.length > 0 && url.indexOf('searchDocuments') > -1) {
triggerTabClicked('#searchDocuments', false);
}
if (vm.processAreas.length > 0 && url.indexOf('searchProcessAreas') > -1) {
triggerTabClicked('#searchProcessAreas', false);
}
if (vm.folders.length > 0 && url.indexOf('searchFolders') > -1) {
triggerTabClicked('#searchFolders', false);
}
if (vm.processesInterconnected.length > 0 && url.indexOf('seachProcessesInterconnected') > -1) {
triggerTabClicked('#seachProcessesInterconnected', false);
}
if (vm.varRecords.length > 0 && url.indexOf('searchVAR') > -1) {
triggerTabClicked('#searchVAR', false);
}
}
function triggerTabClicked(tabId, clickItSelf) {
setTimeout(function () {
var childTab = $(tabId + ' a');
if (childTab) {
$(childTab).click();
if (clickItSelf && $(tabId)) {
$(tabId).click();
}
}
});
}
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 buildAreaGridSetting() {
vm.areaGridSetting.push({ id: 'name', name: globalResources.ProcessArea, width: 50, coldefault: true, icon: 'icon' });
vm.areaGridSetting.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.exportDocumentParams.columns = getDocumentColumnsForExporting(gridSettingKeys.commonVisibilitySettings, E.GridViewModelType.Document);
vm.exportProcessParams.columns = getDocumentColumnsForExporting(gridSettingKeys.commonVisibilitySettings, E.GridViewModelType.Process);
vm.exportProcessInterconnectedParams.columns = getDocumentColumnsForExporting(gridSettingKeys.commonVisibilitySettings, E.GridViewModelType.InterconnectedProcess);
}
});
$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) {
if (vm.advancedSearchLocationType == parseInt(E.advancedSearchLocationType.processArea)) {
$http.get('/api/qmsMetaData/GetRegisterAndRegisterItemsForModule', { params: { application: 200 } })
.then(function (response) {
if (response && response.data) {
if (!vm.folderId) {
vm.initMetadata.metadatas = response.data;
}
vm.metaDataAll = response.data;
}
})
}
else {
metaDataService.getRegisterAndRegisterItems().then(function (data) {
if (data) {
if (!vm.folderId) {
vm.initMetadata.metadatas = data;
}
vm.metaDataAll = data;
}
});
}
}
};
$scope.$watch('vm.selectedItem.selectedMetadata', function (selectedMetadata) {
if (selectedMetadata) {
vm.registerItemId = selectedMetadata.registerItemId;
vm.selectedItem.selectedMetadata = vm.initMetadata.metadatas.find((x) => x.registerItemId == vm.registerItemId);
}
if (vm.registerItemId) {
vm.selectedItem.selectedMetadata = vm.initMetadata.metadatas.find((x) => x.registerItemId == vm.registerItemId);
}
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 isProcessNode(node) {
return isNaN(node.id);
}
function selectNodeHead(node) {
if (!node.isLoaded && vm.advancedSearchLocationType == parseInt(E.advancedSearchLocationType.folder)) {
$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;
});
}
else if (!node.isLoaded && vm.advancedSearchLocationType == parseInt(E.advancedSearchLocationType.processArea)) {
$http.get('/api/ProcessAreas/GetContent', { params: { AreaId: node.id, ShowProcessesInTree: false, IsOnlyApproved: false } })
.success(function (data, status, headers, config) {
node.children = data.areas;
node.isLoaded = true;
})
.error(function (data, status, headers, config) {
node.isLoaded = true;
});
}
};
function selectNodeLabel(node) {
getGetRegisterItemByAreaOrFolder(node.id);
$scope.selectedNode = node;
$scope.showFolderTree = false;
};
function getGetRegisterItemByAreaOrFolder(id) {
if (!id || !vm.isMetadataSearch || (vm.advancedSearchLocationType !== parseInt(E.advancedSearchLocationType.folder) && vm.advancedSearchLocationType !== parseInt(E.advancedSearchLocationType.processArea))) {
return;
}
if (vm.advancedSearchLocationType == E.advancedSearchLocationType.folder) {
getRegisterItemsByModule(id);
}
else {
getRegisterItemOfArea(id);
};
}
function getRegisterItemsByModule(id) {
$http.get('/api/qmsMetaData/GetRegisterItemsByModule', { params: { folderId: id, application: 136 } })
.then(function (response) {
if (response && response.data) {
vm.initMetadata.metadatas = response.data;
vm.initMetadata.metadatas.forEach((item) => {
var metaDataItem = vm.metaDataAll.find((x) => x.registerItemId == item.registerItemId);
item.name = metaDataItem.name;
});
}
})
}
function getRegisterItemOfArea(id) {
$http.get('/api/qmsMetaData/GetRegisterItemOfArea', { params: { areaId: id } })
.then(function (response) {
if (response && response.data) {
vm.initMetadata.metadatas = response.data;
vm.initMetadata.metadatas.forEach((item) => {
var metaDataItem = vm.metaDataAll.find((x) => x.registerItemId == item.registerItemId);
item.name = metaDataItem.name;
});
}
})
}
function clearSelectedNode() {
$scope.selectedNode = null;
vm.initMetadata.metadatas = vm.metaDataAll;
if (vm.registerItemId) {
vm.selectedItem.selectedMetadata = vm.initMetadata.metadatas.find((x) => x.registerItemId == vm.registerItemId);
};
//getRegisterItems();
}
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) {
setHeightForGrid();
}
}
function changeSearchType(type) {
if (type == parseInt(E.searchTypeHandbook.titleSearch)) {
$scope.isAdvanceSearch = false;
$scope.isMetadataSearch = false;
$scope.searchPlaceHolder = $scope.translation.TitleSearch;
$scope.selectedSearchType = $scope.searchTypes[0];
} else if (type == parseInt(E.searchTypeHandbook.contentSearch)) {
$scope.isAdvanceSearch = false;
$scope.isMetadataSearch = false;
$scope.searchPlaceHolder = $scope.translation.ContentSearch;
$scope.selectedSearchType = $scope.searchTypes[1];
}
else if (type == parseInt(E.searchTypeHandbook.advancedSearch) && vm.enabledAdvanceSearch) {
$scope.isAdvanceSearch = true;
$scope.isMetadataSearch = false;
$scope.searchPlaceHolder = $scope.translation.AdvanceSearch;
$scope.selectedSearchType = $scope.searchTypes[2];
activeLocationTypeButtonGroup(vm.advancedSearchLocationType);
} else if (type == parseInt(E.searchTypeHandbook.metadataSearch) && vm.enabledMetadataSearch) {
$scope.isAdvanceSearch = false;
$scope.isMetadataSearch = true;
$scope.searchPlaceHolder = $scope.translation.MetadataSearch;
$scope.selectedSearchType = $scope.searchTypes[3];
activeLocationTypeButtonGroup(vm.advancedSearchLocationType);
getGetRegisterItemByAreaOrFolder(vm.folderId);
}
setHeightForGrid();
$timeout(function () {
activeButtonGroup(type);
}, 500);
}
function activeLocationTypeButtonGroup(type) {
angular.element('#search-folder-id').addClass('label-btn-disabled');
angular.element('#search-process-area-id').addClass('label-btn-disabled');
if (type == 1) {
angular.element('#search-folder-id').removeClass('label-btn-disabled');
} else if (type == 2) {
angular.element('#search-process-area-id').removeClass('label-btn-disabled');
}
}
function setSearchLocationType(type) {
vm.advancedSearchLocationType = type;
clearSelectedNode();
if (vm.isMetadataSearch) {
getRegisterItems();
}
activeLocationTypeButtonGroup(type);
}
function search() {
if ($scope.selectedSearchType.id == E.searchTypeHandbook.titleSearch) {
searchTitle();
} else if ($scope.selectedSearchType.id == E.searchTypeHandbook.contentSearch) {
searchContent();
} else if ($scope.selectedSearchType.id == E.searchTypeHandbook.advancedSearch) {
searchAdvance();
} else if ($scope.selectedSearchType.id == E.searchTypeHandbook.metadataSearch) {
searchMetadata();
}
var searchCondition = ((vm.keyword != null && vm.keyword != "")
|| vm.folderId != ''
|| 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() {
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() {
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) {
const quickSearchKeyword = vm.keyword ? vm.keyword.trim() : '';
if (!quickSearchKeyword && (vm.type != parseInt(E.searchTypeHandbook.advancedSearch) && vm.type != parseInt(E.searchTypeHandbook.metadataSearch))) {
return;
}
if (vm.enableProcess) {
triggerSearchProcessModule(searchType);
}
if (vm.enableVAR) {
triggerSearchVAR(quickSearchKeyword, vm.VAROffset);
}
var searchCondition = ((vm.keyword != null && vm.keyword != "")
|| vm.folderId != ''
|| vm.fromDate != null
|| vm.toDate != null
|| (vm.registerItemId != null && vm.registerItemId != undefined && vm.registerItemId != 0))
&& stringValidationService.notContainSpecialCharacter(vm.keyword);
if (!searchCondition) {
vm.searchConditionTrue = false;
return;
}
vm.searchConditionTrue = true;
vm.totalHits = specialCharacter.questionMark;
vm.totalFound = specialCharacter.questionMark;
if (vm.fromDate != null && typeof vm.fromDate != 'string') {
vm.fromDate = vm.fromDate.toLocaleDateString() + ' GMT';
}
if (vm.toDate != null && typeof vm.toDate != 'string') {
vm.toDate = vm.toDate.toLocaleDateString() + ' 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);
if (isGuid(vm.folderId)) {
return;
}
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.filter(x => !x.hidden);
vm.totalHits = vm.documents.length;
vm.totalFound = response.data.totalCount;
var showMoreItem = (vm.type == parseInt(E.searchTypeHandbook.contentSearch) || vm.type == parseInt(E.searchTypeHandbook.metadataSearch));
} 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.type != parseInt(E.searchTypeHandbook.advancedSearch) && vm.type != parseInt(E.searchTypeHandbook.metadataSearch))) {
vm.folders = response.data.folders.filter(x => !x.hidden);
angular.forEach(vm.folders, function (node) {
node.icon = getFolderClass(node.type)
});
vm.totalFolderHits = vm.folders.length;
}
showFolderSearch = (showFolderSearch && vm.folders.length > 0 || vm.processAreas.length > 0);
if (reCalculateHeigth) {
$timeout(function () {
setHeightForGrid();
}, 200);
}
});
}
function triggerSearchProcessModule(searchType) {
if (vm.type != parseInt(E.searchTypeHandbook.advancedSearch) && vm.type != parseInt(E.searchTypeHandbook.metadataSearch)) {
getProcessAreaSearchResult(searchType);
getProcessSearchResult(searchType);
if (vm.enableInterconnectedProcess) {
getProcessInterconnectedSearchResult(searchType);
}
return;
}
if (vm.folderId == null || isNaN(vm.folderId)) {
advancedSearchProcess(vm.keyword, searchType)
if (vm.enableInterconnectedProcess) {
advancedSearchProcessInterconnected(vm.keyword, searchType);
}
return;
}
}
function advancedSearchProcess(keyword, searchType) {
let searchParams = generateSearchProcessAdvanceParams(keyword, searchType);
return $http.get(handbookRequests.SearchProcessesAdvance, { params: searchParams })
.success(function (response) {
if (response != null && response.length) {
updateAttachmentsForProcesses(response);
vm.processes = response;
vm.processes = vm.processes.map(ele => {
ele.handbookId = ele.folderId;
return ele;
});
angular.forEach(vm.folders, function (node) {
node.icon = getFolderClass(node.type)
});
vm.processRecords = vm.processes.length;
}
})
.error(function (data, status, headers, config) {
});
}
function advancedSearchProcessInterconnected(keyword, searchType) {
let searchParams = generateSearchProcessAdvanceParams(keyword, searchType);
return $http.get(handbookRequests.SearchProcessInterconnectedAdvance, { params: searchParams })
.success(function (response) {
if (response != null && response.length) {
updateAttachmentsForProcessesInterconnected(response);
vm.processesInterconnected = response;
vm.processesInterconnected = vm.processesInterconnected.map(ele => {
ele.handbookId = ele.folderId;
return ele;
});
angular.forEach(vm.folders, function (node) {
node.icon = getFolderClass(node.type)
});
}
})
.error(function (data, status, headers, config) {
});
}
function getProcessAreaSearchResult(searchType) {
var processRequestParams = {
keyword: vm.keyword ? vm.keyword : '',
searchType: searchType,
isFrontend: true,
isContentSearch: vm.searchInContents
};
return $http.get(handbookRequests.SearchProcessAreas, { params: processRequestParams })
.then(function (response) {
if (response != null && response.data != null && response.data.length) {
vm.processAreas = response.data;
angular.forEach(vm.processAreas, function (node) {
node.icon = 'fa fa-folder areas-color';
});
vm.areasRecords = vm.processAreas.length;
}
});
}
function getProcessSearchResult(searchType) {
var processRequestParams = generateSearchProcessParams(searchType);
return $http.get(handbookRequests.SearchProcesses, { params: processRequestParams })
.then(function (response) {
if (response != null && response.data != null && response.data.length) {
updateAttachmentsForProcesses(response.data);
vm.processes = response.data;
vm.processes = vm.processes.map(ele => {
ele.handbookId = ele.folderId;
return ele;
});
angular.forEach(vm.folders, function (node) {
node.icon = getFolderClass(node.type)
});
vm.processRecords = vm.processes.length;
}
});
}
function getProcessInterconnectedSearchResult(searchType) {
var processRequestParams = generateSearchProcessParams(searchType);
return $http.get(handbookRequests.SearchProcessInterconnected, { params: processRequestParams })
.then(function (response) {
if (response != null && response.data != null && response.data.length) {
updateAttachmentsForProcessesInterconnected(response.data);
vm.processesInterconnected = response.data;
vm.processesInterconnected = vm.processesInterconnected.map(ele => {
ele.handbookId = ele.folderId;
return ele;
});
angular.forEach(vm.folders, function (node) {
node.icon = getFolderClass(node.type)
});
}
});
}
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 == parseInt(E.searchTypeHandbook.titleSearch)) {
searchUrl = handbookRequests.CompendiaDocument_TitleSearch;
} else if (vm.type == parseInt(E.searchTypeHandbook.contentSearch)) {
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) {
if (!isNaN(vm.folderId)) {
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;
}
}
else {
$http.get('/api/ProcessAreas/GetContent', { params: { AreaId: vm.folderId, ShowProcessesInTree: false, IsOnlyApproved: false } })
.success(function (data, status, headers, config) {
vm.folderName = data.areaInformation.name;
$scope.selectedNode = data.areaInformation;
});
}
}
};
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() {
// Does not follow config showDocumentInTree
$http.get(handbookRequests.GetFoldersRequest, { params: { 'id': null, 'showDocumentInTree': false } })
.success(function (data, status, headers, config) {
$scope.folderTree = data;
if (vm.advancedSearchLocationType == parseInt(E.advancedSearchLocationType.folder))
loadSearchType();
});
}
function loadAreaTree() {
$http.get('/api/ProcessAreas/GetContent', { params: { AreaId: null, ShowProcessesInTree: false, IsOnlyApproved: false } })
.success(function (data, status, headers, config) {
$scope.areaTree = data.areas;
if (vm.advancedSearchLocationType == parseInt(E.advancedSearchLocationType.processArea))
loadSearchType();
});
}
function loadSearchType() {
if (vm.type == parseInt(E.searchTypeHandbook.advancedSearch)) {
$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;
if (vm.advancedSearchLocationType == parseInt(E.advancedSearchLocationType.folder)) {
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;
}
}
}
else if (vm.advancedSearchLocationType == parseInt(E.advancedSearchLocationType.processArea)) {
for (var i = 0; i < $scope.areaTree.length; i++) {
if (vm.folderId == $scope.areaTree[i].id) {
$scope.selectedNode = $scope.areaTree[i];
vm.folderName = $scope.selectedNode != null ? $scope.selectedNode.name : null;
break;
}
}
}
$scope.isAdvanceSearch = true;
$scope.isMetadataSearch = false;
} else if (vm.type == parseInt(E.searchTypeHandbook.contentSearch)) {
$scope.searchPlaceHolder = $scope.translation.ContentSearch;
$scope.selectedSearchType = $scope.searchTypes[1];
$scope.keyword = vm.keyword;
$scope.isAdvanceSearch = false;
$scope.isMetadataSearch = false;
} else if (vm.type == parseInt(E.searchTypeHandbook.titleSearch)) {
$scope.searchPlaceHolder = $scope.translation.TitleSearch;
$scope.selectedSearchType = $scope.searchTypes[0];
$scope.keyword = vm.keyword;
$scope.isAdvanceSearch = false;
$scope.isMetadataSearch = false;
} else if (vm.type == parseInt(E.searchTypeHandbook.metadataSearch)) {
$scope.searchPlaceHolder = $scope.translation.MetadataSearch;
$scope.keyword = vm.keyword;
$scope.selectedSearchType = $scope.searchTypes[3];
$scope.isAdvanceSearch = false;
$scope.isMetadataSearch = true;
if (vm.advancedSearchLocationType == parseInt(E.advancedSearchLocationType.folder)) {
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;
}
}
}
else if (vm.advancedSearchLocationType == parseInt(E.advancedSearchLocationType.processArea)) {
for (var i = 0; i < $scope.areaTree.length; i++) {
if (vm.folderId == $scope.areaTree[i].id) {
$scope.selectedNode = $scope.areaTree[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
.post('/api/Documents/GetAttachmentsForDocuments', { 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 updateAttachmentsForProcesses(processes) {
if (processes == null || processes.length == 0) {
return processes;
}
var processEntityIds = [];
for (var i = 0; i < processes.length; i++) {
if (processes[i].hasAttachment && processes[i].isProcess) {
processEntityIds.push(processes[i].entityId);
}
}
if (processEntityIds.length > 0) {
$http.get('/api/Processes/GetAttachmentsForProcesses', {
params: { processEntityIds },
})
.success(function (data) {
if (data && data.length > 0) {
data.forEach(x => {
x.itemId = x.extraId ? x.extraId : x.itemId;
});
}
for (var i = 0; i < processes.length; i++) {
if (processes[i].hasAttachment) {
processes[i].attachments = [];
processes[i].attachmentHtml = '';
for (var j = 0; j < data.length; j++) {
if (data[j].processEntityId === processes[i].entityId) {
processes[i].attachments.push(data[j]);
}
}
}
}
});
}
}
function updateAttachmentsForProcessesInterconnected(processesInterconnected) {
if (processesInterconnected == null || processesInterconnected.length == 0) {
return processesInterconnected;
}
var processInterconnectedEntityIds = [];
for (var i = 0; i < processesInterconnected.length; i++) {
if (processesInterconnected[i].hasAttachment && processesInterconnected[i].isProcess) {
processInterconnectedEntityIds.push(processesInterconnected[i].processInterconnectedEntityId);
}
}
if (processInterconnectedEntityIds.length > 0) {
$http.get(handbookRequests.GetAttachmentsForProcessesInterconnected, {
params: { processInterconnectedEntityIds },
})
.success(function (data) {
if (data && data.length > 0) {
data.forEach(x => {
x.itemId = x.extraId ? x.extraId : x.itemId;
});
}
for (var i = 0; i < processesInterconnected.length; i++) {
if (processesInterconnected[i].hasAttachment) {
processesInterconnected[i].attachments = [];
processesInterconnected[i].attachmentHtml = '';
for (var j = 0; j < data.length; j++) {
if (data[j].processInterconnectedEntityId === processesInterconnected[i].processInterconnectedEntityId) {
processesInterconnected[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;
//}
function setHeightForGrid() {
$timeout(function () {
var filter = $('.advanced-search-more').height();
if (Number(filter) > 0) {
vm.maxHeight = 570;
} else {
vm.maxHeight = 635;
}
calculateHeightForDocumentGrids();
}, 100);
}
function calculateHeightForDocumentGrids() {
$('.handbook-folders #gridController tbody').css('max-height', vm.maxHeight);
$('.compendia-documents .content-wrapper').css('max-height', vm.maxHeight);
$('.handbook-documents #gridController tbody').css('max-height', vm.maxHeight);
}
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 onVARClick(row) {
window.open(row.url);
}
function triggerSearchVAR(keyword, offset) {
if (vm.isLoadingVar) return;
vm.isLoadingVar = true;
return $http.get('/api/var/', {
params: {
method: 'PROCEDURE',
query: keyword,
offset: offset
}
}).then(response => {
if (!response || !response.data || !response.data.documents || !response.data.documents.length) return;
vm.numFoundOfVar = response.data.numFound;
vm.varRecords = [...vm.varRecords, ...(response.data.documents || [])];
vm.VAROffset += response.data.documents.length;
vm.varRecords.forEach(record => {
record.status = inferVarRecordStatus(record.changeType);
record.updatedDate = $filter('date')(record.lastUpdated, 'dd.MM.yyyy');
});
}).finally(() => {
vm.isLoadingVar = false;
});
}
function inferVarRecordStatus(changeType) {
if (!changeType) return '';
changeType = changeType.toLowerCase();
const prefix = window.resources.L.Common.degree.toUpperCase();
switch (changeType) {
case 'none': return `${prefix}: 0`;
case 'insignificant': return `${prefix}: 1`;
case 'small': return `${prefix}: 2`;
case 'medium': return `${prefix}: 3`;
case 'large': return `${prefix}: 4`;
case 'new': return `${prefix}: ${window.resources.L.Common.new}`;
default: return '';
}
}
function watchVARGridScroll() {
$('#searchVAR').bind('scroll', (event) => {
var element = event.target;
if ($(element).scrollTop() + $(element).innerHeight() >= $(element)[0].scrollHeight) {
const quickSearchKeyword = vm.keyword ? vm.keyword.trim() : '';
triggerSearchVAR(quickSearchKeyword, vm.VAROffset).then(() => {
broadcastService(broadcastType.gridDataChanges, { id: 'searchVAR', data: vm.varRecords, isForced: true });
});
}
});
}
function isGuid(char) {
return /^[0-9a-fA-F]{8}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{12}$/gi.test(char);
}
function getExportParams() {
if (vm.processes.length) {
vm.enableExportButton = true;
setProcessExportParams();
}
else if (vm.documents.length) {
vm.enableExportButton = true;
setDocumentExportParams();
} else if (vm.processesInterconnected.length) {
vm.enableExportButton = true;
setProcessInterconnectedExportParams();
}
}
function generateSearchProcessParams(searchType) {
return {
keyword: vm.keyword ? vm.keyword : '',
searchType: searchType,
isFrontend: true,
isContentSearch: vm.searchInContents
};
}
function generateSearchProcessAdvanceParams(keyword, searchType) {
var fromDate = null;
if (vm.fromDateBK != null && typeof vm.fromDateBK != 'string') {
fromDate = vm.fromDateBK.toUTCString().replace('UTC', 'GMT');
}
var toDate = null;
if (vm.toDateBK != null && typeof vm.toDateBK != 'string') {
toDate = vm.toDateBK.toUTCString().replace('UTC', 'GMT');
}
return {
keyword: keyword,
isContentSearch: vm.searchInContents ? true : false,
areaId: vm.folderId,
metadataMustContainAll: vm.type == parseInt(E.searchTypeHandbook.metadataSearch),
myProcessOnly: false,
processStatusApprovalFilter: E.advancedSearchApprovalProcessStatus.Approved,
fromDate: fromDate,
toDate: toDate,
searchType: searchType,
registerItemId: vm.registerItemId,
registerItemValueId: vm.registerItemValueId,
dateFilter: 4,
hasQuit: false,
hasQuitApprove: false,
includeSubAreas: vm.type == parseInt(E.searchTypeHandbook.advancedSearch) || vm.type == parseInt(E.searchTypeHandbook.metadataSearch),
includeVirtualProcesses: true,
isFrontend: true,
}
}
function generateExportParams() {
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,
advancedSearchLocationType: vm.advancedSearchLocationType,
version: vm.version,
documentType: vm.documentType
};
vm.exportDocumentParams = {
folderId: vm.folderId,
isRecursive: false,
groupBy: E.exportDocumentGroupsByColumn.none,
filter: vm.filter
};
vm.exportDocumentParams.columns = getDocumentColumnsForExporting(gridSettingKeys.commonVisibilitySettings, E.GridViewModelType.Document);
if (vm.type == E.searchTypeHandbook.titleSearch || vm.type == E.searchTypeHandbook.contentSearch) {
vm.searchProcessParams = generateSearchProcessParams(E.searchType.Maximum);
} else if (vm.type == E.searchTypeHandbook.advancedSearch || vm.type == E.searchTypeHandbook.metadataSearch) {
vm.searchProcessParams = generateSearchProcessAdvanceParams(vm.keyword, E.searchType.Maximum);
}
vm.exportProcessParams = {
filter: vm.searchProcessParams,
columns: getDocumentColumnsForExporting(gridSettingKeys.commonVisibilitySettings, E.GridViewModelType.Process)
};
vm.exportProcessInterconnectedParams = {
filter: vm.searchProcessParams,
columns: getDocumentColumnsForExporting(gridSettingKeys.commonVisibilitySettings, E.GridViewModelType.InterconnectedProcess)
};
}
function setDocumentExportParams() {
vm.exportParams = vm.exportDocumentParams;
vm.exportRequestUrl = vm.handbookRequests.ExportSearchedDocuments;
}
function setProcessExportParams() {
vm.exportParams = vm.exportProcessParams;
if (vm.type == E.searchTypeHandbook.titleSearch || vm.type == E.searchTypeHandbook.contentSearch) {
vm.exportRequestUrl = vm.handbookRequests.ExportSearchedProcesses;
}
else if (vm.type == E.searchTypeHandbook.advancedSearch || vm.type == E.searchTypeHandbook.metadataSearch) {
vm.exportRequestUrl = vm.handbookRequests.ExportSearchedProcessesAdvance;
}
}
function setProcessInterconnectedExportParams() {
vm.exportParams = vm.exportProcessInterconnectedParams;
if (vm.type == E.searchTypeHandbook.titleSearch || vm.type == E.searchTypeHandbook.contentSearch) {
vm.exportRequestUrl = vm.handbookRequests.ExportSearchedProcessesInterconnected;
}
else if (vm.type == E.searchTypeHandbook.advancedSearch || vm.type == E.searchTypeHandbook.metadataSearch) {
vm.exportRequestUrl = vm.handbookRequests.ExportSearchedProcessesInterconnectedAdvance;
}
}
function handleChangeTabForExportList(activeTab) {
vm.enableExportButton = true;
switch (activeTab) {
case vm.tabNameToExport.processTab:
setProcessExportParams();
break;
case vm.tabNameToExport.documentTab:
setDocumentExportParams();
break;
case vm.tabNameToExport.interconnectedTab:
setProcessInterconnectedExportParams();
break;
default:
vm.enableExportButton = false;
break;
}
}
}
})();;
(function () {
var model = angular.module('managementModule', ['ngDraggable']);
model.controller(controllers.manageFavoritesController, ['$scope', '$http', '$state', '$uibModal', '$uibModalInstance', 'broadcastService', 'items', 'pubSub', '$q', 'configService',
function ($scope, $http, $state, $uibModal, $modalInstance, broadcastService, items, pubSub, $q, configService) {
$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.areas = [];
$scope.processes = [];
$scope.showSort = $scope.currentTab !== manageFavoriteTabs.emailSubscribed;
$scope.simpleSubscription = configService.getBool(HandbookConfiguration.SimpleSubscription);
$scope.enableProcessModule = configService.getBool(HandbookConfiguration.EnableProcess);
initDataSource();
$scope.loadEmailSubscribedFolder = function () {
if ($scope.enableProcessModule) {
$http.get('/api/CombineDocumentAndProcess/GetUserEmailSubscriptionsForDocumentAndProcess')
.then(function (res) {
if (res) {
var items = []
items = res.data;
items.forEach(function (item) {
if (checkFolder(item.type) || item.isProcessArea) {
if (item.isRecursiveFolder) {
item.subscriptionName = $scope.translation.FolderAndSubFolders;
} else {
item.subscriptionName = $scope.translation.FolderOnly;
}
}
});
$scope.emailSubsribed = items;
}
});
return;
}
$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.removeAreaFromFavorites = function (area) {
var params = {
areaId: area.id
}
var requestUrl = handbookRequests.RemoveAreaFromFavoritesRequest;
confirmAndDeleteItem(area, requestUrl, $scope.areas, null, true, params);
};
$scope.removeProcessFromFavorites = function (process) {
var params = {
processId: process.processId
};
var requestUrl = "/api/ProcessAreas/RemoveProcessFromFavorites/" + params;
confirmAndDeleteItem(process, requestUrl, $scope.processes, null, true, params);
};
$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 = '';
var params;
if (folder.isProcess) {
requestUrl = handbookRequests.RemoveProcessEmailSubscription;
params = { ProcessId: folder.id };
confirmAndDeleteItem(folder, requestUrl, $scope.emailSubsribed, null, false, { ProcessId: folder.id });
return;
}
else if (folder.isProcessArea) {
params = { AreaId: folder.id };
if (folder.isRecursiveFolder) {
requestUrl = handbookRequests.RemoveAreaAndItsChildrenFromEmailSubscription;
}
else {
requestUrl = handbookRequests.RemoveOnlyAreaFromEmailSubscription;
}
confirmAndDeleteItem(folder, requestUrl, $scope.emailSubsribed, null, false, { AreaId: folder.id });
return;
}
else if (checkFolder(folder.type)) {
params = false;
if (folder.isRecursiveFolder) {
requestUrl = handbookRequests.RemoveEmailSubscription + '/' + folder.id;
} else {
requestUrl = handbookRequests.RemoveOnlyFolderFromEmailSubscription + '/' + folder.id;
}
} else {
params = false;
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, isProcessAreaItem) {
if (!$scope.runOnce) { // to prevent this evt run twice
$scope.isChanged = true;
var dataSource = isProcessAreaItem ? getSourceProcessAreasByItemType(obj.type) : getSourceByItemType(obj.type);
removeBorderAndUpdateOrder(index, evt.element, obj, dataSource, false, false);
}
}
$scope.onDropCompleteForLastItem = function (index, obj, evt, isProcessAreaItem) {
$scope.isChanged = true;
var dataSource = isProcessAreaItem ? getSourceProcessAreasByItemType(obj.type) : getSourceByItemType(obj.type);
removeBorderAndUpdateOrder(index, evt.element, obj, dataSource, false, true);
}
$scope.onDropCompleteForTopItem = function (index, obj, evt, isProcessAreaItem) {
$scope.isChanged = true;
var dataSource = isProcessAreaItem ? getSourceProcessAreasByItemType(obj.type) : getSourceByItemType(obj.type);
removeBorderAndUpdateOrder(index, evt.element, obj, dataSource, true, false);
}
$scope.setCurrentTab = function (tab) {
$scope.currentTab = tab;
$scope.showSort = $scope.currentTab !== manageFavoriteTabs.emailSubscribed;
};
$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 () {
$modalInstance.close();
};
$scope.saveAndClose = function () {
if ($scope.isChanged) {
$q.all([updateSortOrderProcessItems(), updateSortOrderHandbookItems()]).then(function () {
closeAndUpdateFavoriteTree();
});
}
else {
$modalInstance.close();
}
};
function updateSortOrderHandbookItems() {
var documents = reArrangeAndGetChangedSortOrderItems($scope.documents, $scope.originalDocumentsData);
var folders = reArrangeAndGetChangedSortOrderItems($scope.folders, $scope.originalFoldersData);
var updatedItems = documents.concat(folders);
return $http.post(handbookRequests.UpdateFavoritesSortOrder, updatedItems)
.then(function () {
$scope.isChanged = false;
updateOriginalData();
});
}
function updateSortOrderProcessItems() {
if ($scope.enableProcessModule) {
var originalAreas = angular.copy($scope.areas);
var originalProcesses = angular.copy($scope.processes);
var areas = reArrangeAndGetChangedSortOrderItems($scope.areas, originalAreas);
var processes = reArrangeAndGetChangedSortOrderItems($scope.processes, originalProcesses);
var params = {
areas: areas,
processes: processes
};
return $http.post("/api/ProcessAreas/UpdateFavoritesSortOrder", params)
.success(function (data, status, headers, config) {
if (data) {
pubSub.publish(broadcastType.updateFavoritesProcesses, true);
}
});
}
}
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;
}
}
loadProcessAndAreas();
}
function loadProcessAndAreas() {
$http.get(handbookRequests.GetFavoritesItemsExcludeForcedFavoriteRequest)
.success(function (data, status, headers, config) {
if (data) {
decorateNodes(data.areas, data.processes);
$scope.areas = data.areas;
$scope.processes = data.processes;
var existedSort = $scope.areas.some(function (item) { return item.sort > 0; }) || $scope.processes.some(function (item) { return item.sort > 0; });
if (existedSort) {
$scope.isSortByAlphabet = false;
}
}
});
}
function decorateNodes(areas, processes) {
if (areas && areas.length > 0) {
for (var i = 0; i < areas.length; i++) {
areas[i].type = 0;
}
}
if (processes && processes.length > 0) {
for (var i = 0; i < processes.length; i++) {
processes[i].type = 1;
processes[i].id = processes[i].processNumber;
}
}
}
function isFolder(type) {
return type > E.nodeTypes.ShortcutDocument;
}
function confirmAndDeleteItem(object, requestUrl, dataSource, originalDataSource, isUpdateFavoriteTree, params) {
var modalInstance = $uibModal.open({
templateUrl: paths.ConfirmationView,
controller: controllers.confirmController,
resolve: {
item: function () {
return object.name;
}
}
});
modalInstance.result.then(function (isConfirm) {
if (isConfirm) {
$http.post(requestUrl, params)
.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);
if ($scope.enableProcessModule) {
pubSub.publish(broadcastType.updateFavoritesProcesses, true);
}
}
});
}
});
}
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 getSourceProcessAreasByItemType(type) {
return type == 0 ? $scope.areas : $scope.processes;
}
function getSourceByCurrentTab(isOriginalSource) {
switch ($scope.currentTab) {
case manageFavoriteTabs.folder:
if (isOriginalSource) {
return $scope.originalFoldersData;
}
else {
return $scope.folders;
}
case manageFavoriteTabs.document:
if (isOriginalSource) {
return $scope.originalDocumentsData;
}
else {
return $scope.documents;
}
case manageFavoriteTabs.processArea:
return $scope.areas;
case manageFavoriteTabs.process:
return $scope.processes;
default:
return $scope.folders;
}
}
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', '$uibModalInstance', 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', '$uibModal', '$location', '$timeout', 'favoriteService',
'treeNavigationService', 'documentService', 'pubSub', 'configService', 'browserService'];
function treeViewController($scope, $http, $state, $uibModal, $location, $timeout, favoriteService,
treeNavigationService, documentService, pubSub, configService, browserService) {
$scope.showTreeFavorites = false;
$scope.showTreeDocument = false;
$scope.showTreeMyMostRead = false;
$scope.showTreeMyLastVisited = false;
$scope.showToggleSearchPanel = false;
$scope.showTreeProcesses = false;
$scope.enableProcessModule = configService.getBool(HandbookConfiguration.EnableProcess);
$scope.documentList = {};
$scope.favoritesList = {};
$scope.myMostReadList = {};
$scope.myLastVisitedList = {};
$scope.showDocumentInTree = configService.getBool(HandbookConfiguration.ShowDocumentsInTree);
var browserType = browserService.detectBrowserWindow();
var previousRequest = { itemId: 0, itemType: '' };
var initOpeningDocumentGroupAsDefault = false;
var killProcessAreaRouteChanged = null;
$scope.init = function () {
openDefaultGroup();
navigateToTreeMenuItem();
};
$scope.$on('$destroy', function () {
killProcessAreaRouteChanged();
});
function openDefaultGroup() {
//debugger;
const groupToOpenAsDefault = parseInt(HandbookConfiguration.GroupToOpenAsDefault);
if (groupToOpenAsDefault != GROUP_TO_OPEN_AS_DEFAULTS.NONE) {
switch (groupToOpenAsDefault) {
case GROUP_TO_OPEN_AS_DEFAULTS.DOCUMENT:
initOpeningDocumentGroupAsDefault = true;
$scope.loadWhenSelectMenu("Document");
break;
case GROUP_TO_OPEN_AS_DEFAULTS.PROCESS:
$scope.loadWhenSelectMenu("Processes");
break;
}
killProcessAreaRouteChanged = pubSub.subscribe(broadcastType.processAreaRouteChanged, processAreaRouteChanged);
}
}
function navigateToTreeMenuItem() {
//debugger;
var urlParams = new URLSearchParams(window.location.search);
var menuType = urlParams.get('treeMenu');
switch (menuType) {
case 'Favorites':
$scope.loadWhenSelectMenu('Favorites');
break;
case 'MyLastVisited':
$scope.loadWhenSelectMenu('MyLastVisited');
break;
default:
break;
}
}
$scope.clearSelect = function () {
if (configService.getBool(HandbookConfiguration.IsAuthenticated) && !configService.getBool(HandbookConfiguration.IsAnonymous)) {
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) {
//debugger;
//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, 'showDocumentInTree': $scope.showDocumentInTree } })
.success(function (data, status, headers, config) {
node.children = data.filter(x => !x.hidden);
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, 'showDocumentInTree': $scope.showDocumentInTree} })
.success(function (data, status, headers, config) {
node.children = data.filter(x => !x.hidden);
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 {
if (browserType == BrowserType.MOBILE) {
$scope.$emit(broadcastType.hideSidebarInMobileWhenOpenDocument);
}
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) {
$timeout(function () {
treeNavigationService.scrollToVisibleView(node);
});
}
}
if ($scope.showTreeDocument && $scope.documentList.length == undefined) {
$http.get(handbookRequests.GetFoldersRequest, { params: { 'Id': null, 'showDocumentInTree': $scope.showDocumentInTree} })
.success(function (data, status, headers, config) {
$scope.documentList = data.filter(x => !x.hidden);
treeNavigationService.navigateToItemLocation(true);
if (parseInt(HandbookConfiguration.DocumentRootItemToExpand) !== NONE_DOCUMENT_ROOT_ITEM_TO_EXPAND
&& initOpeningDocumentGroupAsDefault) {
initOpeningDocumentGroupAsDefault = false;
if ($scope.documentList && $scope.documentList.length > 0) {
var node = null;
const documentRootItemToExpandId = parseInt(HandbookConfiguration.DocumentRootItemToExpand);
for (var i = 0; i < $scope.documentList.length; i++) {
if ($scope.documentList[i].id == documentRootItemToExpandId) {
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) {
//debugger;
$http.get(handbookRequests.GetFavoritesRequest).
success(function (data, status, headers, config) {
getFavoritesData(data);
});
$scope.$broadcast("Favorites_GetProcessFavoritesList");
}
break;
case "MyMostRead":
//debugger;
$scope.showTreeMyMostRead = !$scope.showTreeMyMostRead;
if ($scope.showTreeMyMostRead && $scope.myMostReadList.length == undefined) {
$http.get(handbookRequests.GetMostViewedDocumentsRequest).
success(function (data, status, headers, config) {
$scope.myMostReadList = data.filter(x => !x.hidden);
});
}
break;
case "MyLastVisited":
//debugger;
$scope.showTreeMyLastVisited = !$scope.showTreeMyLastVisited;
if ($scope.showTreeMyLastVisited && $scope.myLastVisitedList.length == undefined) {
$http.get(handbookRequests.GetRecentDocumentsRequest).
success(function (data, status, headers, config) {
$scope.myLastVisitedList = data.filter(x => !x.hidden);
});
}
break;
case "ToggleSearchPanel":
//debugger;
$scope.showToggleSearchPanel = true;
break;
case "Processes":
//debugger;
$scope.showTreeProcesses = !$scope.showTreeProcesses;
$state.go('areas-root-view');
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.showTreeProcesses = (menuType != "Processes") ? false : $scope.showTreeProcesses;
};
$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) {
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 processAreaRouteChanged(target) {
if (!$scope.showTreeProcesses)
$scope.showTreeProcesses = !$scope.showTreeProcesses;
}
function navigateToCurrentItem(parents) {
if (!$scope.showTreeDocument) {
if (!$scope.showTreeFavorites && !$scope.showTreeMyMostRead && !$scope.showTreeMyLastVisited) {
$scope.showTreeDocument = true;
$scope.showHideMenuLeft('Document');
}
if ($scope.documentList.length == undefined) {
$http.get(handbookRequests.GetFoldersRequest, { params: { 'Id': null, 'showDocumentInTree': $scope.showDocumentInTree } })
.success(function (data, status, headers, config) {
$scope.documentList = data.filter(x => !x.hidden);
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 || !parents.length) {
var element = $location.path().split('/');
if ($location.path().indexOf('process-fe/') >= 0) return;
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 = $uibModal.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) {
$scope.favoritesList = data.map(v => {
v.isFavorited = true;
return v;
}).filter(x => !x.hidden);
};
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 () {
//debugger;
$http.get(handbookRequests.GetFavoritesRequest).
success(function (data, status, headers, config) {
getFavoritesData(data);
});
$scope.$broadcast("Favorites_GetProcessFavoritesList");
}
$scope.refreshDocument = function () {
$http.get(handbookRequests.GetFoldersRequest, { params: { 'Id': null, 'showDocumentInTree': $scope.showDocumentInTree } })
.success(function (data, status, headers, config) {
$scope.documentList = data.filter(x => !x.hidden);
treeNavigationService.navigateToItemLocation(true);
});
}
$scope.goToProcessAreasRootView = function () {
$state.go('areas-root-view');
}
};
})();
;
(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 () {
var model = angular.module('feedbackModule', []);
model.controller(controllers.feedbackController, ['$scope', '$http', '$uibModal', 'feedBackService', '$uibModalInstance', 'model', '$sce', 'configService',
function ($scope, $http, $uibModal, feedBackService, $modalInstance, model, $sce, configService) {
var 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 = configService.getBool(HandbookConfiguration.EnableExtendedFeedback);
$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.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.MyReadingListsReport, {
url: "/myReadingLists",
templateUrl: '/app/components/home/templates/reportsMyReadingListView.html',
controller: 'reportsMyReadingListViewController',
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', '$uibModalInstance', 'quickSearchKeyword', 'metaDataService', 'broadcastService', 'configService',
function ($scope, $state, $http, $document, folderService, $modalInstance, quickSearchKeyword, metaDataService, broadcastService, configService) {
$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;
$scope.showDocumentInTree = configService.getBool(HandbookConfiguration.ShowDocumentsInTree);
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, { params: { 'Id': null, 'showDocumentInTree': $scope.showDocumentInTree } })
.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(modules.homeModule)
.controller('reportsMyReadingListViewController', reportsMyReadingListViewController);
reportsMyReadingListViewController.$inject = ['$state', '$stateParams', '$http'];
function reportsMyReadingListViewController($state, $stateParams, $http) {
var vm = this;
initialize();
function initialize() {
var screenHeight = window.innerHeight;
angular.element('#frameReport').height(screenHeight - 50);
vm.reportPage = `/Reports/Viewer.aspx?reportType=11&userId=${user.userId}`;
};
$(window).on('resize', function () {
var screenHeight = window.innerHeight;
angular.element('#frameReport').height(screenHeight - 50);
});
};
})();;
(function () {
angular
.module('processModule', ['ui.bootstrap', 'ui.router'])
.run(['$location', '$state', 'pubSub', 'documentService', 'tabStateService', '$rootScope', function ($location, $state, pubSub, documentService, tabStateService, $rootScope) {
window.addEventListener("message", (event) => {
if (!event.data || event.data.moduleName != 'process' || !event.data.eventName)
return;
let backendRoute = '';
switch (event.data.eventName) {
case 'process-route-change':
let frontendRoute = event.data.value.toLowerCase();
let areaIdTarget = null;
let processNumberTarget = null;
let processClassificationTarget = null;
if (frontendRoute.indexOf('process/home/details') > -1) {
backendRoute = '/process-fe/home/root-details';
$state.go('areas-root-view')
}
else if (frontendRoute.indexOf('process/area/detail') > -1) {
backendRoute = '/process-fe' + frontendRoute.replace('process', '');
let areaId = backendRoute.substring(backendRoute.lastIndexOf('/') + 1);
if (areaId.indexOf('?isfrontend') > -1) {
areaId = areaId.substring(0, areaId.indexOf('?isfrontend'));
}
if (areaId && areaId != '') {
areaIdTarget = areaId;
}
}
else if (frontendRoute.indexOf('process/process-detail/management') > -1) {
let processNumber = frontendRoute.substring(frontendRoute.lastIndexOf('/') + 1);
if (processNumber.indexOf('?isfrontend') > -1) {
processNumber = processNumber.substring(0, processNumber.indexOf('?isfrontend'));
}
if (processNumber && processNumber != '') {
processNumberTarget = processNumber;
backendRoute = '/process-fe/process-detail/' + processNumber;
}
processClassificationTarget = E.processClassificationTypes.Processes;
}
else if (frontendRoute.indexOf('process/process-interconnected/management') > -1) {
let processNumber = frontendRoute.substring(frontendRoute.lastIndexOf('/') + 1);
if (processNumber.indexOf('?isfrontend') > -1) {
processNumber = processNumber.substring(0, processNumber.indexOf('?isfrontend'));
}
if (processNumber && processNumber != '') {
processNumberTarget = processNumber;
backendRoute = '/process-fe/process-interconnected/' + processNumber;
}
processClassificationTarget = E.processClassificationTypes.ProcessInterconnected;
}
else if (frontendRoute.indexOf('process/process-detail/viewsendtohearing') > -1 ||
frontendRoute.indexOf('process/process-interconnected/viewsendtohearing') > -1) {
backendRoute = '/process-fe' + frontendRoute.replace('process', '');
let processNumber = backendRoute.substring(backendRoute.lastIndexOf('/') + 1);
if (processNumber) {
processNumberTarget = processNumber;
}
}
pubSub.publish(broadcastType.processAreaRouteChanged, {
areaId: areaIdTarget,
processNumber: processNumberTarget,
processClassification: processClassificationTarget
});
break;
case 'go-to-handbook-home':
backendRoute = '/';
$state.go('home');
break;
case 'open-full-screen-diagram':
documentService.showFullscreen();
break;
case 'close-full-screen-diagram':
documentService.showNormal();
tabStateService.adjustContentHeightPosition(tabStateType.documentTabState);
$('#document-content-identifier').css('margin-top', '0px');
break;
case 'hide-navigation-bar':
angular.element('#dropdownusername').removeClass('open');
if (angular.element('.activity-notifications > div').css('display') === 'block') {
angular.element('.activity-notifications > div').css('display', 'none');
}
break;
case 'update-favorites-processes':
pubSub.publish(broadcastType.updateFavoritesProcesses, true);
break;
case 'rebuild-tree-view':
// pubSub.publish(broadcastType.rebuildTreeView);
break;
case 'start-loading-spinner':
var loadingSpinner = document.getElementById('ng-loading-spinner');
if (loadingSpinner)
loadingSpinner.style.display = 'block';
break;
case 'stop-loading-spinner':
var loadingSpinner = document.getElementById('ng-loading-spinner');
if (loadingSpinner)
loadingSpinner.style.display = 'none';
break;
case 'update-document-title':
$rootScope.$apply(function () {
$rootScope.title = globalResources.Handbook + " - " + event.data.value;
$rootScope.metaDescription = event.data.value;
});
break;
default:
backendRoute = '/';
}
if (!backendRoute) return;
let url = $location.url();
if (backendRoute.indexOf('?isfrontend') > -1) {
backendRoute = backendRoute.substring(0, backendRoute.indexOf('?isfrontend'));
}
if (url === backendRoute) return;
if (!history.state || !history.state.id || (history.state.id !== backendRoute)) {
history.pushState({ id: backendRoute }, backendRoute, backendRoute);
}
});
}]);
})();;
(function () {
'use strict';
angular.module('processModule')
.config(['$stateProvider', '$urlRouterProvider', routesConfig]);
function routesConfig($stateProvider, $urlRouterProvider) {
$stateProvider
.state('areas-root-view', {
url: '/process-fe/home/root-details',
params: {},
templateUrl: 'app/process/areas-root-view/areas-root-view.html',
controller: 'areas-root-view.controller',
controllerAs: 'vm',
data: {
title: 'Process Home',
description: 'Process Home'
}
})
.state('process-area-detail', {
url: '/process-fe/area/detail/:areaId',
params: { areaId: '0' },
templateUrl: 'app/process/area-detail/area-detail.html',
controller: 'area-detail.controller',
controllerAs: 'vm',
data: {
title: 'Area detail',
description: 'Area detail'
}
})
.state('process-detail', {
url: '/process-fe/process-detail/:processNumber',
params: { processNumber: 0 },
templateUrl: 'app/process/process-detail-view/process-detail-view.html',
controller: 'process-detail-view.controller',
controllerAs: 'vm',
data: {
title: 'Process detail',
description: 'Process detail'
}
})
.state('process-interconnected', {
url: '/process-fe/process-interconnected/:processNumber',
params: { processNumber: 0 },
templateUrl: 'app/process/process-interconnected-view/process-interconnected-view.html',
controller: 'process-interconnected-view.controller',
controllerAs: 'vm',
data: {
title: 'Process Interconnected',
description: 'Process Interconnected'
}
})
.state('process-hearing-view', {
url: '/process-fe/process-detail/viewsendtohearing/:processNumber/:version',
params: { processNumber: '0', version: '' },
templateUrl: 'app/process/process-hearing-view/process-hearing-view.html',
controller: 'process-hearing-view.controller',
controllerAs: 'vm',
data: {
title: 'Process hearing',
description: 'Process hearing'
}
})
.state('process-interconnected-hearing-view', {
url: '/process-fe/process-interconnected/viewsendtohearing/:processNumber/:version',
params: { processNumber: '0', version: '' },
templateUrl: 'app/process/process-interconnected-hearing-view/process-interconnected-hearing-view.html',
controller: 'process-interconnected-hearing-view.controller',
controllerAs: 'vm',
data: {
title: 'Interconnected hearing',
description: 'Interconnected hearing'
}
});
$urlRouterProvider.otherwise('/');
};
})();;
(function () {
angular
.module('checklistModule', [])
.run(['$location', '$state', 'pubSub', 'documentService', 'tabStateService', '$rootScope', function ($location, $state, pubSub, documentService, tabStateService, $rootScope) {
window.addEventListener("message", (event) => {
if (!event.data || event.data.moduleName != 'checklist' || !event.data.eventName)
return;
let backendRoute = '';
switch (event.data.eventName) {
case 'checklist-route-change':
let frontendRoute = event.data.value.toLowerCase();
if (frontendRoute.indexOf('checklist/home') > -1) {
backendRoute = '/checklist-fe/home';
} else {
backendRoute = '/checklist-fe/' + frontendRoute;
}
break;
default:
backendRoute = '/';
}
if (!backendRoute) return;
let url = $location.url();
if (url === backendRoute) return;
if (backendRoute.indexOf('?isHideTopbar') > -1) {
backendRoute = backendRoute.substring(0, backendRoute.indexOf('?isHideTopbar'));
}
if (!history.state || !history.state.id || (history.state.id !== backendRoute)) {
history.pushState({}, backendRoute, backendRoute);
//window.dispatchEvent(new PopStateEvent('popstate', {
// state: history.state
//}));
}
});
}]);
})();;
(function () {
'use strict';
angular.module('checklistModule')
.config(['$stateProvider', '$urlRouterProvider', routesConfig]);
function routesConfig($stateProvider, $urlRouterProvider) {
var internalPaths = window.paths;
$stateProvider
.state('checklistHome', {
url: '/checklist-fe/home',
templateUrl: internalPaths.FrontpageHome,
controller: 'homeController',
controllerAs: 'vm',
reloadOnSearch: false,
data: {
title: 'Checklist Home',
description: 'Checklist Home'
}
})
.state('checklistCategories', {
url: '/checklist-fe/categories?isHideTopbar',
templateUrl: internalPaths.FrontpageHome,
controller: 'homeController',
controllerAs: 'vm',
reloadOnSearch: false,
data: {
title: 'Checklist categories',
description: 'Checklist categories'
}
})
.state('completedchecklists', {
url: '/checklist-fe/completedchecklists',
templateUrl: internalPaths.FrontpageHome,
controller: 'homeController',
controllerAs: 'vm',
reloadOnSearch: false,
data: {
title: 'Completed checklist categories',
description: 'Completed checklist categories'
}
})
.state('fillchecklistfromcategorymain', {
url: '/checklist-fe/category/main',
templateUrl: internalPaths.FrontpageHome,
controller: 'homeController',
controllerAs: 'vm',
reloadOnSearch: false,
data: {
title: 'Fill checklist categories',
description: 'Fill checklist categories'
}
})
.state('adminsubcategory', {
url: '/checklist-fe/adminsubcategory/:categoryId',
templateUrl: internalPaths.FrontpageHome,
controller: 'homeController',
controllerAs: 'vm',
reloadOnSearch: false,
data: {
title: 'Admin sub categories',
description: 'Admin sub categories'
}
})
.state('adminsubcategoryadd', {
url: '/checklist-fe/adminsubcategory/add/:categoryId',
templateUrl: internalPaths.FrontpageHome,
controller: 'homeController',
controllerAs: 'vm',
reloadOnSearch: false,
data: {
title: 'Add admin sub category',
description: 'Add admin sub category'
}
})
.state('adminsubcategoryedit', {
url: '/checklist-fe/adminsubcategory/edit/:categoryId',
templateUrl: internalPaths.FrontpageHome,
controller: 'homeController',
controllerAs: 'vm',
reloadOnSearch: false,
data: {
title: 'Edit admin sub category',
description: 'Edit admin sub category'
}
})
.state('admincategoryadd', {
url: '/checklist-fe/category/add',
templateUrl: internalPaths.FrontpageHome,
controller: 'homeController',
controllerAs: 'vm',
reloadOnSearch: false,
data: {
title: 'Add admin category',
description: 'Add admin category'
}
})
.state('admincategoryedit', {
url: '/checklist-fe/category/edit/:id',
templateUrl: internalPaths.FrontpageHome,
controller: 'homeController',
controllerAs: 'vm',
reloadOnSearch: false,
data: {
title: 'Edit admin category',
description: 'Edit admin category'
}
})
.state('checklistofsubcategory', {
url: '/checklist-fe/list/:categoryId',
templateUrl: internalPaths.FrontpageHome,
controller: 'homeController',
controllerAs: 'vm',
reloadOnSearch: false,
data: {
title: 'List Checklist',
description: 'List Checklist'
}
})
.state('editchecklistdetail', {
url: '/checklist-fe/tem/edit/:categoryId/:checklistId/:type',
templateUrl: internalPaths.FrontpageHome,
controller: 'homeController',
controllerAs: 'vm',
reloadOnSearch: false,
data: {
title: 'Edit Checklist detail',
description: 'Edit Checklist detail'
}
})
.state('editchecklistfield', {
url: '/checklist-fe/tem/addeditfield/:categoryId/:checkListId/:type',
templateUrl: internalPaths.FrontpageHome,
controller: 'homeController',
controllerAs: 'vm',
reloadOnSearch: false,
data: {
title: 'Edit Checklist field',
description: 'Edit Checklist field'
}
})
.state('adminmaincategoryaccess', {
url: '/checklist-fe/adminmaincategoryaccess',
templateUrl: internalPaths.FrontpageHome,
controller: 'homeController',
controllerAs: 'vm',
reloadOnSearch: false,
data: {
title: 'Main categories Access',
description: 'Main categories Access'
}
})
.state('editaccesscategory', {
url: '/checklist-fe/editaccesscategory/:fromEntityId/:id/:fromType',
templateUrl: internalPaths.FrontpageHome,
controller: 'homeController',
controllerAs: 'vm',
reloadOnSearch: false,
data: {
title: 'Edit categories Access',
description: 'Edit categories Access'
}
})
.state('editaccesschecklist', {
url: '/checklist-fe/editaccesschecklist/:fromEntityId/:id/:fromType',
templateUrl: internalPaths.FrontpageHome,
controller: 'homeController',
controllerAs: 'vm',
reloadOnSearch: false,
data: {
title: 'Edit checklist Access',
description: 'Edit checklist Access'
}
})
.state('editaccessmaincategory', {
url: '/checklist-fe/editaccessmaincategory/:id',
templateUrl: internalPaths.FrontpageHome,
controller: 'homeController',
controllerAs: 'vm',
reloadOnSearch: false,
data: {
title: 'Edit Access main category',
description: 'Edit Access main category'
}
})
.state('editaccesscategorychecklist', {
url: '/checklist-fe/editaccesscategorychecklist/:fromEntityId/:id/:type',
templateUrl: internalPaths.FrontpageHome,
controller: 'homeController',
controllerAs: 'vm',
reloadOnSearch: false,
data: {
title: 'Edit Access category',
description: 'Edit Access category'
}
})
.state('adminsubcategoryaccess', {
url: '/checklist-fe/adminsubcategoryaccess/:id',
templateUrl: internalPaths.FrontpageHome,
controller: 'homeController',
controllerAs: 'vm',
reloadOnSearch: false,
data: {
title: 'Admin sub category access',
description: 'Admin sub category access'
}
})
.state('categorysubcategory', {
url: '/checklist-fe/category/subcategory/:cateId',
templateUrl: internalPaths.FrontpageHome,
controller: 'homeController',
controllerAs: 'vm',
reloadOnSearch: false,
data: {
title: 'Sub category',
description: 'Sub category'
}
})
.state('checklistWidget', {
url: '/checklist-fe/tem/viewlist/:cateId',
templateUrl: internalPaths.FrontpageHome,
controller: 'homeController',
controllerAs: 'vm',
reloadOnSearch: false,
data: {
title: 'Checklist',
description: 'Checklist'
}
})
.state('completedchecklistsdetail', {
url: '/checklist-fe/completedchecklists/detail/:id',
templateUrl: internalPaths.FrontpageHome,
controller: 'homeController',
controllerAs: 'vm',
reloadOnSearch: false,
data: {
title: 'Completed Checklist',
description: 'Completed Checklist'
}
})
.state('implementChecklist', {
url: '/checklist-fe/implement/add/:categoryId/:checklistId',
templateUrl: internalPaths.FrontpageHome,
controller: 'homeController',
controllerAs: 'vm',
reloadOnSearch: false,
data: {
title: 'Implement Checklist',
description: 'Implement Checklist'
}
})
.state('implementChecklistNoPermission', {
url: '/checklist-fe/implement/fromemail/add/:categoryId/:checklistId',
templateUrl: internalPaths.FrontpageHome,
controller: 'homeController',
controllerAs: 'vm',
reloadOnSearch: false,
data: {
title: 'Implement Checklist',
description: 'Implement Checklist'
}
})
.state('editDraftChecklist', {
url: '/checklist-fe/implement/edit/:categoryId/:checklistId/:implementId/:fieldId',
templateUrl: internalPaths.FrontpageHome,
controller: 'homeController',
controllerAs: 'vm',
reloadOnSearch: false,
data: {
title: 'Edit Draft Checklist',
description: 'Edit Draft Checklist'
}
})
;
$urlRouterProvider.otherwise('/');
};
})();;
(function () {
'use strict';
angular.module('processModule')
.controller('areasTreeview', areasTreeviewController);
areasTreeviewController.$inject = ['$scope', '$timeout', '$http', '$state', 'pubSub', 'configService'];
function areasTreeviewController($scope, $timeout, $http, $state, pubSub, configService) {
var vm = this;
var currentRecursiveIndex = 0;
var indexOfChildren = 0;
var killProcessAreaRouteChanged = null;
vm.isExpanded = false;
vm.initialize = initialize;
vm.items = [];
vm.parentList = [];
vm.allAreas = [];
vm.selectNodeInAreaTree = selectNodeInAreaTree;
vm.handleExpandArea = handleExpandArea;
vm.wrapText = configService.getBool(HandbookConfiguration.WrapTextInNavigationTree);
vm.InterconnectedProcess = configService.getBool(HandbookConfiguration.InterconnectedProcess);
vm.processClassificationTypes = E.processClassificationTypes;
vm.processRelatedItemType = E.processRelatedItemType;
function initialize() {
getAllAccessibleAreas();
buildTree();
killProcessAreaRouteChanged = pubSub.subscribe(broadcastType.processAreaRouteChanged, processAreaRouteChanged);
}
$scope.$on('$destroy', function () {
killProcessAreaRouteChanged();
});
function buildTree() {
$http.get(handbookRequests.GetProcessAreasRequest, {
params: {
areaId: null,
showProcessesInTree: true,
isOnlyApproved: true,
isInterconnectedProcess: vm.InterconnectedProcess
}
}).success(function (data) {
if (data) {
$scope.processAreasList = data.areas;
decorateNodes($scope.processAreasList, null);
if (window.location.href.indexOf('/area/detail') > -1) {
let areaId = window.location.href.substring(window.location.href.lastIndexOf('/') + 1);
if (areaId && areaId != '') {
getParentAreasRecursive(areaId, true);
}
}
else if (window.location.href.indexOf('/process-detail/viewsendtohearing') > -1) {
const url = '/process-detail/viewsendtohearing/';
let substringFrom = window.location.href.lastIndexOf(url) + url.length;
let substringTo = window.location.href.lastIndexOf('/');
let processNumber = window.location.href.slice(substringFrom, substringTo);
if (processNumber && processNumber != '') {
getParentAreasRecursive(processNumber, false);
}
}
else if (window.location.href.indexOf('/process-detail') > -1) {
let processNumber = window.location.href.substring(window.location.href.lastIndexOf('/') + 1);
if (processNumber && processNumber != '') {
getParentAreasRecursive(processNumber, false);
}
}
else if (window.location.href.indexOf('/process-interconnected') > -1) {
let processNumber = window.location.href.substring(window.location.href.lastIndexOf('/') + 1);
if (processNumber && processNumber != '') {
getParentAreasProcessInterconnectedRecursive(processNumber, false);
}
}
}
});
}
$scope.options = {
dropped: function (event) { },
beforeDrop: function (event) { }
};
function getAllAccessibleAreas() {
return $http.get(handbookRequests.GetAllAccessibleAreasRequest, {
params: {
changeLocationMode: 0 //changeLocationMode.ReadArea
}
}).success(function (data) {
if (data) {
vm.allAreas = data;
}
},
function () {
vm.allAreas = [];
});
}
function processAreaRouteChanged(target) {
if (target.areaId == null && target.processNumber == null) {
$('.selected').removeClass('selected');
}
if (target.processNumber && target.processClassification == E.processClassificationTypes.Processes) {
getParentAreasRecursive(target.processNumber, false);
} else if (target.processNumber && target.processClassification == E.processClassificationTypes.ProcessInterconnected) {
getParentAreasProcessInterconnectedRecursive(target.processNumber, false);
} else {
let isExistAreaId = vm.allAreas.some(function (item) { return item.id == target.areaId; });
if (isExistAreaId) {
getParentAreasRecursive(target.areaId, true);
}
}
}
function handleExpandArea(expanded, itemId, selectedNode) {
if (expanded == true && selectedNode.$modelValue.type == 0 && (selectedNode.$modelValue.childCount > 0)) {
var siblings = selectedNode.$parentNodeScope == null ? selectedNode.processAreasList : selectedNode.$parentNodeScope.$modelValue.items;
var modelValue = selectedNode.$modelValue;
if (modelValue.isLoaded) {
afterExpanded(itemId, 0);
return;
} else {
modelValue.isLoaded = true;
}
$http.get(handbookRequests.GetProcessAreasRequest, {
params: {
areaId: itemId,
showProcessesInTree: true,
isOnlyApproved: true,
isInterconnectedProcess: vm.InterconnectedProcess
}
})
.success(function (data, status, headers, config) {
if (data) {
decorateNodes(data.areas, data.processes);
var length = siblings.length;
for (var i = 0; i < length; i++) {
if (siblings[i].id == itemId) {
vm.selectedNode = siblings[i];
if (siblings[i].items == null) {
siblings[i].items = [];
}
siblings[i].items = siblings[i].items.concat(data.areas);
siblings[i].items = siblings[i].items.concat(data.processes);
afterExpanded(itemId, 0);
break;
}
}
}
},
function (data, status, headers, config) {
//modelValue.items = [];
});
}
}
function selectNodeInAreaTree(node, item, collapsed, $event) {
if ((item.type == 0 || !item.type) && !item.processClassification) {
$state.go('process-area-detail', { areaId: item.id });
}
else if (item.type == E.processRelatedItemType.Process && item.processClassification == 1) {
$state.go('process-detail', { processNumber: item.processNumber });
}
else if (item.type == E.processRelatedItemType.ProcessInterconnected && item.processClassification == 2) {
$state.go('process-interconnected', { processNumber: item.processNumber });
}
let isSelectedFolder = $(event.target).hasClass('selected');
if ((isSelectedFolder || collapsed) && HandbookConfiguration.ToggleFolderUponClick.toUpperCase() == "TRUE") {
vm.isExpanded = true;
item.expanded = !item.expanded;
handleExpandArea(collapsed, item.id, node);
$scope.toggle(node);
}
setHighlight($event);
}
$scope.toggle = function (scope) {
scope.toggle();
};
$scope.$on(broadcastType.collapseExpandSidebar, function (e, target) {
if (target.navigateSideBar) {
currentRecursiveIndex = 0;
//navigateToCurrentItem(null);
}
});
function decorateNodes(areas, processes) {
if (areas && areas.length) {
for (var i = 0; i < areas.length; i++) {
areas[i].type = 0;
}
}
if (processes && processes.length) {
for (var i = 0; i < processes.length; i++) {
if (processes[i].processClassification == E.processClassificationTypes.Processes) {
processes[i].type = E.processRelatedItemType.Process;
} else {
processes[i].type = E.processRelatedItemType.ProcessInterconnected;
}
processes[i].id = processes[i].processNumber;
}
}
}
function getParentAreasRecursive(itemId, isArea) {
return $http.get(handbookRequests.GetParentAreas, {
params: {
processNumber: isArea ? null : itemId,
areaId: isArea ? itemId : null,
isArea: isArea
}
})
.success(function (data, status, headers, config) {
if (data && data.length) {
var _parents = data;
decorateNodes(_parents, null);
if (!isArea) {
var process = {
id: itemId,
type: E.processRelatedItemType.Process,
parentAreaId: _parents[0].id
}
_parents = _parents.concat([process]);
}
navigateToCurrentItem($scope.processAreasList, _parents);
}
vm.isExpanded = false;
},
function (data, status, headers, config) {
modelValue.items = [];
});
}
function navigateToCurrentItem(tempItems, recursives) {
$timeout(function () {
onChildrenLoaded(tempItems, recursives);
}, 0);
}
function onChildrenLoaded(tempItems, recursives) {
vm.parentList = recursives;
vm.items = tempItems;
if (currentRecursiveIndex < vm.parentList.length) {
if (vm.items != null && vm.items.length) {
for (var i = 0; i < vm.items.length; i++) {
if (vm.items[i].id == vm.parentList[currentRecursiveIndex].id && vm.items[i].type == vm.parentList[currentRecursiveIndex].type) {
currentRecursiveIndex += 1;
indexOfChildren = i;
var node = angular.element('#treeProcesses #' + vm.items[indexOfChildren].id + '_' + vm.items[indexOfChildren].type);
if (!vm.items[indexOfChildren].expanded && vm.items[indexOfChildren].childCount > 0) {
node.trigger('click');
} else {
afterExpanded(vm.items[indexOfChildren].id, vm.items[indexOfChildren].type);
}
break;
}
}
}
}
}
function afterExpanded(nodeId, nodeType) {
if (currentRecursiveIndex == vm.parentList.length) { // it's current area/process
$timeout(function () {
var idSelected = angular.element("#treeProcesses #" + nodeId + '_' + (nodeType == E.processRelatedItemType.Process ? 'process' :
nodeType == E.processRelatedItemType.ProcessInterconnected ? 'processInterconnected' : 'area'));
$('.selected').removeClass('selected');
if (idSelected.length != 0) {
$(idSelected).addClass('selected');
$('.selected').focus();
}
}, 0);
currentRecursiveIndex = 0;
} else if (currentRecursiveIndex != 0) {
$timeout(function () {
vm.items = vm.items[indexOfChildren].items.map(function (element) {
if (element.entityId) {
let elementType = null;
if (element.processClassification == E.processClassificationTypes.ProcessInterconnected) {
elementType = E.processRelatedItemType.ProcessInterconnected;
} else {
elementType = E.processRelatedItemType.Process;
}
return {
id: element.processNumber,
type: elementType,
parentAreaId: element.processAreaId,
name: element.name,
expanded: true
}
}
else
return element;
});
onChildrenLoaded(vm.items, vm.parentList);
}, 0);
}
}
function setHighlight(event) {
$('.selected').removeClass('selected');
$(event.target).addClass('selected');
}
function getParentAreasProcessInterconnectedRecursive(itemId, isArea) {
return $http.get(handbookRequests.GetParentAreasOfInterconnectedProcess, {
params: {
processNumber: isArea ? null : itemId,
areaId: isArea ? itemId : null,
isArea: isArea
}
})
.success(function (data, status, headers, config) {
if (data && data.length) {
var _parents = data;
decorateNodes(_parents, null);
if (!isArea) {
var process = {
id: itemId,
type: E.processRelatedItemType.ProcessInterconnected,
parentAreaId: _parents[0].id
}
_parents = _parents.concat([process]);
}
navigateToCurrentItem($scope.processAreasList, _parents);
}
vm.isExpanded = false;
},
function (data, status, headers, config) {
modelValue.items = [];
});
}
};
})();
;
(function () {
angular
.module('dashboardModule', ['ui.bootstrap', 'ui.router'])
.run(['$location', '$state', function ($location, $state) {
window.addEventListener("message", (event) => {
if (!event.data || event.data.moduleName != 'dashboard' || !event.data.eventName)
return;
let backendRoute = '';
switch (event.data.eventName) {
case 'dashboard-route-change':
let frontendRoute = event.data.value.toLowerCase();
if (frontendRoute.indexOf('/reading-list/') > -1) {
let readingListId = frontendRoute.substring(frontendRoute.lastIndexOf('/') + 1);
if (readingListId.indexOf('?hidetopbar') > -1) {
readingListId = readingListId.substring(0, readingListId.indexOf('?hidetopbar'));
}
if (readingListId && readingListId != '') {
backendRoute = '/reading-list/' + readingListId;
$state.go('reading-list-detail', { readingListId: readingListId });
}
} else if (frontendRoute.indexOf('/reading-list') > -1) {
backendRoute = '/reading-list';
$state.go('reading-list');
}
break;
case 'handbook-home':
backendRoute = '/';
$state.go('home');
break;
default:
backendRoute = '/';
}
if (!backendRoute) return;
let url = $location.url();
if (backendRoute.indexOf('?hidetopbar') > -1) {
backendRoute = backendRoute.substring(0, backendRoute.indexOf('?hidetopbar'));
}
//if (url === backendRoute) return;
if (!history.state || !history.state.id || (history.state.id !== backendRoute)) {
history.pushState({ id: backendRoute }, backendRoute, backendRoute);
}
});
}]);
})();;
(function () {
'use strict';
angular.module('dashboardModule')
.config(['$stateProvider', '$urlRouterProvider', routesConfig]);
function routesConfig($stateProvider, $urlRouterProvider) {
$stateProvider
.state('reading-list', {
url: '/reading-list',
templateUrl: 'app/dashboard/reading-list/reading-list-view.html',
controller: 'reading-list-view.controller',
controllerAs: 'vm',
data: {
title: 'Reading list',
description: 'Reading list'
}
})
.state('reading-list-detail', {
url: '/reading-list/:readingListId',
params: { readingListId: null },
templateUrl: 'app/dashboard/reading-list/reading-list-view.html',
controller: 'reading-list-view.controller',
controllerAs: 'vm',
data: {
title: 'Reading list',
description: 'Reading list'
}
});
$urlRouterProvider.otherwise('/');
};
})();;
(function () {
'use strict';
angular.module('servicesModule')
.controller('AddMembersController', controller);
controller.$inject = ['$uibModalInstance', '$http', '$scope', 'existedEmployees', 'titlePage', 'roleId', 'excludedQuitDepartmentId', 'folderId', 'isHearing'];
function controller($modalInstance, $http, $scope, existedEmployees, titlePage, roleId, excludedQuitDepartmentId, folderId, isHearing) {
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;
vm.isHearing = isHearing;
vm.changeSaveSearch = changeSaveSearch;
vm.searchPatterns = [];
vm.searchByHearing = false;
initialize();
function initialize() {
if (vm.isHearing) {
getUserFilterSearches();
}
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) {
vm.searchByHearing = false;
resetselectedSearchPattern();
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.searchByHearing = false;
resetselectedSearchPattern();
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.searchByHearing = false;
resetselectedSearchPattern();
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 getUserFilterSearches() {
vm.searchPatterns = [];
$http.get('/api/Users/GetUserSavedSearches', { params: { searchFilterType: searchFilterTypes.hearingMembers } })
.then(function (res) {
if (res.data && res.data.length > 0) {
vm.searchPatterns = res.data;
vm.searchPatterns.unshift({
id: 0,
name: vm.translation.ChooseSavedHearingMembersList,
searchFilterType: searchFilterTypes.hearingMembers
});
vm.selectedSearchPattern = vm.searchPatterns[0];
}
vm.isHearing = (res.data && res.data.length > 0);
});
}
function changeSaveSearch() {
vm.selectedEmployees = [];
vm.selectedEmployeesCount = 0;
vm.search.pageIndex = 1;
vm.searchByHearing = true;
var selectedRequest = vm.selectedSearchPattern;
if (!selectedRequest || !selectedRequest.searchFilters) {
return;
}
var request = {
pageIndex: 1,
pageSize: 0,
searchIds: selectedRequest.searchFilters,
folderId: vm.search.folderId
};
$http.post('/api/users/GetEmployees', request).then(function (response) {
if (response.data) {
if (!vm.excludedEmployees)
vm.excludedEmployees = [];
vm.rowCollection = response.data.filter(x => !vm.excludedEmployees.find(y => y == x.id));
vm.originalCollection = angular.copy(vm.rowCollection);
}
});
}
function resetselectedSearchPattern() {
if (vm.isHearing && vm.searchPatterns.length > 0) {
vm.selectedSearchPattern = vm.searchPatterns[0];
}
}
};
})();;
(function () {
'use strict';
angular.module("handbookApp")
.controller('SendDocumentToHearingEmailController', controller);
controller.$inject = ['$uibModalInstance', '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', 'localStorageService', 'configService'];
function documentHearingFieldsController($http, $sce, $timeout, $location, $scope, $rootScope, $state, $anchorScroll,
documentService, anchorService, documentContentsSearchService, resizeService, $stateParams, folderService, localStorageService, configService) {
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 = configService.getBool(HandbookConfiguration.MetadataEnabled);
vm.isShowMetatagTab = configService.getBool(HandbookConfiguration.ShowMetatagTab);
vm.publishedVersion = configService.getBool(HandbookConfiguration.PublishedVersion);
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;
vm.clickChangeTab = clickChangeTab;
const listTabCanChange = ['document-about', 'document-searchincontent', 'document-metadata'];
vm.documentCKVersion = CkVersion.CK4;
vm.ckVersion = { 'CK4': CkVersion.CK4, 'CK5': CkVersion.CK5 };
initialize();
function initialize() {
processEmbedUrl();
//check and resize the view
resizeService.resizeView();
let tabState = localStorageService.getItem('DocumentTabState');
if (tabState && listTabCanChange.includes(tabState)) {
angular.element('#document-top-menu-identifier').css('top', '0px');
angular.element('#document-content-identifier').css('top', '0px');
}
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) {
if (result.data.hidden) {
showMessageError(globalResources.NoAccessDocument, '632');
return;
}
createTooltipsRelatedDocument(result.data);
vm.oldData = result.data;
vm.documentCKVersion = vm.oldData.isNewCKVersion;
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;
calculateMaxHeightOForDocumentContentIdentifierInit()
return vm.currentData;
})
.catch(function (result, status, headers, config) {
showMessageError(result.data, result.status);
});
};
function showMessageError(message, status) {
if (!status || status.toString() == '600') {
vm.errorMessage = globalResources.RequiredPermissionsToReadDocument;
} else if (status.toString() == '632') {
vm.errorMessage = globalResources.DocumentDoNotExistOrIsArchived;
} else if (status.toString() == '633') {
vm.errorMessage = globalResources.DocumentDoNotExistOrIsArchivedOrNotPublished;
vm.showDocumentLinkToBackendWhenError = true;
} else {
vm.errorMessage = message;
}
vm.showError = true;
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 = '';
}
}
}
angular.copy(vm.documentInformation, vm.originalData);
}
};
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 clickChangeTab() {
let tabStateChange = localStorageService.getItem('DocumentTabState');
if (!listTabCanChange.includes(tabStateChange)) {
angular.element('#document-top-menu-identifier').css('top', '65px');
angular.element('#document-content-identifier').css('top', '65px');
} else {
angular.element('#document-top-menu-identifier').css('top', '0px');
angular.element('#document-content-identifier').css('top', '0px');
}
}
function calculateMaxHeightOForDocumentContentIdentifierInit() {
let calculateMaxHeight = localStorageService.getItem('DocumentTabState');
if (!calculateMaxHeight || calculateMaxHeight == 'null' ) {
if (angular.element('#document-content-identifier')) {
angular.element('#document-content-identifier').css('maxHeight', `calc(100vh - ${angular.element('#document-content-identifier').position(0).top}px)`);
}
}
}
};
})();;
(function () {
'use strict';
angular.module('compareWithEarlierVersionModule', [])
.controller('CompareWithEarlierVersionController', controller);
controller.$inject = ['$http', '$state', '$sce', '$q', 'documentService', 'configService', 'anchorService', '$timeout', '$anchorScroll', '$location', '$scope'];
function controller($http, $state, $sce, $q, documentService, configService, anchorService, $timeout, $anchorScroll, $location, $scope) {
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.documentCKVersion = CkVersion.CK4;
vm.ckVersion = { 'CK4': CkVersion.CK4, 'CK5': CkVersion.CK5 };
vm.enableDocumentExtention = configService.getBool(HandbookConfiguration.EnableDocumentExtention);
vm.showCompareParentExtension = false;
vm.showCompareChildrenExtension = false;
initialize();
vm.printDocumentComparison = printDocumentComparison;
vm.changeFromVersion = changeFromVersion;
vm.changeToVersion = changeToVersion;
vm.viewCompareParentDocument = viewCompareParentDocument;
vm.viewCompareChildDocument = viewCompareChildDocument;
function initialize() {
angular.element('.main-container_header').hide();
documentService.showFullscreen();
if (vm.enableDocumentExtention) {
vm.parentDocumentId = 0;
var promises = [];
var hearingMode = true;
promises.push(documentService.getParentIdExtendDocument(vm.currentDocumentId, hearingMode));
promises.push(documentService.checkDocumentHaveToCompareById(vm.currentDocumentId, hearingMode));
$q.all(promises).then(function (result) {
var resultGetParentId = parseInt(result[0]);
if (resultGetParentId && resultGetParentId > 0) {
vm.parentDocumentId = resultGetParentId;
}
var resultCheckDocumentHaveToCompareById = result[1];
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.documentCKVersion = data.isNewCKVersion;
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(documentService.changeUrlBackendToFrontend(window.location.origin, data.earlierVersionHtml, true));
vm.data.latestVersionHtml = $sce.trustAsHtml(documentService.changeUrlBackendToFrontend(window.location.origin, data.latestVersionHtml, true));
vm.data.comparisonResult = $sce.trustAsHtml(documentService.changeUrlBackendToFrontend(window.location.origin, data.comparisonResult, true));
runServicesAfterInit();
})
.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 runServicesAfterInit() {
$timeout(function () {
updateLocalAnchors();
scrollToAnchorIfExists();
});
}
function updateLocalAnchors() {
var domContent = angular.element('div#comparisonResult');
anchorService.updateLocalAnchors(domContent);
}
function scrollToAnchorIfExists() {
var hash = $location.hash();
if (hash != '') {
$anchorScroll();
}
}
}
})();;
(function () {
'use strict';
angular.module('documentCompareWithEarlierVersionModule', [])
.controller('DocumentCompareWithEarlierVersionController', controller);
controller.$inject = ['$http', '$state', '$sce', '$scope', '$q', 'documentService', 'configService', 'anchorService', '$timeout', '$anchorScroll', '$location'];
function controller($http, $state, $sce, $scope, $q, documentService, configService, anchorService, $timeout, $anchorScroll, $location) {
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.documentCKVersion = CkVersion.CK4;
vm.ckVersion = { 'CK4': CkVersion.CK4, 'CK5': CkVersion.CK5 };
vm.advancedCompare = configService.getBool(HandbookConfiguration.AdvancedCompare);
vm.enableDocumentExtention = configService.getBool(HandbookConfiguration.EnableDocumentExtention);
vm.showCompareParentExtension = false;
vm.showCompareChildrenExtension = false;
initialize();
vm.printDocumentComparison = printDocumentComparison;
vm.changeFromVersion = changeFromVersion;
vm.changeToVersion = changeToVersion;
vm.viewCompareParentDocument = viewCompareParentDocument;
vm.viewCompareChildDocument = viewCompareChildDocument;
function initialize() {
documentService.showFullscreen();
window.addEventListener('resize', initCompareScrollEvent, true /*Capture event*/);
angular.element('.main-container_header').hide();
$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];
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.documentCKVersion = data.isNewCKVersion;
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(documentService.changeUrlBackendToFrontend(window.location.origin, data.earlierVersionHtml));
vm.data.latestVersionHtml = $sce.trustAsHtml(documentService.changeUrlBackendToFrontend(window.location.origin, data.latestVersionHtml));
vm.data.comparisonResult = $sce.trustAsHtml(documentService.changeUrlBackendToFrontend(window.location.origin, data.comparisonResult));
runServicesAfterInit();
})
.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}', vm.currentDocumentId, 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 runServicesAfterInit() {
$timeout(function () {
updateLocalAnchors();
scrollToAnchorIfExists();
});
}
function updateLocalAnchors() {
var domContent = angular.element('div#comparisonResult');
anchorService.updateLocalAnchors(domContent);
}
function scrollToAnchorIfExists() {
var hash = $location.hash();
if (hash != '') {
$anchorScroll();
}
}
}
})();;
(function () {
'use strict';
angular.module('handbookApp')
.controller("FieldsContentWholeDocumentController", FieldsContentWholeDocumentController);
FieldsContentWholeDocumentController.$inject = ['$http','$state', '$sce', '$timeout', '$location', '$scope', '$rootScope', '$anchorScroll',
'documentService', 'anchorService', 'documentContentsSearchService', 'resizeService', '$stateParams', 'pubSub', 'folderService',
'treeNavigationService', '$q', 'tabStateService', 'configService'];
function FieldsContentWholeDocumentController($http, $state, $sce, $timeout, $location, $scope, $rootScope, $anchorScroll,
documentService, anchorService, documentContentsSearchService, resizeService, $stateParams, pubSub, folderService,
treeNavigationService, $q, tabStateService, configService) {
var ignoreRichText = configService.getBool(HandbookConfiguration.LazyLoadRichText);
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 = configService.getBool(HandbookConfiguration.ShowDocumentLinkToBackend);
vm.simpleSubscription = configService.getBool(HandbookConfiguration.SimpleSubscription);
vm.isShowMetadata = configService.getBool(HandbookConfiguration.MetadataEnabled);
vm.isShowMetatagTab = configService.getBool(HandbookConfiguration.ShowMetatagTab);
vm.publishedVersion = configService.getBool(HandbookConfiguration.PublishedVersion);
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;
vm.documentCKVersion = CkVersion.CK4;
vm.ckVersion = { 'CK4': CkVersion.CK4, 'CK5': CkVersion.CK5 };
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;
vm.documentCKVersion = vm.currentData.isNewCKVersion;
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 = documentService.changeUrlBackendToFrontend(window.location.origin, response.data.content);
fieldContent.content = $sce.trustAsHtml(`${fieldContent.content} `);
fieldContent.isVisible = true;
}
});
richTextRequests.push(getRichText);
} else {
if (fieldContent.content) {
fieldContent.content = documentService.changeUrlBackendToFrontend(window.location.origin, response.data.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 = configService.getBool(HandbookConfiguration.EnableCompare) && vm.currentData.version > 0;
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');
}
};
})();;
(function () {
'use strict';
angular.module(modules.homeModule)
.controller('statisticsController', controller);
controller.$inject = ['$scope', '$location'];
function controller($scope, $location) {
var vm = this;
vm.firstLoaded = true;
vm.translation = resources;
// Variables
vm.alerts = [];
var urlParams = $location.url().split('/');
vm.tabsSetting = [];
vm.onTabSelected = onTabSelected;
// Main features
$scope.$on("tabActived", function (evt, data) {
if (vm.firstLoaded && data == 'statistics-tab') {
initialize();
vm.firstLoaded = false;
}
});
function initialize() {
buildTabsSetting();
onTabSelected(1);
}
function buildTabsSetting() {
vm.tabsSetting.push({
name: resources.L.Statistics.useAndKeyValues,
description: resources.L.Statistics.useAndKeyValues,
href: 'dailyStatistics',
icon: '',
tabIndex: 1,
active: true,
count: 0,
activatedClass: 'home-tab-active',
hide: false,
url: '/app/components/statistics/daily-statistics/daily-statistics.html',
elementContentId: 'dailyStatistics'
});
vm.tabsSetting.push({
name: resources.L.Statistics.folderStatistics,
description: resources.L.Statistics.folderStatistics,
href: 'folderStatistics',
icon: '',
tabIndex: 2,
active: false,
count: 0,
activatedClass: 'home-tab-active',
hide: false,
url: '/app/components/statistics/folder-statistics/folder-statistics.html',
elementContentId: 'folderStatistics'
});
}
function onTabSelected(tabIndex) {
var tab = vm.tabsSetting.find(x => x.tabIndex == tabIndex);
setTimeout(function () {
$scope.$apply(function () {
$scope.$broadcast("tabStatisticsActived", tab.href);
});
}, 100);
}
}
})();;
(function () {
'use strict';
angular.module(modules.homeModule).component('handbookDailyStatistics', {
templateUrl: 'app/components/statistics/daily-statistics/daily-statistics.html',
controller: controller,
controllerAs: 'vm',
bindings: {
}
});
controller.$inject = ['$http', '$scope'];
function controller($http, $scope) {
var vm = this;
vm.docUsageTodaysSetting = [];
$scope.$on("tabStatisticsActived", function (evt, data) {
if (data == 'dailyStatistics' && (!vm.docUsageTodaysSetting || vm.docUsageTodaysSetting.length == 0)) {
initialize();
}
});
function initialize() {
buildGridSetting();
getDailyStatistics();
}
function getDailyStatistics() {
var promise = $http.get('/api/Documents/GetDailyStatisticsOverView', {});
promise.success(function (data, status, headers, config) {
var result = data;
vm.objHandbookStatistics = result.objHandbookStatistics;
vm.arrDailyStatistics = result.arrDailyStatistics;
vm.docUsageTodays = result.docUsageTodays;
getHighCharts(vm.arrDailyStatistics);
});
}
function buildGridSetting() {
vm.docUsageTodaysSetting = [
{ id: 'name', name: resources.L.Statistics.mostReadToday, width: 57, coldefault: true , isObject: false },
{ id: 'id', name: resources.L.Statistics.documentId, width: 26, coldefault: true, isObject: false },
{ id: 'countValue', name: resources.L.Statistics.quantity, width: 18, coldefault: true, isObject: false, customCss: 'text-right' }
];
}
function getHighCharts(data) {
if (!data || !data.length)
return;
var categories = data.map(x => x.accessDateDisplay);
var documents = data.map(x => x.docAccessCount);
var users = data.map(x => x.userAccessCount);
var aa = document.getElementById('daily-charts-id');
var chart = Highcharts.chart('daily-charts-id', {
chart: {
zoomType: 'xy',
},
title: {
text: resources.L.Statistics.dailyUseDoc
},
subtitle: {
text: ''
},
xAxis: [{
categories: categories,
crosshair: true
}],
yAxis: [{ // Primary yAxis
allowDecimals: false,
labels: {
format: '{value}',
style: {
color: Highcharts.getOptions().colors[1]
}
},
title: {
text: resources.L.Statistics.users,
style: {
color: Highcharts.getOptions().colors[1]
}
}
}, { // Secondary yAxis
title: {
text: resources.L.Common.documents,
style: {
color: Highcharts.getOptions().colors[0]
}
},
labels: {
format: '{value}',
style: {
color: Highcharts.getOptions().colors[0]
}
},
opposite: true
}],
tooltip: {
shared: true
},
legend: {
layout: 'vertical',
align: 'left',
x: 50,
verticalAlign: 'top',
y: -10,
floating: true,
backgroundColor:
Highcharts.defaultOptions.legend.backgroundColor || // theme
'rgba(255,255,255,0.25)'
},
series: [{
name: resources.L.Common.documents,
type: 'column',
yAxis: 1,
data: documents,
tooltip: {
valueSuffix: ''
}
}, {
name: resources.L.Statistics.users,
type: 'spline',
data: users,
tooltip: {
valueSuffix: ''
}
}]
});
}
}
})();;
(function () {
'use strict';
angular.module(modules.homeModule).component('handbookFoderStatistics', {
templateUrl: 'app/components/statistics/folder-statistics/folder-statistics.html',
controller: controller,
controllerAs: 'vm',
bindings: {
}
});
controller.$inject = ['$http', '$scope', 'configService'];
function controller($http, $scope, configService) {
var vm = this;
vm.tabsChartsSetting = [];
vm.periods = [];
vm.subFolderStatisticsSetting = [];
vm.defaultSelectedFolder = { id: null, name: resources.L.Common.all, type: 0 };
vm.folderName = resources.L.Common.all;
vm.statisticsPercentageForAwaitingApproval = configService.getBool(HandbookConfiguration.StatisticsPercentageForAwaitingApproval);
vm.folderId = null;
vm.getSelectedNode = getSelectedNode;
vm.changePeriod = changePeriod;
$scope.$on("tabStatisticsActived", function (evt, data) {
if (data == 'folderStatistics' && (!vm.tabsChartsSetting || vm.tabsChartsSetting.length == 0)) {
initialize();
}
});
function initialize() {
getPeriods();
vm.selectOptionPeriod = 2;
buildTabsSetting();
getFolderStatistics(null, vm.selectOptionPeriod);
}
function buildGridSetting(nameFolder) {
vm.subFolderStatisticsSetting = [
{ id: 'folderName', name: nameFolder, width: 30, coldefault: true, isObject: false },
{ id: 'approved', name: resources.L.Statistics.docsInUse, width: 10, coldefault: true, isObject: false, customCss: 'font-weight-normal' },
{ id: 'internet', name: resources.L.Document.internet, width: 10, coldefault: true, isObject: false, customCss: 'font-weight-normal' },
{ id: 'newCount', name: resources.L.Statistics.newThisMonth, width: 10, coldefault: true, isObject: false, customCss: 'font-weight-normal' },
{ id: 'revised', name: resources.L.Statistics.revisedThisMonth, width: 10, coldefault: true, isObject: false, customCss: 'font-weight-normal' },
{ id: 'archived', name: resources.L.Statistics.archivedThisMonth, width: 10, coldefault: true, isObject: false, customCss: 'font-weight-normal' },
{ id: 'awaitingApproval', name: resources.L.Enum.DocumentStatuses.awaitingApproval, width: 10, coldefault: true, isObject: false, customCss: 'font-weight-normal' },
{ id: 'expired', name: resources.L.Statistics.expired, width: 10, coldefault: true, isObject: false, customCss: 'font-weight-normal' }
];
}
function getPeriods() {
vm.periods = [
{ id: 0, name: resources.L.Common.all },
{ id: 1, name: resources.L.Statistics.fiveYear },
{ id: 2, name: resources.L.Statistics.last13Months },
];
}
function buildTabsSetting() {
vm.tabsChartsSetting.push({
name: resources.L.Statistics.approvedVsInternet,
description: resources.L.Statistics.approvedVsInternet,
href: 'approveInternet',
icon: 'fa fa-line-chart',
tabIndex: 1,
active: true,
count: 0,
activatedClass: 'home-tab-active',
hide: false,
url: '',
elementContentId: 'approveInternet'
});
vm.tabsChartsSetting.push({
name: resources.L.Statistics.newVsRevisedVsArchived,
description: resources.L.Statistics.newVsRevisedVsArchived,
href: 'newRevisedArchived',
icon: 'fa fa-line-chart',
tabIndex: 2,
active: false,
count: 0,
activatedClass: 'home-tab-active',
hide: false,
url: '',
elementContentId: 'newRevisedArchived'
});
vm.tabsChartsSetting.push({
name: resources.L.Statistics.awaitingApprovalVsExpired,
description: resources.L.Statistics.awaitingApprovalVsExpired,
href: 'awaitingApprovedExpired',
icon: 'fa fa-line-chart',
tabIndex: 2,
active: false,
count: 0,
activatedClass: 'home-tab-active',
hide: false,
url: '',
elementContentId: 'awaitingApprovedExpired'
});
}
function getFolderStatistics(folderId, type) {
buildGridSetting(vm.folderName);
var request = {
handbookId: folderId,
type: type
};
var promise = $http.get('/api/Documents/GetFolderStatisticsOverView', { params: request });
promise.success(function (data, status, headers, config) {
var result = data;
vm.folderStatistics = result.folderStatistics;
vm.subFolderStatistics = result.subFolderStatistics;
buildChartApprovedInternet(result.folderStatisticsForCharts);
buildChartNewRevisedArchived(result.folderStatisticsForCharts);
buildChartAwaitingApprovalExpired(result.folderStatisticsForCharts);
});
}
function buildChartApprovedInternet(data) {
var approveTitle = resources.L.Document.approved;
var internetTitle = resources.L.Document.internet;
var categories = data.map(x => x.monthYear);
var approvedDocs = data.map(x => x.approved);
var internetDocs = data.map(x => x.internet);
Highcharts.chart('approve-internet-charts-id', {
title: {
text: resources.L.Statistics.approvedVsInternet
},
subtitle: {
text: ''
},
yAxis: {
title: {
text: resources.L.Common.number
}
},
xAxis: {
categories: categories
},
legend: {
layout: 'vertical',
align: 'right',
verticalAlign: 'middle'
},
plotOptions: {
series: {
label: {
connectorAllowed: false
},
pointStart: null
}
},
series: [{
name: approveTitle,
data: approvedDocs
}, {
name: internetTitle,
data: internetDocs
}],
responsive: {
rules: [{
condition: {
maxWidth: 500
},
chartOptions: {
legend: {
layout: 'horizontal',
align: 'center',
verticalAlign: 'bottom'
}
}
}]
}
});
}
function buildChartNewRevisedArchived(data) {
var categories = data.map(x => x.monthYear);
var newCountDocs = data.map(x => x.newCount);
var revisedDocs = data.map(x => x.revised);
var archivedDocs = data.map(x => x.archived);
Highcharts.chart('new-revised-archived-charts-id', {
title: {
text: resources.L.Statistics.newVsRevisedVsArchived
},
subtitle: {
text: ''
},
yAxis: {
title: {
text: resources.L.Common.number
}
},
xAxis: {
categories: categories
},
legend: {
layout: 'vertical',
align: 'right',
verticalAlign: 'middle'
},
plotOptions: {
series: {
label: {
connectorAllowed: false
},
pointStart: null
}
},
series: [{
name: resources.L.Action.new,
data: newCountDocs
}, {
name: resources.L.Statistics.revised,
data: revisedDocs
}, {
name: resources.L.Common.archived,
data: archivedDocs
}],
responsive: {
rules: [{
condition: {
maxWidth: 500
},
chartOptions: {
legend: {
layout: 'horizontal',
align: 'center',
verticalAlign: 'bottom'
}
}
}]
}
});
}
function buildChartAwaitingApprovalExpired(data) {
var categories = data.map(x => x.monthYear);
var awaitingApprovalDocs = data.map(x => x.awaitingApproval);
var expiredDocs = data.map(x => x.expired);
Highcharts.chart('awaiting-approved-expired-charts-id', {
title: {
text: resources.L.Statistics.awaitingApprovalVsExpired
},
subtitle: {
text: ''
},
yAxis: {
title: {
text: resources.L.Common.number
}
},
xAxis: {
categories: categories
},
legend: {
layout: 'vertical',
align: 'right',
verticalAlign: 'middle'
},
plotOptions: {
series: {
label: {
connectorAllowed: false
},
pointStart: null
}
},
series: [{
name: resources.L.Enum.DocumentStatuses.awaitingApproval,
data: awaitingApprovalDocs
}, {
name: resources.L.Statistics.expired,
data: expiredDocs
}],
responsive: {
rules: [{
condition: {
maxWidth: 500
},
chartOptions: {
legend: {
layout: 'horizontal',
align: 'center',
verticalAlign: 'bottom'
}
}
}]
}
});
}
function getSelectedNode(node) {
if (node != null) {
vm.folderId = node.id;
vm.folderName = node.name;
getFolderStatistics(vm.folderId, vm.selectOptionPeriod);
}
}
function changePeriod() {
var request = {
handbookId: vm.folderId,
type: vm.selectOptionPeriod
};
var promise = $http.get('/api/Documents/GetFolderStatisticsForChart', { params: request });
promise.success(function (data, status, headers, config) {
var result = data;
buildChartApprovedInternet(result);
buildChartNewRevisedArchived(result);
buildChartAwaitingApprovalExpired(result);
});
}
}
})();;
(function () {
'use strict';
angular.module('servicesModule')
.controller('AboutFolderModalController', controller);
controller.$inject = ['$scope', '$http', '$uibModal', '$uibModalInstance', 'model', '$sce'];
function controller($scope, $http, $uibModal, $modalInstance, model, $sce) {
var vm = this;
vm.globalResources = angular.copy(globalResources);
vm.data = model;
vm.close = close;
initialize();
function initialize() {
}
function close() {
$modalInstance.close(true);
};
};
})();;
(function () {
'use strict';
angular.module('servicesModule').controller('WhatsNewFolderModalController', controller);
controller.$inject = ['$scope', '$http', '$uibModal', '$uibModalInstance', 'model', '$sce'];
function controller($scope, $http, $uibModal, $modalInstance, model, $sce) {
var vm = this;
vm.globalResources = angular.copy(globalResources);
vm.data = model;
vm.close = close;
vm.showDropdown = false;
vm.listPeriod = [
{ name: vm.globalResources.Today, value: 0 },
{ name: vm.globalResources.LastWeek, value: 1 },
{ name: vm.globalResources.LastMonth, value: 2 },
{ name: vm.globalResources.Last3Months, value: 3 },
];
vm.selectedPeriod = vm.listPeriod[parseInt(HandbookConfiguration.WhatsNewPeriodFolder)];
vm.selectPeriod = selectPeriod;
vm.whatsNewDocuments = vm.data.WhatsNewDocuments;
vm.showWhatsNewDocumentsInSubChapters = vm.data.showWhatsNewDocumentsInSubChapters;
vm.showWhatsNewDocumentsRecursive = showWhatsNewDocumentsRecursive;
initialize();
function initialize() {
setPeriod(parseInt(vm.data.selectedOption))
}
function setPeriod(optionNumber) {
const period = vm.listPeriod.filter(function (period) {
return period.value == optionNumber;
})
if (period && period.length) {
vm.selectedPeriod = period[0];
}
}
function selectPeriod(period) {
vm.data.changeSelectedOptionInMobileView(period);
setPeriod(period.value);
getWhatsNewForFolder();
}
function showWhatsNewDocumentsRecursive() {
getWhatsNewForFolder();
}
function getWhatsNewForFolder() {
$http.get(handbookRequests.GetRecentlyApprovedDocumentsForFolder, { params: { 'folderId': vm.data.folderData.id, 'includeSubFolder': vm.showWhatsNewDocumentsInSubChapters, 'periodOption': vm.selectedPeriod.value } })
.success(function (data, status, headers, config) {
vm.whatsNewDocuments = data;
});
};
function close() {
$modalInstance.close(true);
};
};
})();;
(function () {
'use strict';
angular.module('servicesModule')
.controller('AboutDocumentModalController', controller);
controller.$inject = ['$scope', '$http', '$uibModal', '$uibModalInstance', 'model', '$sce'];
function controller($scope, $http, $uibModal, $modalInstance, model, $sce) {
var vm = this;
vm.globalResources = angular.copy(globalResources);
vm.data = model;
vm.close = close;
vm.goToFolder = goToFolder;
initialize();
function initialize() {
handleScroll();
}
function handleScroll() {
setTimeout(function () {
angular.element(document.querySelector('.about-detail-container')).bind('scroll', function () {
const aboutDetailContainerTop = $('#documentViewId').position().top;
const documentTitleContainerBottom = $('#documentTitleContainer').position().top + $('#documentTitleContainer').height();
if (aboutDetailContainerTop < documentTitleContainerBottom) {
angular.element('#documentTitleContainer').addClass('shadow-effect');
}
else {
angular.element('#documentTitleContainer').removeClass('shadow-effect');
}
})
}, 0)
}
function close() {
$modalInstance.close(true);
};
function goToFolder(folderId) {
vm.close();
window.open(`/folder/${folderId}`, '_self')
}
};
})();;
(function () {
angular.module('annualCycleModule', ['ui.bootstrap', 'ui.router']).run(['$location', '$state', function ($location, $state) {
window.addEventListener("message", (event) => {
if (!event.data || event.data.moduleName != 'annualCycle' || !event.data.eventName)
return;
let backendRoute = '';
switch (event.data.eventName) {
case 'annual-cycle-route-change':
let frontendRoute = event.data.value.toLowerCase();
if (frontendRoute.indexOf('activity/') > -1) {
let activityId = frontendRoute.substring(frontendRoute.lastIndexOf('/') + 1);
if (activityId && activityId != '') {
backendRoute = 'ac/activity/' + activityId;
}
} else if (frontendRoute.indexOf('task/') > -1) {
let taskId = frontendRoute.substring(frontendRoute.lastIndexOf('/') + 1);
if (taskId && taskId != '') {
backendRoute = 'ac/task/' + taskId;
}
}
else if (frontendRoute == '/home') {
backendRoute = 'ac/home';
}
break;
default:
backendRoute = '/';
break;
}
if (!backendRoute) return;
if (!history.state || !history.state.id || (history.state.id !== backendRoute)) {
history.pushState({ id: backendRoute }, backendRoute, backendRoute);
}
});
}]);
})();;
(function () {
'use strict';
angular.module('annualCycleModule')
.config(['$stateProvider', '$urlRouterProvider', routesConfig]);
function routesConfig($stateProvider, $urlRouterProvider) {
var internalPaths = window.paths;
$stateProvider
.state('oldActivityDetail', {
url: '/ac/activity/activityDetail/:activityId',
params: { activityId: '' },
templateUrl: internalPaths.FrontpageHome,
controller: 'homeController',
controllerAs: 'vm',
data: {
title: 'Activity Detail',
description: 'Activity Detail'
}
})
.state('activityDetail', {
url: '/ac/activity/:activityId',
params: { activityId: '' },
templateUrl: internalPaths.FrontpageHome,
controller: 'homeController',
controllerAs: 'vm',
data: {
title: 'Activity Detail',
description: 'Activity Detail'
}
})
.state('oldTaskDetail', {
url: '/ac/task/taskDetail/:taskId',
params: { taskId: '' },
templateUrl: internalPaths.FrontpageHome,
controller: 'homeController',
controllerAs: 'vm',
data: {
title: 'Task Detail',
description: 'Task Detail'
}
})
.state('taskDetail', {
url: '/ac/task/:taskId',
params: { taskId: '' },
templateUrl: internalPaths.FrontpageHome,
controller: 'homeController',
controllerAs: 'vm',
data: {
title: 'Task Detail',
description: 'Task Detail'
}
})
.state('activityList', {
url: '/ac/home',
templateUrl: internalPaths.FrontpageHome,
controller: 'homeController',
controllerAs: 'vm',
data: {
title: 'Activity List',
description: 'Activity List'
}
})
$urlRouterProvider.otherwise('/');
};
})();;
(function () {
'use strict';
angular.module('processModule')
.controller('area-detail.controller', areaDetailController);
areaDetailController.$inject = ['$stateParams', 'routeService', '$sce', 'pubSub'];
function areaDetailController($stateParams, routeService, $sce, pubSub) {
var vm = this;
vm.initialize = initialize;
vm.areaId = $stateParams.areaId;
vm.areaDetailIframe = '';
initialize();
function initialize() {
vm.areaDetailIframe = $sce.trustAsResourceUrl(routeService.getBaseRouteProcess() + 'area/detail/' + vm.areaId + '?isFrontend=true');
pubSub.publish(broadcastType.processAreaRouteChanged, {
areaId: vm.areaId
});
}
};
})();;
(function () {
'use strict';
angular.module('processModule')
.controller('areas-root-view.controller', areasRootViewController);
areasRootViewController.$inject = ['$scope', 'routeService', '$sce'];
function areasRootViewController($stateParams, routeService, $sce) {
var vm = this;
vm.initialize = initialize;
vm.areaId = $stateParams.areaId;
vm.areasRootViewIframe = '';
initialize();
function initialize() {
vm.areasRootViewIframe = $sce.trustAsResourceUrl(routeService.getBaseRouteProcess() + 'home/details?isOnlyApproved=true&isFrontend=true');
}
}
})();
;
(function () {
'use strict';
angular.module('processModule')
.controller('favoritesTreeView', favoritesTreeViewController);
favoritesTreeViewController.$inject = ['$scope', '$timeout', '$http', '$state', 'pubSub', 'configService'];
function favoritesTreeViewController($scope, $timeout, $http, $state, pubSub, configService) {
var vm = this;
var killUpdateFavoritesProcesses = null;
vm.isExpanded = false;
vm.initialize = initialize;
vm.items = [];
vm.selectNodeInAreaTree = selectNodeInAreaTree;
vm.handleExpandArea = handleExpandArea;
$scope.favoritesList = [];
vm.wrapText = configService.getBool(HandbookConfiguration.WrapTextInNavigationTree);
vm.processNodeType = E.ProcessNodeType;
vm.enableInterconnected = configService.getBool(HandbookConfiguration.InterconnectedProcess);
vm.processRoute = {
processAreaDetail: 'process-area-detail',
processDetail: 'process-detail',
processInterconnected: 'process-interconnected'
};
function initialize() {
killUpdateFavoritesProcesses = pubSub.subscribe(broadcastType.updateFavoritesProcesses, updateFavoritesProcesses);
}
$scope.$on('$destroy', function () {
killUpdateFavoritesProcesses();
});
$scope.$on("Favorites_GetProcessFavoritesList", function () {
getFavoritesList();
});
function getFavoritesList() {
$http.get(handbookRequests.GetFavoritesProcessesAreasRequest,
{ params: { isInterconnectedProcess: vm.enableInterconnected } })
.success(function (data) {
if (data) {
decorateNodes(data.areas, data.processes, data.processesInterconnected);
$scope.favoritesList = [];
$scope.favoritesList = data.processesInterconnected && data.processesInterconnected.length ? data.processesInterconnected : $scope.favoritesList;
$scope.favoritesList = $scope.favoritesList && $scope.favoritesList.length ? $scope.favoritesList.concat(data.processes) : data.processes;
$scope.favoritesList = $scope.favoritesList && $scope.favoritesList.length ? $scope.favoritesList.concat(data.areas) : data.areas;
}
});
}
$scope.options = {
dropped: function (event) { },
beforeDrop: function (event) { }
};
function updateFavoritesProcesses(target) {
if (target) {
getFavoritesList();
}
}
function handleExpandArea(expanded, itemId, selectedNode) {
if (expanded == true && selectedNode.$modelValue.type == 0 && (selectedNode.$modelValue.childCount > 0)) {
var siblings = selectedNode.$parentNodeScope == null ? selectedNode.favoritesList : selectedNode.$parentNodeScope.$modelValue.items;
var modelValue = selectedNode.$modelValue;
if (modelValue.isLoaded) {
return;
} else {
modelValue.isLoaded = true;
}
$http.get(handbookRequests.GetProcessAreasRequest, {
params: {
areaId: itemId,
showProcessesInTree: true,
isOnlyApproved: true,
isInterconnectedProcess: vm.enableInterconnected
}
})
.success(function (data) {
if (data) {
decorateNodes(data.areas, data.processes, data.processesInterconnected);
var length = siblings.length;
for (var i = 0; i < length; i++) {
if (siblings[i].id == itemId) {
vm.selectedNode = siblings[i];
if (siblings[i].items == null) {
siblings[i].items = [];
}
siblings[i].items = siblings[i].items.concat(data.areas);
siblings[i].items = siblings[i].items.concat(data.processes);
siblings[i].items = siblings[i].items.concat(data.processesInterconnected);
break;
}
}
}
},
function (data, status, headers, config) {
//modelValue.items = [];
});
}
}
function selectNodeInAreaTree(node, item, collapsed, $event) {
if (item.type == vm.processNodeType.Area || !item.type) {
$state.go(vm.processRoute.processAreaDetail, { areaId: item.id });
}
else if (item.type == vm.processNodeType.Process) {
$state.go(vm.processRoute.processDetail, { processNumber: item.processNumber });
}
else if (item.type == vm.processNodeType.InterconnectedProcess) {
$state.go(vm.processRoute.processInterconnected, { processNumber: item.processInterconnectedNumber });
}
let isSelectedFolder = $(event.target).hasClass('selected');
if ((isSelectedFolder || collapsed) && HandbookConfiguration.ToggleFolderUponClick.toUpperCase() == "TRUE") {
vm.isExpanded = true;
item.expanded = !item.expanded;
handleExpandArea(collapsed, item.id, node);
$scope.toggle(node);
}
setHighlight($event);
}
$scope.toggle = function (scope) {
scope.toggle();
};
function decorateNodes(areas, processes, processesInterconnected) {
if (areas && areas.length) {
areas.forEach(item => item.type = vm.processNodeType.Area);
}
if (processes && processes.length) {
processes.forEach(item => {
item.type = vm.processNodeType.Process;
item.id = item.processNumber;
});
}
if (processesInterconnected && processesInterconnected.length) {
processesInterconnected.forEach(item => {
item.type = vm.processNodeType.InterconnectedProcess;
item.id = item.processInterconnectedNumber;
});
}
}
function setHighlight(event) {
$('.selected').removeClass('selected');
$(event.target).addClass('selected');
}
};
})();
;
(function () {
'use strict';
angular.module('processModule')
.controller('process-detail-view.controller', processDetailViewController);
processDetailViewController.$inject = ['$stateParams', 'routeService', '$sce', 'pubSub'];
function processDetailViewController($stateParams, routeService, $sce, pubSub) {
var vm = this;
vm.initialize = initialize;
vm.processNumber = $stateParams.processNumber;
vm.processDetailViewIframe = '';
initialize();
function initialize() {
vm.processDetailViewIframe = $sce.trustAsResourceUrl(routeService.getBaseRouteProcess() + 'process-detail/management/' + vm.processNumber + '?isFrontend=true');
let elements = document.getElementsByClassName('main-container_body');
if (elements && elements.length) {
let element = elements[0];
element.style.overflowY = 'hidden';
}
pubSub.publish(broadcastType.processAreaRouteChanged, {
processNumber: vm.processNumber,
processClassification: E.processClassificationTypes.Processes
});
}
}
})();
;
(function () {
'use strict';
angular.module('processModule')
.controller('process-hearing-view.controller', processHearingViewController);
processHearingViewController.$inject = ['$stateParams', 'routeService', '$sce'];
function processHearingViewController($stateParams, routeService, $sce) {
var vm = this;
vm.initialize = initialize;
vm.processNumber = $stateParams.processNumber
vm.version = $stateParams.version;
vm.processHearingViewFrame = '';
initialize();
function initialize() {
vm.processHearingViewFrame = $sce.trustAsResourceUrl(routeService.getBaseRouteProcess() + `process-detail/viewsendtohearing/${vm.processNumber}/${vm.version}?isFrontend=true`);
}
};
})();
;
(function () {
'use strict';
angular.module('processModule')
.controller('process-interconnected-hearing-view.controller', processInterconnectedHearingViewController);
processInterconnectedHearingViewController.$inject = ['$stateParams', 'routeService', '$sce'];
function processInterconnectedHearingViewController($stateParams, routeService, $sce) {
var vm = this;
vm.initialize = initialize;
vm.processNumber = $stateParams.processNumber
vm.version = $stateParams.version;
vm.processHearingViewFrame = '';
initialize();
function initialize() {
vm.processHearingViewFrame = $sce.trustAsResourceUrl(routeService.getBaseRouteProcess() + `process-interconnected/viewsendtohearing/${vm.processNumber}/${vm.version}?isFrontend=true`);
}
};
})();
;
(function () {
'use strict';
angular.module('processModule')
.controller('process-interconnected-view.controller', processInterconnectedViewController);
processInterconnectedViewController.$inject = ['$stateParams', 'routeService', '$sce', 'pubSub'];
function processInterconnectedViewController($stateParams, routeService, $sce, pubSub) {
var vm = this;
vm.initialize = initialize;
vm.processNumber = $stateParams.processNumber;
vm.processInterconnectedViewIframe = '';
initialize();
function initialize() {
vm.processInterconnectedViewIframe = $sce.trustAsResourceUrl(routeService.getBaseRouteProcess() + 'process-interconnected/management/' + vm.processNumber + '?isFrontend=true');
pubSub.publish(broadcastType.processAreaRouteChanged, {
processNumber: vm.processNumber,
processClassification: E.processClassificationTypes.ProcessInterconnected
});
angular.element(".main-container_body").css({
overflowY: 'hidden'
});
}
}
})();
;
(function () {
'use strict';
angular.module('dashboardModule')
.controller('reading-list-view.controller', readingListViewController);
readingListViewController.$inject = ['$stateParams', 'routeService', '$sce'];
function readingListViewController($stateParams, routeService, $sce) {
var vm = this;
vm.initialize = initialize;
vm.readingListId = $stateParams.readingListId;
vm.readingListIframe = '';
initialize();
function initialize() {
vm.readingListIframe = vm.readingListId ? $sce.trustAsResourceUrl(HandbookConfiguration.BackendURL + `dashboard/reading-list/${vm.readingListId}?hideTopBar=true`)
: $sce.trustAsResourceUrl(HandbookConfiguration.BackendURL + 'dashboard/reading-list?hideTopBar=true');
}
};
})();;