Skip to content

Commit

Permalink
Merge pull request #2978 from MetaPhase-Consulting/maintain-asn-sep-h…
Browse files Browse the repository at this point in the history
…otfixes

[TM-5896] Maintain Separation Hotfixes
  • Loading branch information
jlam-mpc committed May 8, 2024
2 parents 5923b79 + d6d2c56 commit a45f801
Show file tree
Hide file tree
Showing 6 changed files with 101 additions and 28 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -455,7 +455,6 @@ const Assignment = (props) => {
<PositionExpandableContent
sections={sections}
form={form}
useCancelModal={false}
saveText={isNew ? 'Create Assignment' : 'Save Assigment'}
/>
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -126,9 +126,9 @@ const AssignmentsSeparations = (props) => {
<span>
Add or review the current assignments or separations for {employeeName}
</span>
<div className="add-buttons">
<div className={`add-buttons ${disableOtherEdits ? 'disabled' : ''}`}>
<div className="create-new-button">
<a role="button" className="width-300" tabIndex={0} onClick={() => setOpenModal(true)}>
<a role="button" className="width-300" tabIndex={0} onClick={() => { if (!disableOtherEdits) setOpenModal(true); }}>
<FA name="briefcase" />
Add New Assignment/Separation
</a>
Expand Down Expand Up @@ -171,7 +171,7 @@ const AssignmentsSeparations = (props) => {
title="Edit Mode"
customClassName="mb-10"
messages={[{
body: 'Discard or save your edits before editing another card.',
body: 'Discard or save your edits before editing or creating another card.',
}]}
/>
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -312,7 +312,7 @@ const Separation = (props) => {
/>
}
</div>,
cancelText: 'Are you sure you want to discard all changes made to this Assignment?',
cancelText: 'Are you sure you want to discard all changes made to this Separation?',
handleSubmit: () => onSubmitForm(),
handleCancel: () => { toggleModal(false); setDisableOtherEdits(false); },
handleEdit: {
Expand Down Expand Up @@ -349,7 +349,6 @@ const Separation = (props) => {
<PositionExpandableContent
sections={sections}
form={form}
useCancelModal={false}
saveText={isNew ? 'Create Separation' : 'Save Separation'}
/>
}
Expand Down
20 changes: 20 additions & 0 deletions src/Constants/SystemMessages.js
Original file line number Diff line number Diff line change
Expand Up @@ -367,3 +367,23 @@ export const CREATE_POSITION_CLASSIFICATION_SUCCESS_TITLE = 'Position Clasificat
export const CREATE_POSITION_CLASSIFICATION_SUCCESS = 'This Position Clasifications has been successfully created.';
export const CREATE_POSITION_CLASSIFICATION_ERROR_TITLE = 'Position Clasifications Error';
export const CREATE_POSITION_CLASSIFICATION_ERROR = 'There was an issue attempting to create this Position Clasifications. Please try again.';

export const UPDATE_ALT_ASSIGNMENT_SUCCESS_TITLE = 'Assignment Updated';
export const UPDATE_ALT_ASSIGNMENT_SUCCESS = 'This Assignment has been successfully updated.';
export const UPDATE_ALT_ASSIGNMENT_ERROR_TITLE = 'Assignment Update Error';
export const UPDATE_ALT_ASSIGNMENT_ERROR = 'There was an issue attempting to update this Assignment. Please try again.';

export const CREATE_ALT_ASSIGNMENT_SUCCESS_TITLE = 'Assignment Created';
export const CREATE_ALT_ASSIGNMENT_SUCCESS = 'This Assignment has been successfully created.';
export const CREATE_ALT_ASSIGNMENT_ERROR_TITLE = 'Assignment Creation Error';
export const CREATE_ALT_ASSIGNMENT_ERROR = 'There was an issue attempting to create this Assignment. Please try again.';

export const UPDATE_ALT_SEPARATION_SUCCESS_TITLE = 'Separation Updated';
export const UPDATE_ALT_SEPARATION_SUCCESS = 'This Separation has been successfully updated.';
export const UPDATE_ALT_SEPARATION_ERROR_TITLE = 'Separation Update Error';
export const UPDATE_ALT_SEPARATION_ERROR = 'There was an issue attempting to update this Separation. Please try again.';

export const CREATE_ALT_SEPARATION_SUCCESS_TITLE = 'Separation Created';
export const CREATE_ALT_SEPARATION_SUCCESS = 'This Separation has been successfully created.';
export const CREATE_ALT_SEPARATION_ERROR_TITLE = 'Separation Creation Error';
export const CREATE_ALT_SEPARATION_ERROR = 'There was an issue attempting to create this Separation. Please try again.';
59 changes: 52 additions & 7 deletions src/actions/assignment.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,15 @@
import { CancelToken } from 'axios';
import { batch } from 'react-redux';
import { toastError, toastSuccess } from './toast';
import api from '../api';
import {
CREATE_ALT_ASSIGNMENT_ERROR, CREATE_ALT_ASSIGNMENT_ERROR_TITLE,
CREATE_ALT_ASSIGNMENT_SUCCESS, CREATE_ALT_ASSIGNMENT_SUCCESS_TITLE,
CREATE_ALT_SEPARATION_ERROR, CREATE_ALT_SEPARATION_ERROR_TITLE,
CREATE_ALT_SEPARATION_SUCCESS, CREATE_ALT_SEPARATION_SUCCESS_TITLE,
UPDATE_ALT_ASSIGNMENT_ERROR, UPDATE_ALT_ASSIGNMENT_ERROR_TITLE,
UPDATE_ALT_ASSIGNMENT_SUCCESS, UPDATE_ALT_ASSIGNMENT_SUCCESS_TITLE, UPDATE_ALT_SEPARATION_ERROR, UPDATE_ALT_SEPARATION_ERROR_TITLE, UPDATE_ALT_SEPARATION_SUCCESS, UPDATE_ALT_SEPARATION_SUCCESS_TITLE,
} from '../Constants/SystemMessages';

// ================ ASSIGNMENT HISTORY LIST ================

Expand Down Expand Up @@ -186,31 +196,66 @@ export function altSeparation(perdet, sepId, revision_num) {

// ================ CREATE/UPDATE ASSIGNMENT/SEPARATION ================

let cancelAction;

export function assignmentSeparationAction(query, perdet, id, isSeparation, onSuccess) {
const type = isSeparation ? 'separations' : 'assignments';

let toastSuccessMessage = CREATE_ALT_ASSIGNMENT_SUCCESS;
let toastSuccessTitle = CREATE_ALT_ASSIGNMENT_SUCCESS_TITLE;
let toastErrorMessage = CREATE_ALT_ASSIGNMENT_ERROR;
let toastErrorTitle = CREATE_ALT_ASSIGNMENT_ERROR_TITLE;

if (!isSeparation && id) {
toastSuccessMessage = UPDATE_ALT_ASSIGNMENT_SUCCESS;
toastSuccessTitle = UPDATE_ALT_ASSIGNMENT_SUCCESS_TITLE;
toastErrorMessage = UPDATE_ALT_ASSIGNMENT_ERROR;
toastErrorTitle = UPDATE_ALT_ASSIGNMENT_ERROR_TITLE;
}

if (isSeparation) {
if (id) {
toastSuccessMessage = UPDATE_ALT_SEPARATION_SUCCESS;
toastSuccessTitle = UPDATE_ALT_SEPARATION_SUCCESS_TITLE;
toastErrorMessage = UPDATE_ALT_SEPARATION_ERROR;
toastErrorTitle = UPDATE_ALT_SEPARATION_ERROR_TITLE;
} else {
toastSuccessMessage = CREATE_ALT_SEPARATION_SUCCESS;
toastSuccessTitle = CREATE_ALT_SEPARATION_SUCCESS_TITLE;
toastErrorMessage = CREATE_ALT_SEPARATION_ERROR;
toastErrorTitle = CREATE_ALT_SEPARATION_ERROR_TITLE;
}
}

return (dispatch) => {
if (cancelAction) {
cancelAction('cancel');
}
const promise = (instance) => {
instance
.then(() => {
batch(() => {
dispatch(toastSuccess(toastSuccessMessage, toastSuccessTitle));
dispatch(altAssignmentsSeparations(perdet));
if (onSuccess) {
onSuccess();
}
});
})
.catch(() => {
batch(() => {
dispatch(altAssignmentsSeparationsErrored(true));
dispatch(altAssignmentsSeparationsLoading(false));
});
.catch((err) => {
if (err?.message !== 'cancel') {
dispatch(toastError(toastErrorMessage, toastErrorTitle));
}
});
};
if (id) {
promise(api().put(`/fsbid/assignment_history/${perdet}/${type}/${id}/`, query));
promise(api().put(`/fsbid/assignment_history/${perdet}/${type}/${id}/`, query, {
cancelToken: new CancelToken((c) => { cancelAction = c; }),
}));
} else {
promise(api().post(`/fsbid/assignment_history/${perdet}/${type}/`, query));
promise(api().post(`/fsbid/assignment_history/${perdet}/${type}/`, query, {
cancelToken: new CancelToken((c) => { cancelAction = c; }),
}));
}
};
}
40 changes: 25 additions & 15 deletions src/sass/_assignments.scss
Original file line number Diff line number Diff line change
Expand Up @@ -9,21 +9,6 @@
padding-left: 5px;
}

.create-new-button {
display: flex;
justify-content: flex-end;
font-size: 17px;
cursor: pointer;

.fa {
margin-right: 5px;
}

a {
text-decoration: none;
}
}

.asg-content {
margin: 25px;

Expand All @@ -44,6 +29,31 @@

.add-buttons {
padding-left: 5px;

.create-new-button {
display: flex;
justify-content: flex-end;
font-size: 17px;
cursor: pointer;

.fa {
margin-right: 5px;
}

a {
text-decoration: none;
}
}

&.disabled {
.create-new-button {
pointer-events: none;

a {
color: $bg-gray-dark-2;
}
}
}
}
}
}
Expand Down

0 comments on commit a45f801

Please sign in to comment.