Skip to content

Commit

Permalink
Merge branch 'master' into GN-4937-snippet-previews
Browse files Browse the repository at this point in the history
  • Loading branch information
elpoelma committed Aug 29, 2024
2 parents 00c342d + 1a32e46 commit e18c038
Show file tree
Hide file tree
Showing 8 changed files with 145 additions and 295 deletions.
5 changes: 5 additions & 0 deletions .changeset/popular-pugs-eat.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'frontend-gelinkt-notuleren': minor
---

Add meeting details modal to inauguration-meeting creation flow
53 changes: 0 additions & 53 deletions app/controllers/inbox/meetings.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import { service } from '@ember/service';
import Controller from '@ember/controller';
import { tracked } from '@glimmer/tracking';
import { action } from '@ember/object';
import InstallatieVergaderingModel from 'frontend-gelinkt-notuleren/models/installatievergadering';
export default class InboxMeetingsController extends Controller {
@service store;
Expand All @@ -20,56 +19,4 @@ export default class InboxMeetingsController extends Controller {
isInaugurationMeeting = (meeting) => {
return meeting instanceof InstallatieVergaderingModel;
};

@action
async createInaugurationMeeting() {
let now = new Date();
const bestuursorgaan = (
await this.store.query('bestuursorgaan', {
include: [
'is-tijdsspecialisatie-van.bestuurseenheid',
'is-tijdsspecialisatie-van.classificatie',
].join(','),
filter: {
'is-tijdsspecialisatie-van': {
bestuurseenheid: {
id: this.currentSession.group.id,
},
classificatie: {
':uri:':
'http://data.vlaanderen.be/id/concept/BestuursorgaanClassificatieCode/5ab0e9b8a3b2ca7c5e000005',
},
},
},
})
)[0];
const inaugurationmeeting = this.store.createRecord(
'installatievergadering',
{
geplandeStart: now,
gestartOpTijdstip: now,
bestuursorgaan,
},
);
await inaugurationmeeting.save();
const promises = [];
let previousAgendapoint;
for (let i = 0; i < 9; i++) {
const agendapoint = this.store.createRecord('agendapunt', {
position: i,
geplandOpenbaar: true,
titel: `Naam Agendapunt ${i}`,
zitting: inaugurationmeeting,
vorigeAgendapunt: previousAgendapoint,
});
const treatment = this.store.createRecord('behandeling-van-agendapunt', {
openbaar: true,
onderwerp: agendapoint,
});
promises.push(agendapoint.save(), treatment.saveAndPersistDocument());
previousAgendapoint = agendapoint;
}
await Promise.all(promises);
this.router.replaceWith('meetings.edit', inaugurationmeeting.id);
}
}
41 changes: 40 additions & 1 deletion app/controllers/inbox/meetings/new.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,15 @@ import Controller from '@ember/controller';
import { action } from '@ember/object';
import { dropTask } from 'ember-concurrency';
import { service } from '@ember/service';
import InstallatieVergaderingModel from '../../../models/installatievergadering';

export default class InboxMeetingsNewController extends Controller {
@service router;
@service store;
@service intl;

queryParams = ['type'];

get meeting() {
return this.model;
}
Expand All @@ -19,6 +23,18 @@ export default class InboxMeetingsNewController extends Controller {
this.meeting.opLocatie = event.target.value;
}

get isInaugurationMeeting() {
return this.meeting instanceof InstallatieVergaderingModel;
}

get title() {
if (this.isInaugurationMeeting) {
return this.intl.t('inbox.meetings.new.inauguration-meeting.title');
} else {
return this.intl.t('inbox.meetings.new.common-meeting.title');
}
}

saveMeetingTask = dropTask(async (event) => {
event.preventDefault();

Expand All @@ -31,14 +47,37 @@ export default class InboxMeetingsNewController extends Controller {
),
);
}

if (this.meeting.isValid) {
this.meeting.gestartOpTijdstip = this.meeting.geplandeStart;
await this.meeting.save();
if (this.isInaugurationMeeting) {
await this.setUpInaugurationMeeting();
}
this.router.replaceWith('meetings.edit', this.meeting.id);
}
});

async setUpInaugurationMeeting() {
const promises = [];
let previousAgendapoint;
for (let i = 0; i < 9; i++) {
const agendapoint = this.store.createRecord('agendapunt', {
position: i,
geplandOpenbaar: true,
titel: `Naam Agendapunt ${i}`,
zitting: this.meeting,
vorigeAgendapunt: previousAgendapoint,
});
const treatment = this.store.createRecord('behandeling-van-agendapunt', {
openbaar: true,
onderwerp: agendapoint,
});
promises.push(agendapoint.save(), treatment.saveAndPersistDocument());
previousAgendapoint = agendapoint;
}
await Promise.all(promises);
}

@action
updateAdministrativeBody(administrativeBody) {
this.meeting.bestuursorgaan = administrativeBody;
Expand Down
51 changes: 50 additions & 1 deletion app/routes/inbox/meetings/new.js
Original file line number Diff line number Diff line change
@@ -1,22 +1,71 @@
import Route from '@ember/routing/route';
import { service } from '@ember/service';
import { format } from 'date-fns/fp';

export default class InboxMeetingsNewRoute extends Route {
@service currentSession;
@service router;
@service store;

queryParams = {
type: {
refreshModel: true,
},
};

beforeModel() {
if (!this.currentSession.canWrite) {
this.router.replaceWith('inbox.meetings');
}
}

model() {
model(params) {
const type = params.type;
switch (type) {
case 'common':
return this.createCommonMeeting();
case 'inauguration-meeting':
return this.createInaugurationMeeting();
}
}

async createCommonMeeting() {
let now = new Date();
return this.store.createRecord('zitting', {
geplandeStart: now,
gestartOpTijdstip: now,
});
}

async createInaugurationMeeting() {
let now = new Date();
const bestuursorgaan = (
await this.store.query('bestuursorgaan', {
include: [
'is-tijdsspecialisatie-van.bestuurseenheid',
'is-tijdsspecialisatie-van.classificatie',
].join(','),
filter: {
':or:': {
':gte:binding-einde': format('yyyy-mm-dd')(now),
':has-no:binding-einde': true,
},
'is-tijdsspecialisatie-van': {
bestuurseenheid: {
id: this.currentSession.group.id,
},
classificatie: {
':uri:':
'http://data.vlaanderen.be/id/concept/BestuursorgaanClassificatieCode/5ab0e9b8a3b2ca7c5e000005',
},
},
},
})
)[0];
return this.store.createRecord('installatievergadering', {
geplandeStart: now,
gestartOpTijdstip: now,
bestuursorgaan,
});
}
}
14 changes: 9 additions & 5 deletions app/templates/inbox/meetings.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -25,16 +25,20 @@
@icon='chevron-down'
role='menu'
>
<AuLink @route='inbox.meetings.new' role='menuitem'>
<AuLink
@route='inbox.meetings.new'
@query={{hash type='common'}}
role='menuitem'
>
{{t 'inbox.meetings.new.common-meeting.title'}}
</AuLink>
<AuButton
@skin='link'
{{on 'click' this.createInaugurationMeeting}}
<AuLink
@route='inbox.meetings.new'
@query={{hash type='inauguration-meeting'}}
role='menuitem'
>
{{t 'inbox.meetings.new.inauguration-meeting.title'}}
</AuButton>
</AuLink>
</AuDropdown>
{{/unless}}
</Group>
Expand Down
56 changes: 38 additions & 18 deletions app/templates/inbox/meetings/new.hbs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{{page-title (t 'inbox.meetings.new.common-meeting.title')}}
{{page-title this.title}}

<AuModal
@title={{t 'inbox.meetings.new.common-meeting.title'}}
@title={{this.title}}
@modalOpen={{true}}
@closeModal={{this.cancelMeetingCreation}}
as |Modal|
Expand All @@ -13,23 +13,43 @@
{{on 'submit' (perform this.saveMeetingTask)}}
>
<div>
{{#let (unique-id) this.meeting.errors.bestuursorgaan as |id errors|}}
<AuLabel @error={{if errors true false}} for={{id}}>
{{#if this.isInaugurationMeeting}}
<p class='au-c-label'>
{{t 'inbox.meetings.new.common-meeting.administrative-body'}}
<RequiredField />
</AuLabel>
<AdministrativeBodySelect
@id={{id}}
@selected={{this.meeting.bestuursorgaan}}
@onChange={{this.updateAdministrativeBody}}
@error={{if errors true false}}
/>
{{#each errors as |error|}}
<AuHelpText @error={{true}}>
{{error.message}}
</AuHelpText>
{{/each}}
{{/let}}
</p>
<p>
{{#let this.meeting.bestuursorgaan as |bestuursorgaan|}}
{{bestuursorgaan.isTijdsspecialisatieVan.naam}}
({{t 'administrative-body-select.period'}}:
{{plain-date bestuursorgaan.bindingStart}}
-
{{#if bestuursorgaan.bindingEinde}}
{{plain-date bestuursorgaan.bindingEinde}}
{{else}}
{{t 'administrative-body-select.not-applicable'}}
{{/if}})
{{/let}}
</p>
{{else}}
{{#let (unique-id) this.meeting.errors.bestuursorgaan as |id errors|}}
<AuLabel @error={{if errors true false}} for={{id}}>
{{t 'inbox.meetings.new.common-meeting.administrative-body'}}
<RequiredField />
</AuLabel>
<AdministrativeBodySelect
@id={{id}}
@selected={{this.meeting.bestuursorgaan}}
@onChange={{this.updateAdministrativeBody}}
@error={{if errors true false}}
/>
{{#each errors as |error|}}
<AuHelpText @error={{true}}>
{{error.message}}
</AuHelpText>
{{/each}}
{{/let}}
{{/if}}

</div>
<div>
{{#let (unique-id) as |id|}}
Expand Down
Loading

0 comments on commit e18c038

Please sign in to comment.