Skip to content

confirm-dialog

Dialog for action confirmation like delete resource action

Usage

Simple usage

vue

<template>
  <!-- simple usage -->
  <we-confirm-dialog
    ref="confirmDialog"  
  />
  <!-- simple usage deletion dialog -->
  <we-confirm-dialog
    ref="confirmDialog"  
    type="delete"
  />
<!-- title and text -->
  <we-confirm-dialog
    ref="confirmDialog"  
    title="Title"
    text="Content"
  />
  <!-- use full custom dialog (slot dialog) -->
  <we-confirm-dialog
    ref="confirmDialog"  
    type="delete"
  >
    <template #dialog="{resolve}">
      <v-card>
        <v-card-title>
          Title
        </v-card-title>
        <v-card-text>
          Content
        </v-card-text>
        <v-card-actions>
          <v-btn @click="resolve(true)">
            Confirm
          </v-btn>
            <v-btn @click="resolve(false)">
            Cancel
          </v-btn>
        </v-card-actions>
      </v-card>
    </template>
  </we-confirm-dialog>
</template>
<script>
export default {
  methods: {
    action() {
      const confirm = await this.$refs.confirmDialog.confirm()
      if(!confirm) { return }

      // execute action
    }
  }
};

</script>

TIP

You can use resolve() function on button when slots dialog/footer/buttons is used

Props

NameTypeDefaultDescription
typeString
confirm
Set defaults for title/text/icon/color.
Types: ['confirm', 'delete']
titleString
undefined
Title of the dialog
textString
undefined
Content of the dialog
confirmButtonTextString
undefined
Confirm button text
cancelButtonTextString
undefined
Cancel button text
iconString
undefined
Confirm button icon
colorString
undefined
Confirm button color

Slots

NameDescription
dialogFull dialog
headerDialog header
titleInner text of the header
contentDialog content
textInner text of the content
footerDialog footer actions slot
buttonsbutton list slot

Methods

NameDescription
confirm()Promise that return (if resolved) `true/false` based on the user input