From 685d8b5e3df6af1a13d4b1207b7303b6f5b84e0b Mon Sep 17 00:00:00 2001
From: Thomas Citharel <tcit@tcit.fr>
Date: Wed, 18 Apr 2018 13:11:17 +0200
Subject: [PATCH] Move VueJS template to x-template DOM and update strings

Signed-off-by: Thomas Citharel <tcit@tcit.fr>
---
 locale/en.json     |  4 +-
 locale/fr.json     |  4 +-
 locale/fr_FR.json  |  4 +-
 tpl/find_polls.tpl | 94 ++++++++++++++++++++++++----------------------
 4 files changed, 59 insertions(+), 47 deletions(-)

diff --git a/locale/en.json b/locale/en.json
index 9a121104..657824a3 100644
--- a/locale/en.json
+++ b/locale/en.json
@@ -165,13 +165,15 @@
       "List of your polls": "List of your polls",
       "PS: this email has been sent because you – or someone else – asked to get back the polls created with your email address.": "PS: this email has been sent because you – or someone else – asked to get back the polls created with your email address.",
       "Polls sent": "Polls sent",
+      "Created polls": "Created polls",
+      "Visited polls": "Visited polls",
       "Send me my polls": "Send me my polls",
       "Send my polls by email": "Send my polls by email",
       "Polls saved inside this browser": "Polls saved inside this browser",
       "Local Storage Help": "To help you find your previous polls, we save inside your browser each poll you create or access to. These informations are saved only inside this browser. The informations saved are the following:",
       "Local Storage Help Information Title": "The title of the poll",
       "Local Storage Help Information Address": "It's address",
-      "Local Storage Help Information Accessed": "The date on which you accessed or created the poll",
+      "Local Storage Help Information Accessed": "The date on which you created or last accessed the poll",
       "Local Storage Help Delete": "To delete this information, you can click the bin matching each line or click the « delete my polls index » option. This won't delete your polls.",
       "Title": "Title",
       "Address": "Address",
diff --git a/locale/fr.json b/locale/fr.json
index 5b39b9d4..7cc21878 100644
--- a/locale/fr.json
+++ b/locale/fr.json
@@ -165,13 +165,15 @@
       "List of your polls": "Liste de vos sondages",
       "PS: this email has been sent because you – or someone else – asked to get back the polls created with your email address.": "PS : ce mail a été envoyé parce que vous – ou quelqu'un d'autre – avez demandé la récupération des sondages créés à l'aide de votre adresse email.",
       "Polls sent": "Sondages envoyés",
+      "Created polls": "Sondages créés",
+      "Visited polls": "Sondages accédés",
       "Send me my polls": "Envoyer mes sondages",
       "Send my polls by email": "Envoyer mes sondages par courriel",
       "Polls saved inside this browser": "Sondages stockés dans ce navigateur",
       "Local Storage Help": "Afin de vous aider à retrouver vos sondages précédents, nous sauvegardons dans votre navigateur internet chaque sondage que vous créez ou auquel vous accédez. Ces informations sont sauvegardées uniquement dans ce navigateur. Les informations sauvegardées sont les suivantes:",
       "Local Storage Help Information Title": "Le titre du sondage",
       "Local Storage Help Information Address": "Son adresse",
-      "Local Storage Help Information Accessed": "La date à laquelle vous avez créé ou avez accédé au sondage",
+      "Local Storage Help Information Accessed": "La date à laquelle vous avez créé ou avez accédé en dernier au sondage",
       "Local Storage Help Delete": "Pour supprimer ces informations, vous pouvez cliquer sur la poubelle en face de chaque sondage ou bien cliquer sur le bouton « supprimer l'index de mes sondages ». Cela ne supprimera pas vos sondages",
       "Title": "Titre",
       "Address": "Adresse",
diff --git a/locale/fr_FR.json b/locale/fr_FR.json
index 5b39b9d4..7cc21878 100644
--- a/locale/fr_FR.json
+++ b/locale/fr_FR.json
@@ -165,13 +165,15 @@
       "List of your polls": "Liste de vos sondages",
       "PS: this email has been sent because you – or someone else – asked to get back the polls created with your email address.": "PS : ce mail a été envoyé parce que vous – ou quelqu'un d'autre – avez demandé la récupération des sondages créés à l'aide de votre adresse email.",
       "Polls sent": "Sondages envoyés",
+      "Created polls": "Sondages créés",
+      "Visited polls": "Sondages accédés",
       "Send me my polls": "Envoyer mes sondages",
       "Send my polls by email": "Envoyer mes sondages par courriel",
       "Polls saved inside this browser": "Sondages stockés dans ce navigateur",
       "Local Storage Help": "Afin de vous aider à retrouver vos sondages précédents, nous sauvegardons dans votre navigateur internet chaque sondage que vous créez ou auquel vous accédez. Ces informations sont sauvegardées uniquement dans ce navigateur. Les informations sauvegardées sont les suivantes:",
       "Local Storage Help Information Title": "Le titre du sondage",
       "Local Storage Help Information Address": "Son adresse",
-      "Local Storage Help Information Accessed": "La date à laquelle vous avez créé ou avez accédé au sondage",
+      "Local Storage Help Information Accessed": "La date à laquelle vous avez créé ou avez accédé en dernier au sondage",
       "Local Storage Help Delete": "Pour supprimer ces informations, vous pouvez cliquer sur la poubelle en face de chaque sondage ou bien cliquer sur le bouton « supprimer l'index de mes sondages ». Cela ne supprimera pas vos sondages",
       "Title": "Titre",
       "Address": "Adresse",
diff --git a/tpl/find_polls.tpl b/tpl/find_polls.tpl
index f2767ae8..ed72d6cd 100644
--- a/tpl/find_polls.tpl
+++ b/tpl/find_polls.tpl
@@ -6,65 +6,69 @@
 {/block}
 
 {block name=main}
-    <div id="local-poll">
-        <h3>
-            {__('FindPolls', 'Polls saved inside this browser')}
-            <a href="#" data-toggle="modal" data-target="#localstorage_help_modal"><i class="glyphicon glyphicon-info-sign"></i></a><!-- TODO Add accessibility -->
-        </h3>
-        <div class="row">
-            <div class="pull-right">
-                <button @click="removeAllPolls" class="btn btn-sm btn-danger">{__('FindPolls', 'Remove all polls from this browser')}</button>
+    <script type="text/x-template" id="poll-finder-component">
+        <div>
+            <h3>
+                {__('FindPolls', 'Polls saved inside this browser')}
+                <a href="#" data-toggle="modal" data-target="#localstorage_help_modal"><i class="glyphicon glyphicon-info-sign"></i></a><!-- TODO Add accessibility -->
+            </h3>
+            <div class="row" v-if="polls.length > 0 || adminPolls.length > 0">
+                <div class="pull-right">
+                    <button @click="removeAllPolls" class="btn btn-sm btn-danger">{__('FindPolls', 'Remove all polls from this browser')}</button>
+                </div>
             </div>
-        </div>
-        <div v-if="polls.length > 0">
-            <h4>Sondages votés</h4>
-            <div class="table-responsive">
-                <table class="table table-hover table-condensed">
-                    <thead>
+            <div v-if="polls.length > 0">
+                <h4>{__('FindPolls', 'Visited polls')}</h4>
+                <div class="table-responsive">
+                    <table class="table table-hover table-condensed">
+                        <thead>
                         <tr>
                             <td>{__('FindPolls', 'Title')}</td>
                             <td>{__('FindPolls', 'Address')}</td>
                             <td>{__('FindPolls', 'Last access date')}</td>
                             <td>{__('FindPolls', 'Remove poll from index')}</td>
                         </tr>
-                    </thead>
-                    <tbody>
+                        </thead>
+                        <tbody>
                         <tr v-for="poll in polls">
                             <td>%% poll.title %%</td>
                             <td><a :href="poll.url">%% poll.url %%</a></td>
                             <td>%% poll.accessed | date %%</td>
                             <td><button class="btn btn-sm btn-danger" @click="removePoll(poll.url)"><i class="glyphicon glyphicon-trash"></i><span class="sr-only">{__('Generic', 'Remove')}</span></button></td>
                         </tr>
-                    </tbody>
-                </table>
+                        </tbody>
+                    </table>
+                </div>
             </div>
-        </div>
-        <div v-if="adminPolls.length > 0">
-            <h4>Sondages créés</h4>
-            <div class="table-responsive">
-                <table class="table table-hover table-condensed">
-                    <thead>
-                    <tr>
-                        <td>{__('FindPolls', 'Title')}</td>
-                        <td>{__('FindPolls', 'Address')}</td>
-                        <td>{__('FindPolls', 'Last access date')}</td>
-                        <td>{__('FindPolls', 'Remove poll from index')}</td>
-                    </tr>
-                    </thead>
-                    <tbody>
-                    <tr v-for="poll in adminPolls">
-                        <td>%% poll.title %%</td>
-                        <td><a :href="poll.url">%% poll.url %%</a></td>
-                        <td>%% poll.accessed | date %%</td>
-                        <td><button class="btn btn-sm btn-danger" @click="removeAdminPoll(poll.url)"><i class="glyphicon glyphicon-trash"></i><span class="sr-only">{__('Generic', 'Remove')}</span></button></td>
-                    </tr>
-                    </tbody>
-                </table>
+            <div v-if="adminPolls.length > 0">
+                <h4>{__('FindPolls', 'Created polls')}</h4>
+                <div class="table-responsive">
+                    <table class="table table-hover table-condensed">
+                        <thead>
+                        <tr>
+                            <td>{__('FindPolls', 'Title')}</td>
+                            <td>{__('FindPolls', 'Address')}</td>
+                            <td>{__('FindPolls', 'Last access date')}</td>
+                            <td>{__('FindPolls', 'Remove poll from index')}</td>
+                        </tr>
+                        </thead>
+                        <tbody>
+                        <tr v-for="poll in adminPolls">
+                            <td>%% poll.title %%</td>
+                            <td><a :href="poll.url">%% poll.url %%</a></td>
+                            <td>%% poll.accessed | date %%</td>
+                            <td><button class="btn btn-sm btn-danger" @click="removeAdminPoll(poll.url)"><i class="glyphicon glyphicon-trash"></i><span class="sr-only">{__('Generic', 'Remove')}</span></button></td>
+                        </tr>
+                        </tbody>
+                    </table>
+                </div>
+            </div>
+            <div v-if="polls.length === 0 && adminPolls.length === 0" class="alert alert-info">
+                {__('FindPolls', 'There are no polls saved inside your browser yet')}
             </div>
         </div>
-        <div v-if="polls.length === 0 && adminPolls.length === 0" class="alert alert-info">
-            {__('FindPolls', 'There are no polls saved inside your browser yet')}
-        </div>
+    </script>
+    <div id="local-polls">
     </div>
     <div>
         <h3>{__('FindPolls', 'Send my polls by email')}</h3>
@@ -114,9 +118,11 @@
     </div><!-- /.modal -->
     <script>
         moment.locale('{$locale}');
+
         var app = new Vue({
             delimiters: ['%%', '%%'],
-            el: '#local-poll',
+            el: '#local-polls',
+            template: '#poll-finder-component',
             data() {
                 return {
                     polls: [],
-- 
GitLab