Skip to content

Commit

Permalink
docs: changeset and minor cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
abeforgit committed Nov 24, 2023
1 parent d4da375 commit af202b9
Show file tree
Hide file tree
Showing 2 changed files with 60 additions and 18 deletions.
11 changes: 11 additions & 0 deletions .changeset/lazy-starfishes-drive.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
---
"frontend-gelinkt-notuleren": patch
---

correctly deal with the 2 types of versionedNotulen

- correctly show signatures even after document is published
- correctly show the full document when signing even if notulen is already published with some parts marked private (you always sign the whole document)
-> the page was showing the wrong document in the signing modal in
niche cases before, leading users to sign a different document than what they
were looking at
67 changes: 49 additions & 18 deletions app/controllers/meetings/publish/notulen.js
Original file line number Diff line number Diff line change
Expand Up @@ -122,57 +122,86 @@ export default class MeetingsPublishNotulenController extends Controller {
}

loadNotulen = task(async () => {
const fullNotulen = (await this.store.query('versioned-notulen', {
'filter[zitting][:id:]': this.model.id,
'filter[:or:][deleted]': false,
'filter[:or:][:has-no:deleted]': 'yes',
'filter[kind]': 'full',
}))[0];

const publicNotulen = (await this.store.query('versioned-notulen', {
'filter[zitting][:id:]': this.model.id,
'filter[:or:][deleted]': false,
'filter[:or:][:has-no:deleted]': 'yes',
'filter[kind]': 'public',
include: 'published-resource.gebruiker',
}))[0];
// this file is incredibly stateful, so we need to do silly things
// like this
this.publishedResource = undefined;
this.signedResources = [];

// published notulen have kind "public", meaning they only
// contain the public content
const publicNotulen = (
await this.store.query('versioned-notulen', {
'filter[zitting][:id:]': this.model.id,
'filter[:or:][deleted]': false,
'filter[:or:][:has-no:deleted]': 'yes',
'filter[kind]': 'public',
include: 'published-resource.gebruiker',
})
)[0];

if (publicNotulen) {
// the notulen have been published, so the final version is locked in
// it can still be signed, which should sign the full version
// the notulen have been published
const publishedResource = await publicNotulen.publishedResource;
if (publishedResource) {
// the else branch _should_ never happen, I don't know what to do
// if it does
this.publishedResource = publishedResource;
}
this.publicBehandelingUris = publicNotulen.publicBehandelingen || [];
this.notulen = publicNotulen;
} else {
try {
// generate a rendered document
const { content, errors } =
await this.createPrePublishedResource.perform();
// save it in a "placeholder" versioned-notulen instance
// note: this instance will never actually be saved using ember
// data, as we call the service that creates the final entry
// in the database. This is just done here for ????? reasons
// that predate me visiting this file.
const rslt = await this.store.createRecord('versioned-notulen', {
zitting: this.model,
content: content,
kind: 'public',
});
this.publishedResource = undefined;
this.signedResources = [];

this.notulen = rslt;
this.validationErrors = errors;
} catch (e) {
console.error(e);
this.errors = [e];
}
}
// signed notulen have kind "full", meaning they always
// contain the full content.
const fullNotulen = (
await this.store.query('versioned-notulen', {
'filter[zitting][:id:]': this.model.id,
'filter[:or:][deleted]': false,
'filter[:or:][:has-no:deleted]': 'yes',
'filter[kind]': 'full',
})
)[0];

if (fullNotulen) {
// load the signed resources. NOTE: we can't use relationships here,
// because we need to filter on the deleted property
const { signedNonDeletedResources, signedDeletedResources } =
await this.loadSignedResources(fullNotulen.id);

// store the rest of the needed state
this.signedResources = signedNonDeletedResources;
this.hasDeletedSignedResources =
!!signedDeletedResources.toArray().length;
this.fullNotulen = fullNotulen;
} else {
// this means there are no signatures
try {
// we generate another preview, independent from the one for
// publishing, so we are sure we're showing the user the actual
// content they will be signing, regardless of the publication state.
// e.g.: a document is published with agenda item contents kept private
// -> this will still show all the contents as they always sign everything
const { content, errors } =
await this.createPrePublishedResource.perform();
const rslt = await this.store.createRecord('versioned-notulen', {
Expand All @@ -188,6 +217,8 @@ export default class MeetingsPublishNotulenController extends Controller {
}
}

// publishing notulen also auto-publishes extracts of the agenda items
// marked as "public content", so we refresh those
if (this.status !== 'published') {
const treatments = await this.fetchTreatments.perform();
this.treatments = treatments;
Expand Down

0 comments on commit af202b9

Please sign in to comment.