Skip to content
This repository was archived by the owner on Jan 14, 2020. It is now read-only.

Commit e048131

Browse files
authored
Merge pull request #47 from fielded/optional-zone-reqs
feat: make state requirement optional
2 parents 354c07c + 23ce05a commit e048131

7 files changed

+9129
-16
lines changed

Diff for: .travis.yml

-2
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,6 @@ cache:
66
- node_modules
77
notifications:
88
email: false
9-
before_script:
10-
- npm prune
119
after_success:
1210
- npm run semantic-release
1311
branches:

Diff for: dist/bundle.js

+15-6
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,8 @@
7878
value: function decorateWithIndicators(stockCounts) {
7979
var _this2 = this;
8080

81+
var opts = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
82+
8183
var lgas = void 0;
8284
var states = void 0;
8385
var zones = void 0;
@@ -99,7 +101,7 @@
99101
});
100102
};
101103

102-
var decorateStockField = function decorateStockField(requiredAllocations, stockCount) {
104+
var decorateStockField = function decorateStockField(stockCount, requiredAllocations) {
103105
var location = void 0;
104106
if (stockCount.location.national) {
105107
location = national;
@@ -108,7 +110,7 @@
108110
}
109111

110112
var locationThresholds = void 0;
111-
if (location && location.level === 'zone') {
113+
if (location && location.level === 'zone' && requiredAllocations) {
112114
locationThresholds = _this2.thresholdsService.calculateThresholds(location, stockCount, products, requiredAllocations[location._id]);
113115
} else {
114116
locationThresholds = _this2.thresholdsService.calculateThresholds(location, stockCount, products);
@@ -223,10 +225,17 @@
223225
states = promiseResults.states;
224226
zones = promiseResults.zones || []; // not available for the state dashboard
225227
products = promiseResults.products;
226-
national = promiseResults.national || [];
227-
228-
nonZoneStockCounts = nonZoneStockCounts.map(decorateStockField.bind(null, null)).map(addReStockField);
229-
zoneStockCounts = zoneStockCounts.map(decorateStockField.bind(null, _this2.stateRequiredAllocationsByZone(nonZoneStockCounts))).map(addReStockField);
228+
national = promiseResults.national || {};
229+
230+
nonZoneStockCounts = nonZoneStockCounts.map(function (nonZoneStockCount) {
231+
return decorateStockField(nonZoneStockCount);
232+
}).map(addReStockField);
233+
zoneStockCounts = zoneStockCounts.map(function (zoneStockCount) {
234+
if (opts.requireChildAllocations === false) {
235+
return decorateStockField(zoneStockCount);
236+
}
237+
return decorateStockField(zoneStockCount, _this2.stateRequiredAllocationsByZone(nonZoneStockCounts));
238+
}).map(addReStockField);
230239

231240
return nonZoneStockCounts.concat(zoneStockCounts).map(addStockLevelStatusField);
232241
};

Diff for: dist/bundle.min.js

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)