Skip to content

Commit 5d6f968

Browse files
codepool867iamareebjamalhb
authored
fix: Reimplement session route to not reload page on filter (#5742)
Co-authored-by: Areeb Jamal <jamal.areeb@gmail.com> Co-authored-by: hb <hb@rm.com>
1 parent 6c70485 commit 5d6f968

File tree

3 files changed

+22
-3
lines changed

3 files changed

+22
-3
lines changed

app/controllers/public/sessions.js

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
import classic from 'ember-classic-decorator';
2-
import { computed } from '@ember/object';
2+
import { action, computed } from '@ember/object';
33
import Controller from '@ember/controller';
44
import moment from 'moment';
5+
import $ from 'jquery';
56

67
@classic
78
export default class SessionsController extends Controller {
@@ -11,6 +12,21 @@ export default class SessionsController extends Controller {
1112
isTrackVisible = false;
1213
timezone = null;
1314

15+
constructor(...args) {
16+
super(...args);
17+
18+
this.addObserver('model.session', this, 'sessionChanged');
19+
}
20+
21+
@action
22+
sessionChanged() {
23+
if (this.model.isFiltering) {
24+
$('html,body').animate({
25+
scrollTop: $('#session-heading').offset()?.top
26+
});
27+
}
28+
}
29+
1430
@computed('model.event.startsAt', 'model.event.endsAt', 'timezone')
1531
get allDates() {
1632
const arr = [];

app/routes/public/sessions.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,8 @@ export default class SessionsRoute extends Route {
8787
});
8888
}
8989

90+
const isFiltering = params.room || params.track || params.date;
91+
9092
return {
9193
event : eventDetails,
9294
session : await this.infinity.model('sessions', {
@@ -98,7 +100,8 @@ export default class SessionsRoute extends Route {
98100
perPageParam : 'page[size]',
99101
pageParam : 'page[number]',
100102
store : eventDetails
101-
})
103+
}),
104+
isFiltering
102105
};
103106
}
104107
}

app/templates/public/sessions.hbs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
<h1 class="ui header">{{t 'Sessions'}}</h1>
1+
<h1 class="ui header" id="session-heading">{{t 'Sessions'}}</h1>
22

33
<div class="d-flex wrap">
44
<LinkTo @route="public.sessions" @models={{array this.model.event.id}} @query={{hash date=null}} class="ui button mb-2">{{t 'All'}}</LinkTo>

0 commit comments

Comments
 (0)