Skip to content

Commit

Permalink
Hide workflows when there are no periods for that workflow and refact…
Browse files Browse the repository at this point in the history
…oring
  • Loading branch information
Markionium committed Apr 11, 2017
1 parent b6d03dc commit 622adce
Show file tree
Hide file tree
Showing 13 changed files with 699 additions and 629 deletions.
1 change: 1 addition & 0 deletions src/header-bar/dataApprovalWorkflows.json
Original file line number Diff line number Diff line change
@@ -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"}]}}]}]}
42 changes: 41 additions & 1 deletion src/main/approvals/workflows-service.js
Original file line number Diff line number Diff line change
Expand Up @@ -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));
});
Expand All @@ -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$,
Expand Down
Loading

0 comments on commit 622adce

Please sign in to comment.