diff --git a/app/components/form/form-form.hbs b/app/components/form/form-form.hbs index e71284722..762b398a7 100644 --- a/app/components/form/form-form.hbs +++ b/app/components/form/form-form.hbs @@ -1,10 +1,10 @@ @@ -26,9 +26,9 @@
{{#if question.isOpenQuestion}} - + {{else}} - + {{/if}}
@@ -39,14 +39,14 @@ diff --git a/app/components/form/form-form.js b/app/components/form/form-form.js index 038070ff0..16789f49b 100644 --- a/app/components/form/form-form.js +++ b/app/components/form/form-form.js @@ -1,31 +1,31 @@ import { inject as service } from '@ember/service'; -import Component from '@ember/component'; +import Component from '@glimmer/component'; +import { action } from '@ember/object'; -export const FormFormComponent = Component.extend({ - model: null, - store: service(), - actions: { - createQuestion(modelClass, fieldType) { - const form = this.model; - const position = form.get('sortedQuestions.lastObject.position') + 1 || 0; - this.store.createRecord(modelClass, { - form, - fieldType, - position, - required: true, - }); - }, - addOpenQuestion() { - this.send('createQuestion', 'form/open-question', 'text'); - }, - addClosedQuestion() { - this.send('createQuestion', 'form/closed-question', 'radio'); - }, - }, -}); +export default class FormFormComponent extends Component { + @service store; + get model() { + return this.args.model; + } -FormFormComponent.reopenClass({ - positionalParams: ['model'], -}); + createQuestion(modelClass, fieldType) { + const form = this.model; + const position = form.get('sortedQuestions.lastObject.position') + 1 || 0; + this.store.createRecord(modelClass, { + form, + fieldType, + position, + required: true, + }); + } -export default FormFormComponent; + @action + addOpenQuestion() { + this.createQuestion('form/open-question', 'text'); + } + + @action + addClosedQuestion() { + this.createQuestion('form/closed-question', 'radio'); + } +} diff --git a/app/components/form/response/open-question.hbs b/app/components/form/response/open-question.hbs index 9bdba5e97..5fd684411 100644 --- a/app/components/form/response/open-question.hbs +++ b/app/components/form/response/open-question.hbs @@ -1,20 +1,20 @@ -{{#if (eq question.fieldType 'textarea')}} +{{#if (eq @question.fieldType 'textarea')}} {{else}} {{/if}} \ No newline at end of file diff --git a/app/components/form/response/open-question.js b/app/components/form/response/open-question.js index d4f0d8f78..2c7e6d3ae 100644 --- a/app/components/form/response/open-question.js +++ b/app/components/form/response/open-question.js @@ -1,14 +1,7 @@ -import Component from '@ember/component'; -import { computed } from '@ember/object'; +import Component from '@glimmer/component'; -const OpenQuestionComponent = Component.extend({ - inputIdentifier: computed('question.id', function () { - return `question-${this.question.id}`; - }), -}); - -OpenQuestionComponent.reopenClass({ - positionalParams: ['question', 'answer'], -}); - -export default OpenQuestionComponent; +export default class OpenQuestionComponent extends Component { + get inputIdentifier() { + return `question-${this.args.question.id}`; + } +} diff --git a/app/components/form/response/response-card.hbs b/app/components/form/response/response-card.hbs index 84f053c9f..5f35765b5 100644 --- a/app/components/form/response/response-card.hbs +++ b/app/components/form/response/response-card.hbs @@ -1,25 +1,27 @@ -
-
-
Inschrijven
- {{form-opened-label form}} +
+
+
+
Inschrijven
+ {{form-opened-label @form}} +
-
-
-
- {{form/response/response-form form response}} +
+ + - - {{#if form.questions}} - - Annuleren - - Vragen met een * zijn verplicht - {{/if}} - - + + {{#if @form.questions}} + + Annuleren + + Vragen met een * zijn verplicht + {{/if}} + + +
\ No newline at end of file diff --git a/app/components/form/response/response-card.js b/app/components/form/response/response-card.js index 0e184c17f..2fa6f365c 100644 --- a/app/components/form/response/response-card.js +++ b/app/components/form/response/response-card.js @@ -1,45 +1,31 @@ -import Component from '@ember/component'; +import Component from '@glimmer/component'; import { inject as service } from '@ember/service'; +import { action } from '@ember/object'; +import { tracked } from '@glimmer/tracking'; -const FormResponseCardComponent = Component.extend({ - flashNotice: service('flash-notice'), - classNames: ['card'], - form: null, - response: null, - errorMessage: null, - actions: { - submitResponse() { - this.response - .saveWithAnswers() - .then(() => { - // The response is the first thing that is saved (in order to save answers), so currently the response is - // always 'incomplete'. Furthermore, the form has a field 'amountOfResponses' which should be updated. - // We now reload the response and the corresponding form. - this.response.reload(); - this.form.reload(); - this.flashNotice.sendSuccess('Inschrijving opgeslagen'); - }) - .catch((error) => { - this.set('errorMessage', error.message); - if ( - error.payload?.errors && - error.payload.errors.isAny( - 'source.pointer', - '/data/attributes/user' - ) - ) { - this.set( - 'errorMessage', - 'Er is al een response gevonden, probeer eerst te refreshen, zie je dit formulier dan nog? Neem dan contact op met de ict-commissie.' - ); - } - }); - }, - }, -}); +export default class FormResponseCardComponent extends Component { + @service flashNotice; + @tracked errorMessage = null; -FormResponseCardComponent.reopenClass({ - positionalParams: ['form', 'response'], -}); - -export default FormResponseCardComponent; + @action + async submitResponse() { + try { + await this.args.response.saveWithAnswers(); + // The response is the first thing that is saved (in order to save answers), so currently the response is + // always 'incomplete'. Furthermore, the form has a field 'amountOfResponses' which should be updated. + // We now reload the response and the corresponding form. + this.args.response.reload(); + this.args.form.reload(); + this.flashNotice.sendSuccess('Inschrijving opgeslagen'); + } catch (error) { + this.errorMessage = error.message; + if ( + error.payload?.errors && + error.payload.errors.isAny('source.pointer', '/data/attributes/user') + ) { + this.errorMessage = + 'Er is al een response gevonden, probeer eerst te refreshen, zie je dit formulier dan nog? Neem dan contact op met de ict-commissie.'; + } + } + } +} diff --git a/app/components/form/response/response-form.hbs b/app/components/form/response/response-form.hbs index e282ec966..08ffae72b 100644 --- a/app/components/form/response/response-form.hbs +++ b/app/components/form/response/response-form.hbs @@ -1,15 +1,13 @@ -{{#each form.sortedQuestions as |question|}} +{{#each @form.sortedQuestions as |question|}} {{#if question.isOpenQuestion}} - {{form/response/open-question - question - question.linkedAnswer - data-test-open-question=question.id - }} + {{else if question.isMultipleChoice}} {{form/response/multiple-choice-question question question.linkedAnswers - updateAnswers=(action 'updateMultipleChoiceAnswers') + updateAnswers=this.updateMultipleChoiceAnswers data-test-closed-question=question.id }} {{else}} diff --git a/app/components/form/response/response-form.js b/app/components/form/response/response-form.js index 0b51033b5..e745ec79d 100644 --- a/app/components/form/response/response-form.js +++ b/app/components/form/response/response-form.js @@ -1,46 +1,40 @@ import { inject as service } from '@ember/service'; -import Component from '@ember/component'; +import Component from '@glimmer/component'; +import { action } from '@ember/object'; -const FormResponseComponent = Component.extend({ - store: service(), - actions: { - updateMultipleChoiceAnswers(question, optionIds) { - setTimeout(() => { - const answers = question.get('linkedAnswers'); - const previousOptionIds = answers - .mapBy('option.id') - .rejectBy('isDeleted'); - const removedOptionIds = previousOptionIds.reject((id) => - optionIds.includes(id) - ); - const addedOptionIds = optionIds.reject((id) => - previousOptionIds.includes(id) - ); - - removedOptionIds.forEach((removedOptionId) => { - const removedAnswer = answers.findBy('option.id', removedOptionId); - answers.removeObject(removedAnswer); - removedAnswer.deleteRecord(); - }); +export default class FormResponseComponent extends Component { + @service store; + @action + updateMultipleChoiceAnswers(question, optionIds) { + setTimeout(() => { + const answers = question.get('linkedAnswers'); + const previousOptionIds = answers + .mapBy('option.id') + .rejectBy('isDeleted'); + const removedOptionIds = previousOptionIds.reject((id) => + optionIds.includes(id) + ); + const addedOptionIds = optionIds.reject((id) => + previousOptionIds.includes(id) + ); - addedOptionIds.forEach((addedOptionId) => { - const option = this.store.peekRecord( - 'form/closed-question-option', - addedOptionId - ); - const addedAnswer = this.store.createRecord( - 'form/closed-question-answer', - { response: this.response, option } - ); - answers.push(addedAnswer); - }); - }, 10); - }, - }, -}); + removedOptionIds.forEach((removedOptionId) => { + const removedAnswer = answers.findBy('option.id', removedOptionId); + answers.removeObject(removedAnswer); + removedAnswer.deleteRecord(); + }); -FormResponseComponent.reopenClass({ - positionalParams: ['form', 'response'], -}); - -export default FormResponseComponent; + addedOptionIds.forEach((addedOptionId) => { + const option = this.store.peekRecord( + 'form/closed-question-option', + addedOptionId + ); + const addedAnswer = this.store.createRecord( + 'form/closed-question-answer', + { response: this.args.response, option } + ); + answers.push(addedAnswer); + }); + }, 10); + } +} diff --git a/app/components/form/responses-table-card.hbs b/app/components/form/responses-table-card.hbs index 065fc9b78..8e58b3c36 100644 --- a/app/components/form/responses-table-card.hbs +++ b/app/components/form/responses-table-card.hbs @@ -1,17 +1,17 @@ -{{#if form.amountOfResponses}} +{{#if @form.amountOfResponses}}
Inschrijvingen
-
- {{form/responses-table - form - form.responses - showAllergyInfo=showAllergyInfo - }} +
{{else}} diff --git a/app/components/form/responses-table-card.js b/app/components/form/responses-table-card.js index 2cf9777f4..bf7d2cb6f 100644 --- a/app/components/form/responses-table-card.js +++ b/app/components/form/responses-table-card.js @@ -1,26 +1,22 @@ -import Component from '@ember/component'; +import Component from '@glimmer/component'; import { inject as service } from '@ember/service'; +import { action } from '@ember/object'; +import { tracked } from '@glimmer/tracking'; -const FormResponsesTableCardComponent = Component.extend({ - session: service('session'), - actions: { - copyUsernames() { - let usernames = this.form - .get('responses') - .map((response) => response.get('user.username')); - if (!this.form.currentUserResponseCompleted) { - usernames = usernames.filter( - (name) => name !== this.session.currentUser.username - ); - } - usernames = usernames.join('\n'); - navigator.clipboard.writeText(usernames); - }, - }, -}); - -FormResponsesTableCardComponent.reopenClass({ - positionalParams: ['form'], -}); - -export default FormResponsesTableCardComponent; +export default class FormResponsesTableCardComponent extends Component { + @service session; + @tracked showAllergyInfo = false; + @action + copyUsernames() { + let usernames = this.form + .get('responses') + .map((response) => response.get('user.username')); + if (!this.form.currentUserResponseCompleted) { + usernames = usernames.filter( + (name) => name !== this.session.currentUser.username + ); + } + usernames = usernames.join('\n'); + navigator.clipboard.writeText(usernames); + } +} diff --git a/app/components/forms/activity-form.hbs b/app/components/forms/activity-form.hbs index 66b21e1a5..2f9345ac1 100644 --- a/app/components/forms/activity-form.hbs +++ b/app/components/forms/activity-form.hbs @@ -3,7 +3,7 @@
{{if @model.isNew 'Activiteit aanmaken' 'Activiteit wijzigen'}}
-
+ {{#if @model.form.hasResponses}}
@@ -106,7 +106,7 @@
- {{form/form-form @model.form}} +
{{/if}} \ No newline at end of file diff --git a/app/components/forms/article-form.hbs b/app/components/forms/article-form.hbs index 337cefa2f..21db2fb95 100644 --- a/app/components/forms/article-form.hbs +++ b/app/components/forms/article-form.hbs @@ -3,7 +3,7 @@
{{if @model.isNew 'Artikel aanmaken' 'Artikel wijzigen'}}
- + - +
diff --git a/app/components/forms/book-form.hbs b/app/components/forms/book-form.hbs index a25f5efe7..605b4ca4b 100644 --- a/app/components/forms/book-form.hbs +++ b/app/components/forms/book-form.hbs @@ -3,7 +3,7 @@
{{if @model.isNew 'Boek aanmaken' 'Boek wijzigen'}}
-
+
- + - diff --git a/app/components/forms/group-form.hbs b/app/components/forms/group-form.hbs index ba0df553f..5ae7d5374 100644 --- a/app/components/forms/group-form.hbs +++ b/app/components/forms/group-form.hbs @@ -1,4 +1,4 @@ - +
Details
@@ -55,7 +55,7 @@ @errors={{@model.errors}} @errorMessage={{@errorMessage}} > - +
@@ -136,7 +136,7 @@ diff --git a/app/components/forms/mail-alias-form.hbs b/app/components/forms/mail-alias-form.hbs index 1dfbe9810..b0605c941 100644 --- a/app/components/forms/mail-alias-form.hbs +++ b/app/components/forms/mail-alias-form.hbs @@ -3,7 +3,7 @@

Details

- + - diff --git a/app/components/forms/mandate-form.hbs b/app/components/forms/mandate-form.hbs index 7b82e0187..653a06f23 100644 --- a/app/components/forms/mandate-form.hbs +++ b/app/components/forms/mandate-form.hbs @@ -3,7 +3,7 @@
{{if @model.isNew 'Mandaat aanmaken' 'Mandaat wijzigen'}}
- + - diff --git a/app/components/forms/photo-album-form.hbs b/app/components/forms/photo-album-form.hbs index 49c884a2b..fe13348ae 100644 --- a/app/components/forms/photo-album-form.hbs +++ b/app/components/forms/photo-album-form.hbs @@ -3,7 +3,7 @@
{{if @model.isNew 'Fotoalbum aanmaken' 'Fotoalbum wijzigen'}}
- + - diff --git a/app/components/forms/poll-form.hbs b/app/components/forms/poll-form.hbs index 99a18a931..106a15dcb 100644 --- a/app/components/forms/poll-form.hbs +++ b/app/components/forms/poll-form.hbs @@ -3,7 +3,7 @@
{{if @model.isNew 'Poll aanmaken' 'Poll wijzigen'}}
- +
- +
- + {{if @model.isNew 'Infopagina aanmaken' 'Infopagina wijzigen'}}
- + - diff --git a/app/components/forms/thread-form.hbs b/app/components/forms/thread-form.hbs index c82311975..4d9aa98e4 100644 --- a/app/components/forms/thread-form.hbs +++ b/app/components/forms/thread-form.hbs @@ -3,7 +3,7 @@
{{if @model.isNew 'Topic aanmaken' 'Topic wijzigen'}}
- +
- + - diff --git a/app/components/forms/user-form.hbs b/app/components/forms/user-form.hbs index ef0d1e97f..83a517210 100644 --- a/app/components/forms/user-form.hbs +++ b/app/components/forms/user-form.hbs @@ -1,4 +1,4 @@ - +
Publieke gegevens

Deze gegevens zijn zichtbaar voor alle leden en oud-leden.

- diff --git a/app/components/forms/vacancy-form.hbs b/app/components/forms/vacancy-form.hbs index 60786d489..a156b900b 100644 --- a/app/components/forms/vacancy-form.hbs +++ b/app/components/forms/vacancy-form.hbs @@ -3,7 +3,7 @@
{{if @model.isNew 'Vacature aanmaken' 'Vacature wijzigen'}}
- +
- @@ -97,7 +97,7 @@ /> - Sluiten - Invoegen + Sluiten + Invoegen \ No newline at end of file diff --git a/app/components/model-form/file-input.hbs b/app/components/model-form/file-input.hbs index a9c2dc03a..8f714617c 100644 --- a/app/components/model-form/file-input.hbs +++ b/app/components/model-form/file-input.hbs @@ -2,7 +2,7 @@ {{label}}{{if required ' *'}}
- {{#let (file-queue name="fileUpload" onFileAdded=(action 'fileLoaded')) as |queue|}} + {{#let (file-queue name="fileUpload" onFileAdded=fileLoaded) as |queue|}}