Bug 32030: Add warning to Dialog
authorJonathan Druart <jonathan.druart@bugs.koha-community.org>
Thu, 14 Jul 2022 13:16:51 +0000 (15:16 +0200)
committerTomas Cohen Arazi <tomascohen@theke.io>
Tue, 8 Nov 2022 12:44:15 +0000 (09:44 -0300)
Signed-off-by: Jonathan Field <jonathan.field@ptfs-europe.com>
Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>
Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com>
Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io>
koha-tmpl/intranet-tmpl/prog/js/vue/components/ERM/Dialog.vue
koha-tmpl/intranet-tmpl/prog/js/vue/messages.js
koha-tmpl/intranet-tmpl/prog/js/vue/stores/main.js

index be910a4..4a7ba92 100644 (file)
@@ -1,6 +1,7 @@
 <template>
     <div class="dialog message" v-if="message">{{ message }}</div>
     <div class="dialog alert" v-if="error">{{ error }}</div>
+    <div class="dialog alert" v-if="warning">{{ warning }}</div> <!-- Must be styled differently -->
 </template>
 
 <script>
@@ -10,8 +11,8 @@ import { useMainStore } from "../../stores/main"
 export default {
     setup(){
         const mainStore = useMainStore()
-        const { message, error } = storeToRefs(mainStore)
-        return { message, error }
+        const { message, error, warning } = storeToRefs(mainStore)
+        return { message, error, warning }
     },
 };
 </script>
\ No newline at end of file
index 7d22908..14f8ac2 100644 (file)
@@ -1,5 +1,4 @@
 import { useMainStore } from "./stores/main";
-import { storeToRefs } from "pinia";
 
 export const setError = function (new_error) {
     const mainStore = useMainStore();
@@ -7,6 +6,12 @@ export const setError = function (new_error) {
     setError("Something went wrong: " + new_error);
 };
 
+export const setWarning = function (new_warning) {
+    const mainStore = useMainStore();
+    const { setWarning } = mainStore;
+    setWarning(new_warning);
+};
+
 export const setMessage = function (message) {
     const mainStore = useMainStore();
     const { setMessage } = mainStore;
index 9e66ce8..94311f7 100644 (file)
@@ -4,6 +4,7 @@ export const useMainStore = defineStore("main", {
     state: () => ({
         message: null,
         error: null,
+        warning: null,
         previousMessage: null,
         previousError: null,
         displayed_already: false,
@@ -11,6 +12,7 @@ export const useMainStore = defineStore("main", {
     actions: {
         setMessage(message) {
             this.error = null;
+            this.warning = null;
             this.message = message;
             this.displayed_already = false; /* Will be displayed on the next view */
         },
@@ -19,9 +21,15 @@ export const useMainStore = defineStore("main", {
             this.message = null;
             this.displayed_already = true; /* Is displayed on the current view */
         },
+        setWarning(warning) {
+            this.warning = warning;
+            this.message = null;
+            this.displayed_already = true; /* Is displayed on the current view */
+        },
         removeMessages() {
             if (this.displayed_already) {
                 this.error = null;
+                this.warning = null;
                 this.message = null;
             }
             this.displayed_already = true;