From f9d5d0a2c3431526079c08626c6ecdd518ecb9c6 Mon Sep 17 00:00:00 2001 From: Jesse Chan Date: Sat, 31 Oct 2020 22:44:24 +0800 Subject: [PATCH] DownloadRulesTab: display form right under the editing rule --- .../modals/feeds-modal/DownloadRulesTab.tsx | 49 +++++++++++++++---- 1 file changed, 39 insertions(+), 10 deletions(-) diff --git a/client/src/javascript/components/modals/feeds-modal/DownloadRulesTab.tsx b/client/src/javascript/components/modals/feeds-modal/DownloadRulesTab.tsx index 68420774..8bf8388e 100644 --- a/client/src/javascript/components/modals/feeds-modal/DownloadRulesTab.tsx +++ b/client/src/javascript/components/modals/feeds-modal/DownloadRulesTab.tsx @@ -370,22 +370,41 @@ class DownloadRulesTab extends React.Component + return [ + - ); + , + null, + ]; } const rulesList = rules.map((rule) => this.getRulesListItem(rule)); - return ; + if (this.state.currentlyEditingRule == null || this.state.currentlyEditingRule === defaultRule) { + return [ + , + null, + ]; + } + + const editingRuleIndex = rules.indexOf(this.state.currentlyEditingRule as Rule); + + return [ + , + , + ]; } handleFormChange = ({ @@ -500,6 +519,8 @@ class DownloadRulesTab extends React.Component {errors} - - {this.getRulesList()} - - {this.state.currentlyEditingRule ? ( + {listAfterEditingRule == null ? ( + + {listBeforeEditingRule} + + ) : ( + + {listBeforeEditingRule} + {this.getModifyRuleForm(this.state.currentlyEditingRule as Partial)} + {listAfterEditingRule} + + )} + {this.state.currentlyEditingRule && listAfterEditingRule == null ? ( this.getModifyRuleForm(this.state.currentlyEditingRule) ) : (