Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
A
AlekSIS-App-Alsijil
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
Service Desk
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
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
AlekSIS®
Official
AlekSIS-App-Alsijil
Commits
1863fe8b
Commit
1863fe8b
authored
1 year ago
by
permcu
Browse files
Options
Downloads
Patches
Plain Diff
Show current day in url hash fragment
It's important to keep the date out of computed gqlQueryArgs to not resend query.
parent
c2b5b178
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
aleksis/apps/alsijil/frontend/components/coursebook/Coursebook.vue
+39
-4
39 additions, 4 deletions
...pps/alsijil/frontend/components/coursebook/Coursebook.vue
with
39 additions
and
4 deletions
aleksis/apps/alsijil/frontend/components/coursebook/Coursebook.vue
+
39
−
4
View file @
1863fe8b
...
...
@@ -61,8 +61,9 @@
v-for=
"day in groupDocsByDay(items)"
two-line
:key=
"'day-' + day[0]"
:id=
"'documentation_' + day[0].toISODate()"
>
<v-list-item-content
:id=
"'documentation_' + day[0].toISODate()"
>
<v-list-item-content>
<v-subheader
class=
"text-h6"
>
{{
$d
(
day
[
0
],
"
dateWithWeekday
"
)
}}
</v-subheader>
...
...
@@ -163,7 +164,6 @@ export default {
computed
:
{
gqlQueryArgs
()
{
console
.
log
(
'
computing gqlQueryArgs
'
);
const
date
=
this
.
$route
.
hash
.
substring
(
1
)
return
{
own
:
this
.
filterType
===
"
all
"
?
false
:
true
,
objId
:
this
.
objId
?
Number
(
this
.
objId
)
:
undefined
,
...
...
@@ -223,6 +223,38 @@ export default {
.
sort
()
.
map
((
key
)
=>
byDay
[
key
]);
}
,
debounce
(
fn
,
delay
)
{
let
timer
;
return
()
=>
{
console
.
log
(
'
debounce
'
);
clearTimeout
(
timer
);
timer
=
setTimeout
(
fn
,
delay
);
}
}
,
// Adapted from
// https://github.com/vuejs/vuepress/blob/38e98634af117f83b6a32c8ff42488d91b66f663/packages/%40vuepress/plugin-active-header-links/clientRootMixin.js
setCurrentDay
()
{
const
days
=
Array
.
from
(
document
.
querySelectorAll
(
"
[id^='documentation_']
"
));
const
scrollTop
=
Math
.
max
(
window
.
pageYOffset
,
document
.
documentElement
.
scrollTop
,
document
.
body
.
scrollTop
);
for
(
let
i
=
0
;
i
<
days
.
length
;
i
++
)
{
const
day
=
days
[
i
];
const
nextDay
=
days
[
i
+
1
];
if
((
scrollTop
>=
day
.
offsetTop
+
10
||
i
==
0
)
&&
(
!
nextDay
||
scrollTop
<
nextDay
.
offsetTop
-
10
))
{
const
date
=
day
.
id
.
split
(
"
_
"
)[
1
];
if
(
date
!==
this
.
$route
.
hash
.
substring
(
1
))
{
this
.
gotoDate
(
date
);
}
return
}
}
}
,
/**
* @param {"prev"|"next"
}
direction
*/
...
...
@@ -286,7 +318,7 @@ export default {
}
,
gotoDate
(
date
,
scroll
)
{
// show
this
.
$router
.
push
({
hash
:
date
.
toISODate
()
}
)
this
.
$router
.
replace
({
hash
:
date
}
)
console
.
log
(
'
hash
'
,
this
.
$route
.
hash
);
// assure
// scroll
...
...
@@ -297,8 +329,11 @@ export default {
console
.
log
(
'
mounted with hash
'
,
this
.
$route
.
hash
);
if
(
!
this
.
$route
.
hash
)
{
console
.
log
(
'
initialized hash
'
);
this
.
$router
.
push
({
hash
:
DateTime
.
now
().
toISODate
()
}
)
this
.
$router
.
replace
({
hash
:
DateTime
.
now
().
toISODate
()
}
)
}
this
.
dateStart
=
this
.
$route
.
hash
.
substring
(
1
);
this
.
dateEnd
=
DateTime
.
fromISO
(
this
.
dateStart
).
plus
({
weeks
:
1
}
).
toISODate
()
window
.
addEventListener
(
'
scroll
'
,
this
.
debounce
(
this
.
setCurrentDay
,
300
));
}
,
}
;
<
/script
>
...
...
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