From 533f70b5eecbaba63f0bd290849f55252573e4c5 Mon Sep 17 00:00:00 2001 From: jelhan Date: Thu, 23 Oct 2014 17:55:04 +0200 Subject: [PATCH] visibilty as a view property + missing translations --- app/controllers/poll.js | 2 +- app/lang/translations.js | 2 ++ app/templates/poll.hbs | 47 ++++++++++++++++++++-------------------- app/views/poll.js | 29 ++++++++++++++++++++----- 4 files changed, 49 insertions(+), 31 deletions(-) diff --git a/app/controllers/poll.js b/app/controllers/poll.js index c0aefec..4b708dd 100644 --- a/app/controllers/poll.js +++ b/app/controllers/poll.js @@ -216,7 +216,7 @@ export default Ember.ObjectController.extend(Ember.Validations.Mixin, { } } }, - + /* * have to manually rerun validation when encryption key is present in model * otherwise ember-validation is not using correct values for properties in diff --git a/app/lang/translations.js b/app/lang/translations.js index 38c1890..99a31f8 100644 --- a/app/lang/translations.js +++ b/app/lang/translations.js @@ -54,6 +54,7 @@ export default { "index.hoster.text": "You don't have to trust our server. You could easily host croodle yourself. All you need is a web space with PHP and SSL encryption enabled. You find the source code and installation instructions on GitHub.", "poll.created-time": "created on {{creationDate}}", "poll.evaluation.label": "Evaluation", + "poll.input.newUserName.placeholder": "Enter your name...", "poll.save": "save", "poll.share": "Share the link and invite other people to participate in your poll.", "poll.share.notice": "Everyone who knows the link could read the data. If your poll consists private data you may only share the link via encrypted channels like PGP encrypted email or instant messaging with OTR." @@ -113,6 +114,7 @@ export default { "index.hoster.text": "Du musst uns nicht vertrauen. Du kannst Croodle einfach auf deinem eigenen Server installieren. Ein Server mit einigen Megabyte Speicherplatz, PHP und SSL-Verschlüsselung ist ausreichend. Den Programmcode und Installationsanweisungen findest du auf GitHub.", "poll.created-time": "Erstellt am {{creationDate}}.", "poll.evaluation.label": "Auswertung", + "poll.input.newUserName.placeholder": "de: Enter your name...", "poll.save": "speichern", "poll.share": "Gib den Link weiter und lade so Andere zu deiner Umfrage ein.", "poll.share.notice": "Jeder, der den Link kennt, kann die Daten deiner Umfrage lesen. Falls deine Umfrage private Daten enthält, überlege dir, ob du ihn nur per verschlüsselter Mail oder Chat mit End-to-End-Verschlüsselung weitergeben möchtest." diff --git a/app/templates/poll.hbs b/app/templates/poll.hbs index 59b79cd..8419089 100644 --- a/app/templates/poll.hbs +++ b/app/templates/poll.hbs @@ -45,19 +45,16 @@ - {{! ToDo: - should be all together in just one form; - not in several forms for each input. - This work-around is due to a problem of - ember-forms in dealing with propertys of - handlebar each helper - }} {{#form-for controller}} - {{input newUserName - label=" " - placeholder="Enter your name..." - }} + {{#input newUserName}} + {{input-field newUserName + placeholderTranslation="poll.input.newUserName.placeholder" + }} + {{#if view.showError}} + {{error-field newUserName}} + {{/if}} + {{/input}} {{/form-for}} {{#each newUserSelection in controller.newUserSelections}} @@ -112,25 +109,27 @@ {{#unless isFreeText}} - {{t "poll.evaluation.label"}} + {{t "poll.evaluation.label"}} - {{#each answer in evaluation}} - - - {{answer.label}} - - - {{#each option in answer.options}} + {{#if view.showEvaluation}} + {{#each answer in evaluation}} + - {{option}} + {{answer.label}} - {{/each}} -   - - {{/each}} + {{#each option in answer.options}} + + {{option}} + + {{/each}} + +   + + {{/each}} + {{/if}} {{/unless}} diff --git a/app/views/poll.js b/app/views/poll.js index b38915a..32fabb5 100644 --- a/app/views/poll.js +++ b/app/views/poll.js @@ -1,13 +1,30 @@ export default Ember.View.extend({ + showEvaluation: false, + + actions: { + switchEvaluationVisibility: function() { + if (this.get('showEvaluation') === true) { + this.set('showEvaluation', false); + } + else { + this.set('showEvaluation', true); + } + } + }, + didInsertElement : function(){ this._super(); Ember.run.scheduleOnce('afterRender', this, function(){ $('.user-selections-table').floatThead({}); }); - - $('.evaluation:not(.evaluation-header)').toggle(); - $('.evaluation-header').click(function(){ - $('.evaluation:not(.evaluation-header)').toggle(); - }); - } + }, + + showEvaluationLabel: function() { + if (this.get('showEvaluation')) { + return "hide"; + } + else { + return "show"; + } + }.property('showEvaluation') });