Skip to content

Commit

Permalink
Merge pull request #732 from lblod/feat/manual-voting
Browse files Browse the repository at this point in the history
Feat/manual voting
  • Loading branch information
abeforgit authored Nov 12, 2024
2 parents b9d55ec + fa0d8af commit a008aaf
Show file tree
Hide file tree
Showing 19 changed files with 645 additions and 157 deletions.
5 changes: 5 additions & 0 deletions .changeset/moody-dodos-care.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'frontend-gelinkt-notuleren': minor
---

Add a way of adding a custom voting
82 changes: 48 additions & 34 deletions app/components/behandeling-van-agendapunt.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -48,25 +48,26 @@
</AuPill>
{{/if}}
</AuToolbar>
<Common::MeetingSubSection
@title={{t 'behandeling-van-agendapunten.visibility'}}
>
<:body>
<div class='au-u-padding-tiny'>
<AuPill @skin='border'>
{{#if this.openbaar}}
{{t 'behandeling-van-agendapunten.openbaar-msg'}}
{{else}}
{{t 'behandeling-van-agendapunten.geen-openbaar-msg'}}
{{/if}}
</AuPill>
</div>
</:body>
</Common::MeetingSubSection>
{{#unless @focusMode}}
<Common::MeetingSubSection
@title={{t 'behandeling-van-agendapunten.visibility'}}
>
<:body>
<div class='au-u-padding-tiny'>
<AuPill @skin='border'>
{{#if this.openbaar}}
{{t 'behandeling-van-agendapunten.openbaar-msg'}}
{{else}}
{{t 'behandeling-van-agendapunten.geen-openbaar-msg'}}
{{/if}}
</AuPill>
</div>
</:body>
</Common::MeetingSubSection>
{{/unless}}
</div>

{{/if}}

{{#unless @focusMode}}
{{#if this.isLoading}}
<AuLoader @padding='small' />
Expand All @@ -93,7 +94,6 @@
}}
/>
{{/if}}

<Common::MeetingSubSection
@title={{t 'behandeling-van-agendapunten.voting-title'}}
>
Expand All @@ -116,23 +116,37 @@
</:body>
<:button>
{{#unless @readOnly}}
<AuButton
{{on 'click' (perform this.addStemming)}}
@icon='add'
@skin='secondary'
@iconAlignment='left'
@loading={{this.addStemming.isRunning}}
>
{{t 'generic.add'}}
</AuButton>
{{#if this.editMode}}
<Treatment::Voting::Edit
@bestuursorgaan={{@bestuursorgaan}}
@onSave={{perform this.saveStemming}}
@onCancel={{this.onCancelEdit}}
@saving={{this.saveStemming.isRunning}}
/>
{{/if}}
<div>

<AuButton
{{on 'click' (perform this.addStandardVoting)}}
@icon='add'
@skin='secondary'
@iconAlignment='left'
@disabled={{not (and this.hasParticipants this.editable)}}
@loading={{this.addStandardVoting.isRunning}}
>
{{t 'generic.add'}}
</AuButton>
<AuButton
{{on 'click' (perform this.addCustomVoting)}}
@icon='add'
@skin='secondary'
@iconAlignment='left'
@disabled={{not (and this.hasParticipants this.editable)}}
@loading={{this.addCustomVoting.isRunning}}
>
{{t 'behandeling-van-agendapunten.add-custom-voting'}}
</AuButton>
{{#if this.editMode}}
<Treatment::Voting::Edit
@bestuursorgaan={{@bestuursorgaan}}
@onSave={{perform this.saveStemming}}
@onCancel={{this.onCancelEdit}}
@saving={{this.saveStemming.isRunning}}
/>
{{/if}}
</div>
{{/unless}}
</:button>
</Common::MeetingSubSection>
Expand Down
34 changes: 33 additions & 1 deletion app/components/behandeling-van-agendapunt.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import { use } from 'ember-could-get-used-to-this';
import RelationshipResource from '../helpers/relationship-resource';
import { trackedFunction } from 'reactiveweb/function';
import InstallatieVergaderingModel from '../models/installatievergadering';
import { PLANNED_STATUS_ID } from 'frontend-gelinkt-notuleren/utils/constants';

/** @typedef {import("../models/mandataris").default} Mandataris */
/** @typedef {import("../models/behandeling-van-agendapunt").default} Behandeling */
Expand All @@ -23,6 +24,7 @@ import InstallatieVergaderingModel from '../models/installatievergadering';
export default class BehandelingVanAgendapuntComponent extends Component {
@service store;
@service router;
@service intl;
@tracked document;
@tracked editor;
@tracked published = false;
Expand All @@ -31,6 +33,8 @@ export default class BehandelingVanAgendapuntComponent extends Component {

@tracked editMode = false;
@service editStemming;
@service documentService;
@service currentSession;

/** @type {RelationshipResourceValue} */
@use meetingChairmanData = new RelationshipResource(() => [
Expand Down Expand Up @@ -201,7 +205,7 @@ export default class BehandelingVanAgendapuntComponent extends Component {
this.onCancelEdit();
});

addStemming = task(async () => {
addStandardVoting = task(async () => {
// high pagesize is set on the model, so this is fine
const participants = await this.args.behandeling.aanwezigen;

Expand All @@ -218,4 +222,32 @@ export default class BehandelingVanAgendapuntComponent extends Component {
stemmingToEdit.stemmers.pushObjects(participants);
this.editStemming.stemming = stemmingToEdit;
});

addCustomVoting = task(async () => {
const container = this.store.createRecord('document-container');
container.status = await this.store.findRecord(
'concept',
PLANNED_STATUS_ID,
);
container.folder = await this.store.findRecord(
'editor-document-folder',
'39fa1367-93dc-4025-af7b-4db8c7029dc3',
);
container.publisher = this.currentSession.group;
const editorDocument =
await this.documentService.createEditorDocument.perform(
this.intl.t('custom-voting.document-title'),
'',
container,
);
container.currentVersion = editorDocument;
await container.save();
const stemmingToEdit = this.store.createRecord('custom-voting', {
votingDocument: container,
behandelingVanAgendapunt: this.args.behandeling,
position: this.behandeling.sortedVotings.length,
});
await stemmingToEdit.save();
this.router.transitionTo('meetings.edit.custom-voting', stemmingToEdit.id);
});
}
178 changes: 113 additions & 65 deletions app/components/treatment/voting/modal.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -31,75 +31,123 @@
<tbody>
{{#if this.stemmingen.length}}
{{#each this.stemmingen as |stemming|}}
<tr>
<td style='max-width: 30rem;'>
{{#if stemming.onderwerp}}
{{stemming.onderwerp}}
{{else}}
<AuHelpText @size='normal' @skin='link'>
{{t 'voting-modal.subject-not-found'}}
</AuHelpText>
{{/if}}
</td>
<td>
{{#if stemming.geheim}}
<AuHelpText @size='normal'>
{{t 'voting-modal.geheim-true-label'}}
</AuHelpText>
{{else}}
<AuHelpText @size='normal'>
{{t 'voting-modal.geheim-false-label'}}
</AuHelpText>
{{/if}}
</td>
<td>
<p class='au-c-help-text au-c-help-text--normal'>
{{t 'voting-modal.aantal-voorstanders-label'}}
<strong>{{stemming.aantalVoorstanders}}</strong>
</p>
<p class='au-c-help-text au-c-help-text--normal'>
{{t 'voting-modal.aantal-tegenstanders-label'}}
<strong>{{stemming.aantalTegenstanders}}</strong>
</p>
<p class='au-c-help-text au-c-help-text--normal'>
{{t 'voting-modal.aantal-onthouders-label'}}
<strong>{{stemming.aantalOnthouders}}</strong>
</p>
</td>
<td style='max-width: 30rem;'>
{{#if stemming.gevolg}}
{{stemming.gevolg}}
{{else}}
<AuHelpText @size='normal' @skin='link'>{{t
'voting-modal.gevolg-not-found'
}}</AuHelpText>
{{/if}}
</td>
{{#unless @readOnly}}
{{#if (this.isStandardVoting stemming)}}
<tr>
<td style='max-width: 30rem;'>
{{#if stemming.onderwerp}}
{{stemming.onderwerp}}
{{else}}
<AuHelpText @size='normal' @skin='link'>
{{t 'voting-modal.subject-not-found'}}
</AuHelpText>
{{/if}}
</td>
<td>
{{#if stemming.geheim}}
<AuHelpText @size='normal'>
{{t 'voting-modal.geheim-true-label'}}
</AuHelpText>
{{else}}
<AuHelpText @size='normal'>
{{t 'voting-modal.geheim-false-label'}}
</AuHelpText>
{{/if}}
</td>
<td>
<p class='au-c-help-text au-c-help-text--normal'>
{{t 'voting-modal.aantal-voorstanders-label'}}
<strong>{{stemming.aantalVoorstanders}}</strong>
</p>
<p class='au-c-help-text au-c-help-text--normal'>
{{t 'voting-modal.aantal-tegenstanders-label'}}
<strong>{{stemming.aantalTegenstanders}}</strong>
</p>
<p class='au-c-help-text au-c-help-text--normal'>
{{t 'voting-modal.aantal-onthouders-label'}}
<strong>{{stemming.aantalOnthouders}}</strong>
</p>
</td>
<td style='max-width: 30rem;'>
{{#if stemming.gevolg}}
{{stemming.gevolg}}
{{else}}
<AuHelpText @size='normal' @skin='link'>{{t
'voting-modal.gevolg-not-found'
}}</AuHelpText>
{{/if}}
</td>
{{#unless @readOnly}}
<td class='au-u-table-right'>
<AuButtonGroup>
<AuButton
{{on 'click' (fn this.toggleEditStemming stemming)}}
@skin='secondary'
@icon='pencil'
@iconAlignment='left'
>
{{t 'voting-modal.toggle-edit-button'}}
</AuButton>
<AuButton
{{on 'click' (fn (perform this.removeStemming) stemming)}}
@skin='secondary'
@alert={{true}}
@icon='bin'
@iconAlignment='left'
@loading={{this.removeStemming.isRunning}}
>
{{t 'voting-modal.delete-button'}}
</AuButton>
</AuButtonGroup>
</td>
{{/unless}}
</tr>
{{else}}
<tr>
<td colspan='4'>
{{stemming.votingDocument.currentVersion.title}}
</td>

<td class='au-u-table-right'>

<AuButtonGroup>
<AuButton
{{on 'click' (fn this.toggleEditStemming stemming)}}
@skin='secondary'
@icon='pencil'
@iconAlignment='left'
>
{{t 'voting-modal.toggle-edit-button'}}
</AuButton>
<AuButton
{{on 'click' (fn (perform this.removeStemming) stemming)}}
@skin='secondary'
@alert={{true}}
@icon='bin'
@iconAlignment='left'
@loading={{this.removeStemming.isRunning}}
>
{{t 'voting-modal.delete-button'}}
</AuButton>
{{#if @readOnly}}
<AuLink
@route='meetings.edit.custom-voting'
@model={{stemming.id}}
@skin='button-secondary'
@icon='eye'
@iconAlignment='left'
>
{{t 'voting-modal.show-button'}}
</AuLink>
{{else}}
{{#unless stemming.isNew}}
<AuLink
@route='meetings.edit.custom-voting'
@model={{stemming.id}}
@skin='button-secondary'
@icon='pencil'
@iconAlignment='left'
>
{{t 'voting-modal.toggle-edit-button'}}
</AuLink>
<AuButton
{{on 'click' (fn (perform this.removeStemming) stemming)}}
@skin='secondary'
@alert={{true}}
@icon='bin'
@iconAlignment='left'
@loading={{this.removeStemming.isRunning}}
>
{{t 'voting-modal.delete-button'}}
</AuButton>
{{/unless}}
{{/if}}
</AuButtonGroup>
</td>
{{/unless}}
</tr>

</tr>
{{/if}}
{{else}}
<tr>
<td colspan='5'>
Expand Down
3 changes: 3 additions & 0 deletions app/components/treatment/voting/modal.js
Original file line number Diff line number Diff line change
Expand Up @@ -78,4 +78,7 @@ export default class TreatmentVotingModalComponent extends Component {
this.editStemming.stemming.rollbackAttributes();
this.editStemming.stemming = null;
}
isStandardVoting(voting) {
return voting.constructor.modelName === 'stemming';
}
}
Loading

0 comments on commit a008aaf

Please sign in to comment.