Skip to content
GitLab
Menu
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
les
gancio
Commits
321b9ea1
Verified
Commit
321b9ea1
authored
May 08, 2021
by
les
Browse files
better calendar attributes to past events
parent
eb719e28
Changes
1
Hide whitespace changes
Inline
Side-by-side
assets/helper.js
View file @
321b9ea1
...
...
@@ -9,15 +9,24 @@ export function attributesFromEvents (_events, _tags) {
attributes
.
push
({
key
:
'
today
'
,
dates
:
new
Date
(),
bar
:
{
color
:
'
green
'
,
fillMode
:
'
outline
'
}
})
const
now
=
dayjs
().
unix
()
function
getColor
(
event
)
{
const
color
=
{
class
:
'
vc-rounded-full
'
,
color
:
'
blue
'
}
function
getColor
(
event
,
where
)
{
const
color
=
{
class
:
'
vc-rounded-full
'
,
color
:
'
blue
'
,
fillMode
:
where
===
'
base
'
?
'
light
'
:
'
solid
'
}
const
tag
=
get
(
event
,
'
tags[0]
'
)
if
(
event
.
start_datetime
<
now
)
{
color
.
class
+=
'
vc-past
'
}
if
(
event
.
start_datetime
<
now
)
{
if
(
event
.
multidate
)
{
color
.
fillMode
=
where
===
'
base
'
?
'
light
'
:
'
outline
'
if
(
where
===
'
base
'
)
{
color
.
class
+=
'
vc-past
'
}
}
else
{
color
.
class
+=
'
vc-past
'
}
}
if
(
!
tag
)
{
return
color
}
const
idx
=
tags
.
indexOf
(
tag
)
if
(
idx
<
0
)
{
return
color
}
color
.
color
=
colors
[
idx
]
if
(
event
.
start_datetime
<
now
)
{
color
.
class
+=
'
vc-past
'
}
//
if (event.start_datetime < now) { color.class += ' vc-past' }
return
color
}
...
...
@@ -35,7 +44,11 @@ export function attributesFromEvents (_events, _tags) {
.
filter
(
e
=>
e
.
multidate
)
.
map
(
e
=>
({
key
:
e
.
id
,
highlight
:
{
start
:
{
...
getColor
(
e
),
fillMode
:
'
solid
'
},
end
:
{
...
getColor
(
e
),
fillMode
:
'
solid
'
}
},
highlight
:
{
start
:
getColor
(
e
),
base
:
getColor
(
e
,
'
base
'
),
end
:
getColor
(
e
)
},
dates
:
{
start
:
new
Date
(
e
.
start_datetime
*
1000
),
end
:
new
Date
(
e
.
end_datetime
*
1000
)
}
})))
...
...
Write
Preview
Supports
Markdown
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