Measurable - Nav Aid for function misdirects user
@@ -57,6 +57,11 @@ function findFirstNonEmptyTab(tabs = []) {
}
+function mkMeasurableKey(categoryId, externalId) {
+ return categoryId + "_" + externalId;
+}
+
+
function controller($q,
$state,
$stateParams,
@@ -81,7 +86,7 @@ function controller($q,
$q.all([measurablePromise, measurableCategoryPromise, countPromise])
.then(([measurables = [], categories = [], counts = []]) => {
vm.tabs = prepareTabs(categories, measurables, counts);
- vm.measurablesByExternalId = _.keyBy(measurables, 'externalId');
+ vm.measurablesByCategoryAndExternalId = _.keyBy(measurables, m => mkMeasurableKey(m.categoryId, m.externalId));
vm.visibility.tab = $stateParams.category || findFirstNonEmptyTab(vm.tabs);
});
@@ -98,7 +103,7 @@ function controller($q,
vm.blockProcessor = b => {
const extId = b.value;
- const measurable = vm.measurablesByExternalId[extId];
+ const measurable = vm.measurablesByCategoryAndExternalId[mkMeasurableKey(vm.visibility.tab, extId)];
if (measurable) {
b.block.onclick = () => $state.go('main.measurable.view', { id: measurable.id });
angular.element(b.block).addClass('clickable');
