Robert Schäfer 27163b8d79 Install vue-sweetalert-icon globally
Updating the package to `v4.0.0` still gives me this warning:
```
 WARN  Compiled with 1 warnings
 WARN  in ./components/PasswordReset/ChangePassword.vue?vue&type=script&lang=js&
"export 'SweetalertIcon' was not found in 'vue-sweetalert-icons'
```

According to this thread https://github.com/JorgenVatle/vue-sweetalert-icons/issues/3
I copy+pasted the example configuration:
https://github.com/JorgenVatle/vue-sweetalert-icons-preview/blob/master/nuxt.config.js
https://github.com/JorgenVatle/vue-sweetalert-icons-preview/blob/master/plugins/vue-sweetalert-icons.js

And now the compile warnings are gone. I'm going to ask the maintainer if the
local import is not possible with `v4.0.0` anymore.
2019-08-06 11:03:12 +02:00

98 lines
2.2 KiB
Vue

<template>
<ds-modal :title="title" :is-open="isOpen" @cancel="cancel">
<transition name="ds-transition-fade">
<ds-flex v-if="success" class="hc-modal-success" centered>
<sweetalert-icon icon="success" />
</ds-flex>
</transition>
<!-- eslint-disable-next-line vue/no-v-html -->
<p v-html="message" />
<template slot="footer">
<ds-button class="cancel" :icon="modalData.buttons.cancel.icon" @click="cancel">
{{ $t(modalData.buttons.cancel.textIdent) }}
</ds-button>
<ds-button
:danger="modalData.buttons.confirm.danger"
class="confirm"
:icon="modalData.buttons.confirm.icon"
:loading="loading"
@click="confirm"
>
{{ $t(modalData.buttons.confirm.textIdent) }}
</ds-button>
</template>
</ds-modal>
</template>
<script>
export default {
name: 'ConfirmModal',
props: {
name: { type: String, default: '' },
type: { type: String, required: true },
modalData: { type: Object, required: true },
id: { type: String, required: true },
},
data() {
return {
isOpen: true,
success: false,
loading: false,
}
},
computed: {
title() {
return this.$t(this.modalData.titleIdent)
},
message() {
return this.$t(this.modalData.messageIdent, this.modalData.messageParams)
},
},
methods: {
async cancel() {
await this.modalData.buttons.cancel.callback()
this.isOpen = false
setTimeout(() => {
this.$emit('close')
}, 1000)
},
async confirm() {
this.loading = true
try {
await this.modalData.buttons.confirm.callback()
this.success = true
setTimeout(() => {
this.isOpen = false
setTimeout(() => {
this.success = false
this.$emit('close')
}, 500)
}, 1500)
} catch (err) {
this.success = false
} finally {
this.loading = false
}
},
},
}
</script>
<style lang="scss">
.hc-modal-success {
pointer-events: none;
position: absolute;
width: 100%;
height: 100%;
top: 0;
left: 0;
background-color: #fff;
opacity: 1;
z-index: $z-index-modal;
border-radius: $border-radius-x-large;
}
</style>