Skip to content

Commit b20c569

Browse files
author
ninjadev999
committed
added title component for profile
1 parent 1435c29 commit b20c569

28 files changed

+808
-136
lines changed

backend/talent_position_type/models.py

+3
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,9 @@ def __str__(self):
1717
talent=self.talent.user.email,
1818
position_type=self.position_type.name)
1919

20+
def get_position_type_id(self):
21+
return self.position_type.id
22+
2023
class Meta:
2124
db_table = "talent_position_type"
2225
ordering = ('talent', 'position_type')

backend/talent_position_type/serializers.py

+5-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,11 @@
44
class TalentPositionTypeSerializer(serializers.ModelSerializer):
55
talent = serializers.SlugRelatedField(many=False, read_only=True, slug_field='id')
66
position_type = serializers.SlugRelatedField(many=False, read_only=True, slug_field='name')
7+
position_type_id = serializers.IntegerField(
8+
source='get_position_type_id',
9+
read_only=True
10+
)
711

812
class Meta:
913
model = TalentPositionType
10-
fields = ('id', 'talent', 'position_type')
14+
fields = ('id', 'talent', 'position_type', 'position_type_id')

backend/talent_skill/models.py

+3
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,9 @@ def __str__(self):
1515
talent=self.talent.user.email,
1616
skill=self.skill.name)
1717

18+
def get_skill_id(self):
19+
return self.skill.id
20+
1821
def get_sub_skills(self):
1922
return self.skill.sub_skills
2023

backend/talent_skill/serializers.py

+3-2
Original file line numberDiff line numberDiff line change
@@ -8,17 +8,18 @@
88
class TalentSkillSerializer(serializers.ModelSerializer):
99
talent = serializers.SlugRelatedField(many=False, read_only=True, slug_field='id')
1010
skill = serializers.SlugRelatedField(many=False, read_only=True, slug_field='name')
11+
skill_id = serializers.IntegerField(source='get_skill_id', read_only=True)
1112

1213
class Meta:
1314
model = TalentSkill
14-
fields = ('id', 'talent', 'skill')
15+
fields = ('id', 'talent', 'skill', 'skill_id')
1516

1617

1718
class GeneralTalentSkillSerializerWithTalent(serializers.ModelSerializer):
1819
talent = serializers.SlugRelatedField(many=False, read_only=True, slug_field='id')
1920
skill = SkillSerializer(many=True)
2021
sub_skills = serializers.Field(source="skill.sub_skills")
21-
22+
2223
# sub_skills = serializers.SerializerMethodField('_get_sub_skills')
2324

2425
def _get_sub_skills(self, obj):

frontend/src/App.css

+1-1
Original file line numberDiff line numberDiff line change
@@ -971,7 +971,7 @@ input[type="button"].btn-block {
971971
position: relative;
972972
width: 100%;
973973
background: #fff;
974-
margin-bottom: 30px;
974+
margin-bottom: 15px;
975975
border-radius: 3px;
976976
box-shadow: 0 4px 16px -2px rgba(0, 0, 0, 0.1), 0 0 0 1px rgba(0, 0, 0, 0.02); }
977977
.readmin-panel.righticonmenu .panel-heading {

frontend/src/apis/adminAPIs.js

+83
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,83 @@
1+
import apiConfig from 'constants/api';
2+
import { getToken, getUserID } from "service/storage";
3+
4+
class AdminAPI {
5+
static processResponse(response, handleResponse) {
6+
console.log('=== response: ', response);
7+
if(response.error) {
8+
console.log('error: ', response.error);
9+
handleResponse(response.error, true);
10+
}
11+
else {
12+
if (response){
13+
console.log('success: ', response);
14+
handleResponse(response, false);
15+
} else {
16+
console.log('error: ', response);
17+
handleResponse(response.error, true);
18+
}
19+
}
20+
}
21+
22+
static processRequest(url, method, data, handleResponse) {
23+
console.log('==== processRequest: ', url, data);
24+
let params = {
25+
method: method,
26+
headers: {
27+
"Content-Type": "application/json"
28+
}
29+
};
30+
31+
if (data) {
32+
params = {
33+
...params,
34+
body: JSON.stringify(data)
35+
};
36+
}
37+
38+
fetch(`${apiConfig.url}/${url}`, params)
39+
.then(response => response.json())
40+
.then(response => {
41+
this.processResponse(response, handleResponse);
42+
})
43+
.catch(error => {
44+
console.log('error: ', error);
45+
handleResponse(error, true);
46+
})
47+
}
48+
49+
static processRequestWithToken(url, method, data, handleResponse) {
50+
console.log('==== processRequest: ', url, data);
51+
let parameters = {
52+
method: method,
53+
headers: {
54+
'Accept': 'application/json',
55+
"Content-Type": "application/json",
56+
"Authorization": `Bearer ${getToken()}`
57+
}
58+
};
59+
60+
if (method !== 'get' && data !== '' && data !== null) {
61+
parameters = {...parameters, body: JSON.stringify(data)};
62+
}
63+
64+
console.log('==== parameters: ', parameters);
65+
console.log('==== url: ', `${apiConfig.url}/${url}/`);
66+
67+
fetch(`${apiConfig.url}/${url}/`, parameters)
68+
.then(response => {console.log('=== response: ', response); return response.json()})
69+
.then(response => {
70+
this.processResponse(response, handleResponse);
71+
})
72+
.catch(error => {
73+
console.log('error: ', error);
74+
handleResponse(error, true);
75+
})
76+
}
77+
78+
static getProfile(profileId, handleResponse) {
79+
this.processRequestWithToken(`talent/${profileId}`, 'get', null, handleResponse);
80+
}
81+
82+
}
83+
export default AdminAPI

frontend/src/components/shiptalent/forms/adminForm.js

+30-18
Original file line numberDiff line numberDiff line change
@@ -30,31 +30,43 @@ class AdminForm extends Component {
3030
children,
3131
backLink, backButtonTitle, handleClickBackButton,
3232
nextLink, nextButtonTitle, handleClickNextButton,
33-
talent, formClassName, classes
33+
talent, showMale, showPosition,
34+
allPositionTypes, allSkills, loading,
35+
formClassName, classes
3436
} = this.props;
3537
let formStyle = formClassName ? {className: formClassName} : {}
3638

3739
return (
3840
<div {...formStyle}>
3941
<Grid container spacing={16}>
40-
{ talent && <Grid item xs={12} ><AdminTalentTitle talent={talent} /></Grid>}
42+
{ talent &&
43+
<Grid item xs={12} >
44+
<AdminTalentTitle talent={talent} showMale={showMale} showPosition={showPosition}
45+
allPositionTypes={allPositionTypes} allSkills={allSkills} loading={loading}
46+
/>
47+
</Grid>
48+
}
4149
<Grid item xs={12} >
42-
<Typography
43-
align="center"
44-
className={[classes.h4SmallMargin, classes.bold]}
45-
>
46-
{formTitle}
47-
</Typography>
48-
<Typography
49-
align="center"
50-
className={
51-
formSubTitleClass
52-
? [classes.adminFormSubTitle, formSubTitleClass]
53-
: classes.adminFormSubTitle
54-
}
55-
>
56-
{formSubTitle}
57-
</Typography>
50+
{ formTitle &&
51+
<Typography
52+
align="center"
53+
className={[classes.h4SmallMargin, classes.bold]}
54+
>
55+
{formTitle}
56+
</Typography>
57+
}
58+
{ formSubTitle &&
59+
<Typography
60+
align="center"
61+
className={
62+
formSubTitleClass
63+
? [classes.adminFormSubTitle, formSubTitleClass]
64+
: classes.adminFormSubTitle
65+
}
66+
>
67+
{formSubTitle}
68+
</Typography>
69+
}
5870
</Grid>
5971

6072
<Grid item xs={12} >
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
import React, {Component} from 'react';
2+
import { withStyles } from '@material-ui/core/styles';
3+
import PropertyButton from './adminTalentPositions/PropertyButton';
4+
import { adminStyles } from 'styles';
5+
6+
7+
class AdminTalentGenders extends Component {
8+
render() {
9+
const { sex } = this.props;
10+
return (
11+
<div>
12+
<PropertyButton title={'Male'} selected={sex === 'm'} />
13+
<PropertyButton title={'Female'} selected={sex === 'f'} />
14+
</div>
15+
);
16+
}
17+
}
18+
19+
export default withStyles(adminStyles)(AdminTalentGenders);
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
import React, {Component} from 'react';
2+
import { withStyles } from '@material-ui/core/styles';
3+
import Grid from '@material-ui/core/Grid';
4+
import SubPositionsSelection from './SubPositionsSelection';
5+
import PropertyButton from './PropertyButton';
6+
import { adminStyles } from 'styles';
7+
8+
9+
class PositionSelection extends Component {
10+
render() {
11+
const { position, selected, titleItem, selectedSubPositions } = this.props;
12+
13+
return (
14+
<div style={{display: 'inline-block'}}>
15+
<PropertyButton title={position[titleItem]} selected={selected} />
16+
<SubPositionsSelection
17+
allSubPositions={position.position_sub_types}
18+
selectedSubPositions={selectedSubPositions}
19+
titleItem={'abbreviated_key'}
20+
/>
21+
</div>
22+
)
23+
24+
// return(
25+
// <Grid container spacing={8} justify="center" alignItems="flex-start">
26+
// <Grid
27+
// item xl={12} lg={12} md={12} sm={12} xs={12}
28+
// className={classes.adminFormTalentPropertyButtonItem}
29+
// >
30+
// <PropertyButton title={position[titleItem]} selected={selected} />
31+
// </Grid>
32+
// <Grid
33+
// item xl={12} lg={12} md={12} sm={12} xs={12}
34+
// className={classes.adminFormTalentPropertyButtonItem}
35+
// >
36+
// <SubPositionsSelection
37+
// allSubPositions={position.position_sub_types}
38+
// selectedSubPositions={selectedSubPositions}
39+
// titleItem={'abbreviated_key'}
40+
// />
41+
// </Grid>
42+
// </Grid>
43+
// );
44+
}
45+
}
46+
47+
export default withStyles(adminStyles)(PositionSelection);
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
import React, {Component} from 'react';
2+
import { withStyles } from '@material-ui/core/styles';
3+
import Grid from '@material-ui/core/Grid';
4+
import CircularProgress from '@material-ui/core/CircularProgress';
5+
import PositionSelection from './PositionSelection';
6+
import { clientDesigns } from 'styles';
7+
import { adminStyles } from 'styles';
8+
9+
10+
class PositionsSelection extends Component {
11+
12+
renderPositions() {
13+
const { classes, selectedPositions, selectedSubPositions, allPositionTypes, titleItem, loading } = this.props;
14+
let items = [];
15+
let titleItemName = titleItem ? titleItem : 'select_option_title';
16+
17+
if (loading) {
18+
return <CircularProgress className={classes.progress} />
19+
}
20+
21+
for (let i = 0; i < allPositionTypes.length; i ++) {
22+
let positionType = allPositionTypes[i];
23+
let selected = selectedPositions.find(p => {
24+
return p.position_type_id === positionType.id;
25+
}) ? true : false;
26+
27+
if (positionType[titleItemName])
28+
items.push(
29+
// <Grid
30+
// item xs
31+
// className={classes.adminFormTalentPropertyButtonItem}
32+
// >
33+
<PositionSelection
34+
position={positionType}
35+
selectedSubPositions={selectedSubPositions}
36+
titleItem={titleItemName}
37+
selected={selected}
38+
/>
39+
// </Grid>
40+
);
41+
}
42+
43+
return items;
44+
}
45+
46+
render() {
47+
const { classes } = this.props;
48+
return(
49+
// <Grid container spacing={16} direction="row" justify="flex-start" alignItems="flex-start">
50+
// <Grid item xs />
51+
<div className={classes.adminTalentTitlePropertiesWrapper}>
52+
{ this.renderPositions() }
53+
</div>
54+
// <Grid item xs />
55+
// </Grid>
56+
);
57+
}
58+
59+
}
60+
61+
export default withStyles(adminStyles)(PositionsSelection);
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
import React, {Component} from 'react';
2+
import { withStyles } from '@material-ui/core/styles';
3+
import Typography from '@material-ui/core/Typography';
4+
import { adminStyles } from 'styles';
5+
6+
class PropertyButton extends Component {
7+
render() {
8+
const { title, selected, classes } = this.props;
9+
10+
return (
11+
<div className={selected ? classes.adminFormTalentGenderButtonSelected : classes.adminFormTalentGenderButton}>
12+
<Typography className={[classes.adminFormTalentGenderButtonTitle]}>
13+
{ title }
14+
</Typography>
15+
</div>
16+
)
17+
}
18+
}
19+
20+
export default withStyles(adminStyles)(PropertyButton);

0 commit comments

Comments
 (0)