Skip to content

Commit 17527af

Browse files
author
KenOshima
committed
Started on activity modification functionality.
1 parent 43996f0 commit 17527af

File tree

2 files changed

+74
-32
lines changed

2 files changed

+74
-32
lines changed

app/client/src/components/Activity/Activity.css

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,18 @@
1-
2-
31
.act-wrapper {
42
padding: 5px 0;
3+
display: flex;
4+
flex-direction: row;
5+
margin: 0 10px;
56
}
7+
68
.act-bar-wrapper {
79
position: relative;
810
display: flex;
9-
/*width: 500px;*/
11+
12+
width: stretch;
1013
align-items: center;
1114
min-height: 50px;
12-
margin: 0 15px;
15+
margin: 0 10px;
1316
}
1417

1518
.act-icon {
@@ -47,3 +50,7 @@
4750
justify-content: center;
4851
padding: 5px 15px;
4952
}
53+
54+
.activity-edit-icon {
55+
56+
}

app/client/src/components/Activity/Activity.jsx

Lines changed: 63 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11

22
import React, { Component } from 'react';
3+
import { Button } from 'react-bootstrap';
34

45
import * as api from '../../api';
56
import './Activity.css';
@@ -8,50 +9,84 @@ export default class Activity extends Component {
89
constructor(props) {
910
super(props);
1011
this.state = {
12+
activityId: -1,
13+
activityType: '',
14+
problemType: '',
15+
editActivity: false,
1116
showContent: false
1217
}
1318
}
19+
20+
editActivity() {
21+
console.log("Activity Id:", this.state.activityId, "Activity Type:", this.state.activityType);
22+
console.log("Content:", this.props.content.props);
23+
}
1424

1525
render() {
26+
let isAdmin = this.props.User.info.role === 1;
27+
let displayEdit = !isAdmin ? {display: "none"} : {};
28+
1629
return (
17-
<div className="act-wrapper">
18-
<div className="act-bar-wrapper"
19-
onClick={() => {
20-
/* If this is a video, update progress */
21-
if (this.props.type === 'video' && !this.state.showContent && this.props.userIsEnrolled) {
22-
let body = {
23-
activityId: this.props.activity.id,
24-
activityType: this.props.activity.activityType,
25-
grade: 100
26-
};
27-
console.log('body:', body);
28-
api.modifyUserProgress(this.props.User.info.id, body);
29-
}
30-
this.setState({ showContent: !this.state.showContent});
31-
}}>
32-
33-
<div className="act-icon">
34-
{ this.props.type === 'video' && <i className="fas fa-play"></i> }
35-
{ this.props.type === 'problems' && <i className="fas fa-pencil-alt"></i> }
36-
{ this.props.type === 'form' && <i className="fas fa-file"></i> }
37-
</div>
30+
<div>
31+
<div className="act-wrapper">
32+
33+
<div className="act-bar-wrapper"
34+
onClick={() => {
35+
/* If this is a video, update progress */
36+
if (this.props.type === 'video' && !this.state.showContent && this.props.userIsEnrolled) {
37+
let body = {
38+
activityId: this.props.activity.id,
39+
activityType: this.props.activity.activityType,
40+
grade: 100
41+
};
42+
console.log('body:', body);
43+
api.modifyUserProgress(this.props.User.info.id, body);
44+
}
45+
this.setState({ showContent: !this.state.showContent});
46+
}}>
3847

39-
<div className={'act-main' + (this.props.done ? ' done' : '' )}>
48+
<div className="act-icon">
49+
{ this.props.type === 'video' && <i className="fas fa-play"></i> }
50+
{ this.props.type === 'problems' && <i className="fas fa-pencil-alt"></i> }
51+
{ this.props.type === 'form' && <i className="fas fa-file"></i> }
52+
</div>
4053

41-
<div className="act-title">{this.props.title}</div>
54+
<div className={'act-main' + (this.props.done ? ' done' : '' )}>
4255

43-
<div className="act-right">
44-
{this.props.right}
45-
</div>
56+
<div className="act-title">{this.props.title}</div>
57+
58+
<div className="act-right">
59+
{this.props.right}
60+
61+
62+
</div>
4663

64+
</div>
65+
4766
</div>
48-
</div>
4967

68+
69+
70+
<Button style={displayEdit} className="activity-edit-icon" onClick={() => {
71+
this.setState({
72+
editTopic: true,
73+
activityId: this.props.activity.id,
74+
activityType: this.props.type,
75+
problemType: this.props.activity.type
76+
});
77+
this.editActivity();
78+
}}>
79+
<i className="fas fa-pencil-alt"></i>
80+
</Button>
81+
82+
83+
84+
</div>
85+
5086
{
5187
this.state.showContent &&
5288
<div className="act-content">{this.props.content}</div>
5389
}
54-
5590
</div>
5691
)
5792

0 commit comments

Comments
 (0)