Skip to content

Commit

Permalink
Merge branch 'dev' of github.com:MetaPhase-Consulting/State-TalentMAP…
Browse files Browse the repository at this point in the history
… into bid-audit-refactor
  • Loading branch information
Mostafa Habib committed May 9, 2024
2 parents 84580d1 + a45f801 commit b68e044
Show file tree
Hide file tree
Showing 8 changed files with 105 additions and 17 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -159,8 +159,8 @@ const AgendaItemMaintenanceContainer = (props) => {

const removeAI = () => {
const data = {
aiseqnum: agendaItemData$?.pmi_seq_num,
aiupdatedate: agendaItemData$?.pmi_update_date,
aiseqnum: agendaItemData$?.id,
aiupdatedate: agendaItemData$?.modifier_date,
};
dispatch(removeAgenda(data));
};
Expand Down
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="icon-text-link no-underline">
<a role="button" className="width-300" tabIndex={0} onClick={() => setOpenModal(true)}>
<div className={`add-buttons ${disableOtherEdits ? 'disabled' : ''}`}>
<div className="create-new-button">
<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.';
2 changes: 1 addition & 1 deletion src/actions/agendaItemMaintenancePane.js
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ export function removeAgenda(aiData) {
const { aiseqnum, aiupdatedate } = aiData;

const regex = /^(\d{4})-(\d{2})-(\d{2})T(\d{2}):(\d{2}):(\d{2}).(\d{3})z$/i;
const aiupdate = aiupdatedate.replace(regex, '$1-$2-$3 $4:$5:$6');
const aiupdate = aiupdatedate.replace(regex, '$1-$2-$3 $4:$5:$6').replace('T', ' ');

return (dispatch) => {
if (cancelRemoveAI) { cancelRemoveAI('cancel'); }
Expand Down
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; }),
}));
}
};
}
25 changes: 25 additions & 0 deletions src/sass/_assignments.scss
Original file line number Diff line number Diff line change
Expand Up @@ -29,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 b68e044

Please sign in to comment.