Skip to content

Commit

Permalink
[New #18] Added role specific buttons depending on extension
Browse files Browse the repository at this point in the history
  • Loading branch information
LaChope committed Nov 30, 2023
1 parent 6cf2678 commit 8cf2c81
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 4 deletions.
23 changes: 19 additions & 4 deletions js/components/record/Record.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,11 @@ import HorizontalInput from "../HorizontalInput";
import RecordForm from "./RecordForm";
import RecordProvenance from "./RecordProvenance";
import RequiredAttributes from "./RequiredAttributes";
import {ACTION_STATUS, ALERT_TYPES, ROLE} from "../../constants/DefaultConstants";
import {ACTION_STATUS, ALERT_TYPES, EXTENSION_CONSTANTS, ROLE} from "../../constants/DefaultConstants";
import AlertMessage from "../AlertMessage";
import {LoaderCard, LoaderSmall} from "../Loader";
import {processTypeaheadOptions} from "./TypeaheadAnswer";
import {EXTENSIONS} from "../../../config";

class Record extends React.Component {
constructor(props) {
Expand Down Expand Up @@ -100,17 +101,31 @@ class Record extends React.Component {
const {record, recordSaved, formgen} = this.props;

return <div className="mt-3 text-center">
<Button variant='success' size='sm'
{this._renderRoleSpecificButtons()}
<Button className="mx-1" variant='success' size='sm'
disabled={formgen.status === ACTION_STATUS.PENDING || recordSaved.status === ACTION_STATUS.PENDING
|| !this.state.isFormValid || !record.state.isComplete()}
|| !this.state.isFormValid || !record.state.isComplete()}
onClick={this.props.handlers.onSave}>
{this.i18n('save')}{recordSaved.status === ACTION_STATUS.PENDING && <LoaderSmall/>}
</Button>
<Button variant='link' size='sm'
<Button className="mx-1" variant='link' size='sm'
onClick={this.props.handlers.onCancel}>{this.i18n('cancel')}</Button>
</div>
}

_renderRoleSpecificButtons() {
return <>
{EXTENSIONS === EXTENSION_CONSTANTS.SUPPLIER &&
<>
<Button className="mx-1" variant='danger' size='sm'>Reject</Button>
<Button className="mx-1" variant='success' size='sm'>Accept</Button>
</>
}
{EXTENSIONS === EXTENSION_CONSTANTS.OPERATOR &&
<Button className="mx-1" variant='success' size='sm'>Complete</Button>}
</>;
}

_renderInstitution() {
const record = this.props.record;
if (!record.institution) {
Expand Down
5 changes: 5 additions & 0 deletions js/constants/DefaultConstants.js
Original file line number Diff line number Diff line change
Expand Up @@ -115,3 +115,8 @@ export const HttpHeaders = {
export const MediaType = {
FORM_URLENCODED: "application/x-www-form-urlencoded"
}

export const EXTENSION_CONSTANTS = {
SUPPLIER: "supplier",
OPERATOR: "operator"
}

0 comments on commit 8cf2c81

Please sign in to comment.