Skip to content

Commit

Permalink
feat: added confirm dialog to cancel print button
Browse files Browse the repository at this point in the history
  • Loading branch information
cadriel committed Oct 9, 2020
1 parent 5e88bf6 commit 3a70c88
Show file tree
Hide file tree
Showing 3 changed files with 69 additions and 4 deletions.
50 changes: 50 additions & 0 deletions src/components/dialogs/dialogConfirm.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
<template>
<v-dialog
@input="emitChange(value)"
:value="value"
:max-width="maxWidthValue"
persistent
>
<v-card>
<v-card-title>
<span class="headline"> {{ title }}</span>
</v-card-title>
<v-card-text>
<slot></slot>
</v-card-text>
<v-card-actions>
<v-spacer></v-spacer>
<v-btn color="secondary" @click="emitChange(false)">No</v-btn>
<v-btn color="warning" @click="emitChange(true)">Yes</v-btn>
</v-card-actions>
</v-card>
</v-dialog>
</template>

<script lang="ts">
import { Component, Mixins, Prop } from 'vue-property-decorator'
import UtilsMixin from '@/mixins/utils'
@Component({})
export default class DialogInput extends Mixins(UtilsMixin) {
@Prop({ type: Boolean, required: true })
public value!: boolean
@Prop({ type: String, required: false, default: 'Confirm' })
title!: string
@Prop({ type: Number, required: false, default: 250 })
maxWidth!: number
get maxWidthValue (): string | undefined {
return (this.maxWidth) ? this.maxWidth.toString() + 'px' : undefined
}
emitChange (val: boolean) {
if (val === true) {
this.$emit('confirm')
}
this.$emit('input', false)
}
}
</script>
4 changes: 2 additions & 2 deletions src/components/dialogs/dialogInput.vue
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@
</v-card-text>
<v-card-actions>
<v-spacer></v-spacer>
<v-btn color="blue darken-1" text @click="emitChange(false)">Close</v-btn>
<v-btn color="blue darken-1" text @click="saveValue()">Save</v-btn>
<v-btn color="secondary" @click="emitChange(false)">Close</v-btn>
<v-btn color="primary" @click="saveValue()">Save</v-btn>
</v-card-actions>
</v-card>
</v-dialog>
Expand Down
19 changes: 17 additions & 2 deletions src/components/widgets/PrintStatusWidget.vue
Original file line number Diff line number Diff line change
Expand Up @@ -58,8 +58,9 @@
<v-icon small>mdi-pause</v-icon>
<span>Pause</span>
</v-btn>

<v-btn
@click="cancelPrint()"
@click="confirmDialog.open = true"
:loading="hasWait(waits.onPrintCancel)"
:width="buttonWidths"
v-if="printerPrinting || printerPaused"
Expand Down Expand Up @@ -104,6 +105,11 @@
</v-row>
</v-expand-transition>
</v-container>
<dialog-confirm
v-model="confirmDialog.open"
@confirm="cancelPrint()">
<p>Are you sure? This will cancel your print.</p>
</dialog-confirm>
</v-sheet>
</template>

Expand All @@ -112,12 +118,21 @@ import { Component, Mixins } from 'vue-property-decorator'
import UtilsMixin from '@/mixins/utils'
import { Waits } from '@/globals'
import { SocketActions } from '@/socketActions'
import DialogConfirm from '@/components/dialogs/dialogConfirm.vue'
@Component({})
@Component({
components: {
DialogConfirm
}
})
export default class PrintStatusWidget extends Mixins(UtilsMixin) {
buttonWidths = 140
waits = Waits
confirmDialog = {
open: false
}
get cameraUrl (): string {
return this.$store.state.config.fileConfig.camera.url
}
Expand Down

0 comments on commit 3a70c88

Please sign in to comment.