Skip to content

Commit 63189db

Browse files
committed
add copy functionality
1 parent 0499719 commit 63189db

File tree

5 files changed

+31
-2
lines changed

5 files changed

+31
-2
lines changed

UI/web-app/src/components/SourcePart/SourcePart.base.tsx

Lines changed: 22 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,11 @@ import {
1111
IDropdownOption,
1212
IProcessedStyleSet,
1313
} from '@fluentui/react';
14-
import { DefaultButton, IconButton } from '@fluentui/react/lib/Button';
14+
import { ActionButton, DefaultButton, IconButton } from '@fluentui/react/lib/Button';
1515
import { useTheme } from '@fluentui/react/lib/Theme';
1616
import { SourcePartStyleProps, SourcePartStyles, SourcePartProps } from './SourcePart.types';
1717
import { AppDispatch } from '../../store';
18-
import { manageMembershipIsEditingExistingJob, updateSourcePart, updateSourcePartType } from '../../store/manageMembership.slice';
18+
import { manageMembershipIsEditingExistingJob, updateSourcePart, copySourcePart, updateSourcePartType } from '../../store/manageMembership.slice';
1919
import { useStrings } from '../../store/hooks';
2020
import { ISourcePart } from '../../models/ISourcePart';
2121
import { HRQuerySource } from '../HRQuerySource';
@@ -88,6 +88,19 @@ export const SourcePartBase: React.FunctionComponent<SourcePartProps> = (props:
8888
}
8989
}
9090

91+
const handleCopy = () => {
92+
const newQuery: HRSourcePart = {
93+
type: SourcePartType.HR,
94+
source: part.query.source as HRSourcePartSource,
95+
exclusionary: isExclusionary
96+
}
97+
const newPart: ISourcePart = {
98+
id: index + 1,
99+
query: newQuery
100+
};
101+
dispatch(copySourcePart(newPart));
102+
};
103+
91104
useEffect(() => {
92105
setErrorMessage('');
93106
}, [query, expanded]);
@@ -191,6 +204,13 @@ export const SourcePartBase: React.FunctionComponent<SourcePartProps> = (props:
191204
<div className={classNames.error}>
192205
{errorMessage}
193206
</div>
207+
{part.query.type === SourcePartType.HR && (part.query.source.filter !== "" || part.query.source.manager?.id !== undefined) && (totalSourceParts === part.id) && (
208+
<ActionButton
209+
iconProps={{ iconName: "Copy" }}
210+
onClick={handleCopy}>
211+
{strings.copy}
212+
</ActionButton>
213+
)}
194214
</div>
195215
}
196216
</div>

UI/web-app/src/services/localization/IStrings.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -316,6 +316,7 @@ export type IStrings = {
316316
clickHere: string;
317317
}
318318
};
319+
copy: string;
319320
remove: string;
320321
delete: string;
321322
edit: string;

UI/web-app/src/services/localization/i18n/locales/en/translations.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -321,6 +321,7 @@ export const strings: IStrings = {
321321
clickHere: 'Click here',
322322
}
323323
},
324+
copy: 'Copy',
324325
remove: 'Remove',
325326
delete: 'Delete',
326327
edit: 'Edit',

UI/web-app/src/services/localization/i18n/locales/es/translations.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -325,6 +325,7 @@ export const strings: IStrings = {
325325
clickHere: 'Haz click aquí',
326326
}
327327
},
328+
copy: 'Copiar',
328329
remove: 'Eliminar',
329330
delete: 'Eliminar',
330331
edit: 'Editar',

UI/web-app/src/store/manageMembership.slice.tsx

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -217,6 +217,11 @@ const manageMembershipSlice = createSlice({
217217
};
218218
}
219219
},
220+
221+
copySourcePart: (state, action: PayloadAction<ISourcePart>) => {
222+
state.sourceParts.push(action.payload);
223+
},
224+
220225
deleteSourcePart: (state, action: PayloadAction<number>) => {
221226
state.sourceParts = state.sourceParts.filter(part => part.id !== action.payload);
222227
const compositeQuery = buildCompositeQuery(state.sourceParts);
@@ -287,6 +292,7 @@ export const {
287292
addSourcePart,
288293
updateSourcePartType,
289294
updateSourcePart,
295+
copySourcePart,
290296
deleteSourcePart,
291297
clearSourceParts,
292298
setJobDetailsForExistingJob,

0 commit comments

Comments
 (0)