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
f4ab6136
Verified
Commit
f4ab6136
authored
May 11, 2021
by
les
Browse files
fix montly recurrent events
parent
563bed45
Changes
3
Hide whitespace changes
Inline
Side-by-side
pages/add/DateInput.vue
View file @
f4ab6136
...
...
@@ -27,7 +27,7 @@ v-col(cols=12)
div
.
text
-
center
.
mb
-
2
(
v
-
if
=
'
type === "recurrent"
'
)
span
(
v
-
if
=
'
value.recurrent.frequency !== "1m" && value.recurrent.frequency !== "2m"
'
)
{{
whenPatterns
}}
v
-
btn
-
toggle
.
mt
-
1
.
flex
-
column
.
flex
-
sm
-
row
(
v
-
else
:
value
=
'
value.recurrent.type
'
color
=
'
primary
'
@
change
=
'
fq => change("", fq)
'
)
v
-
btn
-
toggle
.
mt
-
1
.
flex
-
column
.
flex
-
sm
-
row
(
v
-
else
:
value
=
'
value.recurrent.type
'
color
=
'
primary
'
@
change
=
'
fq => change("
recurrentType
", fq)
'
)
v
-
btn
(
v
-
for
=
'
whenPattern in whenPatterns
'
:
value
=
'
whenPattern.key
'
:
key
=
'
whenPatterns.key
'
small
)
{{
whenPattern
.
label
}}
v
-
row
.
mt
-
3
.
col
-
md
-
6
.
mx
-
auto
...
...
@@ -133,27 +133,26 @@ export default {
//
{
label
:
this
.
$tc
(
`event.recurrent_${freq
}
_ordinal`
,
{
n
,
days
:
weekDay
}
),
key
:
'
weekday
'
}
]
// if selected day is in last week, propose also this type of selection
const
lastWeek
=
date
.
daysInMonth
()
-
monthDay
<
7
if
(
lastWeek
)
{
if
(
n
<
5
)
{
patterns
.
push
(
{
label
:
this
.
$t
(
`event.recurrent_${freq
}
_ordinal`
,
{
n
:
this
.
$t
(
'
ordinal.-1
'
),
days
:
weekDay
}
),
key
:
'
weekday
'
label
:
this
.
$t
(
`event.recurrent_${freq
}
_ordinal`
,
{
n
:
this
.
$t
(
`ordinal.${n
}
`
),
days
:
weekDay
}
),
key
:
n
}
)
}
if
(
n
<
5
)
{
// if selected day is in last week, propose also this type of selection
const
lastWeek
=
date
.
daysInMonth
()
-
monthDay
<
7
if
(
lastWeek
)
{
patterns
.
push
(
{
label
:
this
.
$t
(
`event.recurrent_${freq
}
_ordinal`
,
{
n
:
this
.
$t
(
`ordinal.${n
}
`
),
days
:
weekDay
}
),
key
:
'
weekday
'
label
:
this
.
$t
(
`event.recurrent_${freq
}
_ordinal`
,
{
n
:
this
.
$t
(
'
ordinal.-1
'
),
days
:
weekDay
}
),
key
:
-
1
}
)
}
return
patterns
}
else
if
(
freq
===
'
1d
'
)
{
return
this
.
$t
(
'
event.recurrent_each_day
'
)
...
...
@@ -198,6 +197,8 @@ export default {
}
}
else
if
(
what
===
'
frequency
'
)
{
this
.
$emit
(
'
input
'
,
{
...
this
.
value
,
recurrent
:
{
...
this
.
value
.
recurrent
,
frequency
:
value
}
}
)
}
else
if
(
what
===
'
recurrentType
'
)
{
this
.
$emit
(
'
input
'
,
{
...
this
.
value
,
recurrent
:
{
...
this
.
value
.
recurrent
,
type
:
value
}
}
)
}
else
if
(
what
===
'
fromHour
'
)
{
if
(
value
)
{
const
[
hour
,
minute
]
=
value
.
split
(
'
:
'
)
...
...
@@ -221,6 +222,7 @@ export default {
}
else
{
this
.
$emit
(
'
input
'
,
{
...
this
.
value
,
dueHour
:
false
}
)
}
// change date in calendar (could be a range or a recurrent event...)
}
else
if
(
what
===
'
date
'
)
{
if
(
value
===
null
)
{
this
.
$emit
(
'
input
'
,
{
...
this
.
value
,
from
:
null
,
fromHour
:
false
}
)
...
...
plugins/filters.js
View file @
f4ab6136
...
...
@@ -44,7 +44,12 @@ export default ({ app, store }) => {
recurrent
=
app
.
i18n
.
t
(
`event.recurrent_
${
frequency
}
_days`
,
{
days
:
dayjs
.
unix
(
parent
.
start_datetime
).
format
(
'
dddd
'
)
})
}
else
if
(
frequency
===
'
1m
'
||
frequency
===
'
2m
'
)
{
const
d
=
type
===
'
ordinal
'
?
dayjs
.
unix
(
parent
.
start_datetime
).
date
()
:
dayjs
.
unix
(
parent
.
start_datetime
).
format
(
'
dddd
'
)
recurrent
=
app
.
i18n
.
tc
(
`event.recurrent_
${
frequency
}
_
${
type
}
`
,
d
)
if
(
type
===
'
ordinal
'
)
{
recurrent
=
app
.
i18n
.
t
(
`event.recurrent_
${
frequency
}
_days`
,
{
days
:
d
})
}
else
{
recurrent
=
app
.
i18n
.
t
(
`event.recurrent_
${
frequency
}
_ordinal`
,
{
n
:
app
.
i18n
.
t
(
'
ordinal.
'
+
type
),
days
:
d
})
}
}
return
recurrent
})
...
...
server/api/controller/event.js
View file @
f4ab6136
...
...
@@ -496,7 +496,7 @@ const eventController = {
},
/**
* Ensure we have the next instance
s
of recurrent event
s
* Ensure we have the next instance of
a
recurrent event
*/
_createRecurrentOccurrence
(
e
)
{
log
.
debug
(
`Create recurrent event [
${
e
.
id
}
]
${
e
.
title
}
"`
)
...
...
@@ -541,17 +541,24 @@ const eventController = {
cursor
=
cursor
.
add
(
1
,
'
month
'
)
}
}
else
{
// weekday
const
monthDay
=
start_date
.
format
(
'
D
'
)
const
n
=
Math
.
floor
((
monthDay
-
1
)
/
7
)
+
1
cursor
=
cursor
.
startOf
(
'
month
'
)
cursor
=
cursor
.
add
(
n
,
'
week
'
)
cursor
=
cursor
.
day
(
start_date
.
day
())
if
(
cursor
.
isBefore
(
dayjs
()))
{
cursor
=
cursor
.
add
(
1
,
'
month
'
)
// get weekday
log
.
info
(
type
)
// get recurrent freq details
if
(
type
===
-
1
)
{
cursor
=
cursor
.
endOf
(
'
month
'
)
cursor
=
cursor
.
subtract
(
1
,
'
week
'
)
cursor
=
cursor
.
day
(
start_date
.
day
())
}
else
{
cursor
=
cursor
.
startOf
(
'
month
'
)
cursor
=
cursor
.
add
(
type
,
'
week
'
)
cursor
=
cursor
.
day
(
start_date
.
day
())
if
(
cursor
.
isBefore
(
dayjs
()))
{
cursor
=
cursor
.
add
(
1
,
'
month
'
)
}
}
}
}
log
.
info
(
cursor
)
event
.
start_datetime
=
cursor
.
unix
()
event
.
end_datetime
=
event
.
start_datetime
+
duration
Event
.
create
(
event
)
...
...
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