From 2e128e3c3ce8607a41fd23689e67dc36146963b1 Mon Sep 17 00:00:00 2001 From: jelhan Date: Mon, 27 Jun 2016 12:53:05 +0200 Subject: [PATCH] Fix: confusing validation present error for answer selection in poll participation --- app/controllers/poll/participation.js | 12 ++++++++++-- app/locales/de/translations.js | 1 + app/locales/en/translations.js | 1 + app/locales/es/translations.js | 1 + 4 files changed, 13 insertions(+), 2 deletions(-) diff --git a/app/controllers/poll/participation.js b/app/controllers/poll/participation.js index c39f5fb..5b8deb3 100644 --- a/app/controllers/poll/participation.js +++ b/app/controllers/poll/participation.js @@ -55,7 +55,14 @@ const SelectionValidations = buildValidations({ return true; } }, - dependentKeys: ['forceAnswer', 'i18n.locale'] + messageKey() { + if (this.get('model.isFreeText')) { + return 'errors.present'; + } else { + return 'errors.present.answer.selection'; + } + }, + dependentKeys: ['isFreeText', 'forceAnswer', 'i18n.locale'] }) }); @@ -204,9 +211,10 @@ export default Ember.Controller.extend(Validations, { return Ember.Object.extend(SelectionValidations, { container, - // force Answer must be included in model + // forceAnswer and isFreeText must be included in model // cause otherwise validations can't depend on it forceAnswer: this.get('forceAnswer'), + isFreeText: this.get('isFreeText'), // a little bit hacky // wasn't able to observe moment.locale since it should be in sync diff --git a/app/locales/de/translations.js b/app/locales/de/translations.js index 517cc2f..69b4f45 100644 --- a/app/locales/de/translations.js +++ b/app/locales/de/translations.js @@ -101,6 +101,7 @@ export default { empty: '{{description}} darf nicht leer sein', blank: '{{description}} darf nicht leer sein', present: '{{description}} muss leer sein', + 'present.answer.selection': 'Eine Antwort muss ausgewählt sein', collection: '{{description}} muss eine Sammlung sein', singular: '{{description}} darf keine Sammlung sein', tooLong: '{{description}} ist zu lang (maximal {{max}} Zeichen)', diff --git a/app/locales/en/translations.js b/app/locales/en/translations.js index 9c6ab05..8e68747 100644 --- a/app/locales/en/translations.js +++ b/app/locales/en/translations.js @@ -101,6 +101,7 @@ export default { empty: '{{description}} must not be empty', blank: '{{description}} must not be empty', present: '{{description}} must be empty', + 'present.answer.selection': 'An answer must be selected', collection: '{{description}} must be a collection', singular: '{{description}} must not be a collection', tooLong: '{{description}} is too long (maxl {{max}} characters)', diff --git a/app/locales/es/translations.js b/app/locales/es/translations.js index f724c7b..8ddc8f5 100644 --- a/app/locales/es/translations.js +++ b/app/locales/es/translations.js @@ -101,6 +101,7 @@ export default { empty: '{{description}} can\'t be empty', blank: '{{description}} can\'t be blank', present: '{{description}} must be blank', + 'present.answer.selection': 'An answer must be selected', collection: '{{description}} must be a collection', singular: '{{description}} can\'t be a collection', tooLong: '{{description}} is too long (maximum is {{max}} characters)',