Skip to content

Commit

Permalink
fix: Reimplement session route to not reload page on filter (#5742)
Browse files Browse the repository at this point in the history
Co-authored-by: Areeb Jamal <jamal.areeb@gmail.com>
Co-authored-by: hb <hb@rm.com>
  • Loading branch information
3 people authored Nov 25, 2020
1 parent 6c70485 commit 5d6f968
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 3 deletions.
18 changes: 17 additions & 1 deletion app/controllers/public/sessions.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
import classic from 'ember-classic-decorator';
import { computed } from '@ember/object';
import { action, computed } from '@ember/object';
import Controller from '@ember/controller';
import moment from 'moment';
import $ from 'jquery';

@classic
export default class SessionsController extends Controller {
Expand All @@ -11,6 +12,21 @@ export default class SessionsController extends Controller {
isTrackVisible = false;
timezone = null;

constructor(...args) {
super(...args);

this.addObserver('model.session', this, 'sessionChanged');
}

@action
sessionChanged() {
if (this.model.isFiltering) {
$('html,body').animate({
scrollTop: $('#session-heading').offset()?.top
});
}
}

@computed('model.event.startsAt', 'model.event.endsAt', 'timezone')
get allDates() {
const arr = [];
Expand Down
5 changes: 4 additions & 1 deletion app/routes/public/sessions.js
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,8 @@ export default class SessionsRoute extends Route {
});
}

const isFiltering = params.room || params.track || params.date;

return {
event : eventDetails,
session : await this.infinity.model('sessions', {
Expand All @@ -98,7 +100,8 @@ export default class SessionsRoute extends Route {
perPageParam : 'page[size]',
pageParam : 'page[number]',
store : eventDetails
})
}),
isFiltering
};
}
}
2 changes: 1 addition & 1 deletion app/templates/public/sessions.hbs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<h1 class="ui header">{{t 'Sessions'}}</h1>
<h1 class="ui header" id="session-heading">{{t 'Sessions'}}</h1>

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

1 comment on commit 5d6f968

@vercel
Copy link

@vercel vercel bot commented on 5d6f968 Nov 25, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.