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-4805 implement emptying interal review private comment feature #2266

Merged
merged 10 commits into from
Jan 7, 2025
Merged
30 changes: 30 additions & 0 deletions app/components/agenda/agenda-header/agenda-actions.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,15 @@
{{t "approve-all-agendaitems"}}
</AuButton>
{{/if}}
{{#if this.canEmptyInternalReviews}}
<AuButton
@skin="link"
{{on "click" this.openConfirmEmptyInternalReviews}}
role="menuitem"
>
{{t "empty-internal-review"}}
</AuButton>
{{/if}}
{{#if this.canPublishDecisions}}
<AuHr />
<AuButton
Expand Down Expand Up @@ -348,3 +357,24 @@
</div>
</:body>
</ConfirmationModal>

{{#if this.showConfirmEmptyInternalReviews}}
<Auk::Modal @size="small">
<Auk::Modal::Header
@title={{t "empty-internal-review"}}
@onClose={{this.cancelEmptyInternalReviews}}
/>
<Auk::Modal::Body>
<p class="auk-u-text-prewrap">{{t "empty-internal-review-message"}}</p>
</Auk::Modal::Body>
<Auk::Modal::Footer @onCancel={{this.cancelEmptyInternalReviews}}>
<AuButton
@skin="primary"
@loading={{this.emptyInteralReviewsOfAgendaitemThrottled.isRunning}}
{{on "click" this.emptyInteralReviews}}
>
{{t "empty-internal-review"}}
</AuButton>
</Auk::Modal::Footer>
</Auk::Modal>
{{/if}}
50 changes: 49 additions & 1 deletion app/components/agenda/agenda-header/agenda-actions.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import {
} from 'frontend-kaleidos/utils/zip-agenda-files';
import CONSTANTS from 'frontend-kaleidos/config/constants';
import bind from 'frontend-kaleidos/utils/bind';
import { isPresent } from '@ember/utils';
import { isEmpty, isPresent } from '@ember/utils';
import DownloadFileToast from 'frontend-kaleidos/components/utils/toaster/download-file-toast';

/**
Expand Down Expand Up @@ -53,6 +53,7 @@ export default class AgendaAgendaHeaderAgendaActions extends Component {
@tracked showDownloadDocuments = false;
@tracked selectedMandatees = [];
@tracked showDownloadDecisions = false;
@tracked showConfirmEmptyInternalReviews = false;

@tracked decisionPublicationActivity;
@tracked documentPublicationActivity;
Expand Down Expand Up @@ -352,6 +353,43 @@ export default class AgendaAgendaHeaderAgendaActions extends Component {
this.router.refresh(this.router.currentRouteName);
}

get canEmptyInternalReviews() {
// action will do nothing on designAgenda A, so hide it instead
const isDesignAgendaA = this.args.currentAgenda.status.get('isDesignAgenda') && this.args.currentAgenda.serialnumber === 'A';
return this.currentSession.may('manage-agendaitems') && !isDesignAgendaA;
}

emptyInteralReviews = async() => {
this.showConfirmEmptyInternalReviews = false;
this.args.onStartLoading(this.intl.t('empty-internal-review'));
// getting all valid agendaitems first gets better results than trying submission-internal-review directly via subcase
const approvedAgendaitems = await this.store.queryAll('agendaitem', {
'filter[:has:previous-version]': true,
ValenberghsSven marked this conversation as resolved.
Show resolved Hide resolved
'filter[agenda][:id:]': this.args.currentAgenda.id,
});
const savePromises = approvedAgendaitems.map((internalReview) => this.emptyInteralReviewsOfAgendaitemThrottled.perform(internalReview));
await all(savePromises);
// TODO KAS-4886 this can go when we no longer have to save agendaitems
this.args.onStopLoading();
this.args.didApproveAgendaitems();
};

emptyInteralReviewsOfAgendaitemThrottled = task({ maxConcurrency: 5}, async (agendaitem) => {
const internalReview = await this.store.queryOne('submission-internal-review', {
'filter[subcase][agenda-activities][agendaitems][:id:]': agendaitem.id,
})
if (internalReview?.id && !isEmpty(internalReview.privateComment)) {
internalReview.privateComment = '';
return await internalReview.save();
}
// This property is still filled in as of now, we should empty it to avoid showing this briefly in agenda overview
// TODO KAS-4886 remove when property is removed from model
if (!isEmpty(agendaitem.privateComment)) {
agendaitem.privateComment = '';
return await agendaitem.save();
Copy link
Contributor

Choose a reason for hiding this comment

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

Could have some unintended effects on approved agendas that have a next version. Will need to implement an extra check here, or wait until https://kanselarij.atlassian.net/browse/KAS-4886 is done.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

fixed this by passing reverseSortedAgendas from args. We can use that to determine the latest agenda without awaiting. Improved check to also only allow the action on the latestAgenda.

}
});

@action
print() {
window.print();
Expand Down Expand Up @@ -463,4 +501,14 @@ export default class AgendaAgendaHeaderAgendaActions extends Component {
onChangeDownloadOption(selectedDownloadOption) {
this.downloadOption = selectedDownloadOption;
}

openConfirmEmptyInternalReviews = () => {
// TODO KAS-4886 this first line can go when we no longer have to save agendaitems
this.reloadAgendaitemsData.perform(); // Do we need to reload anything?? The interalreview may not be loaded yet, but the model itself cannot be stale
this.showConfirmEmptyInternalReviews = true;
};

cancelEmptyInternalReviews = () => {
this.showConfirmEmptyInternalReviews = false;
};
}
2 changes: 1 addition & 1 deletion app/controllers/newsletters/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ export default class NewslettersIndexController extends Controller {
const agendas = await meeting.agendas;
return agendas
?.slice()
.sort((a1, a2) => a1.serialNumber.localeCompare(a2.serialNumber))
.sort((a1, a2) => a1.serialnumber.localeCompare(a2.serialnumber))
Copy link
Contributor Author

Choose a reason for hiding this comment

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

this is sidetracking, should not be capital N. No errors ever came of this? latestAgenda could have been incorrect in this view

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I accidentally found where this has an effect.
right here (screenshot on PROD)
image

If there is more then 1 agenda version > no modified.
Only modified when there is only agenda A.
This should be fixed after merging this.

.reverse()
.at(0);
}
Expand Down
4 changes: 3 additions & 1 deletion translations/nl-be.json
Original file line number Diff line number Diff line change
Expand Up @@ -1485,5 +1485,7 @@
"press-agenda": "Persagenda",
"generate-press-agenda": "Genereer persagenda",
"login-text" : "Meld u aan",
"show-definitive-cases-only": "Toon enkel dossiers zonder definitieve goedkeuring"
"show-definitive-cases-only": "Toon enkel dossiers zonder definitieve goedkeuring",
"empty-internal-review": "Interne opmerkingen leegmaken",
"empty-internal-review-message": "Bent u zeker dat u alle interne opmerkingen voor de goedgekeurde agendapunten op deze agenda wil leegmaken?\nDeze actie kan niet ongedaan worden gemaakt.\nDe interne opmerkingen van nieuwe agendapunten blijven ongewijzigd."
}