diff --git a/app/components/agenda/agenda-header.hbs b/app/components/agenda/agenda-header.hbs index 34e3d3b1bf..fc3b1c2951 100644 --- a/app/components/agenda/agenda-header.hbs +++ b/app/components/agenda/agenda-header.hbs @@ -27,6 +27,7 @@ diff --git a/app/components/agenda/agenda-header/agenda-tabs.hbs b/app/components/agenda/agenda-header/agenda-tabs.hbs index 66ac5f3efb..20d49beed1 100644 --- a/app/components/agenda/agenda-header/agenda-tabs.hbs +++ b/app/components/agenda/agenda-header/agenda-tabs.hbs @@ -2,6 +2,10 @@ {{t "overview"}} diff --git a/app/components/agenda/agenda-header/agenda-tabs.js b/app/components/agenda/agenda-header/agenda-tabs.js index 7f00f5aa28..39fd858074 100644 --- a/app/components/agenda/agenda-header/agenda-tabs.js +++ b/app/components/agenda/agenda-header/agenda-tabs.js @@ -1,6 +1,5 @@ import Component from '@glimmer/component'; import { inject as service } from '@ember/service'; -import { task, lastValue } from 'ember-concurrency'; export default class AgendaAgendaHeaderAgendaTabsComponent extends Component { /** @@ -11,23 +10,8 @@ export default class AgendaAgendaHeaderAgendaTabsComponent extends Component { @service store; @service currentSession; - @lastValue('loadFirstAgendaitem') firstAgendaitem; - - constructor() { - super(...arguments); - this.loadFirstAgendaitem.perform(); - } - - @task - *loadFirstAgendaitem() { - if (this.args.currentAgenda) { - // sorting on show-as-remark prevents defaulting to an announcement when there are notas - return yield this.store.queryOne('agendaitem', { - 'filter[agenda][:id:]': this.args.currentAgenda.id, - sort: 'show-as-remark,number', - }); - } - return null; + get firstAgendaitem() { + return this.args.currentAgendaitems?.toArray().sortBy('show-as-remark').sortBy('number').firstObject; } get modelsForDetailRoute() { @@ -41,11 +25,16 @@ export default class AgendaAgendaHeaderAgendaTabsComponent extends Component { get currentAgendaItemId() { const currentRoute = this.router.currentRoute; let agendaItemsRoute = currentRoute; - if (currentRoute && currentRoute.name.startsWith('agenda.agendaitems.agendaitem')) { + if (currentRoute?.name?.startsWith('agenda.agendaitems.agendaitem')) { while (agendaItemsRoute.name !== 'agenda.agendaitems.agendaitem') { agendaItemsRoute = agendaItemsRoute.parent; } return agendaItemsRoute.params.agendaitem_id; + } else if (currentRoute?.name?.startsWith('agenda.agendaitems')) { + while (agendaItemsRoute.name !== 'agenda.agendaitems') { + agendaItemsRoute = agendaItemsRoute.parent; + } + return agendaItemsRoute.queryParams.anchor; } return null; } diff --git a/app/pods/agenda/agendaitems/agendaitem/index/controller.js b/app/pods/agenda/agendaitems/agendaitem/index/controller.js index 78c814ce02..7f3f09f2fb 100644 --- a/app/pods/agenda/agendaitems/agendaitem/index/controller.js +++ b/app/pods/agenda/agendaitems/agendaitem/index/controller.js @@ -32,11 +32,12 @@ export default class IndexAgendaitemAgendaitemsAgendaController extends Controll 'filter[agenda][:id:]': this.agenda.id, 'filter[show-as-remark]': agendaitem.showAsRemark, 'filter[:lte:number]': `"${previousNumber}"`, // Needs quotes because of bug in mu-cl-resources + sort: '-number', }); if (neighbouringItem) { this.router.transitionTo('agenda.agendaitems.agendaitem', this.meeting.id, this.agenda.id, neighbouringItem.id); } else { - this.router.transitionTo('agenda.agendaitems', this.meeting.id, this.agenda.id,{ queryParams: { anchor: neighbouringItem.id }}); + this.router.transitionTo('agenda.agendaitems', this.meeting.id, this.agenda.id,{ queryParams: { anchor: null }}); } } @@ -48,8 +49,12 @@ export default class IndexAgendaitemAgendaitemsAgendaController extends Controll @action async reassignNumbersAndNavigateToNeighbouringAgendaitem() { await this.reassignNumbersForAgendaitems(); - this.agendaitemsController.send('reloadModel'); await this.navigateToNeighbouringItem(this.model); + this.agendaitemsController.send('reloadModel'); + // The call to reloadModel causes a refresh of the agenda.agendaitems route, so its model gets recalculated + // Because we're a subroute of that route, our model will also get recalculated, using the current route + // That means that we're going to query for the current agendaitem, which has been deleted, because + // this method only gets called when the agendaitem gets deleted. } @action diff --git a/app/pods/agenda/route.js b/app/pods/agenda/route.js index 512a484ac5..7f33aa564f 100644 --- a/app/pods/agenda/route.js +++ b/app/pods/agenda/route.js @@ -25,10 +25,15 @@ export default class AgendaRoute extends Route { sort: '-serialnumber', include: 'status', }); + const agendaitems = await this.store.query('agendaitem', { + 'filter[agenda][:id:]': agenda.id, + sort: 'show-as-remark,number', + }); return { meeting, agenda, + agendaitems, reverseSortedAgendas, }; } diff --git a/app/pods/agenda/template.hbs b/app/pods/agenda/template.hbs index e17e9d1c21..92341bee8f 100644 --- a/app/pods/agenda/template.hbs +++ b/app/pods/agenda/template.hbs @@ -9,6 +9,7 @@