Skip to content

Commit 7bef943

Browse files
authored
Merge pull request #1200 from topcoder-platform/PM-1504_edit-create-scorecard
PM-1504 edit create scorecard
2 parents bf218fa + 99c3158 commit 7bef943

File tree

7 files changed

+113
-11
lines changed

7 files changed

+113
-11
lines changed

src/apps/review/src/pages/scorecards/EditScorecardPage/EditScorecardPage.module.scss

Lines changed: 73 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,9 @@
3535
background-color: #F6F7F9;
3636
border-radius: $sp-2;
3737
padding: $sp-8;
38+
@include ltemd {
39+
padding: $sp-3;
40+
}
3841
}
3942

4043
.scorecardInfo {
@@ -60,11 +63,25 @@
6063
display: flex;
6164
gap: $sp-4;
6265
width: 100%;
66+
@include ltemd {
67+
flex-wrap: wrap;
68+
position: relative;
69+
70+
.trashIcon {
71+
position: absolute;
72+
bottom: 100%;
73+
right: 0;
74+
flex: 0 0 100%;
75+
}
76+
}
6377
}
6478
}
6579

6680
.contentArea {
6781
padding: $sp-5 $sp-4;
82+
@include ltemd {
83+
padding: $sp-3;
84+
}
6885
}
6986

7087
.groupWrap {
@@ -76,6 +93,9 @@
7693
.contentArea {
7794
background: #E0E4E84D;
7895
padding: $sp-10 $sp-8;
96+
@include ltemd {
97+
padding: $sp-3;
98+
}
7999
}
80100
}
81101

@@ -92,8 +112,11 @@
92112

93113
.questionWrap {
94114
.questionItem {
115+
--pad-x: #{$sp-4};
116+
--pad-y: #{$sp-5};
117+
95118
width: 100%;
96-
padding: $sp-5 $sp-4;
119+
padding: var(--pad-y) var(--pad-x);
97120
background: #F6F7F9;
98121

99122
display: grid;
@@ -120,6 +143,42 @@
120143
.headerAreaLabel {
121144
width: 100%;
122145
}
146+
147+
@include ltemd {
148+
.questionItem {
149+
--pad-x: #{$sp-3};
150+
--pad-y: #{$sp-3};
151+
position: relative;
152+
grid-template-columns: 1fr 1fr;
153+
grid-template-rows: auto auto;
154+
gap: $sp-4;
155+
156+
:global(.main-group) {
157+
grid-column: 1 / -1;
158+
}
159+
160+
:global(.weight-group) {
161+
grid-column: 1 / -1;
162+
}
163+
164+
:global(.action-group) {
165+
position: absolute;
166+
top: var(--pad-y);
167+
right: var(--pad-x);
168+
height: 28px;
169+
}
170+
171+
.doubleInputWrap {
172+
display: flex;
173+
flex-direction: column;
174+
gap: $sp-4;
175+
176+
> * {
177+
flex: 1;
178+
}
179+
}
180+
}
181+
}
123182
}
124183

125184
.xlWidthInput {
@@ -135,6 +194,15 @@
135194
flex: 0 0 40%;
136195
}
137196

197+
.xlWidthInput,
198+
.smWidthInput,
199+
.mdWidthInput {
200+
@include ltemd {
201+
flex: 0 0 100%;
202+
}
203+
}
204+
205+
138206
.doubleInputWrap {
139207
display: flex;
140208
gap: $sp-3;
@@ -160,6 +228,10 @@
160228
justify-content: space-between;
161229
align-items: center;
162230
margin-top: $sp-5;
231+
@include ltemd {
232+
flex-direction: column;
233+
align-items: center;
234+
}
163235
}
164236

165237
.bottomContainer {

src/apps/review/src/pages/scorecards/EditScorecardPage/components/BasicSelect.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ const BasicSelect: FC<BasicSelectProps<any>> = props => (
2626
{props.options.map(option => (
2727
<option
2828
key={`${option.value}`}
29-
value={option.value as string}
29+
value={`${option.value}`}
3030
>
3131
{option.label}
3232
</option>

src/apps/review/src/pages/scorecards/EditScorecardPage/components/CalculatedWeightsSum.module.scss

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,21 @@
66
align-items: center;
77

88
margin-right: 56px;
9+
10+
@include ltemd {
11+
margin-right: 0;
12+
}
913
}
1014

1115
.labels {
1216
text-align: right;
1317
> * {
1418
line-height: 20px;
1519
}
20+
21+
@include ltemd {
22+
text-align: left;
23+
}
1624
}
1725

1826
.value {

src/apps/review/src/pages/scorecards/EditScorecardPage/components/ScorecardInfoForm.tsx

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -28,14 +28,15 @@ export const scorecardInfoSchema = {
2828
.required('Category is required'),
2929
maxScore: yup
3030
.number()
31-
.typeError('Max. Score must be a number')
32-
.required('Max. Score is required')
33-
.moreThan(yup.ref('minScore'), 'Max. Score must be greater than Min. Score'),
31+
.typeError('Max score must be a number')
32+
.required('Max score is required')
33+
.moreThan(yup.ref('minScore'), 'Max score must be greater than min score')
34+
.max(100, 'Max score must be lower than 100'),
3435
minScore: yup
3536
.number()
36-
.typeError('Min. Score must be a number')
37-
.required('Min. Score is required')
38-
.min(0, 'Min. Score must be at least 0'),
37+
.typeError('Min Score must be a number')
38+
.required('Min Score is required')
39+
.min(0, 'Min Score must be at least 0'),
3940
name: yup.string()
4041
.required('Scorecard Name is required'),
4142
status: yup.string()

src/apps/review/src/pages/scorecards/EditScorecardPage/components/ScorecardQuestionForm.tsx

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,15 @@ export const scorecardQuestionSchema = {
2929
.required('Description is required'),
3030
guidelines: yup.string()
3131
.nullable(),
32+
requiresUpload: yup.boolean()
33+
.transform((value, originalValue) => {
34+
// Handle empty string as undefined (so required() can catch it)
35+
if (originalValue === '') return undefined
36+
37+
// Yup already transforms "true"/"false" strings into booleans
38+
return value
39+
})
40+
.required('Documents requirements is required'),
3241
type: yup.string()
3342
.required('Scale is required'),
3443
weight: yup
@@ -168,7 +177,18 @@ const ScorecardQuestionForm: FC<ScorecardQuestionFormProps> = props => {
168177
name={`${name}.${index}.requiresUpload`}
169178
placeholder='Select Document Requirements'
170179
>
171-
<BasicSelect options={yesNoOptions} />
180+
<BasicSelect
181+
options={yesNoOptions}
182+
onChange={(function handleChangeRequireUpload(
183+
ev: ChangeEvent<HTMLInputElement>,
184+
field: any,
185+
) {
186+
field.onChange({
187+
...ev,
188+
target: { ...ev.target, value: ev.target.value === 'true' },
189+
})
190+
}) as ChangeEventHandler}
191+
/>
172192
</InputWrapper>
173193
</div>
174194
</div>

src/apps/review/src/pages/scorecards/EditScorecardPage/utils.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import { Scorecard, ScorecardGroup, ScorecardQuestion, ScorecardSection } from '
77
export const getEmptyScorecardQuestion = (): ScorecardQuestion => ({
88
description: '',
99
guidelines: '',
10-
requiresUpload: false,
10+
requiresUpload: '',
1111
scaleMax: '',
1212
scaleMin: '',
1313
sortOrder: 0,
@@ -61,7 +61,7 @@ export const weightsSum = (
6161
if (!items?.length) return false
6262
const sum = items.reduce((acc, g) => acc + (Number(g.weight) || 0), 0)
6363

64-
if (sum !== 100) {
64+
if (sum !== value) {
6565
// force the error to go into `.root`, otherwise it will overwride the array errors
6666
return ctx.createError({
6767
path: ctx.path.replace(/(\.root$)|$/, '.root'),

src/libs/ui/lib/components/button/base-button/BaseButton.module.scss

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -253,4 +253,5 @@ $btn-secondary-border-width: $border;
253253
--btn-secondary-border-width: 1px;
254254

255255
font-weight: $font-weight-medium;
256+
font-family: "Nunito Sans", sans-serif;
256257
}

0 commit comments

Comments
 (0)