diff --git a/src/header-bar/dataApprovalWorkflows.json b/src/header-bar/dataApprovalWorkflows.json new file mode 100644 index 0000000..c3fb5c5 --- /dev/null +++ b/src/header-bar/dataApprovalWorkflows.json @@ -0,0 +1 @@ +{"pager":{"page":1,"pageCount":1,"total":2,"pageSize":50},"dataApprovalWorkflows":[{"name":"MER Results","id":"RwNpkAM7Hw7","displayName":"MER Results","dataApprovalLevels":[{"id":"aypLtfWShE5","level":1,"displayName":"Global"},{"id":"fsIo8vU2VFZ","level":4,"displayName":"Implementing Partner"},{"id":"rImhZfF6RKy","level":2,"displayName":"Inter-Agency"},{"id":"jtLSx6a19Ps","level":3,"displayName":"Funding Agency"}],"dataSets":[{"name":"MER Results: Medical Store FY2016Q3","id":"hIm0HGCKiPv","shortName":"MER R: Medical Store FY2016Q3","periodType":"Quarterly","workflow":{"id":"RwNpkAM7Hw7","periodType":"Quarterly"},"categoryCombo":{"name":"Funding Mechanism","id":"wUpfppgjEza","categories":[{"id":"SH885jaRe0o"}]}},{"name":"MER Results: Community Based - DoD ONLY FY2016Q4","id":"j9bKklpTDBZ","shortName":"MER R: Community Based - DoD ONLY FY2016Q4","periodType":"Quarterly","workflow":{"id":"RwNpkAM7Hw7","periodType":"Quarterly"},"categoryCombo":{"name":"Funding Mechanism","id":"wUpfppgjEza","categories":[{"id":"SH885jaRe0o"}]}},{"name":"MER Results: Narratives (IM)","id":"LWE9GdlygD5","shortName":"MER R: Narratives (IM)","periodType":"Quarterly","workflow":{"id":"RwNpkAM7Hw7","periodType":"Quarterly"},"categoryCombo":{"name":"Funding Mechanism","id":"wUpfppgjEza","categories":[{"id":"SH885jaRe0o"}]}},{"name":"MER Results: Facility Based FY2017Q1","id":"hgOW2BSUDaN","shortName":"MER R: Facility Based FY2017Q1","periodType":"Quarterly","workflow":{"id":"RwNpkAM7Hw7","periodType":"Quarterly"},"categoryCombo":{"name":"Funding Mechanism","id":"wUpfppgjEza","categories":[{"id":"SH885jaRe0o"}]}},{"name":"MER Results: Operating Unit Level (IM) FY2017Q1","id":"KwkuZhKulqs","shortName":"MER R: Operating Unit Level (IM) FY2017Q1","periodType":"Quarterly","workflow":{"id":"RwNpkAM7Hw7","periodType":"Quarterly"},"categoryCombo":{"name":"Funding Mechanism","id":"wUpfppgjEza","categories":[{"id":"SH885jaRe0o"}]}},{"name":"MER Results: Facility Based - DoD ONLY FY2017Q1","id":"CS958XpDaUf","shortName":"MER R: Facility Based - DoD ONLY FY2017Q1","periodType":"Quarterly","workflow":{"id":"RwNpkAM7Hw7","periodType":"Quarterly"},"categoryCombo":{"name":"Funding Mechanism","id":"wUpfppgjEza","categories":[{"id":"SH885jaRe0o"}]}},{"name":"MER Results: Operating Unit Level (IM) FY2016Q3","id":"ovYEbELCknv","shortName":"MER R: Operating Unit Level (IM) FY2016Q3","periodType":"Quarterly","workflow":{"id":"RwNpkAM7Hw7","periodType":"Quarterly"},"categoryCombo":{"name":"Funding Mechanism","id":"wUpfppgjEza","categories":[{"id":"SH885jaRe0o"}]}},{"name":"MER Results: Community Based - DoD ONLY","id":"UZ2PLqSe5Ri","shortName":"MER R: Community Based - DoD ONLY","periodType":"Quarterly","workflow":{"id":"RwNpkAM7Hw7","periodType":"Quarterly"},"categoryCombo":{"name":"Funding Mechanism","id":"wUpfppgjEza","categories":[{"id":"SH885jaRe0o"}]}},{"name":"MER Results: Narratives (IM) FY2016Q4","id":"xBRAscSmemV","shortName":"MER R: Narratives (IM) FY2016Q4","periodType":"Quarterly","workflow":{"id":"RwNpkAM7Hw7","periodType":"Quarterly"},"categoryCombo":{"name":"Funding Mechanism","id":"wUpfppgjEza","categories":[{"id":"SH885jaRe0o"}]}},{"name":"MER Results: Facility Based - DoD ONLY FY2016Q4","id":"vvHCWnhULAf","shortName":"MER R: Facility Based - DoD ONLY FY2016Q4","periodType":"Quarterly","workflow":{"id":"RwNpkAM7Hw7","periodType":"Quarterly"},"categoryCombo":{"name":"Funding Mechanism","id":"wUpfppgjEza","categories":[{"id":"SH885jaRe0o"}]}},{"name":"MER Results: Community Based FY2017Q1","id":"Awq346fnVLV","shortName":"MER R: Community Based FY2017Q1","periodType":"Quarterly","workflow":{"id":"RwNpkAM7Hw7","periodType":"Quarterly"},"categoryCombo":{"name":"Funding Mechanism","id":"wUpfppgjEza","categories":[{"id":"SH885jaRe0o"}]}},{"name":"MER Results: Community Based FY2016Q3","id":"STL4izfLznL","shortName":"MER R: Community Based FY2016Q3","periodType":"Quarterly","workflow":{"id":"RwNpkAM7Hw7","periodType":"Quarterly"},"categoryCombo":{"name":"Funding Mechanism","id":"wUpfppgjEza","categories":[{"id":"SH885jaRe0o"}]}},{"name":"MER Results: Narratives (IM) FY2016Q3","id":"NJlAVhe4zjv","shortName":"MER R: Narratives (IM) FY2016Q3","periodType":"Quarterly","workflow":{"id":"RwNpkAM7Hw7","periodType":"Quarterly"},"categoryCombo":{"name":"Funding Mechanism","id":"wUpfppgjEza","categories":[{"id":"SH885jaRe0o"}]}},{"name":"MER Results: Medical Store","id":"CGoi5wjLHDy","shortName":"MER R: Medical Store","periodType":"Quarterly","workflow":{"id":"RwNpkAM7Hw7","periodType":"Quarterly"},"categoryCombo":{"name":"Funding Mechanism","id":"wUpfppgjEza","categories":[{"id":"SH885jaRe0o"}]}},{"name":"MER Results: Operating Unit Level (IM)","id":"tG2hjDIaYQD","shortName":"MER R: Operating Unit Level (IM)","periodType":"Quarterly","workflow":{"id":"RwNpkAM7Hw7","periodType":"Quarterly"},"categoryCombo":{"name":"Funding Mechanism","id":"wUpfppgjEza","categories":[{"id":"SH885jaRe0o"}]}},{"name":"MER Results: Operating Unit Level (IM) FY2016Q4","id":"VWdBdkfYntI","shortName":"MER R: Operating Unit Level (IM) FY2016Q4","periodType":"Quarterly","workflow":{"id":"RwNpkAM7Hw7","periodType":"Quarterly"},"categoryCombo":{"name":"Funding Mechanism","id":"wUpfppgjEza","categories":[{"id":"SH885jaRe0o"}]}},{"name":"MER Results: Facility Based - DoD ONLY","id":"K7FMzevlBAp","shortName":"MER R: Facility Based - DoD ONLY","periodType":"Quarterly","workflow":{"id":"RwNpkAM7Hw7","periodType":"Quarterly"},"categoryCombo":{"name":"Funding Mechanism","id":"wUpfppgjEza","categories":[{"id":"SH885jaRe0o"}]}},{"name":"MER Results: Facility Based FY2016Q3","id":"i29foJcLY9Y","shortName":"MER R: Facility Based FY2016Q3","periodType":"Quarterly","workflow":{"id":"RwNpkAM7Hw7","periodType":"Quarterly"},"categoryCombo":{"name":"Funding Mechanism","id":"wUpfppgjEza","categories":[{"id":"SH885jaRe0o"}]}},{"name":"MER Results: Medical Store FY2016Q4","id":"gZ1FgiGUlSj","shortName":"MER R: Medical Store FY2016Q4","periodType":"Quarterly","workflow":{"id":"RwNpkAM7Hw7","periodType":"Quarterly"},"categoryCombo":{"name":"Funding Mechanism","id":"wUpfppgjEza","categories":[{"id":"SH885jaRe0o"}]}},{"name":"MER Results: Community Based - DoD ONLY FY2016Q3","id":"asHh1YkxBU5","shortName":"MER R: Community Based - DoD ONLY FY2016Q3","periodType":"Quarterly","workflow":{"id":"RwNpkAM7Hw7","periodType":"Quarterly"},"categoryCombo":{"name":"Funding Mechanism","id":"wUpfppgjEza","categories":[{"id":"SH885jaRe0o"}]}},{"name":"MER Results: Facility Based - DoD ONLY FY2016Q3","id":"j1i6JjOpxEq","shortName":"MER R: Facility Based - DoD ONLY FY2016Q3","periodType":"Quarterly","workflow":{"id":"RwNpkAM7Hw7","periodType":"Quarterly"},"categoryCombo":{"name":"Funding Mechanism","id":"wUpfppgjEza","categories":[{"id":"SH885jaRe0o"}]}},{"name":"MER Results: Community Based - DoD ONLY FY2017Q1","id":"ovmC3HNi4LN","shortName":"MER R: Community Based - DoD ONLY FY2017Q1","periodType":"Quarterly","workflow":{"id":"RwNpkAM7Hw7","periodType":"Quarterly"},"categoryCombo":{"name":"Funding Mechanism","id":"wUpfppgjEza","categories":[{"id":"SH885jaRe0o"}]}},{"name":"MER Results: Community Based","id":"MqNLEXmzIzr","shortName":"MER R: Community Based","periodType":"Quarterly","workflow":{"id":"RwNpkAM7Hw7","periodType":"Quarterly"},"categoryCombo":{"name":"Funding Mechanism","id":"wUpfppgjEza","categories":[{"id":"SH885jaRe0o"}]}},{"name":"MER Results: Facility Based","id":"kkXf2zXqTM0","shortName":"MER R: Facility Based","periodType":"Quarterly","workflow":{"id":"RwNpkAM7Hw7","periodType":"Quarterly"},"categoryCombo":{"name":"Funding Mechanism","id":"wUpfppgjEza","categories":[{"id":"SH885jaRe0o"}]}},{"name":"MER Results: Facility Based FY2016Q4","id":"ZaV4VSLstg7","shortName":"MER R: Facility Based FY2016Q4","periodType":"Quarterly","workflow":{"id":"RwNpkAM7Hw7","periodType":"Quarterly"},"categoryCombo":{"name":"Funding Mechanism","id":"wUpfppgjEza","categories":[{"id":"SH885jaRe0o"}]}},{"name":"MER Results: Narratives (IM) FY2017Q1","id":"zTgQ3MvHYtk","shortName":"MER R: Narratives (IM) FY2017Q1","periodType":"Quarterly","workflow":{"id":"RwNpkAM7Hw7","periodType":"Quarterly"},"categoryCombo":{"name":"Funding Mechanism","id":"wUpfppgjEza","categories":[{"id":"SH885jaRe0o"}]}},{"name":"MER Results: Community Based FY2016Q4","id":"sCar694kKxH","shortName":"MER R: Community Based FY2016Q4","periodType":"Quarterly","workflow":{"id":"RwNpkAM7Hw7","periodType":"Quarterly"},"categoryCombo":{"name":"Funding Mechanism","id":"wUpfppgjEza","categories":[{"id":"SH885jaRe0o"}]}}]},{"name":"MER Targets","id":"TAjCBkG6hl6","displayName":"MER Targets","dataApprovalLevels":[{"id":"aypLtfWShE5","level":1,"displayName":"Global"},{"id":"fsIo8vU2VFZ","level":4,"displayName":"Implementing Partner"},{"id":"rImhZfF6RKy","level":2,"displayName":"Inter-Agency"},{"id":"jtLSx6a19Ps","level":3,"displayName":"Funding Agency"}],"dataSets":[{"name":"MER Targets: Operating Unit Level (IM) FY2016","id":"PHyD22loBQH","shortName":"MER T: Operating Unit Level (IM) FY2016","periodType":"FinancialOct","workflow":{"id":"TAjCBkG6hl6","periodType":"FinancialOct"},"categoryCombo":{"name":"Funding Mechanism","id":"wUpfppgjEza","categories":[{"id":"SH885jaRe0o"}]}},{"name":"MER Targets: Facility Based - DoD ONLY","id":"jEzgpBt5Icf","shortName":"MER T: Facility Based - DoD ONLY","periodType":"FinancialOct","workflow":{"id":"TAjCBkG6hl6","periodType":"FinancialOct"},"categoryCombo":{"name":"Funding Mechanism","id":"wUpfppgjEza","categories":[{"id":"SH885jaRe0o"}]}},{"name":"MER Targets: Narratives (IM) FY2017","id":"AyFVOGbAvcH","shortName":"MER T: Narratives (IM) FY2017","periodType":"FinancialOct","workflow":{"id":"TAjCBkG6hl6","periodType":"FinancialOct"},"categoryCombo":{"name":"Funding Mechanism","id":"wUpfppgjEza","categories":[{"id":"SH885jaRe0o"}]}},{"name":"MER Targets: Community Based - DoD ONLY FY2017","id":"lbwuIo56YoG","shortName":"MER T: Community Based - DoD ONLY FY2017","periodType":"FinancialOct","workflow":{"id":"TAjCBkG6hl6","periodType":"FinancialOct"},"categoryCombo":{"name":"Funding Mechanism","id":"wUpfppgjEza","categories":[{"id":"SH885jaRe0o"}]}},{"name":"MER Targets: Operating Unit Level (IM)","id":"bqiB5G6qgzn","shortName":"MER T: Operating Unit Level (IM)","periodType":"FinancialOct","workflow":{"id":"TAjCBkG6hl6","periodType":"FinancialOct"},"categoryCombo":{"name":"Funding Mechanism","id":"wUpfppgjEza","categories":[{"id":"SH885jaRe0o"}]}},{"name":"MER Targets: Operating Unit Level (IM) FY2017","id":"xxo1G5V1JG2","shortName":"MER T: Operating Unit Level (IM) FY2017","periodType":"FinancialOct","workflow":{"id":"TAjCBkG6hl6","periodType":"FinancialOct"},"categoryCombo":{"name":"Funding Mechanism","id":"wUpfppgjEza","categories":[{"id":"SH885jaRe0o"}]}},{"name":"MER Targets: Community Based FY2016","id":"xJ06pxmxfU6","shortName":"MER T: Community Based FY2016","periodType":"FinancialOct","workflow":{"id":"TAjCBkG6hl6","periodType":"FinancialOct"},"categoryCombo":{"name":"Funding Mechanism","id":"wUpfppgjEza","categories":[{"id":"SH885jaRe0o"}]}},{"name":"MER Targets: Narratives (IM) FY2016","id":"VjGqATduoEX","shortName":"MER T: Narratives (IM) FY2016","periodType":"FinancialOct","workflow":{"id":"TAjCBkG6hl6","periodType":"FinancialOct"},"categoryCombo":{"name":"Funding Mechanism","id":"wUpfppgjEza","categories":[{"id":"SH885jaRe0o"}]}},{"name":"MER Targets: Facility Based FY2016","id":"rDAUgkkexU1","shortName":"MER T: Facility Based FY2016","periodType":"FinancialOct","workflow":{"id":"TAjCBkG6hl6","periodType":"FinancialOct"},"categoryCombo":{"name":"Funding Mechanism","id":"wUpfppgjEza","categories":[{"id":"SH885jaRe0o"}]}},{"name":"MER Targets: Facility Based - DoD ONLY FY2016","id":"IOarm0ctDVL","shortName":"MER T: Facility Based - DoD ONLY FY2016","periodType":"FinancialOct","workflow":{"id":"TAjCBkG6hl6","periodType":"FinancialOct"},"categoryCombo":{"name":"Funding Mechanism","id":"wUpfppgjEza","categories":[{"id":"SH885jaRe0o"}]}},{"name":"MER Targets: Facility Based FY2017","id":"qRvKHvlzNdv","shortName":"MER T: Facility Based FY2017","periodType":"FinancialOct","workflow":{"id":"TAjCBkG6hl6","periodType":"FinancialOct"},"categoryCombo":{"name":"Funding Mechanism","id":"wUpfppgjEza","categories":[{"id":"SH885jaRe0o"}]}},{"name":"MER Targets: Community Based FY2017","id":"tCIW2VFd8uu","shortName":"MER T: Community Based FY2017","periodType":"FinancialOct","workflow":{"id":"TAjCBkG6hl6","periodType":"FinancialOct"},"categoryCombo":{"name":"Funding Mechanism","id":"wUpfppgjEza","categories":[{"id":"SH885jaRe0o"}]}},{"name":"MER Targets: Community Based - DoD ONLY","id":"ePndtmDbOJj","shortName":"MER T: Community Based - DoD ONLY","periodType":"FinancialOct","workflow":{"id":"TAjCBkG6hl6","periodType":"FinancialOct"},"categoryCombo":{"name":"Funding Mechanism","id":"wUpfppgjEza","categories":[{"id":"SH885jaRe0o"}]}},{"name":"MER Targets: Facility Based - DoD ONLY FY2017","id":"JXKUYJqmyDd","shortName":"MER T: Facility Based - DoD ONLY FY2017","periodType":"FinancialOct","workflow":{"id":"TAjCBkG6hl6","periodType":"FinancialOct"},"categoryCombo":{"name":"Funding Mechanism","id":"wUpfppgjEza","categories":[{"id":"SH885jaRe0o"}]}},{"name":"MER Targets: Narratives (IM)","id":"AvmGbcurn4K","shortName":"MER T: Narratives (IM)","periodType":"FinancialOct","workflow":{"id":"TAjCBkG6hl6","periodType":"FinancialOct"},"categoryCombo":{"name":"Funding Mechanism","id":"wUpfppgjEza","categories":[{"id":"SH885jaRe0o"}]}},{"name":"MER Targets: Facility Based","id":"AitXBHsC7RA","shortName":"MER T: Facility Based","periodType":"FinancialOct","workflow":{"id":"TAjCBkG6hl6","periodType":"FinancialOct"},"categoryCombo":{"name":"Funding Mechanism","id":"wUpfppgjEza","categories":[{"id":"SH885jaRe0o"}]}},{"name":"MER Targets: Community Based","id":"BuRoS9i851o","shortName":"MER T: Community Based","periodType":"FinancialOct","workflow":{"id":"TAjCBkG6hl6","periodType":"FinancialOct"},"categoryCombo":{"name":"Funding Mechanism","id":"wUpfppgjEza","categories":[{"id":"SH885jaRe0o"}]}},{"name":"MER Targets: Medical Store FY2017","id":"Om3TJBRH8G8","shortName":"MER T: Medical Store FY2017","periodType":"FinancialOct","workflow":{"id":"TAjCBkG6hl6","periodType":"FinancialOct"},"categoryCombo":{"name":"Funding Mechanism","id":"wUpfppgjEza","categories":[{"id":"SH885jaRe0o"}]}},{"name":"MER Targets: Community Based - DoD ONLY FY2016","id":"LBSk271pP7J","shortName":"MER T: Community Based - DoD ONLY FY2016","periodType":"FinancialOct","workflow":{"id":"TAjCBkG6hl6","periodType":"FinancialOct"},"categoryCombo":{"name":"Funding Mechanism","id":"wUpfppgjEza","categories":[{"id":"SH885jaRe0o"}]}}]}]} \ No newline at end of file diff --git a/src/main/approvals/workflows-service.js b/src/main/approvals/workflows-service.js index be21ffa..a7b3ee9 100644 --- a/src/main/approvals/workflows-service.js +++ b/src/main/approvals/workflows-service.js @@ -70,13 +70,36 @@ function workflowService(rx, Restangular, $q) { }); } + function setDefaultsWhenMissing(workflow) { + if (!workflow.dataSets) { + workflow.dataSets = []; + } + + return workflow; + } + function requestWorkflowsFromApi() { var workflowRequest = Restangular.all('dataApprovalWorkflows') .withHttpConfig({cache: true}) .getList({ - fields: 'id,name,displayName,dataApprovalLevels[displayName,id,level]', + fields: 'id,name,displayName,periodType,dataApprovalLevels[displayName,id,level],dataSets[name,shortName,id,periodType,workflow[id,periodType],categoryCombo[id,name,categories[id]]]', paging: false }) + .then(function (workflows) { + return _.map(workflows, setDefaultsWhenMissing); + }) + .then(function (workflows) { + return $q.all(workflows.map(function (workflow) { + if (workflow && workflow.dataSets) { + return loadCategoryOptionCombosForDataSets(workflow.dataSets) + .then(function () { + return workflow; + }); + } else { + return $q.when(workflow); + } + })); + }) .catch(function (response) { return $q.reject(new Error(response.data)); }); @@ -90,6 +113,23 @@ function workflowService(rx, Restangular, $q) { return workflow$; } + function loadCategoryOptionCombosForDataSets(dataSets) { + var categoryCombosForDataSets = _.map(dataSets, function (dataSet) { + return Restangular + .all('categoryCombos') + .withHttpConfig({cache: true}) + .get(dataSet.categoryCombo.id, {fields: 'id,categoryOptionCombos[id,name]'}) + .then(function (categoryCombo) { + dataSet.categoryCombo.categoryOptionCombos = categoryCombo.categoryOptionCombos; + }); + }); + + return $q.all(categoryCombosForDataSets) + .then(function () { + return dataSets; + }); + } + return { currentWorkflow$: currentWorkflow$, workflows$: workflows$, diff --git a/src/main/datasets/datasetgroup-service.js b/src/main/datasets/datasetgroup-service.js index 9c70299..c94edd7 100644 --- a/src/main/datasets/datasetgroup-service.js +++ b/src/main/datasets/datasetgroup-service.js @@ -1,134 +1,51 @@ -function dataSetGroupService($q, periodService, Restangular, workflowService, rx, errorHandler) { - var dataSetGroups = {}; - var dataSetGroupNames = []; - var dataSetGroups$ = new rx.ReplaySubject(1); +function dataSetGroupService($rootScope, $q, periodService, Restangular, workflowService, rx, errorHandler) { + var dataSetGroups$; var currentDataSetGroup$ = new rx.ReplaySubject(1); - workflowService.workflows$ + dataSetGroups$ = workflowService.workflows$ .flatMap(function (workflows) { - return rx.Observable.fromPromise( - loadDataSetsForWorkflows(workflows) - .then(matchDataSetsToWorkflows) - .then(setWorkflowsOntoService) - ); + return rx.Observable + .fromArray(workflows) + .flatMap(function (workflow) { + return rx.Observable.combineLatest( + rx.Observable.just(workflow), + periodService.getPeriodsForWorkflow(workflow), + function (workflow, periodsForWorkflow) { + return { + workflow: workflow, + periods: periodsForWorkflow + }; + } + ); + }) + .safeApply($rootScope); }) - .subscribe( - function () {}, - function (error) { - errorHandler.error(error.message); + // Only use workflows that actually have periods + .filter(function (workflowAndPeriods) { + return workflowAndPeriods.periods.length && workflowAndPeriods.workflow; + }) + // Combine the workflows back into an array + .reduce(function (acc, value) { + return acc.concat(value.workflow); + }, []) + .tap(function (workflows) { + // Show an error when there are no available workflows + if (workflows.length === 0) { + errorHandler.error('Could not not find any workflows (Data Streams)'); } - ); + }); return { setCurrentDataSetGroup: setCurrentDataSetGroup, dataSetGroups$: dataSetGroups$, currentDataSetGroup$: currentDataSetGroup$, - getDataSetsForGroup: getDataSetsForGroup }; - function setCurrentDataSetGroup(selectedDataSetGroup) { - var dataSetGroup = dataSetGroupFactory(getDataSetsForGroup(selectedDataSetGroup)); + function setCurrentDataSetGroup(workflow) { + var dataSetGroup = dataSetGroupFactory(workflow.dataSets); currentDataSetGroup$.onNext(dataSetGroup); } - - function filterDataSetsForUser(workflows) { - function onlyWorkflowsWithDataSets(workflow) { - return Array.isArray(workflow.dataSets) && workflow.dataSets.length > 0; - } - - function toObjectByName(acc, workflow) { - acc[workflow.name] = workflow; - - return acc; - } - - dataSetGroups = workflows - .filter(onlyWorkflowsWithDataSets) - .reduce(toObjectByName, {}); - - dataSetGroupNames = _.chain(dataSetGroups) - .map(function (dataSetGroup, key) { - return key; - }) - .value() - .sort(); - - if (!(dataSetGroups && dataSetGroupNames[0] && dataSetGroups[dataSetGroupNames[0]])) { - errorHandler.warning('No dataset groups were found that your account can access. This could be the result of your account not having access to these datasets.', true); - } else { - dataSetGroups$.onNext(dataSetGroupNames); - } - } - - function getDataSetsForGroup(dataSetGroupName) { - if (dataSetGroups[dataSetGroupName]) { - return dataSetGroups[dataSetGroupName].dataSets; - } - } - - function pickId(value) { - return value.id; - } - - function getWorkFlowIds(dataApprovalWorkflows) { - return _.map(dataApprovalWorkflows, pickId); - } - - function loadCategoryOptionCombosForDataSets(data) { - var dataSets = data[1]; - - var categoryCombosForDataSets = _.map(dataSets, function (dataSet) { - return Restangular.all('categoryCombos').withHttpConfig({cache: true}).get(dataSet.categoryCombo.id, {fields: 'id,categoryOptionCombos[id,name]'}) - .then(function (categoryCombo) { - dataSet.categoryCombo.categoryOptionCombos = categoryCombo.categoryOptionCombos; - }); - }); - - return $q.all(categoryCombosForDataSets) - .then(function () { - return data; - }); - } - - function loadDataSetsForWorkflows(dataApprovalWorkflows) { - return Restangular - .all('dataSets') - .getList({ - fields: 'name,shortName,id,periodType,workflow[id,periodType],categoryCombo[id,name,categories[id]]', - filter: 'workflow.id:in:[' + getWorkFlowIds(dataApprovalWorkflows).join(',') + ']', - paging: false - }) - .then(function (dataSets) { - return [dataApprovalWorkflows, dataSets]; - }) - .then(loadCategoryOptionCombosForDataSets); - } - - function addDataSetsToWorkflow(dataSetsForWorkflow, workflow) { - workflow.dataSets = dataSetsForWorkflow[workflow.id] || []; - - return workflow; - } - - function matchDataSetsToWorkflows(data) { - var dataApprovalWorkflows = data[0]; - var dataSets = data[1]; - - var dataSetsForWorkflow = _.groupBy(dataSets, function (ds) {return ds.workflow.id;}); - - return dataApprovalWorkflows - .map(addDataSetsToWorkflow.bind(null, dataSetsForWorkflow)); - } - - function setWorkflowsOntoService(workflows) { - // Workflows including dataSets that belong to those workflows - if (!Array.isArray(workflows)) { - return $q.reject('Could not properly load the Workflows from the api.'); - } - - filterDataSetsForUser(workflows); - } } function dataSetGroupFactory(dataSets) { diff --git a/src/main/datasets/datasetgroupselector-directive.js b/src/main/datasets/datasetgroupselector-directive.js index 7557da1..2039cec 100644 --- a/src/main/datasets/datasetgroupselector-directive.js +++ b/src/main/datasets/datasetgroupselector-directive.js @@ -1,3 +1,4 @@ +// TODO: Rename to workflow selector function dataSetGroupSelectorDirective(dataSetGroupService) { return { restrict: 'E', @@ -20,7 +21,7 @@ function dataSetGroupSelectorDirective(dataSetGroupService) { .dataSetGroups$ .take(1) .map(function (datasetGroups) { - if (angular.isArray(datasetGroups)) { + if (angular.isArray(datasetGroups) && datasetGroups.length) { scope.dataset.groups = datasetGroups; // Fire onChange to set to the first group diff --git a/src/main/datasets/datasetgroupselector.html b/src/main/datasets/datasetgroupselector.html index 60dd39f..44e7044 100644 --- a/src/main/datasets/datasetgroupselector.html +++ b/src/main/datasets/datasetgroupselector.html @@ -1,9 +1,9 @@
- {{$select.selected}} - -
{{datasetGroup}}
+ {{$select.selected.name}} + +
{{datasetGroup.name}}
diff --git a/src/main/manifest.webapp b/src/main/manifest.webapp index 052fc38..9443e7f 100644 --- a/src/main/manifest.webapp +++ b/src/main/manifest.webapp @@ -1,5 +1,5 @@ { - "version": "1.4.1", + "version": "1.4.2", "name": "Data Approval", "description": "Approvals app for PEPFAR", "icons": { @@ -11,7 +11,7 @@ "company": "DHIS2 Core Team", "email": "markpo@ifi.uio.no" }, - "launch_path": "index.html?v=1.4.1", + "launch_path": "index.html?v=1.4.2", "default_locale": "en", "activities": { "dhis": { diff --git a/src/main/period/period-service.js b/src/main/period/period-service.js index 23f556c..0c9d715 100644 --- a/src/main/period/period-service.js +++ b/src/main/period/period-service.js @@ -53,7 +53,7 @@ function periodService(dataStore, rx, $rootScope) { } function periodSettingsToArray(periodSettings) { - return Object.keys(periodSettings) + return Object.keys(periodSettings || {}) .reduce(function (acc, periodKey) { return acc.concat([ _.extend({ id: periodKey }, periodSettings[periodKey]) ]); }, []); diff --git a/src/test/fixtures/fixtures.js b/src/test/fixtures/fixtures.js index 8f1cbf2..a9338bd 100644 --- a/src/test/fixtures/fixtures.js +++ b/src/test/fixtures/fixtures.js @@ -1,72 +1,98 @@ (function (window) { var library = {}; - library.orgUnitLevel1 = {"organisationUnits": [ - {"id": "a9OHUtkxjO8", "level": 1, "name": "Eshu Dispensary", "children": [ - {"id": "XCOuSJUVman", "level": 2, "name": "Hekima Community Health Unit"} - ]}, - {"id": "ybg3MO3hcf4", "level": 1, "name": "Global", "children": [ - {"id": "XtxUYCsDWrR", "level": 2, "name": "Rwanda"}, - {"id": "h11OyvlPxpJ", "level": 2, "name": "Mozambique"}, - {"id": "lZsCb6y0KDX", "level": 2, "name": "Malawi"}, - {"id": "HfVjCurKxh2", "level": 2, "name": "Kenya"}, - {"id": "cDGPF739ZZr", "level": 2, "name": "South Africa"}, - {"id": "f5RoebaDLMx", "level": 2, "name": "Zambia"}, - {"id": "PqlFzhuPcF1", "level": 2, "name": "Nigeria"}, - {"id": "l1KFEXKI4Dg", "level": 2, "name": "Botswana"}, - {"id": "a71G4Gtcttv", "level": 2, "name": "Zimbabwe"}, - {"id": "FFVkaV9Zk1S", "level": 2, "name": "Namibia"}, - {"id": "FETQ6OmnsKB", "level": 2, "name": "Uganda"} - ]}, - {"id": "tqOO4WrOA1L", "level": 1, "name": "Khalala Dispensary", "children": [ - {"id": "h33zAuVtyST", "level": 2, "name": "Khalala Community Health Unit"}, - {"id": "C8xF4yCjvIc", "level": 2, "name": "Sitikho Community Health Unit"} - ]}, - {"id": "UrRsO2NsxHZ", "level": 1, "name": "Kikoneni Health Centre", "children": [ - {"id": "yjKOwzXkcOX", "level": 2, "name": "Bumbani Community Health Unit"}, - {"id": "baXgVdyKY8Q", "level": 2, "name": "Central Community Health Unit"}, - {"id": "gKlqGghOXB5", "level": 2, "name": "Jitahidi Community Health Unit"} - ]}, - {"id": "RYumT9hJ8Ss", "level": 1, "name": "Mafisini Dispensary", "children": [ - {"id": "WBkMP1NTove", "level": 2, "name": "Uzima Self Help Group Community Health Unit"} - ]}, - {"id": "ksNfsN3CiNc", "level": 1, "name": "Majimoto Dispensary", "children": [ - {"id": "DN2hCg5uQKR", "level": 2, "name": "Majimoto Commnity Unit"} - ]}, - {"id": "PbgfcQ8jDQr", "level": 1, "name": "Mamba Dispensary (MSAMBWENI)", "children": []}, - {"id": "lf5XVTQP2Cp", "level": 1, "name": "Miendo Dispensary", "children": [ - {"id": "HVR2Og2MspE", "level": 2, "name": "Miendo Community Health Unit"} - ]}, - {"id": "IBO76lif4Fr", "level": 1, "name": "Mivumoni Catholic", "children": []}, - {"id": "cOgv5EHeFRj", "level": 1, "name": "Mwananyamala Dispensary (CDF)", "children": [ - {"id": "ZImy6KUXwBi", "level": 2, "name": "Morning Star Community Health Unit"}, - {"id": "P9RSVjkLleV", "level": 2, "name": "Majimoto Community Unit"} - ]}, - {"id": "Jfpsre91xXE", "level": 1, "name": "Webuye Health Centre", "children": [ - {"id": "NLi3hET8BdJ", "level": 2, "name": "Nang'eni Community Unit"} - ]} - ]}; - library.approvalLevels = {"dataApprovalLevels": [ - {"id": "aypLtfWShE5", "name": "1", "level": 1, "orgUnitLevel": 1}, - {"id": "MROYE5CmsDF", "name": "2 - Global Funding Agency", "level": 2, "orgUnitLevel": 1}, - {"id": "JNpaWdWCyDN", "name": "3", "level": 3, "orgUnitLevel": 2}, - {"id": "vqWNeqjozr9", "name": "2 - Funding Agency", "level": 4, "orgUnitLevel": 2, "categoryOptionGroupSet": {"id": "bw8KHXzxd9i", "name": "Funding Agency", "displayName": "Funding Agency"}}, - {"id": "WccDi5x6FSp", "name": "2 - Implementing Partner", "level": 5, "orgUnitLevel": 2, "categoryOptionGroupSet": {"id": "BOyWrF33hiR", "name": "Implementing Partner", "displayName": "Implementing Partner"}} - ]}; - library.fundingAgenciesCOG = {"categoryOptionGroups": [ - {"id": "OO5qyDIwoMk", "name": "DOD"}, - {"id": "FPUgmtt8HRi", "name": "HHS/CDC"}, - {"id": "RGC9tURSc3W", "name": "HHS/HRSA"}, - {"id": "m4mzzwVQOUi", "name": "U.S. Peace Corps"}, - {"id": "m4mzzwVQOUi", "name": "U.S. Peace Corps"}, - {"id": "NLV6dy7BE2O", "name": "USAID"}, - {"id": "ICxISjHPJF4", "name": "USDOS/BAA"}, - {"id": "MWmqTPSvhD1", "name": "USDOS/BPRM"} - ]}; - library.implementingPartnersCOG = {"categoryOptionGroups": [ - {"id": "Cs2c30KKxg6", "name": "Apple"}, - {"id": "pBimh5znu2H", "name": "Banana"} - ]}; + library.orgUnitLevel1 = { + "organisationUnits": [ + { + "id": "a9OHUtkxjO8", "level": 1, "name": "Eshu Dispensary", "children": [ + { "id": "XCOuSJUVman", "level": 2, "name": "Hekima Community Health Unit" } + ] + }, + { + "id": "ybg3MO3hcf4", "level": 1, "name": "Global", "children": [ + { "id": "XtxUYCsDWrR", "level": 2, "name": "Rwanda" }, + { "id": "h11OyvlPxpJ", "level": 2, "name": "Mozambique" }, + { "id": "lZsCb6y0KDX", "level": 2, "name": "Malawi" }, + { "id": "HfVjCurKxh2", "level": 2, "name": "Kenya" }, + { "id": "cDGPF739ZZr", "level": 2, "name": "South Africa" }, + { "id": "f5RoebaDLMx", "level": 2, "name": "Zambia" }, + { "id": "PqlFzhuPcF1", "level": 2, "name": "Nigeria" }, + { "id": "l1KFEXKI4Dg", "level": 2, "name": "Botswana" }, + { "id": "a71G4Gtcttv", "level": 2, "name": "Zimbabwe" }, + { "id": "FFVkaV9Zk1S", "level": 2, "name": "Namibia" }, + { "id": "FETQ6OmnsKB", "level": 2, "name": "Uganda" } + ] + }, + { + "id": "tqOO4WrOA1L", "level": 1, "name": "Khalala Dispensary", "children": [ + { "id": "h33zAuVtyST", "level": 2, "name": "Khalala Community Health Unit" }, + { "id": "C8xF4yCjvIc", "level": 2, "name": "Sitikho Community Health Unit" } + ] + }, + { + "id": "UrRsO2NsxHZ", "level": 1, "name": "Kikoneni Health Centre", "children": [ + { "id": "yjKOwzXkcOX", "level": 2, "name": "Bumbani Community Health Unit" }, + { "id": "baXgVdyKY8Q", "level": 2, "name": "Central Community Health Unit" }, + { "id": "gKlqGghOXB5", "level": 2, "name": "Jitahidi Community Health Unit" } + ] + }, + { + "id": "RYumT9hJ8Ss", "level": 1, "name": "Mafisini Dispensary", "children": [ + { "id": "WBkMP1NTove", "level": 2, "name": "Uzima Self Help Group Community Health Unit" } + ] + }, + { + "id": "ksNfsN3CiNc", "level": 1, "name": "Majimoto Dispensary", "children": [ + { "id": "DN2hCg5uQKR", "level": 2, "name": "Majimoto Commnity Unit" } + ] + }, + { "id": "PbgfcQ8jDQr", "level": 1, "name": "Mamba Dispensary (MSAMBWENI)", "children": [] }, + { + "id": "lf5XVTQP2Cp", "level": 1, "name": "Miendo Dispensary", "children": [ + { "id": "HVR2Og2MspE", "level": 2, "name": "Miendo Community Health Unit" } + ] + }, + { "id": "IBO76lif4Fr", "level": 1, "name": "Mivumoni Catholic", "children": [] }, + { + "id": "cOgv5EHeFRj", "level": 1, "name": "Mwananyamala Dispensary (CDF)", "children": [ + { "id": "ZImy6KUXwBi", "level": 2, "name": "Morning Star Community Health Unit" }, + { "id": "P9RSVjkLleV", "level": 2, "name": "Majimoto Community Unit" } + ] + }, + { + "id": "Jfpsre91xXE", "level": 1, "name": "Webuye Health Centre", "children": [ + { "id": "NLi3hET8BdJ", "level": 2, "name": "Nang'eni Community Unit" } + ] + } + ] + }; + library.approvalLevels = { + "dataApprovalLevels": [ + { "id": "aypLtfWShE5", "name": "1", "level": 1, "orgUnitLevel": 1 }, + { "id": "MROYE5CmsDF", "name": "2 - Global Funding Agency", "level": 2, "orgUnitLevel": 1 }, + { "id": "JNpaWdWCyDN", "name": "3", "level": 3, "orgUnitLevel": 2 }, + { "id": "vqWNeqjozr9", "name": "2 - Funding Agency", "level": 4, "orgUnitLevel": 2, "categoryOptionGroupSet": { "id": "bw8KHXzxd9i", "name": "Funding Agency", "displayName": "Funding Agency" } }, + { "id": "WccDi5x6FSp", "name": "2 - Implementing Partner", "level": 5, "orgUnitLevel": 2, "categoryOptionGroupSet": { "id": "BOyWrF33hiR", "name": "Implementing Partner", "displayName": "Implementing Partner" } } + ] + }; + library.fundingAgenciesCOG = { + "categoryOptionGroups": [ + { "id": "OO5qyDIwoMk", "name": "DOD" }, + { "id": "FPUgmtt8HRi", "name": "HHS/CDC" }, + { "id": "RGC9tURSc3W", "name": "HHS/HRSA" }, + { "id": "m4mzzwVQOUi", "name": "U.S. Peace Corps" }, + { "id": "m4mzzwVQOUi", "name": "U.S. Peace Corps" }, + { "id": "NLV6dy7BE2O", "name": "USAID" }, + { "id": "ICxISjHPJF4", "name": "USDOS/BAA" }, + { "id": "MWmqTPSvhD1", "name": "USDOS/BPRM" } + ] + }; + library.implementingPartnersCOG = { + "categoryOptionGroups": [ + { "id": "Cs2c30KKxg6", "name": "Apple" }, + { "id": "pBimh5znu2H", "name": "Banana" } + ] + }; library.dataSetGroups = JSON.stringify([ { "name": "MER", @@ -98,249 +124,273 @@ } ]); library.dataSets = [ - {"id": "Zqg76KonUx1", "name": "DS: Dataset One", "shortName": "DS: Dataset One", "periodType": "Monthly", "categoryCombo": {"categories": [ - {"id": "SH885jaRe0o"} - ]}}, - {"id": "cIGsv0OBVi8", "name": "DS: Dataset Two", "shortName": "DS: Dataset Two", "periodType": "Monthly", "categoryCombo": {"categories": [ - {"id": "SH885jaRe0o"} - ]}}, - {"id": "lr508Rm7mHS", "name": "DS: Dataset Three", "shortName": "DS: Dataset Three", "periodType": "Monthly", "categoryCombo": {"categories": [ - {"id": "GLevLNI9wkl"} - ]}}, - {"id": "xY5nwObRyi7", "name": "DS: Dataset Four", "shortName": "DS: Dataset Four", "periodType": "Yearly", "categoryCombo": {"categories": [ - {"id": "SH885jaRe0o"} - ]}}, - {"id": "vX0MoAE7JfL", "name": "DS: Dataset Five", "shortName": "DS: Dataset Five", "periodType": "Monthly", "categoryCombo": {"categories": [ - {"id": "SH885jaRe0o"} - ]}} - ]; - library.categories = {"categories": [ { - "id": "SH885jaRe0o", - "name": "Funding Mechanism", - "categoryOptions": [ - { - "id": "IzVbuMzCCEe", - "name": "1234 - How...", - "organisationUnits": [ - { - "id": "lZsCb6y0KDX", - "name": "Malawi", - "created": "2013-06-10T00:34:22.000+0000", - "lastUpdated": "2014-09-18T11:03:00.174+0000" - } - ], - categoryOptionCombos: [ - { - id: "qS0ABIH66TS", - name: "(1234 - How....)" - } - ], - groups: [ - { - id: "BnjwQmbgK1b", - name: "Partner 1", - categoryOptionGroupSet: { - id: "BOyWrF33hiR" + "id": "Zqg76KonUx1", "name": "DS: Dataset One", "shortName": "DS: Dataset One", "periodType": "Monthly", "categoryCombo": { + "categories": [ + { "id": "SH885jaRe0o" } + ] + } + }, + { + "id": "cIGsv0OBVi8", "name": "DS: Dataset Two", "shortName": "DS: Dataset Two", "periodType": "Monthly", "categoryCombo": { + "categories": [ + { "id": "SH885jaRe0o" } + ] + } + }, + { + "id": "lr508Rm7mHS", "name": "DS: Dataset Three", "shortName": "DS: Dataset Three", "periodType": "Monthly", "categoryCombo": { + "categories": [ + { "id": "GLevLNI9wkl" } + ] + } + }, + { + "id": "xY5nwObRyi7", "name": "DS: Dataset Four", "shortName": "DS: Dataset Four", "periodType": "Yearly", "categoryCombo": { + "categories": [ + { "id": "SH885jaRe0o" } + ] + } + }, + { + "id": "vX0MoAE7JfL", "name": "DS: Dataset Five", "shortName": "DS: Dataset Five", "periodType": "Monthly", "categoryCombo": { + "categories": [ + { "id": "SH885jaRe0o" } + ] + } + } + ]; + library.categories = { + "categories": [ + { + "id": "SH885jaRe0o", + "name": "Funding Mechanism", + "categoryOptions": [ + { + "id": "IzVbuMzCCEe", + "name": "1234 - How...", + "organisationUnits": [ + { + "id": "lZsCb6y0KDX", + "name": "Malawi", + "created": "2013-06-10T00:34:22.000+0000", + "lastUpdated": "2014-09-18T11:03:00.174+0000" } - }, - { - id: "FPUgmtt8HRi", - name: "Agency 1", - categoryOptionGroupSet: { - id: "bw8KHXzxd9i" + ], + categoryOptionCombos: [ + { + id: "qS0ABIH66TS", + name: "(1234 - How....)" } - } - ] - }, - { - "id": "KlqBLXUUwhW", - "name": "9876 - Nat...", - "organisationUnits": [ - { - "id": "lZsCb6y0KDX", - "name": "Malawi", - "created": "2013-06-10T00:34:22.000+0000", - "lastUpdated": "2014-09-18T11:03:00.174+0000" - } - ], - categoryOptionCombos: [ - { - id: "Oae8B8z5H5Y", - name: "(9876 - Nat...)" - } - ], - groups: [ - { - id: "wxAh2TvsTUj", - name: "Partner 5", - categoryOptionGroupSet: { - id: "BOyWrF33hiR" + ], + groups: [ + { + id: "BnjwQmbgK1b", + name: "Partner 1", + categoryOptionGroupSet: { + id: "BOyWrF33hiR" + } + }, + { + id: "FPUgmtt8HRi", + name: "Agency 1", + categoryOptionGroupSet: { + id: "bw8KHXzxd9i" + } } - }, - { - id: "FPUgmtt8HRi", - name: "Agency 1", - categoryOptionGroupSet: { - id: "bw8KHXzxd9i" + ] + }, + { + "id": "KlqBLXUUwhW", + "name": "9876 - Nat...", + "organisationUnits": [ + { + "id": "lZsCb6y0KDX", + "name": "Malawi", + "created": "2013-06-10T00:34:22.000+0000", + "lastUpdated": "2014-09-18T11:03:00.174+0000" } - } - ] - }, - { - "id": "F544HMM7tT7", - "name": "2342 - Wat..", - "organisationUnits": [ - { - "id": "RZdCb6y0KRD", - "name": "Rwanda", - "created": "2013-06-10T00:34:22.000+0000", - "lastUpdated": "2014-09-18T11:03:00.174+0000" - } - ], - categoryOptionCombos: [ - { - id: "RrjmU53u2Ls", - name: "(2342 - Wat...)" - } - ], - groups: [ - { - id: "CSPJnuxBAnz", - name: "Partner 4", - categoryOptionGroupSet: { - id: "BOyWrF33hiR" + ], + categoryOptionCombos: [ + { + id: "Oae8B8z5H5Y", + name: "(9876 - Nat...)" } - }, - { - id: "RGC9tURSc3W", - name: "Agency 3", - categoryOptionGroupSet: { - id: "bw8KHXzxd9i" + ], + groups: [ + { + id: "wxAh2TvsTUj", + name: "Partner 5", + categoryOptionGroupSet: { + id: "BOyWrF33hiR" + } + }, + { + id: "FPUgmtt8HRi", + name: "Agency 1", + categoryOptionGroupSet: { + id: "bw8KHXzxd9i" + } } - } - ] - }, - { - "id": "l32yP94G7HL", - "name": "5433 - JH...", - categoryOptionCombos: [ - { - id: "tJoZs2lVXFc", - name: "(5433 - JH...)" - } - ], - groups: [ - { - id: "NLV6dy7BE2O", - name: "Agency 2", - categoryOptionGroupSet: { - id: "bw8KHXzxd9i" + ] + }, + { + "id": "F544HMM7tT7", + "name": "2342 - Wat..", + "organisationUnits": [ + { + "id": "RZdCb6y0KRD", + "name": "Rwanda", + "created": "2013-06-10T00:34:22.000+0000", + "lastUpdated": "2014-09-18T11:03:00.174+0000" } - }, - { - id: "yrIYjIn0aom", - name: "Partner 3", - categoryOptionGroupSet: { - id: "BOyWrF33hiR" + ], + categoryOptionCombos: [ + { + id: "RrjmU53u2Ls", + name: "(2342 - Wat...)" } - } - ] - }, - { - "id": "tQV5xTc2JYj", - "name": "7654 - Pre...", - "organisationUnits": [ - { - "id": "lZsCb6y0KDX", - "name": "Malawi", - "created": "2013-06-10T00:34:22.000+0000", - "lastUpdated": "2014-09-18T11:03:00.174+0000" - } - ], - categoryOptionCombos: [ - { - id: "qofeYTu7w0R", - name: "(7654 - Pre...)" - } - ], - groups: [ - { - id: "vNQlvpUamTo", - name: "Partner 2", - categoryOptionGroupSet: { - id: "BOyWrF33hiR" + ], + groups: [ + { + id: "CSPJnuxBAnz", + name: "Partner 4", + categoryOptionGroupSet: { + id: "BOyWrF33hiR" + } + }, + { + id: "RGC9tURSc3W", + name: "Agency 3", + categoryOptionGroupSet: { + id: "bw8KHXzxd9i" + } } - }, - { - id: "NLV6dy7BE2O", - name: "Agency 2", - categoryOptionGroupSet: { - id: "bw8KHXzxd9i" + ] + }, + { + "id": "l32yP94G7HL", + "name": "5433 - JH...", + categoryOptionCombos: [ + { + id: "tJoZs2lVXFc", + name: "(5433 - JH...)" } - } - ] - }, - { - "id": "GZIYLG1HWSW", - "name": "1233 - Mal...", - "organisationUnits": [ - { - "id": "lZsCb6y0KDX", - "name": "Malawi", - "created": "2013-06-10T00:34:22.000+0000", - "lastUpdated": "2014-09-18T11:03:00.174+0000" - } - ], - groups: [ - { - id: "iadd8tHFS9C", - name: "Partner 1", - categoryOptionGroupSet: { - id: "BOyWrF33hiR" + ], + groups: [ + { + id: "NLV6dy7BE2O", + name: "Agency 2", + categoryOptionGroupSet: { + id: "bw8KHXzxd9i" + } + }, + { + id: "yrIYjIn0aom", + name: "Partner 3", + categoryOptionGroupSet: { + id: "BOyWrF33hiR" + } } - }, - { - id: "FPUgmtt8HRi", - name: "Agency 1", - categoryOptionGroupSet: { - id: "bw8KHXzxd9i" + ] + }, + { + "id": "tQV5xTc2JYj", + "name": "7654 - Pre...", + "organisationUnits": [ + { + "id": "lZsCb6y0KDX", + "name": "Malawi", + "created": "2013-06-10T00:34:22.000+0000", + "lastUpdated": "2014-09-18T11:03:00.174+0000" } - } - ] - } - ] - }, + ], + categoryOptionCombos: [ + { + id: "qofeYTu7w0R", + name: "(7654 - Pre...)" + } + ], + groups: [ + { + id: "vNQlvpUamTo", + name: "Partner 2", + categoryOptionGroupSet: { + id: "BOyWrF33hiR" + } + }, + { + id: "NLV6dy7BE2O", + name: "Agency 2", + categoryOptionGroupSet: { + id: "bw8KHXzxd9i" + } + } + ] + }, + { + "id": "GZIYLG1HWSW", + "name": "1233 - Mal...", + "organisationUnits": [ + { + "id": "lZsCb6y0KDX", + "name": "Malawi", + "created": "2013-06-10T00:34:22.000+0000", + "lastUpdated": "2014-09-18T11:03:00.174+0000" + } + ], + groups: [ + { + id: "iadd8tHFS9C", + name: "Partner 1", + categoryOptionGroupSet: { + id: "BOyWrF33hiR" + } + }, + { + id: "FPUgmtt8HRi", + name: "Agency 1", + categoryOptionGroupSet: { + id: "bw8KHXzxd9i" + } + } + ] + } + ] + }, + { + "id": "GLevLNI9wkl", + "name": "default", + "categoryOptions": [ + { + "id": "xYerKDKCefk", + "name": "default", + "organisationUnits": [], + categoryOptionCombos: [ + { + id: "HllvX50cXC0", + name: "(default)" + } + ], + groups: [] + } + ] + } + ] + }; + library.orgUnitLevels = { - "id": "GLevLNI9wkl", - "name": "default", - "categoryOptions": [ - { - "id": "xYerKDKCefk", - "name": "default", - "organisationUnits": [], - categoryOptionCombos: [ - { - id: "HllvX50cXC0", - name: "(default)" - } - ], - groups: [ ] - } + "organisationUnitLevels": [ + { "level": 2, "displayName": "Country" }, + { "level": 1, "displayName": "Global" }, + { "level": 4, "displayName": "In-country level 3" }, + { "level": 5, "displayName": "In-country level 4" }, + { "level": 6, "displayName": "In-country level 5" }, + { "level": 7, "displayName": "In-country level 6" }, + { "level": 8, "displayName": "In-country level 7" }, + { "level": 3, "displayName": "Province / Region" } ] - } - ]}; - library.orgUnitLevels = - {"organisationUnitLevels": [ - {"level": 2, "displayName": "Country"}, - {"level": 1, "displayName": "Global"}, - {"level": 4, "displayName": "In-country level 3"}, - {"level": 5, "displayName": "In-country level 4"}, - {"level": 6, "displayName": "In-country level 5"}, - {"level": 7, "displayName": "In-country level 6"}, - {"level": 8, "displayName": "In-country level 7"}, - {"level": 3, "displayName": "Province / Region"} - ]}; + }; library.cocApprovalStatus = [ { "id": "qS0ABIH66TS", @@ -425,10 +475,10 @@ } ]; - library.organisationUnitsForLevelThree = {"organisationUnits":[{"id":"XOivy2uDpMF","name":"Angola"},{"id":"iD2i0aynOGm","name":"Asia Regional Program"},{"id":"l1KFEXKI4Dg","name":"Botswana"},{"id":"wChmwjpXOw2","name":"Burma"},{"id":"Qh4XMQJhbk8","name":"Burundi"},{"id":"XWZK2nop7pM","name":"Cambodia"},{"id":"bQQJe0cC1eD","name":"Cameroon"},{"id":"nBo9Y4yZubB","name":"Caribbean Region"},{"id":"vSu0nPMbq7b","name":"Central America Region"},{"id":"t25400wXrNB","name":"Central Asia Region"},{"id":"CZ9ysPg2dSk","name":"China"},{"id":"ds0ADyc9UCU","name":"Cote d'Ivoire"},{"id":"ANN4YCOufcP","name":"Democratic Republic of the Congo"},{"id":"NzelIFhEv3C","name":"Dominican Republic"},{"id":"IH1kchw86uA","name":"Ethiopia"},{"id":"y3zhsvdXlhN","name":"Ghana"},{"id":"PeOHqAwdtez","name":"Guyana"},{"id":"JTypsdEUNPw","name":"Haiti"},{"id":"skj3e4YSiJY","name":"India"},{"id":"W73PRZcjFIU","name":"Indonesia"},{"id":"HfVjCurKxh2","name":"Kenya"},{"id":"qllxzIjjurr","name":"Lesotho"},{"id":"lZsCb6y0KDX","name":"Malawi"},{"id":"h11OyvlPxpJ","name":"Mozambique"},{"id":"FFVkaV9Zk1S","name":"Namibia"},{"id":"PqlFzhuPcF1","name":"Nigeria"},{"id":"cl7jVQOW3Ks","name":"Papua New Guinea"},{"id":"XtxUYCsDWrR","name":"Rwanda"},{"id":"cDGPF739ZZr","name":"South Africa"},{"id":"WLG0z5NxQs8","name":"South Sudan"},{"id":"V0qMZH29CtN","name":"Swaziland"},{"id":"mdXu6iCbn2G","name":"Tanzania"},{"id":"FETQ6OmnsKB","name":"Uganda"},{"id":"ligZVIYs2rL","name":"Ukraine"},{"id":"YM6xn5QxNpY","name":"Vietnam"},{"id":"f5RoebaDLMx","name":"Zambia"},{"id":"a71G4Gtcttv","name":"Zimbabwe"}]}; + library.organisationUnitsForLevelThree = { "organisationUnits": [{ "id": "XOivy2uDpMF", "name": "Angola" }, { "id": "iD2i0aynOGm", "name": "Asia Regional Program" }, { "id": "l1KFEXKI4Dg", "name": "Botswana" }, { "id": "wChmwjpXOw2", "name": "Burma" }, { "id": "Qh4XMQJhbk8", "name": "Burundi" }, { "id": "XWZK2nop7pM", "name": "Cambodia" }, { "id": "bQQJe0cC1eD", "name": "Cameroon" }, { "id": "nBo9Y4yZubB", "name": "Caribbean Region" }, { "id": "vSu0nPMbq7b", "name": "Central America Region" }, { "id": "t25400wXrNB", "name": "Central Asia Region" }, { "id": "CZ9ysPg2dSk", "name": "China" }, { "id": "ds0ADyc9UCU", "name": "Cote d'Ivoire" }, { "id": "ANN4YCOufcP", "name": "Democratic Republic of the Congo" }, { "id": "NzelIFhEv3C", "name": "Dominican Republic" }, { "id": "IH1kchw86uA", "name": "Ethiopia" }, { "id": "y3zhsvdXlhN", "name": "Ghana" }, { "id": "PeOHqAwdtez", "name": "Guyana" }, { "id": "JTypsdEUNPw", "name": "Haiti" }, { "id": "skj3e4YSiJY", "name": "India" }, { "id": "W73PRZcjFIU", "name": "Indonesia" }, { "id": "HfVjCurKxh2", "name": "Kenya" }, { "id": "qllxzIjjurr", "name": "Lesotho" }, { "id": "lZsCb6y0KDX", "name": "Malawi" }, { "id": "h11OyvlPxpJ", "name": "Mozambique" }, { "id": "FFVkaV9Zk1S", "name": "Namibia" }, { "id": "PqlFzhuPcF1", "name": "Nigeria" }, { "id": "cl7jVQOW3Ks", "name": "Papua New Guinea" }, { "id": "XtxUYCsDWrR", "name": "Rwanda" }, { "id": "cDGPF739ZZr", "name": "South Africa" }, { "id": "WLG0z5NxQs8", "name": "South Sudan" }, { "id": "V0qMZH29CtN", "name": "Swaziland" }, { "id": "mdXu6iCbn2G", "name": "Tanzania" }, { "id": "FETQ6OmnsKB", "name": "Uganda" }, { "id": "ligZVIYs2rL", "name": "Ukraine" }, { "id": "YM6xn5QxNpY", "name": "Vietnam" }, { "id": "f5RoebaDLMx", "name": "Zambia" }, { "id": "a71G4Gtcttv", "name": "Zimbabwe" }] }; library['system/info'] = - {"contextPath":"http://localhost:8080/dhis","userAgent":"Mozilla/5.0 (Macintosh; Intel Mac OS X 10_9_4) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/42.0.2311.82 Safari/537.36 OPR/29.0.1795.41 (Edition beta)","calendar":"iso8601","dateFormat":"yyyy-mm-dd","serverDate":"2015-04-25T11:39:39.109+0000","lastAnalyticsTableSuccess":"2015-03-14T23:03:27.809+0000","intervalSinceLastAnalyticsTableSuccess":"996 h, 36 m, 11 s","version":"2.19-SNAPSHOT","revision":"19021","buildTime":"2015-04-25T10:57:02.000+0000","environmentVariable":"DHIS2_HOME","javaVersion":"1.7.0_25","javaVendor":"Oracle Corporation","javaHome":"/Library/Java/JavaVirtualMachines/jdk1.7.0_25.jdk/Contents/Home/jre","javaIoTmpDir":"/usr/local/apache-tomcat-8.0.5/temp","javaOpts":"-Xms512m -Xmx1024m -XX:MaxPermSize=256M","osName":"Mac OS X","osArchitecture":"x86_64","osVersion":"10.9.4","externalDirectory":"/Work/UIO/dhis","databaseInfo":{"type":"PostgreSQL","name":"dedupe","user":"postgres"},"memoryInfo":"Mem Total in JVM: 757 Free in JVM: 484 Max Limit: 989","cpuCores":4,"systemId":"4892b46d-b5dd-4d41-9a8b-2e39d8e445de"}; + { "contextPath": "http://localhost:8080/dhis", "userAgent": "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_9_4) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/42.0.2311.82 Safari/537.36 OPR/29.0.1795.41 (Edition beta)", "calendar": "iso8601", "dateFormat": "yyyy-mm-dd", "serverDate": "2015-04-25T11:39:39.109+0000", "lastAnalyticsTableSuccess": "2015-03-14T23:03:27.809+0000", "intervalSinceLastAnalyticsTableSuccess": "996 h, 36 m, 11 s", "version": "2.19-SNAPSHOT", "revision": "19021", "buildTime": "2015-04-25T10:57:02.000+0000", "environmentVariable": "DHIS2_HOME", "javaVersion": "1.7.0_25", "javaVendor": "Oracle Corporation", "javaHome": "/Library/Java/JavaVirtualMachines/jdk1.7.0_25.jdk/Contents/Home/jre", "javaIoTmpDir": "/usr/local/apache-tomcat-8.0.5/temp", "javaOpts": "-Xms512m -Xmx1024m -XX:MaxPermSize=256M", "osName": "Mac OS X", "osArchitecture": "x86_64", "osVersion": "10.9.4", "externalDirectory": "/Work/UIO/dhis", "databaseInfo": { "type": "PostgreSQL", "name": "dedupe", "user": "postgres" }, "memoryInfo": "Mem Total in JVM: 757 Free in JVM: 484 Max Limit: 989", "cpuCores": 4, "systemId": "4892b46d-b5dd-4d41-9a8b-2e39d8e445de" }; library.fundingMechanismCategory = { "categoryOptions": [ @@ -637,11 +687,128 @@ name: "(default)" } ], - groups: [ ] + groups: [] } ] }; + library.categoryCombos = { + "id": "wUpfppgjEza", + "categoryOptionCombos": [ + { + "id": "hCBvGswtVQc", + "name": "11 - Some mechanism ", + }, + { + "id": "FIB6cf0GnUE", + "name": "12 - Some other mechanism ", + } + ] + }; + + library.workflowsWithDatasets = { + "dataApprovalWorkflows": [ + { + "name": "MER Results", + "id": "RwNpkAM7Hw7", + "periodType": "Quarterly", + "displayName": "MER Results", + "dataApprovalLevels": [ + { + "id": "aypLtfWShE5", + "level": 1, + "displayName": "Global" + }, { + "id": "fsIo8vU2VFZ", + "level": 4, + "displayName": "Implementing Partner" + }, { + "id": "rImhZfF6RKy", + "level": 2, + "displayName": "Inter-Agency" + }, { + "id": "jtLSx6a19Ps", + "level": 3, + "displayName": "Funding Agency" + }], + "dataSets": [ + { "name": "MER Results: Medical Store FY2016Q3", "id": "hIm0HGCKiPv", "shortName": "MER R: Medical Store FY2016Q3", "periodType": "Quarterly", "workflow": { "id": "RwNpkAM7Hw7", "periodType": "Quarterly" }, "categoryCombo": { "name": "Funding Mechanism", "id": "wUpfppgjEza", "categories": [{ "id": "SH885jaRe0o" }] } }, { "name": "MER Results: Community Based - DoD ONLY FY2016Q4", "id": "j9bKklpTDBZ", "shortName": "MER R: Community Based - DoD ONLY FY2016Q4", "periodType": "Quarterly", "workflow": { "id": "RwNpkAM7Hw7", "periodType": "Quarterly" }, "categoryCombo": { "name": "Funding Mechanism", "id": "wUpfppgjEza", "categories": [{ "id": "SH885jaRe0o" }] } }, { "name": "MER Results: Narratives (IM)", "id": "LWE9GdlygD5", "shortName": "MER R: Narratives (IM)", "periodType": "Quarterly", "workflow": { "id": "RwNpkAM7Hw7", "periodType": "Quarterly" }, "categoryCombo": { "name": "Funding Mechanism", "id": "wUpfppgjEza", "categories": [{ "id": "SH885jaRe0o" }] } }, { "name": "MER Results: Facility Based FY2017Q1", "id": "hgOW2BSUDaN", "shortName": "MER R: Facility Based FY2017Q1", "periodType": "Quarterly", "workflow": { "id": "RwNpkAM7Hw7", "periodType": "Quarterly" }, "categoryCombo": { "name": "Funding Mechanism", "id": "wUpfppgjEza", "categories": [{ "id": "SH885jaRe0o" }] } }, { "name": "MER Results: Operating Unit Level (IM) FY2017Q1", "id": "KwkuZhKulqs", "shortName": "MER R: Operating Unit Level (IM) FY2017Q1", "periodType": "Quarterly", "workflow": { "id": "RwNpkAM7Hw7", "periodType": "Quarterly" }, "categoryCombo": { "name": "Funding Mechanism", "id": "wUpfppgjEza", "categories": [{ "id": "SH885jaRe0o" }] } }, { "name": "MER Results: Facility Based - DoD ONLY FY2017Q1", "id": "CS958XpDaUf", "shortName": "MER R: Facility Based - DoD ONLY FY2017Q1", "periodType": "Quarterly", "workflow": { "id": "RwNpkAM7Hw7", "periodType": "Quarterly" }, "categoryCombo": { "name": "Funding Mechanism", "id": "wUpfppgjEza", "categories": [{ "id": "SH885jaRe0o" }] } }, { "name": "MER Results: Operating Unit Level (IM) FY2016Q3", "id": "ovYEbELCknv", "shortName": "MER R: Operating Unit Level (IM) FY2016Q3", "periodType": "Quarterly", "workflow": { "id": "RwNpkAM7Hw7", "periodType": "Quarterly" }, "categoryCombo": { "name": "Funding Mechanism", "id": "wUpfppgjEza", "categories": [{ "id": "SH885jaRe0o" }] } }, { "name": "MER Results: Community Based - DoD ONLY", "id": "UZ2PLqSe5Ri", "shortName": "MER R: Community Based - DoD ONLY", "periodType": "Quarterly", "workflow": { "id": "RwNpkAM7Hw7", "periodType": "Quarterly" }, "categoryCombo": { "name": "Funding Mechanism", "id": "wUpfppgjEza", "categories": [{ "id": "SH885jaRe0o" }] } }, { "name": "MER Results: Narratives (IM) FY2016Q4", "id": "xBRAscSmemV", "shortName": "MER R: Narratives (IM) FY2016Q4", "periodType": "Quarterly", "workflow": { "id": "RwNpkAM7Hw7", "periodType": "Quarterly" }, "categoryCombo": { "name": "Funding Mechanism", "id": "wUpfppgjEza", "categories": [{ "id": "SH885jaRe0o" }] } }, { "name": "MER Results: Facility Based - DoD ONLY FY2016Q4", "id": "vvHCWnhULAf", "shortName": "MER R: Facility Based - DoD ONLY FY2016Q4", "periodType": "Quarterly", "workflow": { "id": "RwNpkAM7Hw7", "periodType": "Quarterly" }, "categoryCombo": { "name": "Funding Mechanism", "id": "wUpfppgjEza", "categories": [{ "id": "SH885jaRe0o" }] } }, { "name": "MER Results: Community Based FY2017Q1", "id": "Awq346fnVLV", "shortName": "MER R: Community Based FY2017Q1", "periodType": "Quarterly", "workflow": { "id": "RwNpkAM7Hw7", "periodType": "Quarterly" }, "categoryCombo": { "name": "Funding Mechanism", "id": "wUpfppgjEza", "categories": [{ "id": "SH885jaRe0o" }] } }, { "name": "MER Results: Community Based FY2016Q3", "id": "STL4izfLznL", "shortName": "MER R: Community Based FY2016Q3", "periodType": "Quarterly", "workflow": { "id": "RwNpkAM7Hw7", "periodType": "Quarterly" }, "categoryCombo": { "name": "Funding Mechanism", "id": "wUpfppgjEza", "categories": [{ "id": "SH885jaRe0o" }] } }, { "name": "MER Results: Narratives (IM) FY2016Q3", "id": "NJlAVhe4zjv", "shortName": "MER R: Narratives (IM) FY2016Q3", "periodType": "Quarterly", "workflow": { "id": "RwNpkAM7Hw7", "periodType": "Quarterly" }, "categoryCombo": { "name": "Funding Mechanism", "id": "wUpfppgjEza", "categories": [{ "id": "SH885jaRe0o" }] } }, { "name": "MER Results: Medical Store", "id": "CGoi5wjLHDy", "shortName": "MER R: Medical Store", "periodType": "Quarterly", "workflow": { "id": "RwNpkAM7Hw7", "periodType": "Quarterly" }, "categoryCombo": { "name": "Funding Mechanism", "id": "wUpfppgjEza", "categories": [{ "id": "SH885jaRe0o" }] } }, { "name": "MER Results: Operating Unit Level (IM)", "id": "tG2hjDIaYQD", "shortName": "MER R: Operating Unit Level (IM)", "periodType": "Quarterly", "workflow": { "id": "RwNpkAM7Hw7", "periodType": "Quarterly" }, "categoryCombo": { "name": "Funding Mechanism", "id": "wUpfppgjEza", "categories": [{ "id": "SH885jaRe0o" }] } }, { "name": "MER Results: Operating Unit Level (IM) FY2016Q4", "id": "VWdBdkfYntI", "shortName": "MER R: Operating Unit Level (IM) FY2016Q4", "periodType": "Quarterly", "workflow": { "id": "RwNpkAM7Hw7", "periodType": "Quarterly" }, "categoryCombo": { "name": "Funding Mechanism", "id": "wUpfppgjEza", "categories": [{ "id": "SH885jaRe0o" }] } }, { "name": "MER Results: Facility Based - DoD ONLY", "id": "K7FMzevlBAp", "shortName": "MER R: Facility Based - DoD ONLY", "periodType": "Quarterly", "workflow": { "id": "RwNpkAM7Hw7", "periodType": "Quarterly" }, "categoryCombo": { "name": "Funding Mechanism", "id": "wUpfppgjEza", "categories": [{ "id": "SH885jaRe0o" }] } }, { "name": "MER Results: Facility Based FY2016Q3", "id": "i29foJcLY9Y", "shortName": "MER R: Facility Based FY2016Q3", "periodType": "Quarterly", "workflow": { "id": "RwNpkAM7Hw7", "periodType": "Quarterly" }, "categoryCombo": { "name": "Funding Mechanism", "id": "wUpfppgjEza", "categories": [{ "id": "SH885jaRe0o" }] } }, { "name": "MER Results: Medical Store FY2016Q4", "id": "gZ1FgiGUlSj", "shortName": "MER R: Medical Store FY2016Q4", "periodType": "Quarterly", "workflow": { "id": "RwNpkAM7Hw7", "periodType": "Quarterly" }, "categoryCombo": { "name": "Funding Mechanism", "id": "wUpfppgjEza", "categories": [{ "id": "SH885jaRe0o" }] } }, { "name": "MER Results: Community Based - DoD ONLY FY2016Q3", "id": "asHh1YkxBU5", "shortName": "MER R: Community Based - DoD ONLY FY2016Q3", "periodType": "Quarterly", "workflow": { "id": "RwNpkAM7Hw7", "periodType": "Quarterly" }, "categoryCombo": { "name": "Funding Mechanism", "id": "wUpfppgjEza", "categories": [{ "id": "SH885jaRe0o" }] } }, { "name": "MER Results: Facility Based - DoD ONLY FY2016Q3", "id": "j1i6JjOpxEq", "shortName": "MER R: Facility Based - DoD ONLY FY2016Q3", "periodType": "Quarterly", "workflow": { "id": "RwNpkAM7Hw7", "periodType": "Quarterly" }, "categoryCombo": { "name": "Funding Mechanism", "id": "wUpfppgjEza", "categories": [{ "id": "SH885jaRe0o" }] } }, { "name": "MER Results: Community Based - DoD ONLY FY2017Q1", "id": "ovmC3HNi4LN", "shortName": "MER R: Community Based - DoD ONLY FY2017Q1", "periodType": "Quarterly", "workflow": { "id": "RwNpkAM7Hw7", "periodType": "Quarterly" }, "categoryCombo": { "name": "Funding Mechanism", "id": "wUpfppgjEza", "categories": [{ "id": "SH885jaRe0o" }] } }, { "name": "MER Results: Community Based", "id": "MqNLEXmzIzr", "shortName": "MER R: Community Based", "periodType": "Quarterly", "workflow": { "id": "RwNpkAM7Hw7", "periodType": "Quarterly" }, "categoryCombo": { "name": "Funding Mechanism", "id": "wUpfppgjEza", "categories": [{ "id": "SH885jaRe0o" }] } }, { "name": "MER Results: Facility Based", "id": "kkXf2zXqTM0", "shortName": "MER R: Facility Based", "periodType": "Quarterly", "workflow": { "id": "RwNpkAM7Hw7", "periodType": "Quarterly" }, "categoryCombo": { "name": "Funding Mechanism", "id": "wUpfppgjEza", "categories": [{ "id": "SH885jaRe0o" }] } }, { "name": "MER Results: Facility Based FY2016Q4", "id": "ZaV4VSLstg7", "shortName": "MER R: Facility Based FY2016Q4", "periodType": "Quarterly", "workflow": { "id": "RwNpkAM7Hw7", "periodType": "Quarterly" }, "categoryCombo": { "name": "Funding Mechanism", "id": "wUpfppgjEza", "categories": [{ "id": "SH885jaRe0o" }] } }, { "name": "MER Results: Narratives (IM) FY2017Q1", "id": "zTgQ3MvHYtk", "shortName": "MER R: Narratives (IM) FY2017Q1", "periodType": "Quarterly", "workflow": { "id": "RwNpkAM7Hw7", "periodType": "Quarterly" }, "categoryCombo": { "name": "Funding Mechanism", "id": "wUpfppgjEza", "categories": [{ "id": "SH885jaRe0o" }] } }, { "name": "MER Results: Community Based FY2016Q4", "id": "sCar694kKxH", "shortName": "MER R: Community Based FY2016Q4", "periodType": "Quarterly", "workflow": { "id": "RwNpkAM7Hw7", "periodType": "Quarterly" }, "categoryCombo": { "name": "Funding Mechanism", "id": "wUpfppgjEza", "categories": [{ "id": "SH885jaRe0o" }] } }] + }, { + "name": "MER Targets", + "id": "TAjCBkG6hl6", + "periodType": "FinancialOct", + "displayName": "MER Targets", + "dataApprovalLevels": [ + { "id": "aypLtfWShE5", "level": 1, "displayName": "Global" }, + { "id": "fsIo8vU2VFZ", "level": 4, "displayName": "Implementing Partner" }, + { "id": "rImhZfF6RKy", "level": 2, "displayName": "Inter-Agency" }, + { "id": "jtLSx6a19Ps", "level": 3, "displayName": "Funding Agency" } + ], + "dataSets": [ + { + "name": "MER Targets: Operating Unit Level (IM) FY2016", + "id": "PHyD22loBQH", + "shortName": "MER T: Operating Unit Level (IM) FY2016", + "periodType": "FinancialOct", + "workflow": { + "id": "TAjCBkG6hl6", + "periodType": "FinancialOct" + }, + "categoryCombo": { + "name": "Funding Mechanism", + "id": "wUpfppgjEza", + "categories": [ + { "id": "SH885jaRe0o" } + ] + } + }, { + "name": "MER Targets: Facility Based - DoD ONLY", + "id": "jEzgpBt5Icf", + "shortName": "MER T: Facility Based - DoD ONLY", + "periodType": "FinancialOct", + "workflow": { + "id": "TAjCBkG6hl6", + "periodType": "FinancialOct" + }, + "categoryCombo": { + "name": "Funding Mechanism", + "id": "wUpfppgjEza", + "categories": [ + { "id": "SH885jaRe0o" } + ] + } + }, { + "name": "MER Targets: Narratives (IM) FY2017", + "id": "AyFVOGbAvcH", + "shortName": "MER T: Narratives (IM) FY2017", + "periodType": "FinancialOct", + "workflow": { + "id": "TAjCBkG6hl6", + "periodType": "FinancialOct" + }, + "categoryCombo": { + "name": "Funding Mechanism", + "id": "wUpfppgjEza", + "categories": [ + { "id": "SH885jaRe0o" } + ] + } + }, { + "name": "MER Targets: Community Based - DoD ONLY FY2017", + "id": "lbwuIo56YoG", + "shortName": "MER T: Community Based - DoD ONLY FY2017", + "periodType": "FinancialOct", + "workflow": { + "id": "TAjCBkG6hl6", + "periodType": "FinancialOct" + }, "categoryCombo": { "name": "Funding Mechanism", "id": "wUpfppgjEza", "categories": [{ "id": "SH885jaRe0o" }] } + }, { "name": "MER Targets: Operating Unit Level (IM)", "id": "bqiB5G6qgzn", "shortName": "MER T: Operating Unit Level (IM)", "periodType": "FinancialOct", "workflow": { "id": "TAjCBkG6hl6", "periodType": "FinancialOct" }, "categoryCombo": { "name": "Funding Mechanism", "id": "wUpfppgjEza", "categories": [{ "id": "SH885jaRe0o" }] } }, { "name": "MER Targets: Operating Unit Level (IM) FY2017", "id": "xxo1G5V1JG2", "shortName": "MER T: Operating Unit Level (IM) FY2017", "periodType": "FinancialOct", "workflow": { "id": "TAjCBkG6hl6", "periodType": "FinancialOct" }, "categoryCombo": { "name": "Funding Mechanism", "id": "wUpfppgjEza", "categories": [{ "id": "SH885jaRe0o" }] } }, { "name": "MER Targets: Community Based FY2016", "id": "xJ06pxmxfU6", "shortName": "MER T: Community Based FY2016", "periodType": "FinancialOct", "workflow": { "id": "TAjCBkG6hl6", "periodType": "FinancialOct" }, "categoryCombo": { "name": "Funding Mechanism", "id": "wUpfppgjEza", "categories": [{ "id": "SH885jaRe0o" }] } }, { "name": "MER Targets: Narratives (IM) FY2016", "id": "VjGqATduoEX", "shortName": "MER T: Narratives (IM) FY2016", "periodType": "FinancialOct", "workflow": { "id": "TAjCBkG6hl6", "periodType": "FinancialOct" }, "categoryCombo": { "name": "Funding Mechanism", "id": "wUpfppgjEza", "categories": [{ "id": "SH885jaRe0o" }] } }, { "name": "MER Targets: Facility Based FY2016", "id": "rDAUgkkexU1", "shortName": "MER T: Facility Based FY2016", "periodType": "FinancialOct", "workflow": { "id": "TAjCBkG6hl6", "periodType": "FinancialOct" }, "categoryCombo": { "name": "Funding Mechanism", "id": "wUpfppgjEza", "categories": [{ "id": "SH885jaRe0o" }] } }, { "name": "MER Targets: Facility Based - DoD ONLY FY2016", "id": "IOarm0ctDVL", "shortName": "MER T: Facility Based - DoD ONLY FY2016", "periodType": "FinancialOct", "workflow": { "id": "TAjCBkG6hl6", "periodType": "FinancialOct" }, "categoryCombo": { "name": "Funding Mechanism", "id": "wUpfppgjEza", "categories": [{ "id": "SH885jaRe0o" }] } }, { "name": "MER Targets: Facility Based FY2017", "id": "qRvKHvlzNdv", "shortName": "MER T: Facility Based FY2017", "periodType": "FinancialOct", "workflow": { "id": "TAjCBkG6hl6", "periodType": "FinancialOct" }, "categoryCombo": { "name": "Funding Mechanism", "id": "wUpfppgjEza", "categories": [{ "id": "SH885jaRe0o" }] } }, { "name": "MER Targets: Community Based FY2017", "id": "tCIW2VFd8uu", "shortName": "MER T: Community Based FY2017", "periodType": "FinancialOct", "workflow": { "id": "TAjCBkG6hl6", "periodType": "FinancialOct" }, "categoryCombo": { "name": "Funding Mechanism", "id": "wUpfppgjEza", "categories": [{ "id": "SH885jaRe0o" }] } }, { "name": "MER Targets: Community Based - DoD ONLY", "id": "ePndtmDbOJj", "shortName": "MER T: Community Based - DoD ONLY", "periodType": "FinancialOct", "workflow": { "id": "TAjCBkG6hl6", "periodType": "FinancialOct" }, "categoryCombo": { "name": "Funding Mechanism", "id": "wUpfppgjEza", "categories": [{ "id": "SH885jaRe0o" }] } }, { "name": "MER Targets: Facility Based - DoD ONLY FY2017", "id": "JXKUYJqmyDd", "shortName": "MER T: Facility Based - DoD ONLY FY2017", "periodType": "FinancialOct", "workflow": { "id": "TAjCBkG6hl6", "periodType": "FinancialOct" }, "categoryCombo": { "name": "Funding Mechanism", "id": "wUpfppgjEza", "categories": [{ "id": "SH885jaRe0o" }] } }, { "name": "MER Targets: Narratives (IM)", "id": "AvmGbcurn4K", "shortName": "MER T: Narratives (IM)", "periodType": "FinancialOct", "workflow": { "id": "TAjCBkG6hl6", "periodType": "FinancialOct" }, "categoryCombo": { "name": "Funding Mechanism", "id": "wUpfppgjEza", "categories": [{ "id": "SH885jaRe0o" }] } }, { "name": "MER Targets: Facility Based", "id": "AitXBHsC7RA", "shortName": "MER T: Facility Based", "periodType": "FinancialOct", "workflow": { "id": "TAjCBkG6hl6", "periodType": "FinancialOct" }, "categoryCombo": { "name": "Funding Mechanism", "id": "wUpfppgjEza", "categories": [{ "id": "SH885jaRe0o" }] } }, { "name": "MER Targets: Community Based", "id": "BuRoS9i851o", "shortName": "MER T: Community Based", "periodType": "FinancialOct", "workflow": { "id": "TAjCBkG6hl6", "periodType": "FinancialOct" }, "categoryCombo": { "name": "Funding Mechanism", "id": "wUpfppgjEza", "categories": [{ "id": "SH885jaRe0o" }] } }, { "name": "MER Targets: Medical Store FY2017", "id": "Om3TJBRH8G8", "shortName": "MER T: Medical Store FY2017", "periodType": "FinancialOct", "workflow": { "id": "TAjCBkG6hl6", "periodType": "FinancialOct" }, "categoryCombo": { "name": "Funding Mechanism", "id": "wUpfppgjEza", "categories": [{ "id": "SH885jaRe0o" }] } }, { "name": "MER Targets: Community Based - DoD ONLY FY2016", "id": "LBSk271pP7J", "shortName": "MER T: Community Based - DoD ONLY FY2016", "periodType": "FinancialOct", "workflow": { "id": "TAjCBkG6hl6", "periodType": "FinancialOct" }, "categoryCombo": { "name": "Funding Mechanism", "id": "wUpfppgjEza", "categories": [{ "id": "SH885jaRe0o" }] } }] + }, { + "name": "Custom workflow", + "id": "AAAAAAAAAAA", + "periodType": "FinancialOct", + }] + } function getFixture(key) { return library[key]; } diff --git a/src/test/mocks/datasetgroup-service_mock.js b/src/test/mocks/datasetgroup-service_mock.js index 376fec0..59f45b6 100644 --- a/src/test/mocks/datasetgroup-service_mock.js +++ b/src/test/mocks/datasetgroup-service_mock.js @@ -1,7 +1,10 @@ function dataSetGroupServiceMock(rx) { return { setCurrentDataSetGroup: function () {}, - dataSetGroups$: rx.Observable.just(['MER', 'EA']) + dataSetGroups$: rx.Observable.just([ + { name: 'MER' }, + { name: 'EA' } + ]) // currentDataSetGroup$: currentDataSetGroup$, // getDataSetsForGroup: getDataSetsForGroup }; diff --git a/src/test/specs/approvals/workflows-service_spec.js b/src/test/specs/approvals/workflows-service_spec.js index 6d3a0f5..6092e2f 100644 --- a/src/test/specs/approvals/workflows-service_spec.js +++ b/src/test/specs/approvals/workflows-service_spec.js @@ -2,48 +2,7 @@ describe('Workflow service', function () { var workflowService; var rx; var $httpBackend; - var workflowResponse = { - "dataApprovalWorkflows": [{ - "name": "MER Results", - "id": "QeGps9iWl1i", - "displayName": "MER Results", - "dataApprovalLevels": [{"id": "aypLtfWShE5", "level": 1, "displayName": "Global"}, { - "id": "fsIo8vU2VFZ", - "level": 5, - "displayName": "Implementing Partner" - }, {"id": "rImhZfF6RKy", "level": 3, "displayName": "Inter-Agency"}, { - "id": "jtLSx6a19Ps", - "level": 4, - "displayName": "Funding Agency" - }] - }, { - "name": "MER Targets", - "id": "AEt9nEjcmhw", - "displayName": "MER Targets", - "dataApprovalLevels": [{"id": "aypLtfWShE5", "level": 1, "displayName": "Global"}, { - "id": "fsIo8vU2VFZ", - "level": 5, - "displayName": "Implementing Partner" - }, {"id": "rImhZfF6RKy", "level": 3, "displayName": "Inter-Agency"}, { - "id": "jtLSx6a19Ps", - "level": 4, - "displayName": "Funding Agency" - }] - }, { - "name": "mg_test", - "id": "rrUYETtwcgu", - "displayName": "mg_test", - }, { - "name": "SIMS", - "id": "FmDY2sTeoYw", - "displayName": "SIMS", - "dataApprovalLevels": [{ - "id": "MROYE5CmsDF", - "level": 2, - "displayName": "Global Funding Agency" - }, {"id": "aypLtfWShE5", "level": 1, "displayName": "Global"}] - }] - }; + var workflowResponse = fixtures.get('workflowsWithDatasets'); var dataApprovalWorkflowsRequest; beforeEach(module('d2-rest')); @@ -54,8 +13,11 @@ describe('Workflow service', function () { $httpBackend = $injector.get('$httpBackend'); dataApprovalWorkflowsRequest = $httpBackend - .expectGET('/dhis/api/dataApprovalWorkflows?fields=id,name,displayName,dataApprovalLevels%5BdisplayName,id,level%5D&paging=false'); + .expectGET('/dhis/api/dataApprovalWorkflows?fields=id,name,displayName,periodType,dataApprovalLevels%5BdisplayName,id,level%5D,dataSets%5Bname,shortName,id,periodType,workflow%5Bid,periodType%5D,categoryCombo%5Bid,name,categories%5Bid%5D%5D%5D&paging=false'); dataApprovalWorkflowsRequest.respond(200, workflowResponse); + + $httpBackend.whenGET('/dhis/api/categoryCombos/wUpfppgjEza?fields=id,categoryOptionCombos%5Bid,name%5D') + .respond(200, fixtures.get('categoryCombos')); })); it('should return an object', function () { @@ -69,8 +31,8 @@ describe('Workflow service', function () { it('should emit a value from currentWorkflow$ when called', function (done) { var newWorkflow = { - name: 'QUR Results', - id: 'QeGps9iWl1i' + name: 'MER Results', + id: 'RwNpkAM7Hw7' }; workflowService.currentWorkflow$ @@ -78,7 +40,7 @@ describe('Workflow service', function () { expect(currentWorkflow.displayName).to.equal(workflowResponse.dataApprovalWorkflows[0].displayName); expect(currentWorkflow.dataApprovalLevels).to.deep.equal(workflowResponse.dataApprovalWorkflows[0].dataApprovalLevels); done(); - }); + }, function (err) { done(err); }); workflowService.setCurrentWorkflow(newWorkflow); $httpBackend.flush(); @@ -95,7 +57,7 @@ describe('Workflow service', function () { workflowService.workflows$ .subscribe(function (workflows) { - expect(workflows.length).to.equal(4); + expect(workflows.length).to.equal(3); workflows .forEach(function (workflow, index) { expect(workflow.displayName).to.equal(expectedWorkflows[index].displayName); @@ -129,7 +91,7 @@ describe('Workflow service', function () { workflowService.workflows$ .subscribe(function (workflows) { - expect(workflows.length).to.equal(4); + expect(workflows.length).to.equal(3); workflows .forEach(function (workflow, index) { expect(workflow.displayName).to.equal(expectedWorkflows[index].displayName); @@ -140,6 +102,31 @@ describe('Workflow service', function () { done(); }); }); + + it('should have loaded the dataSets for the workflows', function (done) { + workflowService.workflows$ + .subscribe(function (workflows) { + expect(workflows[0].dataSets).to.have.length(27); + expect(workflows[1].dataSets).to.have.length(19); + expect(workflows[2].dataSets).to.have.length(0); + + done(); + }); + + $httpBackend.flush(); + }); + + it('should have loaded the categoryOptionCombos for the datasets', function (done) { + workflowService.workflows$ + .subscribe(function (workflows) { + expect(workflows[0].dataSets[0].categoryCombo.categoryOptionCombos).to.have.length(2); + expect(workflows[1].dataSets[0].categoryCombo.categoryOptionCombos).to.have.length(2); + + done(); + }); + + $httpBackend.flush(); + }); }); describe('getApprovalLevelById()', function () { @@ -163,7 +150,7 @@ describe('Workflow service', function () { }); it('should return the correct level for a workflow', function () { - expect(workflow.getApprovalLevelById('rImhZfF6RKy')).to.deep.equal({"id": "rImhZfF6RKy", "level": 3, "displayName": "Inter-Agency"}); + expect(workflow.getApprovalLevelById('rImhZfF6RKy')).to.deep.equal({"id": "rImhZfF6RKy", "level": 2, "displayName": "Inter-Agency"}); }); }); @@ -176,7 +163,7 @@ describe('Workflow service', function () { done(); }); - workflowService.setCurrentWorkflow({id: 'rrUYETtwcgu'}); + workflowService.setCurrentWorkflow({id: 'AAAAAAAAAAA'}); $httpBackend.flush(); }); }); @@ -202,7 +189,11 @@ describe('Workflow service', function () { }); it('should return the correct level before the provided level', function () { - expect(workflow.getApprovalLevelBeforeLevel('rImhZfF6RKy')).to.deep.equal({"id": "aypLtfWShE5", "level": 1, "displayName": "Global"}); + expect(workflow.getApprovalLevelBeforeLevel('jtLSx6a19Ps')).to.deep.equal({ + "id": "rImhZfF6RKy", + "level": 2, + "displayName": "Inter-Agency" + }); }); it('should throw an error when there is no higher level', function () { @@ -216,12 +207,12 @@ describe('Workflow service', function () { workflowService.currentWorkflow$ .subscribe(function (workflow) { expect(function () { - workflow.getApprovalLevelBeforeLevel('rrUYETtwcgu'); + workflow.getApprovalLevelBeforeLevel('fsIo8vU2VFZ'); }).to.throw('This workflow does not have any approval levels'); done(); }); - workflowService.setCurrentWorkflow({id: 'rrUYETtwcgu'}); + workflowService.setCurrentWorkflow({id: 'AAAAAAAAAAA'}); $httpBackend.flush(); }); }); @@ -247,7 +238,11 @@ describe('Workflow service', function () { }); it('should return the correct level before the provided level', function () { - expect(workflow.getApprovalLevelBelowLevel('rImhZfF6RKy')).to.deep.equal({"id": "jtLSx6a19Ps", "level": 4, "displayName": "Funding Agency"}); + expect(workflow.getApprovalLevelBelowLevel('rImhZfF6RKy')).to.deep.equal({ + "id": "jtLSx6a19Ps", + "level": 3, + "displayName": "Funding Agency" + }); }); it('should throw an error when there is no higher level', function () { @@ -261,12 +256,12 @@ describe('Workflow service', function () { workflowService.currentWorkflow$ .subscribe(function (workflow) { expect(function () { - workflow.getApprovalLevelBelowLevel('rrUYETtwcgu'); + workflow.getApprovalLevelBelowLevel('aypLtfWShE5'); }).to.throw('This workflow does not have any approval levels'); done(); }); - workflowService.setCurrentWorkflow({id: 'rrUYETtwcgu'}); + workflowService.setCurrentWorkflow({id: 'AAAAAAAAAAA'}); $httpBackend.flush(); }); }); diff --git a/src/test/specs/dataset/datasetgroup-service_spec.js b/src/test/specs/dataset/datasetgroup-service_spec.js index 48dc35d..7f5be6e 100644 --- a/src/test/specs/dataset/datasetgroup-service_spec.js +++ b/src/test/specs/dataset/datasetgroup-service_spec.js @@ -1,16 +1,20 @@ describe('Datasetgroup service', function () { - var merUrl = '/dhis/api/dataSets?fields=name,shortName,id,periodType,categoryCombo%5Bid,name,categories%5Bid%5D%5D&filter=id:in:%5Bfx2HjpODE5y,xXmmo2so2V8,gpJ2TLXI3mY,w9BiI08vABw%5D&paging=false'; - var eaUrl = '/dhis/api/dataSets?fields=name,shortName,id,periodType,categoryCombo%5Bid,name,categories%5Bid%5D%5D&filter=id:in:%5BeLRAaV32xH5,kLPghhtGPvZ,A4ivU53utt2,wEKkfO7aAI3,JmnzNK18klO%5D&paging=false'; - var service; var $httpBackend; + var $rootScope; var periodService = { - filterPeriodTypes: sinon.spy() + getPeriodsForWorkflow: sinon.stub() }; var errorHandlerMock; + var dataApprovalWorkflows = fixtures.get('workflowsWithDatasets').dataApprovalWorkflows; beforeEach(module('d2-rest')); beforeEach(module('PEPFAR.approvals', function ($provide) { + $provide.factory('workflowService', function (rx, $rootScope) { + return { + workflows$: rx.Observable.just(dataApprovalWorkflows).safeApply($rootScope) + }; + }); $provide.factory('periodService', function () { return periodService; }); @@ -21,87 +25,110 @@ describe('Datasetgroup service', function () { }; }); })); - beforeEach(inject(function (_$httpBackend_, dataSetGroupService, errorHandler) { + beforeEach(inject(function (_$httpBackend_, _$rootScope_, errorHandler) { errorHandlerMock = errorHandler; $httpBackend = _$httpBackend_; - service = dataSetGroupService; + $rootScope = _$rootScope_; - $httpBackend.expectGET('/dhis/api/dataApprovalWorkflows?fields=id,name,displayName,dataApprovalLevels%5BdisplayName,id,level%5D&paging=false') - .respond(200, { - "dataApprovalWorkflows": [{ - "name": "EA", - "id": "h7g3CDxdExi", - "displayName": "EA", - "dataApprovalLevels": [{"id": "aypLtfWShE5"}, {"id": "fsIo8vU2VFZ"}, {"id": "rImhZfF6RKy"}, {"id": "jtLSx6a19Ps"}] - }, { - "name": "MER", - "id": "QeGps9iWl1i", - "displayName": "MER", - "dataApprovalLevels": [{"id": "aypLtfWShE5"}, {"id": "fsIo8vU2VFZ"}, {"id": "rImhZfF6RKy"}, {"id": "jtLSx6a19Ps"}] - }, { - "name": "SIMS", - "id": "FmDY2sTeoYw", - "displayName": "SIMS", - "dataApprovalLevels": [{"id": "MROYE5CmsDF"}, {"id": "aypLtfWShE5"}] - }] - }); - - $httpBackend.whenGET('/dhis/api/dataSets?fields=name,shortName,id,periodType,workflow%5Bid,periodType%5D,categoryCombo%5Bid,name,categories%5Bid%5D%5D&filter=workflow.id:in:%5Bh7g3CDxdExi,QeGps9iWl1i,FmDY2sTeoYw%5D&paging=false') - .respond(200, { - dataSets: [ - { - id: 'iP8irTNtByO', - name: 'DSD: DS 1', - shortName: 'DSD: DS 1', - workflow: { - id: "QeGps9iWl1i" - }, - categoryCombo: { - name: "Funding Mechanism", - id: "wUpfppgjEza", - categories: [ - {id: "SH885jaRe0o"} - ] - } - }, - { - id: 'iP8irTNtByO', - name: 'DSD: DS 1', - shortName: 'DSD: DS 1', - workflow: { - id: "h7g3CDxdExi" - }, - categoryCombo: { - name: "Funding Mechanism", - id: "wUpfppgjEza", - categories: [ - {id: "SH885jaRe0o"} - ] - } - }, - ], - }); - - $httpBackend.whenGET('/dhis/api/categoryCombos/wUpfppgjEza?fields=id,categoryOptionCombos%5Bid,name%5D') - .respond(200, { - id: 'da885jaRe0o', - name: '11 - Some mechanism ', - }); + periodService.getPeriodsForWorkflow + .returns(Rx.Observable.just([])); + })); + beforeEach(inject(function (dataSetGroupService) { + service = dataSetGroupService; })); afterEach(function () { $httpBackend.verifyNoOutstandingRequest(); + $httpBackend.verifyNoOutstandingExpectation(); }); it('should be defined', function () { expect(service).to.be.a('object'); }); - xit('after loading the datasets it should call the periodService', function () { - $httpBackend.flush(); + describe('dataSetGroups$', function () { + it('should emit the workflows', function (done) { + periodService.getPeriodsForWorkflow + .withArgs(dataApprovalWorkflows[0]) + .returns(Rx.Observable.just([ + { id: '2016Q2', "name": "April - June 2016", }, + { id: '2017Q1', name: 'January - March 2017' } + ])); + + periodService.getPeriodsForWorkflow + .withArgs(dataApprovalWorkflows[1]) + .returns(Rx.Observable.just([ + { id: '2017Oct', "name": "October 2017 - September 2018", }, + ])); + + service.dataSetGroups$ + .subscribe( + function (workflows) { + expect(workflows).to.have.length(2); + done(); + }, + function (err) { done(err) } + ); + }); + + it('should return just the workflow that has periods', function (done) { + periodService.getPeriodsForWorkflow + .withArgs(dataApprovalWorkflows[0]) + .returns(Rx.Observable.just([])); - expect(periodService.filterPeriodTypes).to.been.called; + periodService.getPeriodsForWorkflow + .withArgs(dataApprovalWorkflows[1]) + .returns(Rx.Observable.just([ + { id: '2017Oct', "name": "October 2017 - September 2018", }, + ])); + + service.dataSetGroups$ + .subscribe( + function (workflows) { + expect(workflows).to.have.length(1); + done(); + }, + function (err) { done(err) } + ); + }); + + it('should log an error message when no workflows have been found', function (done) { + periodService.getPeriodsForWorkflow + .withArgs(dataApprovalWorkflows[0]) + .returns(Rx.Observable.just([])); + + periodService.getPeriodsForWorkflow + .withArgs(dataApprovalWorkflows[1]) + .returns(Rx.Observable.just([])); + + service.dataSetGroups$ + .subscribe( + function (workflows) { + expect(errorHandlerMock.error).to.be.calledWith('Could not not find any workflows (Data Streams)'); + expect(workflows).to.have.length(0); + done(); + }, + function (err) { done(err) } + ); + }); + + it('should not log an error when there are workflows', function (done) { + periodService.getPeriodsForWorkflow + .withArgs(dataApprovalWorkflows[1]) + .returns(Rx.Observable.just([ + { id: '2017Oct', "name": "October 2017 - September 2018", }, + ])); + + service.dataSetGroups$ + .subscribe( + function (workflows) { + expect(errorHandlerMock.error).not.to.be.called; + done(); + }, + function (err) { done(err) } + ); + }); }); }); diff --git a/src/test/specs/dataset/datasetgroupselector-directive_spec.js b/src/test/specs/dataset/datasetgroupselector-directive_spec.js index 219764e..bf5e045 100644 --- a/src/test/specs/dataset/datasetgroupselector-directive_spec.js +++ b/src/test/specs/dataset/datasetgroupselector-directive_spec.js @@ -32,9 +32,6 @@ describe('Dataset group selector directive', function () { describe('select', function () { var selectElement; beforeEach(function () { - dataSetGroupService.datasetGroups = ['MER', 'EA']; - scope.$apply(); - selectElement = element.children().first(); }); diff --git a/src/test/specs/period/period-service_spec.js b/src/test/specs/period/period-service_spec.js index 60c91bf..0e60126 100644 --- a/src/test/specs/period/period-service_spec.js +++ b/src/test/specs/period/period-service_spec.js @@ -85,84 +85,6 @@ describe('Period service', function () { $rootScope.$apply(); }); }); - - xit('should have the period types', function () { - var periodTypes = [ - "Daily", - "Weekly", - "Monthly", - "BiMonthly", - "Quarterly", - "SixMonthly", - "SixMonthlyApril", - "Yearly", - "FinancialApril", - "FinancialJuly", - "FinancialOct" - ]; - - expect(service.getPeriodTypes()).to.deep.equal(periodTypes); - }); - - //TODO: Mock out the period generator - xdescribe('getPastPeriodsRecentFirst', function () { - it('should return periods', function () { - service.setPeriodType('Monthly'); - - expect(service.getPastPeriodsRecentFirst()).to.be.a('array'); - }); - - it('it should not return a new array', function () { - service.setPeriodType('Monthly'); - - expect(service.getPastPeriodsRecentFirst()).to.equal(service.getPastPeriodsRecentFirst()); - }); - }); - - xdescribe('setPeriodType', function () { - it('should generate the correct yearly periods', function () { - service.setPeriodType('Yearly'); - - var generatedPeriods = service.getPastPeriodsRecentFirst(); - var thisYearString = (new Date()).getFullYear().toString(); - - expect(thisYearString).to.equal(generatedPeriods[0].name); - }) - }); - - xdescribe('filterPeriodTypes', function () { - it('should be a method', function () { - expect(service.filterPeriodTypes).to.be.a('function'); - }); - - it('filter period types on the lowerst available one', function () { - var filteredPeriods; - - service.filterPeriodTypes(['Monthly', 'BiMonthly', 'Weekly', 'Daily']); - filteredPeriods = service.getPeriodTypes(); - - expect(filteredPeriods).to.deep.equal(['BiMonthly', 'Quarterly', 'SixMonthly', 'SixMonthlyApril', 'Yearly', 'FinancialApril', 'FinancialJuly', 'FinancialOct']); - }); - - it('filter period types with yearly as the lowest', function () { - var filteredPeriods; - - service.filterPeriodTypes(['Monthly', 'BiMonthly', 'Weekly', 'Daily', 'Yearly']); - filteredPeriods = service.getPeriodTypes(); - - expect(filteredPeriods).to.deep.equal(['Yearly', 'FinancialApril', 'FinancialJuly', 'FinancialOct']); - }); - - it('should emit a value from the periodTypes$ observable', function (done) { - service.filterPeriodTypes(['Monthly', 'BiMonthly', 'Weekly', 'Daily', 'Yearly']); - - service.periodTypes$ - .subscribe(function (filteredPeriods) { - expect(filteredPeriods).to.deep.equal(['Yearly', 'FinancialApril', 'FinancialJuly', 'FinancialOct']); - done(); - }); - }); - }); describe('setPeriod', function () { it('should emit the set value from the observable', function (done) {