Skip to content

Commit

Permalink
Merge pull request #42 from /issues/41-load-record-form-in-user-role
Browse files Browse the repository at this point in the history
Issues/41 load record form in user role
  • Loading branch information
blcham authored Dec 12, 2023
2 parents d2a7240 + 792a0a9 commit 3596605
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 12 deletions.
7 changes: 6 additions & 1 deletion 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 All @@ -59,7 +64,7 @@ class Record extends React.Component {
{this._showInstitution() && this._renderInstitution()}
<RecordProvenance record={record}/>
</form>
{record.formTemplate && this._renderForm()}
{this._renderForm()}
{this._renderButtons()}
{showAlert && recordSaved.status === ACTION_STATUS.ERROR &&
<div>
Expand Down
2 changes: 1 addition & 1 deletion js/components/record/RecordForm.js
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ class RecordForm extends React.Component {
return <Loader/>;
}

return <SForms
return !!this.state.form && <SForms
ref={this.refForm}
form={this.state.form}
formData={this.props.record.question}
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 3596605

Please sign in to comment.