This commit is contained in:
2019-11-07 22:43:03 +00:00
parent 171a389af9
commit 69f8ededb8
3 changed files with 31 additions and 17 deletions

View File

@@ -156,7 +156,7 @@ export default {
},
mounted() {
//this.$root.$gzconfirm = this.$refs.gzconfirm.open;
this.$root.$gznotify = this.$refs.gznotify.open;
this.$root.$gznotify = this.$refs.gznotify.addNotification;
//redirect to login if not authenticated
if (!this.$store.state.authenticated) {

View File

@@ -154,18 +154,18 @@ export default function initialize() {
localOffset
);
// window.$gz.eventBus.$emit(
// "notify-warning",
// "this is a warning test"
// );
// window.$gz.eventBus.$emit(
// "notify-error",
// "this is an error test"
// );
// window.$gz.eventBus.$emit(
// "notify-success",
// "this is a success test"
// );
window.$gz.eventBus.$emit(
"notify-warning",
"this is a warning test"
);
window.$gz.eventBus.$emit(
"notify-error",
"this is an error test"
);
window.$gz.eventBus.$emit(
"notify-success",
"this is a success test"
);
}
//Store offset in locale data

View File

@@ -3,7 +3,6 @@
:value="isVisible"
:color="options.type"
:timeout="options.timeout"
>
<v-alert :type="options.type">
{{ message }}
@@ -15,11 +14,11 @@
</template>
<script>
//todo: queify this so it can display multiple but sequentially
//todo: modify this to MD standards so it can display multiple notifications sequentially but one at a time only
//and no new one will overwrite an old one until the old one has had at least 2 seconds to show or some good default maybe based on how much text is on it?
export default {
data: () => ({
isVisible: false,
message: null,
options: {
type: "info", //one of success, info, warning, and error, see v-alert docs for more info
@@ -28,9 +27,24 @@ export default {
}),
methods: {
open(message, options) {
this.isVisible = true;
this.message = message;
this.options = Object.assign(this.options, options);
this.isVisible = true;
},
addNotification(message, options) {
//if it's not currently displaying anything then just show it immediately
if (!this.isVisible) {
this.message = message;
this.options = Object.assign(this.options, options);
this.isVisible = true;
} else {
//it *is* showing something so give it maximum 2 seconds then show the new one
setTimeout(() => {
this.message = message;
this.options = Object.assign(this.options, options);
this.isVisible = true;
}, 2000);
}
}
}
};