Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ZEVA 360 - Delete transfer #474

Merged
merged 16 commits into from
Jan 4, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion backend/api/viewsets/credit_transfer.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,8 @@ def get_queryset(self):
CreditTransferStatuses.REJECTED,
CreditTransferStatuses.VALIDATED
])) |
Q(debit_from_id=request.user.organization.id))
Q(debit_from_id=request.user.organization.id)
).exclude(status__in=[CreditTransferStatuses.DELETED])
return queryset

def get_serializer_class(self):
Expand Down
4 changes: 2 additions & 2 deletions frontend/src/credits/CreditTransfersEditContainer.js
Original file line number Diff line number Diff line change
Expand Up @@ -151,8 +151,8 @@ const CreditTransfersEditContainer = (props) => {
submitOrSave('DRAFT');
};

const handleSubmit = () => {
submitOrSave('SUBMITTED');
const handleSubmit = (type) => {
submitOrSave(type);
};

const refreshDetails = () => {
Expand Down
22 changes: 17 additions & 5 deletions frontend/src/credits/components/CreditTransfersForm.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,20 +36,21 @@ const CreditTransfersForm = (props) => {
submission,
} = props;
const [showModal, setShowModal] = useState(false);
const [modalType, setModalType] = useState({ type: '', buttonText: '', message: '' });
const submitTooltip = 'You must acknowledge the three confirmation checkboxes prior to submitting this transfer.';
const modal = (
<Modal
confirmLabel=" Submit Notice"
confirmLabel={modalType.buttonText}
handleCancel={() => { setShowModal(false); }}
handleSubmit={() => { setShowModal(false); handleSubmit(); }}
handleSubmit={() => { setShowModal(false); handleSubmit(modalType.type); }}
modalClass="w-75"
showModal={showModal}
confirmClass="button primary"
icon={<FontAwesomeIcon icon="paper-plane" />}
confirmClass={modalType === 'SUBMITTED' ? 'button primary' : 'btn-outline-danger'}
icon={modalType === 'SUBMITTED' ? <FontAwesomeIcon icon="paper-plane" /> : <FontAwesomeIcon icon="trash" />}
>
<div>
<div><br /><br /></div>
<h3 className="d-inline">Submit credit transfer notice to trade partner?
<h3 className="d-inline">{modalType.message}
</h3>
<div><br /><br /></div>
</div>
Expand All @@ -61,6 +62,16 @@ const CreditTransfersForm = (props) => {
<div className="action-bar">
<span className="left-content">
<Button buttonType="back" locationRoute="/credit-transfers" />
{submission.status === 'DRAFT'
&& (
<Button
buttonType="delete"
action={() => {
setModalType({ type: 'DELETED', buttonText: ' Delete Notice', message: 'Delete transfer notice? WARNING: this action cannot be undone.' });
setShowModal(true);
}}
/>
)}
</span>
<span className="right-content">
{user.hasPermission('CREATE_CREDIT_TRANSFERS') && (
Expand All @@ -77,6 +88,7 @@ const CreditTransfersForm = (props) => {
buttonType="submit"
action={() => {
setShowModal(true);
setModalType({ type: 'SUBMITTED', buttonText: ' Submit Notice', message: 'Submit credit transfer notice to trade partner?' });
}}
optionalText="Submit Notice"
buttonTooltip={submitTooltip}
Expand Down