Skip to content

Commit

Permalink
[#41] Set record.formTemplate from props.formTemplate in Record inste…
Browse files Browse the repository at this point in the history
…ad in RequiredAttributes component.
  • Loading branch information
kostobog committed Dec 12, 2023
1 parent 81cd957 commit 3b5edde
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 10 deletions.
5 changes: 5 additions & 0 deletions js/components/record/Record.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 <AlertMessage type={ALERT_TYPES.DANGER}
message={this.props.formatMessage('record.load-error', {error: this.props.recordLoaded.error.message})}/>;
Expand Down
10 changes: 0 additions & 10 deletions js/components/record/RequiredAttributes.js
Original file line number Diff line number Diff line change
Expand Up @@ -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`;
Expand Down

0 comments on commit 3b5edde

Please sign in to comment.