Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
dashboard
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
AURA
dashboard
Commits
bfe7f813
Commit
bfe7f813
authored
1 year ago
by
Konrad Mohrfeldt
Browse files
Options
Downloads
Patches
Plain Diff
feat: hide event content if it wouldn’t be legible anyway
refs
#151
parent
8b40e1d7
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/Pages/EmissionManager.vue
+41
-1
41 additions, 1 deletion
src/Pages/EmissionManager.vue
src/util.ts
+4
-0
4 additions, 0 deletions
src/util.ts
with
45 additions
and
1 deletion
src/Pages/EmissionManager.vue
+
41
−
1
View file @
bfe7f813
...
...
@@ -211,6 +211,8 @@
</template>
<
script
>
import
{
parseISO
}
from
'
date-fns
'
import
{
h
}
from
'
vue
'
import
{
mapGetters
}
from
'
vuex
'
import
FullCalendar
from
'
@fullcalendar/vue3
'
...
...
@@ -227,7 +229,12 @@ import playlist from '@/mixins/playlist'
import
ServerErrors
from
'
@/components/ServerErrors.vue
'
import
{
getISODateString
}
from
'
@/utilities
'
import
PageHeader
from
'
@/components/PageHeader.vue
'
import
{
getClosestSlot
,
getNextAvailableSlot
,
sanitizeHTML
}
from
'
@/util
'
import
{
calculateDurationSeconds
,
getClosestSlot
,
getNextAvailableSlot
,
sanitizeHTML
,
}
from
'
@/util
'
import
SafeHTML
from
'
@/components/generic/SafeHTML
'
export
default
{
...
...
@@ -341,6 +348,37 @@ export default {
allDaySlot
:
false
,
editable
:
false
,
nowIndicator
:
true
,
eventContent
({
event
,
timeText
})
{
// The eventContent function doesn’t quite seem to work like documented in the fullcalendar docs:
// * the slot is broken because it doesn’t receive a context object ('arg' is undefined)
// * the Preact createElement/h function that is passed as the second argument to this function
// doesn’t render anything
// * returning { html: '
<
i
>
hello
<
/i>' } doesn’t render anythin
g
// * returning { domNodes: [(() => { const i = document.createElement('i'); i.textContent = 'hello'; return i })()] }
// doesn’t render anything
//
// Instead, this comment [1] mentions that one should use the Vue createElement/h function.
// Surprisingly this works.
//
// It is unclear to me why all these (documented) options fail. One major difference is that we run Vue 3 in
// Vue 2 compat mode which might be a source of errors.
//
// [1]: https://github.com/fullcalendar/fullcalendar/issues/7175#issuecomment-1409519357
const
{
durationMinutes
,
title
}
=
event
.
extendedProps
// don’t render any content if it would be crammed anyway
const
content
=
durationMinutes
>
slotDurationMinutes
?
[
h
(
'
div
'
,
{
class
:
'
fc-event-time
'
},
timeText
),
h
(
'
div
'
,
{
class
:
'
fc-event-title-container
'
},
[
h
(
'
div
'
,
{
class
:
'
fc-event-title fc-sticky
'
},
title
),
]),
]
:
[]
return
h
(
'
div
'
,
{
class
:
'
fc-event-main-frame
'
},
content
)
},
datesSet
:
(
view
)
=>
{
if
(
this
.
currentStart
?.
toISOString
?.()
!==
view
.
start
.
toISOString
()
||
...
...
@@ -802,6 +840,8 @@ export default {
start
:
timeslot
.
start
,
end
:
timeslot
.
end
,
title
,
durationMinutes
:
calculateDurationSeconds
(
parseISO
(
timeslot
.
start
),
parseISO
(
timeslot
.
end
))
/
60
,
},
})
}
...
...
This diff is collapsed.
Click to expand it.
src/util.ts
+
4
−
0
View file @
bfe7f813
...
...
@@ -75,6 +75,10 @@ export function getNextAvailableSlot(slotDurationMinutes: number, date?: Date):
return
new
Date
(
nextSlotTimestamp
)
}
export
function
calculateDurationSeconds
(
start
:
Date
,
end
:
Date
):
number
{
return
Math
.
abs
(
end
.
getTime
()
-
start
.
getTime
())
/
1000
}
export
function
sanitizeHTML
(
html
:
string
,
preset
?:
'
inline-noninteractive
'
|
'
safe-html
'
|
'
strip
'
,
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment