Skip to content

Commit de55c10

Browse files
authored
Merge pull request #1054 from CDharmateja/default-terms-and-nda
add default terms and refractor nda input
2 parents 6a0579a + 6247a54 commit de55c10

File tree

4 files changed

+171
-42
lines changed

4 files changed

+171
-42
lines changed

src/components/ChallengeEditor/ChallengeView/index.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -150,7 +150,6 @@ const ChallengeView = ({
150150
<span><span className={styles.fieldTitle}>Challenge Name:</span> {challenge.name}</span>
151151
</div>
152152
</div>
153-
<NDAField challenge={challenge} readOnly />
154153
{isTask && <AssignedMemberField challenge={challenge} assignedMemberDetails={assignedMemberDetails} readOnly /> }
155154
<CopilotField challenge={{
156155
copilot
@@ -182,7 +181,8 @@ const ChallengeView = ({
182181
</div>
183182
</div>
184183
{openAdvanceSettings && (
185-
<React.Fragment>
184+
<>
185+
<NDAField beta challenge={challenge} readOnly />
186186
<div className={cn(styles.row, styles.topRow)}>
187187
<div className={styles.col}>
188188
<span><span className={styles.fieldTitle}>Groups:</span> {groups}</span>
@@ -198,7 +198,7 @@ const ChallengeView = ({
198198
</div>
199199
</div>
200200
)}
201-
</React.Fragment>
201+
</>
202202
)}
203203
{
204204
<div className={styles.PhaseRow}>

src/components/ChallengeEditor/NDAField/NDAField.module.scss

Lines changed: 117 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -8,18 +8,114 @@
88
align-content: space-between;
99
justify-content: flex-start;
1010

11-
.tcCheckbox {
12-
@include tc-checkbox;
11+
.fieldTitle {
12+
@include roboto-bold();
13+
font-size: 16px;
14+
line-height: 19px;
15+
font-weight: 500;
16+
color: $tc-gray-80;
17+
margin-right: 10px;
18+
}
19+
20+
.field {
21+
@include upto-sm {
22+
display: block;
23+
padding-bottom: 10px;
24+
}
25+
26+
label {
27+
@include roboto-bold();
28+
29+
font-size: 16px;
30+
line-height: 19px;
31+
font-weight: 500;
32+
color: $tc-gray-80;
33+
}
34+
35+
&.col1 {
36+
max-width: 185px;
37+
min-width: 185px;
38+
margin-right: 14px;
39+
margin-bottom: auto;
40+
margin-top: auto;
41+
padding-top: 10px;
42+
white-space: nowrap;
43+
display: flex;
44+
align-items: center;
45+
46+
span {
47+
color: $tc-red;
48+
}
49+
}
50+
51+
&.col2 {
52+
align-self: flex-end;
53+
width: 80%;
54+
margin-bottom: auto;
55+
margin-top: auto;
56+
display: flex;
57+
flex-direction: row;
58+
max-width: 600px;
59+
min-width: 600px;
60+
}
61+
}
62+
63+
.col1 {
64+
display: flex;
65+
flex-grow: 1;
66+
align-items: center;
67+
max-width: 0;
68+
min-width: 0;
69+
margin-right: 0;
70+
width: auto;
71+
margin-top: 0 !important;
72+
margin-bottom: 0 !important;
73+
padding-top: 0 !important;
74+
}
75+
76+
.col2 {
77+
width: auto;
78+
79+
.subGroup {
80+
width: 100%;
81+
display: flex;
82+
flex-direction: column;
83+
84+
.subRow {
85+
display: flex;
86+
align-items: center;
87+
margin-bottom: 18px;
88+
}
89+
90+
.subRow:last-of-type {
91+
margin-bottom: 0;
92+
}
93+
}
94+
}
95+
96+
.tcRadioButton {
97+
.tc-radioButton-label {
98+
@include roboto-light();
99+
100+
line-height: 17px;
101+
font-weight: 300;
102+
margin-left: 21px;
103+
user-select: none;
104+
cursor: pointer;
105+
width: 195px;
106+
font-size: 14px;
107+
color: #3d3d3d;
108+
}
13109

14110
height: 18px;
15-
width: 210px;
111+
width: 80px;
16112
margin: 0;
17113
padding: 0;
18114
vertical-align: bottom;
19115
position: relative;
20116
display: inline-block;
21117

22-
input[type='checkbox'] {
118+
input[type=radio] {
23119
display: none;
24120
}
25121

@@ -31,54 +127,52 @@
31127
cursor: pointer;
32128
position: absolute;
33129
display: inline-block;
34-
width: 14px;
35-
height: 14px;
130+
width: 16px;
131+
height: 16px;
132+
border-radius: 8px;
36133
top: 0;
37134
left: 0;
38135
border: none;
39136
box-shadow: none;
40137
background: $tc-gray-30;
41138
transition: all 0.15s ease-in-out;
42139

43-
44-
&.readOnly {
45-
cursor: auto;
46-
}
47-
48140
&::after {
49141
opacity: 0;
50142
content: '';
51143
position: absolute;
52-
width: 9px;
53-
height: 5px;
144+
width: 8px;
145+
height: 8px;
54146
background: transparent;
55-
top: 2px;
56-
left: 2px;
57-
border-top: none;
58-
border-right: none;
59-
transform: rotate(-45deg);
147+
top: 4px;
148+
left: 4px;
149+
border: 4px solid $tc-blue-20;
150+
border-radius: 4px;
60151
transition: all 0.15s ease-in-out;
61152
}
62153

63154
&:hover::after {
64155
opacity: 0.3;
65156
}
66-
&:hover:read-only::after {
67-
opacity: 0;
68-
}
69157

70158
div {
71159
margin-left: 24px;
72160
width: 300px;
73161
}
74162
}
75163

76-
input[type='checkbox']:checked ~ label {
164+
input[type=radio]:checked ~ label {
77165
background: $tc-blue-20;
78166
}
79167

80-
input[type='checkbox']:checked + label::after {
168+
input[type=radio]:checked + label::after {
169+
opacity: 1;
81170
border-color: $white;
82171
}
83172
}
173+
174+
&.error {
175+
color: $tc-red;
176+
margin-top: -25px;
177+
}
84178
}

src/components/ChallengeEditor/NDAField/index.js

Lines changed: 39 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,52 @@
11
import _ from 'lodash'
22
import React from 'react'
33
import PropTypes from 'prop-types'
4+
import cn from 'classnames'
45
import styles from './NDAField.module.scss'
56
import { DEFAULT_NDA_UUID } from '../../../config/constants'
67

78
const NDAField = ({ challenge, toggleNdaRequire, readOnly }) => {
89
const isRequiredNda = challenge.terms && _.some(challenge.terms, { id: DEFAULT_NDA_UUID })
10+
11+
if (readOnly) {
12+
return (
13+
<div className={styles.row}>
14+
<div className={cn(styles.field, styles.col1, styles.fieldTitle)}>NDA Required :</div>
15+
<div className={cn(styles.field, styles.col2)}>
16+
{ isRequiredNda ? 'Yes' : 'No' }
17+
</div>
18+
</div>
19+
)
20+
}
21+
922
return (
1023
<div className={styles.row}>
11-
<div className={styles.tcCheckbox}>
12-
<input
13-
name='isRequiredNda'
14-
type='checkbox'
15-
id='isRequiredNda'
16-
checked={isRequiredNda}
17-
onChange={toggleNdaRequire}
18-
readOnly={readOnly}
19-
/>
20-
<label htmlFor='isRequiredNda' className={readOnly ? styles.readOnly : ''}>
21-
<div>NDA Required</div>
22-
<input type='hidden' />
23-
</label>
24+
<div className={cn(styles.field, styles.col1, styles.fieldTitle)}>NDA Required :</div>
25+
<div className={cn(styles.field, styles.col2)}>
26+
<div className={styles.tcRadioButton}>
27+
<input
28+
name='nda'
29+
type='radio'
30+
id='nda-yes'
31+
checked={isRequiredNda}
32+
onChange={toggleNdaRequire}
33+
/>
34+
<label className={styles['tc-RadioButton-label']} htmlFor='nda-yes'>
35+
<div>Yes</div>
36+
</label>
37+
</div>
38+
<div className={styles.tcRadioButton}>
39+
<input
40+
name='nda'
41+
type='radio'
42+
id='nda-no'
43+
checked={!isRequiredNda}
44+
onChange={toggleNdaRequire}
45+
/>
46+
<label className={styles['tc-RadioButton-label']} htmlFor='nda-no'>
47+
<div>No</div>
48+
</label>
49+
</div>
2450
</div>
2551
</div>
2652
)

src/components/ChallengeEditor/index.js

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -195,7 +195,8 @@ class ChallengeEditor extends Component {
195195
challengeData.copilot = copilot || copilotFromResources
196196
challengeData.reviewer = reviewer || reviewerFromResources
197197
const challengeDetail = { ...challengeData }
198-
const isOpenAdvanceSettings = challengeDetail.groups.length > 0
198+
const isRequiredNda = challengeDetail.terms && _.some(challengeDetail.terms, { id: DEFAULT_NDA_UUID })
199+
const isOpenAdvanceSettings = challengeDetail.groups.length > 0 || isRequiredNda
199200
setState({
200201
challenge: challengeDetail,
201202
assignedMemberDetails,
@@ -809,7 +810,7 @@ class ChallengeEditor extends Component {
809810

810811
async createNewChallenge () {
811812
if (!this.props.isNew) return
812-
const { metadata, createChallenge } = this.props
813+
const { metadata, createChallenge, projectDetail } = this.props
813814
const { name, trackId, typeId } = this.state.challenge
814815
const { timelineTemplates } = metadata
815816
const isDesignChallenge = trackId === DES_TRACK_ID
@@ -838,6 +839,14 @@ class ChallengeEditor extends Component {
838839
terms: [{ id: DEFAULT_TERM_UUID, roleId: SUBMITTER_ROLE_UUID }]
839840
// prizeSets: this.getDefaultPrizeSets()
840841
}
842+
if (projectDetail.terms) {
843+
const currTerms = new Set(newChallenge.terms.map(term => term.id))
844+
newChallenge.terms.push(
845+
...projectDetail.terms
846+
.filter(term => !currTerms.has(term))
847+
.map(term => ({ id: term, roleId: SUBMITTER_ROLE_UUID }))
848+
)
849+
}
841850
const discussions = this.getDiscussionsConfig(newChallenge)
842851
if (discussions) {
843852
newChallenge.discussions = discussions
@@ -1361,7 +1370,6 @@ class ChallengeEditor extends Component {
13611370
</div>
13621371
</div>
13631372
<ChallengeNameField challenge={challenge} onUpdateInput={this.onUpdateInput} />
1364-
<NDAField challenge={challenge} toggleNdaRequire={this.toggleNdaRequire} />
13651373
{isTask && (
13661374
<AssignedMemberField
13671375
challenge={challenge}
@@ -1394,6 +1402,7 @@ class ChallengeEditor extends Component {
13941402
</div>
13951403
{ isOpenAdvanceSettings && (
13961404
<React.Fragment>
1405+
<NDAField challenge={challenge} toggleNdaRequire={this.toggleNdaRequire} />
13971406
{/* remove terms field and use default term */}
13981407
{false && (<TermsField terms={metadata.challengeTerms} challenge={challenge} onUpdateMultiSelect={this.onUpdateMultiSelect} />)}
13991408
<GroupsField onUpdateMultiSelect={this.onUpdateMultiSelect} challenge={challenge} />

0 commit comments

Comments
 (0)