Skip to content

Commit

Permalink
fix: show delete dialog for single files too (mainsail-crew#1442)
Browse files Browse the repository at this point in the history
  • Loading branch information
dw-0 authored Jun 24, 2023
1 parent 2962df2 commit 7da3352
Show file tree
Hide file tree
Showing 7 changed files with 257 additions and 86 deletions.
66 changes: 45 additions & 21 deletions src/components/panels/GcodefilesPanel.vue
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
<template>
<div>
<panel
:title="$t('Files.GCodeFiles').toString()"
:icon="mdiFileDocumentMultipleOutline"
card-class="gcode-files-panel">
<panel :title="$t('Files.GCodeFiles')" :icon="mdiFileDocumentMultipleOutline" card-class="gcode-files-panel">
<v-card-text>
<v-row>
<v-col class="col-12 d-flex align-center">
Expand Down Expand Up @@ -372,7 +369,7 @@
<v-icon class="mr-1">{{ mdiContentCopy }}</v-icon>
{{ $t('Files.Duplicate') }}
</v-list-item>
<v-list-item v-if="!contextMenu.item.isDirectory" class="red--text" @click="removeFile">
<v-list-item v-if="!contextMenu.item.isDirectory" class="red--text" @click="deleteDialog = true">
<v-icon class="mr-1" color="error">{{ mdiDelete }}</v-icon>
{{ $t('Files.Delete') }}
</v-list-item>
Expand All @@ -387,7 +384,7 @@
</v-menu>
<v-dialog v-model="dialogCreateDirectory.show" :max-width="400">
<panel
:title="$t('Files.NewDirectory').toString()"
:title="$t('Files.NewDirectory')"
card-class="gcode-files-new-directory-dialog"
:margin-bottom="false">
<template #buttons>
Expand Down Expand Up @@ -415,10 +412,7 @@
</panel>
</v-dialog>
<v-dialog v-model="dialogRenameFile.show" :max-width="400">
<panel
:title="$t('Files.RenameFile').toString()"
card-class="gcode-files-rename-file-dialog"
:margin-bottom="false">
<panel :title="$t('Files.RenameFile')" card-class="gcode-files-rename-file-dialog" :margin-bottom="false">
<template #buttons>
<v-btn icon tile @click="dialogRenameFile.show = false">
<v-icon>{{ mdiCloseThick }}</v-icon>
Expand All @@ -428,7 +422,7 @@
<v-text-field
ref="inputFieldRenameFile"
v-model="dialogRenameFile.newName"
:label="$t('Files.Name').toString()"
:label="$t('Files.Name')"
required
:rules="nameInputRules"
@update:error="(bool) => (isInvalidName = bool)"
Expand All @@ -445,7 +439,7 @@
</v-dialog>
<v-dialog v-model="dialogDuplicateFile.show" :max-width="400">
<panel
:title="$t('Files.DuplicateFile').toString()"
:title="$t('Files.DuplicateFile')"
card-class="gcode-files-duplicate-file-dialog"
:margin-bottom="false">
<template #buttons>
Expand All @@ -457,7 +451,7 @@
<v-text-field
ref="inputFieldDuplicateFile"
v-model="dialogDuplicateFile.newName"
:label="$t('Files.Name').toString()"
:label="$t('Files.Name')"
required
:rules="nameInputRules"
@update:error="(bool) => (isInvalidName = bool)"
Expand All @@ -474,7 +468,7 @@
</v-dialog>
<v-dialog v-model="dialogRenameDirectory.show" max-width="400">
<panel
:title="$t('Files.RenameDirectory').toString()"
:title="$t('Files.RenameDirectory')"
card-class="gcode-files-rename-directory-dialog"
:margin-bottom="false">
<template #buttons>
Expand Down Expand Up @@ -503,7 +497,7 @@
</v-dialog>
<v-dialog v-model="dialogDeleteDirectory.show" max-width="400">
<panel
:title="$t('Files.DeleteDirectory').toString()"
:title="$t('Files.DeleteDirectory')"
card-class="gcode-files-delete-directory-dialog"
:margin-bottom="false">
<template #buttons>
Expand All @@ -523,18 +517,45 @@
</v-card-actions>
</panel>
</v-dialog>

<!-- CONFIRM DELETE SINGLE FILE DIALOG -->
<v-dialog v-model="deleteDialog" max-width="400">
<panel :title="$t('Files.Delete')" card-class="gcode-files-delete-dialog" :margin-bottom="false">
<template #buttons>
<v-btn icon tile @click="deleteDialog = false">
<v-icon>{{ mdiCloseThick }}</v-icon>
</v-btn>
</template>
<v-card-text>
<p class="mb-0">
{{ $t('Files.DeleteSingleFileQuestion', { name: contextMenu.item.filename }) }}
</p>
</v-card-text>
<v-card-actions>
<v-spacer></v-spacer>
<v-btn color="" text @click="deleteDialog = false">
{{ $t('Files.Cancel') }}
</v-btn>
<v-btn color="error" text @click="removeFile">
{{ $t('Files.Delete') }}
</v-btn>
</v-card-actions>
</panel>
</v-dialog>

<!-- CONFIRM DELETE MULTIPLE FILES DIALOG -->
<v-dialog v-model="deleteSelectedDialog" max-width="400">
<panel
:title="$t('Files.Delete').toString()"
card-class="gcode-files-delete-selected-dialog"
:margin-bottom="false">
<panel :title="$t('Files.Delete')" card-class="gcode-files-delete-selected-dialog" :margin-bottom="false">
<template #buttons>
<v-btn icon tile @click="deleteSelectedDialog = false">
<v-icon>{{ mdiCloseThick }}</v-icon>
</v-btn>
</template>
<v-card-text>
<p class="mb-0">{{ $t('Files.DeleteSelectedQuestion', { count: selectedFiles.length }) }}</p>
<p v-if="selectedFiles.length === 1" class="mb-0">
{{ $t('Files.DeleteSingleFileQuestion', { name: selectedFiles[0].filename }) }}
</p>
<p v-else class="mb-0">{{ $t('Files.DeleteSelectedQuestion', { count: selectedFiles.length }) }}</p>
</v-card-text>
<v-card-actions>
<v-spacer></v-spacer>
Expand All @@ -545,7 +566,7 @@
</v-dialog>
<v-dialog v-model="dialogAddBatchToQueue.show" max-width="400">
<panel
:title="$t('Files.AddToQueue').toString()"
:title="$t('Files.AddToQueue')"
card-class="gcode-files-add-to-queue-dialog"
:icon="mdiPlaylistPlus"
:margin-bottom="false">
Expand Down Expand Up @@ -783,6 +804,7 @@ export default class GcodefilesPanel extends Mixins(BaseMixin, ControlMixin) {
item: { ...this.contextMenu.item },
}
private deleteDialog = false
private deleteSelectedDialog = false
private isInvalidName = true
Expand Down Expand Up @@ -1379,6 +1401,8 @@ export default class GcodefilesPanel extends Mixins(BaseMixin, ControlMixin) {
{ path: 'gcodes' + this.currentPath + '/' + this.contextMenu.item.filename },
{ action: 'files/getDeleteFile' }
)
this.deleteDialog = false
}
deleteDirectory(item: FileStateGcodefile) {
Expand Down
72 changes: 52 additions & 20 deletions src/components/panels/HistoryListPanel.vue
Original file line number Diff line number Diff line change
@@ -1,18 +1,8 @@
<style>
.history-jobs-table th {
white-space: nowrap;
}
.history-jobs-table th.text-start {
padding-right: 0 !important;
}
</style>

<template>
<div>
<panel
:icon="mdiFileDocumentMultipleOutline"
:title="$t('History.PrintHistory').toString()"
:title="$t('History.PrintHistory')"
card-class="history-list-panel">
<v-card-text>
<v-row>
Expand Down Expand Up @@ -234,7 +224,7 @@
<v-icon class="mr-1">{{ mdiPrinter }}</v-icon>
{{ $t('History.Reprint') }}
</v-list-item>
<v-list-item class="red--text" @click="deleteJob(contextMenu.item)">
<v-list-item class="red--text" @click="deleteDialog = true">
<v-icon class="mr-1" color="error">{{ mdiDelete }}</v-icon>
{{ $t('History.Delete') }}
</v-list-item>
Expand All @@ -246,7 +236,7 @@
persistent
@keydown.esc="detailsDialog.boolShow = false">
<panel
:title="$t('History.JobDetails').toString()"
:title="$t('History.JobDetails')"
:icon="mdiUpdate"
card-class="history-detail-dialog"
:margin-bottom="false">
Expand Down Expand Up @@ -430,18 +420,47 @@
</v-card-text>
</panel>
</v-dialog>

<!-- CONFIRM DELETE SINGLE FILE DIALOG -->
<v-dialog v-model="deleteDialog" max-width="400">
<panel :title="$t('History.Delete')" card-class="history-delete-dialog" :margin-bottom="false">
<template #buttons>
<v-btn icon tile @click="deleteDialog = false">
<v-icon>{{ mdiCloseThick }}</v-icon>
</v-btn>
</template>
<v-card-text>
<p class="mb-0">
{{ $t('History.DeleteSingleJobQuestion') }}
</p>
</v-card-text>
<v-card-actions>
<v-spacer></v-spacer>
<v-btn color="" text @click="deleteDialog = false">
{{ $t('History.Cancel') }}
</v-btn>
<v-btn color="error" text @click="deleteJob">
{{ $t('History.Delete') }}
</v-btn>
</v-card-actions>
</panel>
</v-dialog>

<!-- CONFIRM DELETE MULTIPLE FILES DIALOG -->
<v-dialog v-model="deleteSelectedDialog" max-width="400">
<panel
:title="$t('History.Delete').toString()"
card-class="history-delete-selected-dialog"
:margin-bottom="false">
<panel :title="$t('History.Delete')" card-class="history-delete-selected-dialog" :margin-bottom="false">
<template #buttons>
<v-btn icon tile @click="deleteSelectedDialog = false">
<v-icon>{{ mdiCloseThick }}</v-icon>
</v-btn>
</template>
<v-card-text>
<p class="mb-0">{{ $t('History.DeleteSelectedQuestion', { count: selectedJobs.length }) }}</p>
<p v-if="selectedJobs.length === 1" class="mb-0">
{{ $t('History.DeleteSingleJobQuestion') }}
</p>
<p v-else class="mb-0">
{{ $t('History.DeleteSelectedQuestion', { count: selectedJobs.length }) }}
</p>
</v-card-text>
<v-card-actions>
<v-spacer></v-spacer>
Expand Down Expand Up @@ -555,6 +574,7 @@ export default class HistoryListPanel extends Mixins(BaseMixin) {
type: 'create',
}
private deleteDialog = false
private deleteSelectedDialog = false
get jobs() {
Expand Down Expand Up @@ -918,12 +938,14 @@ export default class HistoryListPanel extends Mixins(BaseMixin) {
this.$socket.emit('printer.print.start', { filename: item.filename }, { action: 'switchToDashboard' })
}
deleteJob(item: ServerHistoryStateJob) {
deleteJob() {
this.$socket.emit(
'server.history.delete_job',
{ uid: item.job_id },
{ uid: this.contextMenu.item.job_id },
{ action: 'server/history/getDeletedJobs' }
)
this.deleteDialog = false
}
deleteSelectedJobs() {
Expand Down Expand Up @@ -1082,3 +1104,13 @@ export default class HistoryListPanel extends Mixins(BaseMixin) {
}
}
</script>

<style scoped>
::v-deep .history-jobs-table th {
white-space: nowrap;
}
::v-deep .history-jobs-table th.text-start {
padding-right: 0 !important;
}
</style>
Loading

0 comments on commit 7da3352

Please sign in to comment.