Skip to content

Commit

Permalink
Merge pull request #162 from lblod/bugfix/sign-and-publish
Browse files Browse the repository at this point in the history
BUGFIX: now you can sign and publish the same document and will be shown as such
  • Loading branch information
abeforgit authored Aug 18, 2021
2 parents 80c6d73 + 674d765 commit 3999721
Show file tree
Hide file tree
Showing 9 changed files with 67 additions and 21 deletions.
2 changes: 2 additions & 0 deletions app/components/signatures/agenda/timeline-step.hbs
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
<Signatures::TimelineStep
@name={{@name}}
@document={{@agenda}}
@signedResources={{@agenda.signedResources}}
@publishedResource={{@agenda.publishedResource}}
@signing={{@signing}}
@publish={{@publish}}
@mockDocument={{this.mockAgenda}}
Expand Down
2 changes: 2 additions & 0 deletions app/components/signatures/behandeling/timeline-step.hbs
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
<Signatures::TimelineStep
@name={{@name}}
@document={{@extract.document}}
@signedResources={{@extract.document.signedResources}}
@publishedResource={{@extract.document.publishedResource}}
@errors={{@extract.errors}}
@signing={{@signing}}
@publish={{@publish}}
Expand Down
2 changes: 2 additions & 0 deletions app/components/signatures/besluitenlijst/timeline-step.hbs
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
<Signatures::TimelineStep
@name={{@name}}
@document={{@lijst}}
@signedResources={{@lijst.signedResources}}
@publishedResource={{@lijst.publishedResource}}
@errors={{@errors}}
@signing={{@signing}}
@publish={{@publish}}
Expand Down
3 changes: 2 additions & 1 deletion app/components/signatures/notulen/timeline-step.hbs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
<Signatures::TimelineStep
@name={{@name}}
@document={{@notulen}}
@signedResources={{@signedResources}}
@publishedResource={{@publishedResource}}
@errors={{@errors}}
@signing={{@signing}}
@publish={{@publish}}
Expand Down
10 changes: 5 additions & 5 deletions app/components/signatures/timeline-step.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@
</AuToolbar>
<div class="au-o-grid au-u-margin-top-none au-u-margin-bottom-large">
{{#if (eq this.signaturesCount 2)}}
{{#each @document.signedResources as |signature index|}}
{{#each @signedResources as |signature index|}}
{{#if (eq index 0)}}
<div class="au-o-grid__item au-u-1-2@medium au-u-padding-bottom-none au-u-padding-bottom-small">
<AuHeading @level="3" @skin="6" class="au-u-margin-bottom-tiny">{{t "timelineStep.firstSignature"}}</AuHeading>
Expand All @@ -68,7 +68,7 @@
{{else if (eq this.signaturesCount 1)}}
<div class="au-o-grid__item au-u-1-2@medium au-u-padding-top-none au-u-padding-bottom-small">
<AuHeading @level="3" @skin="6" class="au-u-margin-bottom-tiny">{{t "timelineStep.firstSignature"}}</AuHeading>
<Signatures::SignedResource @signature={{@document.signedResources.firstObject}} />
<Signatures::SignedResource @signature={{@signedResources.firstObject}} />
</div>
<div class="au-o-grid__item au-u-1-2@medium au-u-padding-top-none au-u-padding-bottom-small">
<AuHeading @level="3" @skin="6" class="au-u-margin-bottom-tiny">{{t "timelineStep.secondSignature"}}</AuHeading>
Expand Down Expand Up @@ -164,15 +164,15 @@
<AuHeading @level="2" @skin="4">{{t "timelineStep.publishButtonLabel" name=@name}}</AuHeading>
</AuToolbarGroup>
<AuToolbarGroup>
<AuPill @skin={{if @document.publishedResource "success"}} class="au-u-margin-left">
{{if @document.publishedResource "Publiek" "Niet publiek"}}
<AuPill @skin={{if @publishedResource "success"}} class="au-u-margin-left">
{{if @publishedResource "Publiek" "Niet publiek"}}
</AuPill>
</AuToolbarGroup>
</AuToolbar>
<div class="au-o-grid au-u-margin-top-none">
{{#if this.isPublished}}
<div class="au-o-grid__item au-u-1-2@medium au-u-padding-top-none">
<Signatures::PublishedResource @publication={{@document.publishedResource}} />
<Signatures::PublishedResource @publication={{@publishedResource}} />
</div>
<div class="au-o-grid__item au-u-1-2@medium au-u-padding-top-none">
<AuHeading @level="3" @skin="6" class="au-u-margin-bottom-tiny">{{t "timelineStep.linkPublish"}}</AuHeading>
Expand Down
10 changes: 5 additions & 5 deletions app/components/signatures/timeline-step.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,8 @@ export default class SignaturesTimelineStep extends Component {
}

get isPublished() {
if(this.args.document && this.args.document.publishedResource) {
return !! this.args.document.publishedResource.get("id");
if(this.args.publishedResource) {
return !! this.args.publishedResource.get("id");
}
return false;
}
Expand All @@ -53,8 +53,8 @@ export default class SignaturesTimelineStep extends Component {
this.bestuurseenheid = this.currentSession.group;
const currentUser = this.currentSession.user;
let firstSignatureUser = null;
if (this.args.document) {
const signedResources = yield this.args.document.signedResources;
if (this.args.signedResources) {
const signedResources = yield this.args.signedResources;
if (signedResources.length > 0) {
this.signedResources = signedResources.sortBy('createdOn');
firstSignatureUser = yield signedResources.firstObject.gebruiker;
Expand Down Expand Up @@ -133,7 +133,7 @@ export default class SignaturesTimelineStep extends Component {
this.showSigningModal = false;
this.isSignedByCurrentUser = true;
yield this.args.signing(signedId);
const signedResources = yield this.args.document.signedResources;
const signedResources = yield this.args.signedResources;
this.signedResources = signedResources.sortBy('createdOn');
}

Expand Down
54 changes: 44 additions & 10 deletions app/controllers/meetings/publish/notulen.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { inject as service } from '@ember/service';
import Controller from '@ember/controller';
import {task} from "ember-concurrency";
import {tracked} from "@glimmer/tracking";
Expand All @@ -8,10 +9,13 @@ export default class MeetingsPublishNotulenController extends Controller {

@tracked notulen;
@tracked errors;
@tracked signedResources = [];
@tracked publishedResource;

behandelingContainerId = 'behandeling-van-agendapunten-container';
@tracked publicBehandelingUris = [];
@tracked behandelings;
@service publish;

constructor() {
super(...arguments);
Expand All @@ -24,19 +28,34 @@ export default class MeetingsPublishNotulenController extends Controller {

@task
* initializeNotulen() {
const notulen = yield this.store.query('versioned-notulen',{
const versionedNotulens = yield this.store.query('versioned-notulen',{
'filter[zitting][:id:]': this.model.id,
include: 'signed-resources,published-resource'
});
if(notulen.length) {
this.notulen = notulen.firstObject;
this.publicBehandelingUris = notulen.firstObject.publicBehandelingen;
if(versionedNotulens.length) {
yield Promise.all(versionedNotulens.map(async (notulen) => {
const publishedResource = await notulen.publishedResource;
const signedResources = await notulen.signedResources;
if(publishedResource) {
this.publishedResource = publishedResource;
this.publicBehandelingUris = notulen.publicBehandelingen || [];
this.notulen = notulen;
}
if(signedResources.length) {
this.signedResources = signedResources;
if(!this.notulen) {
this.notulen = notulen;
}
}
}));
} else {
const {content, errors} = yield this.createPrePublishedResource.perform();
const rslt = yield this.store.createRecord("versioned-notulen", {
zitting: this.model,
content: content
});
this.publishedResource = undefined;
this.signedResources = [];
this.notulen = rslt;
this.errors = errors;
}
Expand All @@ -46,12 +65,28 @@ export default class MeetingsPublishNotulenController extends Controller {

@task
*reloadNotulen() {
const notulen = yield this.store.query('versioned-notulen',{
const versionedNotulens = yield this.store.query('versioned-notulen',{
'filter[zitting][:id:]': this.model.id,
include: 'signed-resources,published-resource'
});
this.notulen = notulen.firstObject;
this.publicBehandelingUris = notulen.firstObject.publicBehandelingen;
if(versionedNotulens.length) {
yield Promise.all(versionedNotulens.map(async (notulen) => {
const publishedResource = await notulen.publishedResource;
const signedResources = await notulen.signedResources;
if(publishedResource) {
this.publishedResource = publishedResource;
this.publicBehandelingUris = notulen.publicBehandelingen || [];
this.notulen = notulen;
}
if(signedResources.length) {
this.signedResources = signedResources;
if(!this.notulen) {
this.notulen = notulen;
}
}
}));
}

const behandelings = yield this.fetchBehandelings.perform();
this.behandelings = behandelings;
}
Expand All @@ -68,10 +103,9 @@ export default class MeetingsPublishNotulenController extends Controller {
@task
*fetchBehandelings() {
const id = this.model.id;
const response = yield fetch(`/prepublish/behandelingen/${id}`);
const json = yield response.json();
const response = yield this.publish.fetchTreatmentPreviews(id);

return json.map((response) => response.data.attributes);
return response.map((res) => res.data.attributes);
}

@task
Expand Down
3 changes: 3 additions & 0 deletions app/services/publish.js
Original file line number Diff line number Diff line change
Expand Up @@ -135,4 +135,7 @@ export default class PublishService extends Service {
return await resp.json();
}
}
async fetchTreatmentPreviews(meetingId) {
return this.pollForPrepublisherResults(meetingId);
}
}
2 changes: 2 additions & 0 deletions app/templates/meetings/publish/notulen.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
<Signatures::Notulen::TimelineStep
@name="notulen"
@notulen={{this.notulen}}
@publishedResource={{this.publishedResource}}
@signedResources={{this.signedResources}}
@errors={{this.errors}}
@publicBehandelingUris={{this.publicBehandelingUris}}
@behandelings={{this.behandelings}}
Expand Down

0 comments on commit 3999721

Please sign in to comment.