Skip to content

Commit

Permalink
fixe and refactoring
Browse files Browse the repository at this point in the history
  • Loading branch information
vmonakhov committed Sep 28, 2024
1 parent 1e42541 commit 63b4522
Showing 1 changed file with 22 additions and 13 deletions.
35 changes: 22 additions & 13 deletions src/components/CognateAnalysisModal/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -176,6 +176,7 @@ const computeCognateAnalysisMutation = gql`
translation_count
result
xlsx_url
json_url
figure_url
minimum_spanning_tree
embedding_2d
Expand Down Expand Up @@ -2801,9 +2802,28 @@ class CognateAnalysisModal extends React.Component {

const { language_list, perspectiveSelectionCountMap } = this.state;

const disabledCompute = (
(!multi && (this.perspective_list.length <= 1 ||
!this.state.perspectiveSelectionList.some(enabled => enabled))) ||
(multi &&
(language_list.length <= 0 ||
(mode === "multi_reconstruction" &&
language_list.filter(language => perspectiveSelectionCountMap[id2str(language.id)] > 0).length <=
1) ||
perspectiveSelectionCountMap[""] <= 0)) ||
this.state.computing
)

return (
<div>
<Modal closeIcon onClose={this.props.closeModal} dimmer open size="fullscreen" className="lingvo-modal2">
<Modal
onKeyDown = { e => {
if (e.key === 'Enter' && !disabledCompute) this.handleCreate(); }}
tabIndex = "0"
closeIcon
onClose={this.props.closeModal}
dimmer open
size="fullscreen" className="lingvo-modal2">
<Modal.Header>
{mode === "acoustic"
? this.context("Cognate acoustic analysis")
Expand Down Expand Up @@ -2842,18 +2862,7 @@ class CognateAnalysisModal extends React.Component {
)
}
onClick={this.handleCreate}
disabled={
(!multi &&
(this.perspective_list.length <= 1 ||
!this.state.perspectiveSelectionList.some(enabled => enabled))) ||
(multi &&
(language_list.length <= 0 ||
(mode === "multi_reconstruction" &&
language_list.filter(language => perspectiveSelectionCountMap[id2str(language.id)] > 0).length <=
1) ||
perspectiveSelectionCountMap[""] <= 0)) ||
this.state.computing
}
disabled={disabledCompute}
className="lingvo-button-violet"
/>
<Button
Expand Down

0 comments on commit 63b4522

Please sign in to comment.