From 80b074102a53ea2200cf8e8890b265c17911e3b9 Mon Sep 17 00:00:00 2001 From: sovanna Date: Mon, 27 Jan 2020 16:38:44 +0100 Subject: [PATCH] fix(issue9): Checks when no connector at all --- static/js/shop.jsx | 20 ++++++++++++++++++++ static/js/shop.min.js | 23 +++++++++++++++++++++++ 2 files changed, 43 insertions(+) diff --git a/static/js/shop.jsx b/static/js/shop.jsx index 3f181b1..0bed239 100644 --- a/static/js/shop.jsx +++ b/static/js/shop.jsx @@ -1583,6 +1583,26 @@ class Shop extends React.PureComponent { } } + if (idxK.length === 0) { + const slots_need_resource = itemsCloned.slice(0); + const idx_need = slots_need_resource.findIndex(e => (e.rules && e.rules.resources)); + + if (idx_need != -1) { + if (idx_need in itemsData) { + if ('warnings' in itemsData[idx_need]) { + itemsData[idx_need].warnings.resources = {...itemsCloned[idx_need].rules.resources}; + } else { + itemsData[idx_need].warnings = {}; + itemsData[idx_need].warnings.resources = {...itemsCloned[idx_need].rules.resources}; + } + } else { + itemsData[idx_need] = {...itemsCloned[idx_need]}; + itemsData[idx_need].warnings = {}; + itemsData[idx_need].warnings.resources = {...itemsCloned[idx_need].rules.resources}; + } + } + } + // check number of clock connector available const idxC = itemsCloned.reduce((prev, next, i) => { diff --git a/static/js/shop.min.js b/static/js/shop.min.js index 96f1b6e..813a1d3 100644 --- a/static/js/shop.min.js +++ b/static/js/shop.min.js @@ -1624,6 +1624,29 @@ function (_React$PureComponent12) { rules[ddkali.rules.follow.type] = _objectSpread({}, ddkali.rules.follow); } } + } + + if (idxK.length === 0) { + var _slots_need_resource = itemsCloned.slice(0); + + var _idx_need = _slots_need_resource.findIndex(function (e) { + return e.rules && e.rules.resources; + }); + + if (_idx_need != -1) { + if (_idx_need in itemsData) { + if ('warnings' in itemsData[_idx_need]) { + itemsData[_idx_need].warnings.resources = _objectSpread({}, itemsCloned[_idx_need].rules.resources); + } else { + itemsData[_idx_need].warnings = {}; + itemsData[_idx_need].warnings.resources = _objectSpread({}, itemsCloned[_idx_need].rules.resources); + } + } else { + itemsData[_idx_need] = _objectSpread({}, itemsCloned[_idx_need]); + itemsData[_idx_need].warnings = {}; + itemsData[_idx_need].warnings.resources = _objectSpread({}, itemsCloned[_idx_need].rules.resources); + } + } } // check number of clock connector available