Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
S
scheduler-react-sample
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Service Desk
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Environments
Packages & Registries
Packages & Registries
Container Registry
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Linh Nguyen
scheduler-react-sample
Commits
f9507bf5
Commit
f9507bf5
authored
Jun 11, 2020
by
Jiawen Lyu
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
change color dynamique
parent
f6f31b12
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
19 additions
and
7 deletions
+19
-7
src/App.js
src/App.js
+4
-0
src/components/Scheduler/Scheduler.js
src/components/Scheduler/Scheduler.js
+15
-7
No files found.
src/App.js
View file @
f9507bf5
...
...
@@ -50,6 +50,8 @@ const extractUvDateInfo = uvs => uvs.map(uv => ({
id
:
uvs
.
indexOf
(
uv
)
}))
const
getCurrentStudents
=
data
=>
Array
.
from
(
new
Set
(
data
.
map
(
elem
=>
elem
.
login
)))
class
App
extends
Component
{
state
=
{
currentTimeFormatState
:
true
,
...
...
@@ -99,6 +101,7 @@ class App extends Component {
render
()
{
const
{
currentTimeFormatState
,
messages
,
error
,
isLoaded
,
uvs
}
=
this
.
state
;
// const data = extractUvDateInfo(uvs)
const
currentStudents
=
getCurrentStudents
(
data
)
if
(
error
)
{
return
<
div
>
Erreur
:
{
error
.
message
}
<
/div>
;
}
else
if
(
!
isLoaded
)
{
...
...
@@ -109,6 +112,7 @@ class App extends Component {
<
div
className
=
"
scheduler-container
"
>
<
Scheduler
events
=
{
data
}
currentStudents
=
{
currentStudents
}
timeFormatState
=
{
currentTimeFormatState
}
onDataUpdated
=
{
this
.
logDataUpdate
}
/
>
...
...
src/components/Scheduler/Scheduler.js
View file @
f9507bf5
...
...
@@ -3,11 +3,19 @@ import 'dhtmlx-scheduler';
import
'
dhtmlx-scheduler/codebase/dhtmlxscheduler_material.css
'
;
const
scheduler
=
window
.
scheduler
;
const
changeColorForEachStudent
=
events
=>
events
.
map
(
event
=>
{
if
(
event
.
login
===
"
jiawen
"
)
{
event
.
color
=
"
green
"
scheduler
.
updateEvent
(
event
.
id
)
}
const
toColorName
=
index
=>
(
{
0
:
"
orange
"
,
1
:
"
green
"
,
2
:
"
red
"
,
}[
index
]
)
const
changeColorForEachStudent
=
(
events
,
currentStudents
)
=>
events
.
map
(
event
=>
{
event
.
color
=
toColorName
(
currentStudents
.
indexOf
(
event
.
login
))
scheduler
.
updateEvent
(
event
.
id
)
})
export
default
class
Scheduler
extends
Component
{
...
...
@@ -55,11 +63,11 @@ export default class Scheduler extends Component {
this
.
initSchedulerEvents
();
const
{
events
}
=
this
.
props
;
const
{
events
,
currentStudents
}
=
this
.
props
;
scheduler
.
init
(
this
.
schedulerContainer
,
new
Date
(
2020
,
5
,
10
));
scheduler
.
clearAll
();
scheduler
.
parse
(
events
);
changeColorForEachStudent
(
events
)
changeColorForEachStudent
(
events
,
currentStudents
)
}
shouldComponentUpdate
(
nextProps
)
{
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment