Skip to content

Commit

Permalink
Merge pull request #97 from folio-org/UIOR-46-Close-order
Browse files Browse the repository at this point in the history
UIOR-46 Close Order
  • Loading branch information
AndreiShumski2 authored Dec 6, 2018
2 parents ec36fb2 + 0d0df28 commit ed90aca
Show file tree
Hide file tree
Showing 5 changed files with 158 additions and 3 deletions.
57 changes: 57 additions & 0 deletions src/components/PurchaseOrder/CloseOrder/CloseOrderModal.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
import React, { Component, Fragment } from 'react';
import { FormattedMessage } from 'react-intl';
import PropTypes from 'prop-types';

import { Button } from '@folio/stripes/components';

import CloseOrderModalForm from './CloseOrderModalForm';

class CloseOrderModal extends Component {
static propTypes = {
orderId: PropTypes.string.isRequired,
};

constructor(props) {
super(props);

this.state = {
openModal: false,
};
}

openModal = () => {
this.setState({
openModal: true,
});
}

closeModal = () => {
this.setState({
openModal: false,
});
}

render() {
const { orderId } = this.props;

return (
<Fragment>
<Button
buttonStyle="primary"
marginBottom0
onClick={this.openModal}
style={{ marginRight: '10px' }}
>
<FormattedMessage id="ui-orders.paneBlock.closeBtn" />
</Button>
<CloseOrderModalForm
close={this.closeModal}
orderId={orderId}
open={this.state.openModal}
/>
</Fragment>
);
}
}

export default CloseOrderModal;
66 changes: 66 additions & 0 deletions src/components/PurchaseOrder/CloseOrder/CloseOrderModalForm.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
import React from 'react';
import { FormattedMessage } from 'react-intl';
import PropTypes from 'prop-types';
import { Field } from 'redux-form';

import stripesForm from '@folio/stripes/form';
import {
Col,
Modal,
ModalFooter,
Row,
Select,
TextArea,
} from '@folio/stripes/components';

const CloseOrderModalForm = ({ close, open, orderId }) => {
const cancelBtn = <FormattedMessage id="ui-orders.closeOrderModal.cancel" />;
const submitBtn = <FormattedMessage id="ui-orders.closeOrderModal.submit" />;
const footer = (
<ModalFooter
secondaryButton={{
label: cancelBtn,
onClick: close,
}}
primaryButton={{
label: submitBtn,
onClick: close,
}}
/>
);

return (
<Modal
footer={footer}
label={<FormattedMessage id="ui-orders.closeOrderModal.title" values={{ orderId }} />}
open={open}
>
<Row>
<Col xs={12}>
<Field
component={Select}
label={<FormattedMessage id="ui-orders.closeOrderModal.reason" />}
name="reason"
/>
<Field
component={TextArea}
label={<FormattedMessage id="ui-orders.closeOrderModal.notes" />}
name="notes"
/>
</Col>
</Row>
</Modal>
);
};

CloseOrderModalForm.propTypes = {
close: PropTypes.func.isRequired,
open: PropTypes.bool.isRequired,
orderId: PropTypes.string.isRequired,
};

export default stripesForm({
form: 'closeOrderModalForm',
navigationCheck: true,
enableReinitialize: true,
})(CloseOrderModalForm);
4 changes: 4 additions & 0 deletions src/components/PurchaseOrder/CloseOrder/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
import CloseOrderModal from './CloseOrderModal';
import CloseOrderModalForm from './CloseOrderModalForm';

export { CloseOrderModal, CloseOrderModalForm };
28 changes: 25 additions & 3 deletions src/components/PurchaseOrder/PO.js
Original file line number Diff line number Diff line change
@@ -1,16 +1,37 @@
import React, { Component } from 'react';
import { FormattedMessage } from 'react-intl';
import PropTypes from 'prop-types';
import { get, isEmpty, isEqual } from 'lodash';

import {
get,
isEmpty,
isEqual,
} from 'lodash';

import { IfPermission } from '@folio/stripes/core';
import { Icon, IconButton, AccordionSet, Accordion, ExpandAllButton, Pane, PaneMenu, Row, Col, Button } from '@folio/stripes/components';
import {
Accordion,
AccordionSet,
Button,
Col,
ExpandAllButton,
Icon,
IconButton,
Pane,
PaneMenu,
Row,
} from '@folio/stripes/components';

import {
LayerPO,
LayerPOLine,
} from '../LayerCollection';
import transitionToParams from '../Utils/transitionToParams';
import { CloseOrderModal } from './CloseOrder';
import { AdjustmentView } from './Adjustment';
import LineListing from './LineListing';
import { PODetailsView } from './PODetails';
import { SummaryView } from './Summary';
import { LayerPO, LayerPOLine } from '../LayerCollection';

class PO extends Component {
static manifest = Object.freeze({
Expand Down Expand Up @@ -166,6 +187,7 @@ class PO extends Component {
const lastMenu = (
<PaneMenu>
<IfPermission perm="purchase_order.item.put">
<CloseOrderModal orderId={get(initialValues, 'id', '')} />
<FormattedMessage id="ui-orders.paneMenu.editOrder">
{ariaLabel => (
<IconButton
Expand Down
6 changes: 6 additions & 0 deletions translations/ui-orders/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -379,6 +379,7 @@
"orderSummary.totalEstimatedPrice": "Total Estimated Price",
"orderSummary.totalUnits": "Total Units",
"orderSummary.workflowStatus": "Workflow Status",
"paneBlock.closeBtn": "Close Order",
"paneBlock.adjustment": "Adjustment",
"paneBlock.POLines": "PO Lines",
"paneBlock.POSummary": "PO Summary",
Expand Down Expand Up @@ -443,6 +444,11 @@
"settings.setPOLInesLimit": "Set Purchase Order Lines Limit",
"settings.setPOLInesLimit.changed": "The Limit of Purchase Order Lines has been successfully saved",
"settings.setPOLInesLimit.validatation": "Please enter a whole number greater than 0 and less than 1000 to continue",
"closeOrderModal.reason": "Reason",
"closeOrderModal.notes": "Notes",
"closeOrderModal.cancel": "Cancel",
"closeOrderModal.submit": "Submit",
"closeOrderModal.title": "Close - Purchase Order #{orderId}",

"errors.noMatch.oops": "Uh-oh!",
"errors.noMatch.how": "How did you get to {location}?"
Expand Down

0 comments on commit ed90aca

Please sign in to comment.