Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

KAS-4890: Uitgestelde punten heragenderen met indieningen #2268

Merged
merged 14 commits into from
Jan 7, 2025
Merged
Show file tree
Hide file tree
Changes from 11 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -78,26 +78,26 @@
</tbody>
</table>
{{#if @previousMandateePersons}}
<hr />
<div class="auk-u-m-4">
{{#let
(removed-from-list
(map-by "fullName" @previousMandateePersons)
(map-by "person.fullName" @mandatees)
)
as |removedPersons|
}}
{{#if removedPersons}}
{{#if removedPersons}}
<hr />
<div class="auk-u-m-4">
<AuAlert
@skin="warning"
@icon="alert-triangle"
@title={{t "mandatees-deleted-in-update" count=removedPersons.length}}
>
{{join ", " removedPersons}}
</AuAlert>
{{/if}}
{{/let}}
</div>
</div>
{{/if}}
{{/let}}
{{/if}}
</Auk::Panel::Body>
{{else}}
Expand Down
69 changes: 43 additions & 26 deletions app/components/subcase/description-panel/view.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -78,32 +78,48 @@
<AuHeading @level="4" @skin="6">{{t "is-on-agenda"}}</AuHeading>
{{#if this.loadAgendaData.isRunning}}
<Auk::Loader />
{{else if this.modelsOfMeetings}}
{{#each this.modelsOfMeetings as |models| }}
{{#if (not (has-next models this.modelsOfMeetings))}}
{{#let (get models "0") (get models "1") (get models "2") as |meeting agenda agendaitem|}}
<AuLink
data-test-subcase-description-agenda-link
@route="agenda.agendaitems.agendaitem"
@models={{array
meeting.id
agenda.id
agendaitem.id
}}
{{else if this.latestMeetingModels}}
{{#let
this.latestMeetingModels.meeting
this.latestMeetingModels.agenda
this.latestMeetingModels.agendaitem
as |meeting agenda agendaitem|}}
<p>
<AuLink
data-test-subcase-description-agenda-link
@route="agenda.agendaitems.agendaitem"
@models={{array
meeting.id
agenda.id
agendaitem.id
}}
>
{{date-phrase meeting.plannedStart}}
</AuLink>
{{#if meeting.hasKindEP}}
<AuPill
@size="small"
>
{{! prettier-ignore}}
{{date-phrase meeting.plannedStart}}{{if (has-next models this.modelsOfMeetings) ", "}}
</AuLink>
{{meeting.kind.label}}
</AuPill>
{{/if}}
</p>
{{/let}}

{{#if this.postponedMeetingModels}}
{{#let this.postponedMeetingModels.meeting as |meeting|}}
<p>
{{date-phrase meeting.plannedStart}}
{{#if meeting.hasKindEP}}
<AuPill
@size="small"
>
{{meeting.kind.label}}
</AuPill>
{{/if}}
{{/let}}
{{/if}}
{{/each}}
</p>
{{/let}}
{{/if}}
{{else}}
<p data-test-subcase-description-not-on-agenda>
{{t "not-yet-on-agenda"}}
Expand All @@ -115,14 +131,15 @@
<p data-test-subcase-description-meeting-number>
{{#if this.loadAgendaData.isRunning}}
<Auk::Loader />
{{else if this.modelsOfMeetings}}
{{#each this.modelsOfMeetings as |models|}}
{{#if (not (has-next models this.modelsOfMeetings))}}
{{#let (get models "0") as |meeting|}}
{{meeting.number}}{{if (has-next models this.modelsOfMeetings) ", "}}
{{/let}}
{{/if}}
{{/each}}
{{else if this.latestMeetingModels}}
{{#let this.latestMeetingModels.meeting as |meeting|}}
<p>{{meeting.number}}</p>
{{/let}}
{{#if this.postponedMeetingModels}}
{{#let this.postponedMeetingModels.meeting as |meeting|}}
<p>{{meeting.number}}</p>
{{/let}}
{{/if}}
{{else}}
{{t "no-number-yet"}}
{{/if}}
Expand Down
105 changes: 56 additions & 49 deletions app/components/subcase/description-panel/view.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,12 @@ export default class SubcaseDescriptionView extends Component {
*/
@service store;
@service currentSession;
@service subcasesService;
@service subcaseService;

@tracked postponedMeetingModels = null; // This is only used for Minister/KBD when the subcase has been postponed and is on a design agenda
@tracked latestMeetingModels = null;

@tracked subcaseType = null;
@tracked latestMeeting = null;
@tracked latestAgenda = null;
@tracked latestAgendaitem = null;
@tracked latestDecisionActivity = null;
@tracked approved = null;
@tracked modelsOfMeetings = [];

constructor() {
super(...arguments);
Expand All @@ -45,59 +42,69 @@ export default class SubcaseDescriptionView extends Component {
return (
this.isFinalMeeting &&
(this.currentSession.may('view-decisions-before-release') ||
this.latestMeeting?.internalDecisionPublicationActivity?.get(
this.latestMeetingModels?.meeting?.internalDecisionPublicationActivity?.get(
'startDate'
))
);
}

get isFinalMeeting() {
return isPresent(this.latestMeeting?.agenda?.get('id'));
return isPresent(this.latestMeetingModels?.meeting?.agenda?.get('id'));
}

@task
*loadAgendaData() {
this.subcaseType = yield this.args.subcase.type;
const agendaActivities = yield this.args.subcase
.hasMany('agendaActivities')
.reload();
const sortedAgendaActivities = agendaActivities
?.slice()
?.sort((a1, a2) => a1.startDate - a2.startDate);
loadAgendaData = task(async () => {
// Returns a sorted array of JSON representations of [meeting, agenda, agendaitem]
// Ordered on meeting start date in descending order (first item is latest meeting)
const relatedAgendas = await this.subcaseService.getRelatedAgendas(this.args.subcase);

if (relatedAgendas.length === 0)
return;

this.modelsOfMeetings = [];
for (const [index, agendaActivity] of sortedAgendaActivities
.slice()
.entries()) {
// load models for linkTo and other uses
const agendaitem = yield this.store.queryOne('agendaitem', {
'filter[agenda-activity][:id:]': agendaActivity.id,
// Check if we can access the last agenda using Ember Data, that means it
// has been propagated and we only care about the latest agenda
const lastRecord = relatedAgendas[0];
if (lastRecord.visible) {
// The latest meeting is visible to the current user
// We can just fetch it using the store and use the real records
const meeting = await this.store.findRecord('meeting', lastRecord.meeting.id);
const agenda = await this.store.findRecord('agenda', lastRecord.agenda.id);
const agendaitem = await this.store.findRecord('agendaitem', lastRecord.agendaitem.id);
this.latestMeetingModels = { meeting, agenda, agendaitem };
} else {
// The latest meeting is not visible, we should display it but not as a link
const visibleRecord = relatedAgendas.find((record) => record.visible);

// At least one meeting must be visible to the user to display
// If no meeting is yet propagated, we also don't show the unpropagated one
if (visibleRecord) {
const meeting = await this.store.findRecord('meeting', visibleRecord.meeting.id);
const agenda = await this.store.findRecord('agenda', visibleRecord.agenda.id);
const agendaitem = await this.store.findRecord('agendaitem', visibleRecord.agendaitem.id);
this.latestMeetingModels = { meeting, agenda, agendaitem };
}
// if the record is not visible, it could be because the latest record is designAgenda.
// It is possible an earlier version of the record is visible, but we have to get that manually
const agendaitem = await this.store.queryOne('agendaitem', {
'filter[agenda-activity][subcase][:id:]': this.args.subcase.id,
'filter[agenda][created-for][:id:]': lastRecord.meeting.id,
'filter[:has-no:next-version]': 't',
sort: '-created',
sort: '-agenda-activity.start-date,-created',
});
const agenda = yield agendaitem.agenda;
const meeting = yield agenda.createdFor;
yield meeting?.kind;
const decisionPublicationActivity = yield meeting
.belongsTo('internalDecisionPublicationActivity')
.reload();
yield decisionPublicationActivity?.status; // used in get-functions above
// load decisionActivity
// agenda-activities are propagated by yggdrail on agenda approval, treatments/decision-activities only when decisions are released
const treatment = yield agendaitem?.treatment;
const decisionActivity = yield treatment?.decisionActivity;
const resultCode = yield decisionActivity?.decisionResultCode;
// Other profiles should not have the latest decision when decisions have not been released yet
if (decisionActivity) {
// the last decision might be null, keep only the last one that exists
this.latestDecisionActivity = decisionActivity;
}

this.modelsOfMeetings.push([meeting, agenda, agendaitem, resultCode]);
// we need this multiple times in the template and navigating the nested array each time is bothersome
if (index === agendaActivities.length - 1) {
this.latestMeeting = meeting;
if (agendaitem) {
// we found an approved agendaitem on the meeting
const agenda = await agendaitem.agenda;
this.postponedMeetingModels = null;
const meeting = await this.store.findRecord('meeting', lastRecord.meeting.id);
this.latestMeetingModels = { meeting, agenda, agendaitem };
} else {
// the agendaitem is not approved yet for this profile but should show
this.postponedMeetingModels = {
meeting: lastRecord.meeting,
agenda: lastRecord.agenda,
agendaitem: lastRecord.agendaitem
};
}
}
}
this.latestDecisionActivity = await this.subcaseService.getLatestDecisionActivity(this.args.subcase);
});
}
6 changes: 5 additions & 1 deletion app/components/subcases/subcase-header.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,11 @@
@icon="plus"
@route="cases.case.subcases.subcase.new-submission"
>
{{t "submit-new-documents"}}
{{#if this.isForPostponedSubcase}}
{{t "resubmit-postponed-agendaitem"}}
{{else}}
{{t "submit-new-documents"}}
{{/if}}
</AuLink>
</Auk::Toolbar::Item>
{{/if}}
Expand Down
9 changes: 9 additions & 0 deletions app/components/subcases/subcase-header.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import { inject as service } from '@ember/service';
import { action } from '@ember/object';
import { task } from 'ember-concurrency';
import { isEnabledCabinetSubmissions } from 'frontend-kaleidos/utils/feature-flag';
import CONSTANTS from 'frontend-kaleidos/config/constants';

/*
* @argument subcase
Expand All @@ -18,6 +19,7 @@ export default class SubcasesSubcaseHeaderComponent extends Component {
@service intl;
@service draftSubmissionService;
@service parliamentService;
@service subcaseService;

@tracked isAssigningToAgenda = false;
@tracked isAssigningToOtherCase = false;
Expand All @@ -35,6 +37,7 @@ export default class SubcasesSubcaseHeaderComponent extends Component {
@tracked canSubmitNewDocuments = false;
@tracked currentSubmission = null;
@tracked parliamentRetrievalActivity = null;
@tracked isForPostponedSubcase = false;

constructor() {
super(...arguments);
Expand Down Expand Up @@ -71,6 +74,12 @@ export default class SubcasesSubcaseHeaderComponent extends Component {
this.currentSubmission = yield this.draftSubmissionService.getOngoingSubmissionForSubcase(this.args.subcase);
}
this.parliamentRetrievalActivity = yield this.args.subcase.parliamentRetrievalActivity;
const decisionActivity = yield this.subcaseService.getLatestDecisionActivity(this.args.subcase);
const decisionResultCode = yield decisionActivity?.decisionResultCode;
if (decisionResultCode?.uri === CONSTANTS.DECISION_RESULT_CODE_URIS.UITGESTELD) {
// Check whether this subcase is already on a design agenda
this.isForPostponedSubcase = !(yield this.subcaseService.isOnDesignAgenda(this.args.subcase));
}
}

triggerDeleteCaseDialog() {
Expand Down
14 changes: 7 additions & 7 deletions app/components/subcases/subcases-overview-header.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,15 @@ import { action } from '@ember/object';
import { tracked } from '@glimmer/tracking';
import { task } from 'ember-concurrency';
import { inject as service } from '@ember/service';
import CONSTANTS from 'frontend-kaleidos/config/constants';
import { isEnabledCabinetSubmissions } from 'frontend-kaleidos/utils/feature-flag';

export default class SubCasesOverviewHeader extends Component {
@service currentSession;
@service router;
@service store;
@service draftSubmissionService;
@service subcaseService;

@tracked case;
@tracked showEditCaseModal = false;
Expand All @@ -35,14 +37,14 @@ export default class SubCasesOverviewHeader extends Component {

get mayCreateSubmissions() {
return (
isEnabledCabinetSubmissions() &&
this.loadData.isIdle &&
this.loadSubmissionsData.isIdle &&
this.currentSession.may('create-submissions') &&
this.router.currentRouteName !== 'cases.case.subcases.new-submission' &&
this.loadLinkedMandatees.isIdle &&
this.linkedMandatees?.length &&
!this.hasOngoingSubcases &&
isEnabledCabinetSubmissions()
!this.hasOngoingSubcases
);
}

Expand Down Expand Up @@ -71,11 +73,9 @@ export default class SubCasesOverviewHeader extends Component {
this.currentSubmission = latestSubmission;
return;
}
const meeting = await this.store.queryOne('meeting', {
'filter[submissions][:id:]': latestSubmission.id
});
const agenda = await meeting?.belongsTo('agenda').reload();
this.hasOngoingSubcases = agenda?.id ? false : true;
const relatedAgendas = await this.subcaseService.getRelatedAgendas(subcase);
if (relatedAgendas.length > 0)
this.hasOngoingSubcases = relatedAgendas[0].agenda.status.uri === CONSTANTS.AGENDA_STATUSSES.DESIGN;
}
});

Expand Down
18 changes: 9 additions & 9 deletions app/components/submission/header.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,15 @@
{{/if}}

{{#if (and (not this.loadAgenda.isRunning) this.isOpenCreateSubcaseModal)}}
{{#if this.isUpdate}}
{{#if (or (not this.isUpdate) this.isForPostponedSubcase)}}
<Cases::Subcases::ProposableAgendasModal
@submission={{@submission}}
@onCancel={{this.toggleCreateSubcaseModal}}
@onConfirm={{perform this.createSubcase}}
@defaultAgenda={{this.selectedAgenda}}
@showSaveWithoutAgenda={{true}}
/>
{{else if this.isUpdate}}
<ConfirmationModal
@modalOpen={{this.isOpenCreateSubcaseModal}}
@onCancel={{this.toggleCreateSubcaseModal}}
Expand All @@ -134,14 +142,6 @@
@loading={{this.createSubcase.isRunning}}
@message={{t "confirm-accept-subcase-update"}}
/>
{{else}}
<Cases::Subcases::ProposableAgendasModal
@submission={{@submission}}
@onCancel={{this.toggleCreateSubcaseModal}}
@onConfirm={{perform this.createSubcase}}
@defaultAgenda={{this.selectedAgenda}}
@showSaveWithoutAgenda={{true}}
/>
{{/if}}
{{/if}}

Expand Down
Loading