From 8ede03b60457a16c19585f706ee19e48150cec8c Mon Sep 17 00:00:00 2001 From: jelhan Date: Mon, 22 Feb 2016 23:42:01 +0100 Subject: [PATCH] Fix: Date was not shown if there were multiple best options --- app/components/poll-evaluation-summary.js | 12 ++++++++++-- .../components/poll-evaluation-summary.hbs | 14 +++----------- 2 files changed, 13 insertions(+), 13 deletions(-) diff --git a/app/components/poll-evaluation-summary.js b/app/components/poll-evaluation-summary.js index 53287b0..99d70fa 100644 --- a/app/components/poll-evaluation-summary.js +++ b/app/components/poll-evaluation-summary.js @@ -1,4 +1,5 @@ import Ember from 'ember'; +import moment from 'moment'; export default Ember.Component.extend({ classNames: ['evaluation-summary'], @@ -72,9 +73,16 @@ export default Ember.Component.extend({ bestOptions.forEach((bestOption, i) => { if (this.get('poll.isFindADate')) { - bestOptions[i].title = this.get('dates')[bestOption.key].title; + const date = this.get(`dates.${bestOption.key}`); + const format = date.hasTime ? 'LLLL' : moment.localeData() + .longDateFormat('LLLL') + .replace( + moment.localeData().longDateFormat('LT'), '') + .trim(); + bestOptions[i].title = date.title.format(format); } else { - bestOptions[i].title = this.get('poll.options')[bestOption.key].title; + const option = this.get(`poll.options.${bestOption.key}`); + bestOptions[i].title = option.get('title'); } }); diff --git a/app/templates/components/poll-evaluation-summary.hbs b/app/templates/components/poll-evaluation-summary.hbs index bd9d7c1..540d814 100644 --- a/app/templates/components/poll-evaluation-summary.hbs +++ b/app/templates/components/poll-evaluation-summary.hbs @@ -15,13 +15,9 @@ {{#if evaluationBestOptionsMultiple}} {{else}} - {{#if poll.isFindADate}} - {{formattedDate evaluationBestOptions.[0].title times=poll.isDateTime}}. - {{else}} - {{evaluationBestOptions.[0].title}}. - {{/if}} + {{evaluationBestOptions.[0].title}}. {{#if poll.isFindADate}} {{#if evaluationBestOptions.[0].answers.yes}}