changeset 2459:408e0f4d4008

clinet:pdf-gen template:unifiy feedback messages for template * improve displaying a message after uploading a template * give a feedback message after deleting a template
author Fadi Abbud <fadi.abbud@intevation.de>
date Mon, 04 Mar 2019 10:26:19 +0100
parents 204b0baac93c
children e2f05ac81471 e3487fa9284d
files client/src/components/systemconfiguration/PDFTemplates.vue
diffstat 1 files changed, 12 insertions(+), 22 deletions(-) [+]
line wrap: on
line diff
--- a/client/src/components/systemconfiguration/PDFTemplates.vue	Mon Mar 04 08:18:06 2019 +0100
+++ b/client/src/components/systemconfiguration/PDFTemplates.vue	Mon Mar 04 10:26:19 2019 +0100
@@ -30,10 +30,7 @@
               <td class="text-right">
                 <button
                   class="btn btn-sm btn-dark"
-                  @click="
-                    deleteTemplate(template);
-                    showSuccessUploadMsg = false;
-                  "
+                  @click="deleteTemplate(template)"
                 >
                   <font-awesome-icon icon="trash" />
                 </button>
@@ -42,13 +39,7 @@
           </transition-group>
         </table>
       </transition>
-      <button
-        class="btn btn-info mt-2"
-        @click="
-          $refs.uploadTemplate.click();
-          showSuccessUploadMsg = false;
-        "
-      >
+      <button class="btn btn-info mt-2" @click="$refs.uploadTemplate.click()">
         <font-awesome-icon
           icon="spinner"
           class="fa-spin fa-fw"
@@ -57,11 +48,6 @@
         <font-awesome-icon icon="upload" class="fa-fw" v-else />
         <translate>Upload new template</translate>
       </button>
-      <div v-if="showSuccessUploadMsg" class="text-center">
-        <p class="text-muted" v-translate>
-          {{ templateToUpload.name }} uploaded successfully
-        </p>
-      </div>
     </div>
   </div>
 </template>
@@ -91,16 +77,14 @@
  * Markus Kottländer <markus@intevation.de>
  */
 import { HTTP } from "@/lib/http";
-import { displayError } from "@/lib/errors.js";
+import { displayError, displayInfo } from "@/lib/errors.js";
 
 export default {
   name: "pdftemplates",
   data() {
     return {
       templates: [],
-      uploading: false,
-      templateToUpload: "",
-      showSuccessUploadMsg: false
+      uploading: false
     };
   },
   methods: {
@@ -135,8 +119,10 @@
           )
             .then(() => {
               this.loadTemplates();
-              this.templateToUpload = template;
-              this.showSuccessUploadMsg = true;
+              displayInfo({
+                message:
+                  template.name + " " + this.$gettext("uploaded successfully")
+              });
             })
             .catch(e => {
               const { status, data } = e.response;
@@ -204,6 +190,10 @@
               );
               if (removeIndex !== -1) {
                 this.templates.splice(removeIndex, 1);
+                displayInfo({
+                  message:
+                    template.name + " " + this.$gettext("deleted successfully")
+                });
               }
             });
           }