From 3b5eddead8e04fb3baa62d58437f1b2f747e7372 Mon Sep 17 00:00:00 2001 From: Bogdan Kostov Date: Tue, 12 Dec 2023 17:00:19 +0100 Subject: [PATCH 1/2] [#41] Set record.formTemplate from props.formTemplate in Record instead in RequiredAttributes component. --- js/components/record/Record.js | 5 +++++ js/components/record/RequiredAttributes.js | 10 ---------- 2 files changed, 5 insertions(+), 10 deletions(-) diff --git a/js/components/record/Record.js b/js/components/record/Record.js index 16e09105..9cc5ec1b 100644 --- a/js/components/record/Record.js +++ b/js/components/record/Record.js @@ -41,6 +41,11 @@ class Record extends React.Component { render() { const {recordLoaded, recordSaved, showAlert, record, formTemplate, currentUser} = this.props; + if (!record?.formTemplate) { + if (formTemplate) { + record.formTemplate = formTemplate; + } + } if (recordLoaded.status === ACTION_STATUS.ERROR) { return ; diff --git a/js/components/record/RequiredAttributes.js b/js/components/record/RequiredAttributes.js index 5857e357..2e14b114 100644 --- a/js/components/record/RequiredAttributes.js +++ b/js/components/record/RequiredAttributes.js @@ -24,16 +24,6 @@ class RequiredAttributes extends React.Component { this.i18n = this.props.i18n; } - componentDidMount() { - const {record, formTemplate} = this.props; - - if (!record.formTemplate) { - if (formTemplate) { - record.formTemplate = formTemplate; - } - } - } - render() { const {record, formTemplate} = this.props; const possibleValuesEndpoint = `${API_URL}/rest/formGen/formTemplates`; From 792a0a96c6416f715f800f35339e59efe7583cc1 Mon Sep 17 00:00:00 2001 From: Bogdan Kostov Date: Tue, 12 Dec 2023 17:01:33 +0100 Subject: [PATCH 2/2] [#41] Move condition to render form in Record to RecordForm component. --- js/components/record/Record.js | 2 +- js/components/record/RecordForm.js | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/js/components/record/Record.js b/js/components/record/Record.js index 9cc5ec1b..6ec3ac62 100644 --- a/js/components/record/Record.js +++ b/js/components/record/Record.js @@ -64,7 +64,7 @@ class Record extends React.Component { {this._showInstitution() && this._renderInstitution()} - {record.formTemplate && this._renderForm()} + {this._renderForm()} {this._renderButtons()} {showAlert && recordSaved.status === ACTION_STATUS.ERROR &&
diff --git a/js/components/record/RecordForm.js b/js/components/record/RecordForm.js index a05ec9d6..4e63b7f3 100644 --- a/js/components/record/RecordForm.js +++ b/js/components/record/RecordForm.js @@ -125,7 +125,7 @@ class RecordForm extends React.Component { return ; } - return