Skip to content

Commit

Permalink
Merge pull request #645 from davidwatkins73/master
Browse files Browse the repository at this point in the history
Fixing some timing issues with ou-view
  • Loading branch information
davidwatkins73 authored Sep 30, 2016
2 parents 8b34969 + 1de5841 commit 332ffea
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ const config = {
};


function calcAppInvestmentPieStats(apps) {
function calcAppInvestmentPieStats(apps = []) {
return toKeyCounts(apps, a => a.overallRating);
}

Expand Down
5 changes: 3 additions & 2 deletions waltz-ng/client/common/index.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import _ from "lodash";

import d3 from 'd3';

/**
* Given data that looks like:
Expand Down Expand Up @@ -184,10 +184,11 @@ function toCountData(data) {


export function toKeyCounts(items = [], fn = x => x) {
if (! items) return [];
return toCountData(d3.nest()
.key(fn)
.rollup(d => d.length)
.entries(items))
.entries(items));
}


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,8 @@ function buildTree(orgUnits = [], self = {}) {
}


function calcParentsAndChildren(hierarchy = [], orgUnit = {}) {
function calcParentsAndChildren(hierarchy = [], orgUnit) {
if (! orgUnit) return { parentOrgUnits: [], childOrgUnits: [] };
const self = _.find(hierarchy, { entityReference: { id: orgUnit.id } });
const parentOrgUnits = self
? _.filter(hierarchy, h => h.level < self.level)
Expand Down
20 changes: 11 additions & 9 deletions waltz-ng/client/org-units/unit-view.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,8 @@
* You must not remove this notice, or any other, from this software.
*
*/
import EventDispatcher from "../common/EventDispatcher";


const addToHistory = (historyStore, orgUnit) => {
if (! orgUnit) { return; }
historyStore.put(
orgUnit.name,
'ORG_UNIT',
Expand All @@ -22,6 +20,12 @@ const addToHistory = (historyStore, orgUnit) => {
};


function initTour(tourService, holder = {}) {
return tourService.initialiseForKey('main.org-unit.view', true)
.then(tour => holder.tour = tour);
}


function controller($stateParams,
$scope,
viewDataService,
Expand All @@ -32,16 +36,15 @@ function controller($stateParams,
const vm = this;

vm.entityRef = { kind: 'ORG_UNIT', id };

vm.eventDispatcher = new EventDispatcher();

vm.viewData = viewDataService.data;

viewDataService
.loadAll(id)
.then(() => addToHistory(historyStore, vm.viewData.orgUnit))
.then(() => tourService.initialiseForKey('main.org-unit.view', true))
.then(tour => vm.tour = tour);
.then(() => initTour(tourService, vm));


// -- INTERACTIONS ---

vm.onAssetBucketSelect = (bucket) => {
$scope.$applyAsync(() => viewDataService.selectAssetBucket(bucket));
Expand All @@ -51,7 +54,6 @@ function controller($stateParams,
.loadFlowDetail()
.then(flowData => vm.viewData.dataFlows = flowData);


vm.loadOrgUnitDescendants = (id) => viewDataService
.loadOrgUnitDescendants(id)
.then(descendants => vm.viewData.orgUnitDescendants = descendants);
Expand Down

0 comments on commit 332ffea

Please sign in to comment.