From 3a89f73eac9d650162b289863a2b70d174889b8f Mon Sep 17 00:00:00 2001 From: Bogdan Kostov Date: Thu, 7 Dec 2023 12:01:10 +0100 Subject: [PATCH 1/6] [#25] In Record, render RecordForm only when is record.formTemplate is defined. --- js/components/record/Record.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/js/components/record/Record.js b/js/components/record/Record.js index 17389e3a..16e09105 100644 --- a/js/components/record/Record.js +++ b/js/components/record/Record.js @@ -59,7 +59,7 @@ class Record extends React.Component { {this._showInstitution() && this._renderInstitution()} - {this._renderForm()} + {record.formTemplate && this._renderForm()} {this._renderButtons()} {showAlert && recordSaved.status === ACTION_STATUS.ERROR &&
From 3e37c3afc599762a030963df08e785a36d8cdce1 Mon Sep 17 00:00:00 2001 From: Bogdan Kostov Date: Thu, 7 Dec 2023 12:05:36 +0100 Subject: [PATCH 2/6] [#25] Load record form wizard only when record.formTemplate is defined --- js/components/record/RecordForm.js | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/js/components/record/RecordForm.js b/js/components/record/RecordForm.js index d1d245eb..7fff5178 100644 --- a/js/components/record/RecordForm.js +++ b/js/components/record/RecordForm.js @@ -34,14 +34,16 @@ class RecordForm extends React.Component { } componentDidMount() { - this.props.loadFormgen(ACTION_STATUS.PENDING); - this.loadWizard(); + if(this.props.record.formTemplate) { + this.props.loadFormgen(ACTION_STATUS.PENDING); + this.loadWizard(); + } } componentDidUpdate(prevProps, prevState, snapshot) { const {record} = this.props; - - if (prevProps.record.question?.uri !== record.question?.uri) { + if(record.formTemplate && record.formTemplate != prevProps.record.formTemplate) { + this.props.loadFormgen(ACTION_STATUS.PENDING); this.loadWizard(); } } From 44116045a4fdf1c0c78f09de62a12fd49fb037d1 Mon Sep 17 00:00:00 2001 From: Bogdan Kostov Date: Thu, 7 Dec 2023 12:06:46 +0100 Subject: [PATCH 3/6] [#25] Make sure the loader appears between events a) selection of record.formTemplate and b) the template is loaded --- js/components/record/RecordForm.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/js/components/record/RecordForm.js b/js/components/record/RecordForm.js index 7fff5178..a05ec9d6 100644 --- a/js/components/record/RecordForm.js +++ b/js/components/record/RecordForm.js @@ -121,7 +121,7 @@ class RecordForm extends React.Component { return ; - } else if (this.props.formgen.status === ACTION_STATUS.PENDING || !this.state.form) { + } else if (!!this.props.record.formTemplate && (this.props.formgen.status === ACTION_STATUS.PENDING || !this.state.form)) { return ; } From ddd8f76fc3fbd3672a83563eeef2b41c7be1afbf Mon Sep 17 00:00:00 2001 From: Bogdan Kostov Date: Thu, 7 Dec 2023 12:07:52 +0100 Subject: [PATCH 4/6] [#25] Allow typeahead to be disabled. --- js/components/record/TypeaheadAnswer.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/js/components/record/TypeaheadAnswer.js b/js/components/record/TypeaheadAnswer.js index fc1a0546..1c79c34e 100644 --- a/js/components/record/TypeaheadAnswer.js +++ b/js/components/record/TypeaheadAnswer.js @@ -58,7 +58,7 @@ const TypeaheadAnswer = (props) => { isSearchable={true} isLoading={isLoading} isClearable={true} - isDisabled={isLoading} + isDisabled={isLoading || (props.isDisabled === undefined ? false : props.isDisabled) } value={options.filter((option) => option.id === props.value)} placeholder={''} getOptionLabel={(option) => option.name} From 7838520aa18c65b720bb4ef98ecbf2ecc0cd5600 Mon Sep 17 00:00:00 2001 From: Bogdan Kostov Date: Thu, 7 Dec 2023 12:08:58 +0100 Subject: [PATCH 5/6] [#25] Disable form-template field when record.formTemplate is defined. --- js/components/record/RequiredAttributes.js | 1 + 1 file changed, 1 insertion(+) diff --git a/js/components/record/RequiredAttributes.js b/js/components/record/RequiredAttributes.js index 4f8a651d..5857e357 100644 --- a/js/components/record/RequiredAttributes.js +++ b/js/components/record/RequiredAttributes.js @@ -44,6 +44,7 @@ class RequiredAttributes extends React.Component {
Date: Mon, 11 Dec 2023 15:55:59 +0100 Subject: [PATCH 6/6] [#25] Simplify condition testing TypeaheadAnswer.props.isDisabled - add isDisabled to TypeaheadAnswer.propTypes --- js/components/record/TypeaheadAnswer.js | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/js/components/record/TypeaheadAnswer.js b/js/components/record/TypeaheadAnswer.js index 1c79c34e..7a479eaf 100644 --- a/js/components/record/TypeaheadAnswer.js +++ b/js/components/record/TypeaheadAnswer.js @@ -58,7 +58,7 @@ const TypeaheadAnswer = (props) => { isSearchable={true} isLoading={isLoading} isClearable={true} - isDisabled={isLoading || (props.isDisabled === undefined ? false : props.isDisabled) } + isDisabled={isLoading || (props.isDisabled === true) } value={options.filter((option) => option.id === props.value)} placeholder={''} getOptionLabel={(option) => option.name} @@ -73,7 +73,8 @@ TypeaheadAnswer.propTypes = { possibleValuesEndpoint: PropTypes.string.isRequired, label: PropTypes.string.isRequired, value: PropTypes.string, - onChange: PropTypes.func.isRequired + onChange: PropTypes.func.isRequired, + isDisabled: PropTypes.bool }; export default TypeaheadAnswer; \ No newline at end of file