Implement common confirmDelete function.

This commit is contained in:
Buster "Silver Eagle" Neece 2021-09-20 13:43:27 -05:00
parent 2e41caa405
commit 093556f413
No known key found for this signature in database
GPG Key ID: 6D9E12FF03411F4E
14 changed files with 77 additions and 134 deletions

View File

@ -49,6 +49,7 @@ import EditModal from './CustomFields/EditModal';
import Icon from '~/components/Common/Icon';
import InfoCard from '~/components/Common/InfoCard';
import handleAxiosError from '~/functions/handleAxiosError';
import confirmDelete from '~/functions/confirmDelete';
import _ from 'lodash';
export default {
@ -81,15 +82,9 @@ export default {
this.$refs.editModal.edit(url);
},
doDelete(url) {
let buttonText = this.$gettext('Delete');
let buttonConfirmText = this.$gettext('Delete Custom Field?');
Swal.fire({
title: buttonConfirmText,
confirmButtonText: buttonText,
confirmButtonColor: '#e64942',
showCancelButton: true,
focusCancel: true
confirmDelete({
title: this.$gettext('Delete Custom Field?'),
confirmButtonText: this.$gettext('Delete'),
}).then((result) => {
if (result.value) {
this.axios.delete(url).then((resp) => {

View File

@ -55,6 +55,7 @@ import Icon from '~/components/Common/Icon';
import InfoCard from '~/components/Common/InfoCard';
import handleAxiosError from '~/functions/handleAxiosError';
import _ from 'lodash';
import confirmDelete from "~/functions/confirmDelete";
export default {
name: 'AdminPermissions',
@ -98,15 +99,9 @@ export default {
this.$refs.editModal.edit(url);
},
doDelete(url) {
let buttonText = this.$gettext('Delete');
let buttonConfirmText = this.$gettext('Delete Role?');
Swal.fire({
title: buttonConfirmText,
confirmButtonText: buttonText,
confirmButtonColor: '#e64942',
showCancelButton: true,
focusCancel: true
confirmDelete({
title: this.$gettext('Delete Role?'),
confirmButtonText: this.$gettext('Delete'),
}).then((result) => {
if (result.value) {
this.axios.delete(url).then((resp) => {

View File

@ -49,6 +49,7 @@ import DataTable from '~/components/Common/DataTable';
import EditModal from './StorageLocations/EditModal';
import Icon from '~/components/Common/Icon';
import handleAxiosError from '~/functions/handleAxiosError';
import confirmDelete from "~/functions/confirmDelete";
export default {
name: 'AdminStorageLocations',
@ -123,15 +124,9 @@ export default {
});
},
doDelete (url) {
let buttonText = this.$gettext('Delete');
let buttonConfirmText = this.$gettext('Delete storage location?');
Swal.fire({
title: buttonConfirmText,
confirmButtonText: buttonText,
confirmButtonColor: '#e64942',
showCancelButton: true,
focusCancel: true
confirmDelete({
title: this.$gettext('Delete Storage Location?'),
confirmButtonText: this.$gettext('Delete'),
}).then((result) => {
if (result.value) {
this.axios.delete(url).then((resp) => {

View File

@ -75,6 +75,7 @@
import _ from 'lodash';
import Icon from '~/components/Common/Icon';
import handleAxiosError from '~/functions/handleAxiosError';
import confirmDelete from "~/functions/confirmDelete";
export default {
name: 'station-media-toolbar',
@ -140,17 +141,12 @@ export default {
this.doBatch('reprocess', this.$gettext('Files marked for reprocessing:'));
},
doDelete (e) {
let buttonText = this.$gettext('Delete');
let buttonConfirmText = this.$gettext('Delete %{ num } media files?');
let numFiles = this.selectedItems.all.length;
Swal.fire({
title: this.$gettextInterpolate(buttonConfirmText, { num: numFiles }),
confirmButtonText: buttonText,
confirmButtonColor: '#e64942',
showCancelButton: true,
focusCancel: true
confirmDelete({
title: this.$gettextInterpolate(buttonConfirmText, {num: numFiles}),
confirmButtonText: this.$gettext('Delete'),
}).then((result) => {
if (result.value) {
this.doBatch('delete', this.$gettext('Files removed:'));

View File

@ -63,6 +63,7 @@ import EditModal from './Mounts/EditModal';
import Icon from '~/components/Common/Icon';
import InfoCard from '~/components/Common/InfoCard';
import handleAxiosError from '~/functions/handleAxiosError';
import confirmDelete from "~/functions/confirmDelete";
export default {
name: 'StationMounts',
@ -102,15 +103,9 @@ export default {
this.$refs.editModal.edit(url);
},
doDelete (url) {
let buttonText = this.$gettext('Delete');
let buttonConfirmText = this.$gettext('Delete Mount Point?');
Swal.fire({
title: buttonConfirmText,
confirmButtonText: buttonText,
confirmButtonColor: '#e64942',
showCancelButton: true,
focusCancel: true
confirmDelete({
title: this.$gettext('Delete Mount Point?'),
confirmButtonText: this.$gettext('Delete'),
}).then((result) => {
if (result.value) {
this.axios.delete(url).then((resp) => {

View File

@ -136,6 +136,7 @@ import handleAxiosError from '~/functions/handleAxiosError';
import CloneModal from './Playlists/CloneModal';
import {DateTime} from 'luxon';
import humanizeDuration from 'humanize-duration';
import confirmDelete from "~/functions/confirmDelete";
export default {
name: 'StationPlaylists',
@ -271,15 +272,9 @@ export default {
});
},
doDelete (url) {
let buttonText = this.$gettext('Delete');
let buttonConfirmText = this.$gettext('Delete playlist?');
Swal.fire({
title: buttonConfirmText,
confirmButtonText: buttonText,
confirmButtonColor: '#e64942',
showCancelButton: true,
focusCancel: true
confirmDelete({
title: this.$gettext('Delete Playlist?'),
confirmButtonText: this.$gettext('Delete'),
}).then((result) => {
if (result.value) {
this.axios.delete(url).then((resp) => {

View File

@ -75,6 +75,7 @@ import AlbumArt from '~/components/Common/AlbumArt';
import EpisodeFormBasicInfo from './EpisodeForm/BasicInfo';
import PodcastCommonArtwork from './Common/Artwork';
import handleAxiosError from '~/functions/handleAxiosError';
import confirmDelete from "~/functions/confirmDelete";
export const episodeViewProps = {
props: {
@ -118,15 +119,9 @@ export default {
this.$emit('clear-podcast');
},
doDelete (url) {
let buttonText = this.$gettext('Delete');
let buttonConfirmText = this.$gettext('Delete episode?');
Swal.fire({
title: buttonConfirmText,
confirmButtonText: buttonText,
confirmButtonColor: '#e64942',
showCancelButton: true,
focusCancel: true
confirmDelete({
title: this.$gettext('Delete Episode?'),
confirmButtonText: this.$gettext('Delete'),
}).then((result) => {
if (result.value) {
this.axios.delete(url).then((resp) => {

View File

@ -64,6 +64,7 @@ import DataTable from '~/components/Common/DataTable';
import EditModal from './PodcastEditModal';
import AlbumArt from '~/components/Common/AlbumArt';
import handleAxiosError from '~/functions/handleAxiosError';
import confirmDelete from "~/functions/confirmDelete";
export const listViewProps = {
props: {
@ -115,15 +116,9 @@ export default {
this.$emit('select-podcast', podcast);
},
doDelete (url) {
let buttonText = this.$gettext('Delete');
let buttonConfirmText = this.$gettext('Delete podcast?');
Swal.fire({
title: buttonConfirmText,
confirmButtonText: buttonText,
confirmButtonColor: '#e64942',
showCancelButton: true,
focusCancel: true
confirmDelete({
title: this.$gettext('Delete Podcast?'),
confirmButtonText: this.$gettext('Delete'),
}).then((result) => {
if (result.value) {
this.axios.delete(url).then((resp) => {

View File

@ -59,6 +59,7 @@ import QueueLogsModal from './Queue/LogsModal';
import handleAxiosError from '~/functions/handleAxiosError';
import Icon from "~/components/Common/Icon";
import {DateTime} from 'luxon';
import confirmDelete from "~/functions/confirmDelete";
export default {
name: 'StationQueue',
@ -86,15 +87,9 @@ export default {
this.$refs.logs_modal.show(logs);
},
doDelete (url) {
let buttonText = this.$gettext('Delete');
let buttonConfirmText = this.$gettext('Delete queue item?');
Swal.fire({
title: buttonConfirmText,
confirmButtonText: buttonText,
confirmButtonColor: '#e64942',
showCancelButton: true,
focusCancel: true
confirmDelete({
title: this.$gettext('Delete Queue Item?'),
confirmButtonText: this.$gettext('Delete'),
}).then((result) => {
if (result.value) {
this.axios.delete(url).then((resp) => {
@ -108,15 +103,9 @@ export default {
});
},
doClear() {
let buttonText = this.$gettext('Clear');
let buttonConfirmText = this.$gettext('Clear upcoming song queue?');
Swal.fire({
title: buttonConfirmText,
confirmButtonText: buttonText,
confirmButtonColor: '#e64942',
showCancelButton: true,
focusCancel: true
confirmDelete({
title: this.$gettext('Clear Upcoming Song Queue?'),
confirmButtonText: this.$gettext('Clear'),
}).then((result) => {
if (result.value) {
this.axios.post(this.clearUrl).then((resp) => {

View File

@ -59,6 +59,7 @@ import Icon from '~/components/Common/Icon';
import InfoCard from '~/components/Common/InfoCard';
import handleAxiosError from '~/functions/handleAxiosError';
import RemoteEditModal from "./Remotes/EditModal";
import confirmDelete from "~/functions/confirmDelete";
export default {
name: 'StationMounts',
@ -96,15 +97,9 @@ export default {
this.$refs.editModal.edit(url);
},
doDelete(url) {
let buttonText = this.$gettext('Delete');
let buttonConfirmText = this.$gettext('Delete Remote Relay?');
Swal.fire({
title: buttonConfirmText,
confirmButtonText: buttonText,
confirmButtonColor: '#e64942',
showCancelButton: true,
focusCancel: true
confirmDelete({
title: this.$gettext('Delete Remote Relay?'),
confirmButtonText: this.$gettext('Delete'),
}).then((result) => {
if (result.value) {
this.axios.delete(url).then((resp) => {

View File

@ -52,6 +52,7 @@ import DataTable from '~/components/Common/DataTable';
import handleAxiosError from '~/functions/handleAxiosError';
import Icon from "~/components/Common/Icon";
import {DateTime} from 'luxon';
import confirmDelete from "~/functions/confirmDelete";
export default {
name: 'StationRequests',
@ -77,15 +78,9 @@ export default {
return DateTime.fromSeconds(time).setZone(this.stationTimeZone).toLocaleString(DateTime.DATETIME_MED);
},
doDelete(url) {
let buttonText = this.$gettext('Delete');
let buttonConfirmText = this.$gettext('Delete request?');
Swal.fire({
title: buttonConfirmText,
confirmButtonText: buttonText,
confirmButtonColor: '#e64942',
showCancelButton: true,
focusCancel: true
confirmDelete({
title: this.$gettext('Delete Request?'),
confirmButtonText: this.$gettext('Delete'),
}).then((result) => {
if (result.value) {
this.axios.delete(url).then((resp) => {
@ -99,15 +94,9 @@ export default {
});
},
doClear() {
let buttonText = this.$gettext('Clear');
let buttonConfirmText = this.$gettext('Clear all pending requests?');
Swal.fire({
title: buttonConfirmText,
confirmButtonText: buttonText,
confirmButtonColor: '#e64942',
showCancelButton: true,
focusCancel: true
confirmDelete({
title: this.$gettext('Clear All Pending Requests?'),
confirmButtonText: this.$gettext('Clear'),
}).then((result) => {
if (result.value) {
this.axios.post(this.clearUrl).then((resp) => {

View File

@ -65,6 +65,7 @@ import BroadcastsModal from './Streamers/BroadcastsModal';
import Schedule from '~/components/Common/ScheduleView';
import Icon from '~/components/Common/Icon';
import handleAxiosError from '~/functions/handleAxiosError';
import confirmDelete from "~/functions/confirmDelete";
export default {
name: 'StationStreamers',
@ -111,15 +112,9 @@ export default {
this.$refs.broadcastsModal.open(url);
},
doDelete (url) {
let buttonText = this.$gettext('Delete');
let buttonConfirmText = this.$gettext('Delete streamer?');
Swal.fire({
title: buttonConfirmText,
confirmButtonText: buttonText,
confirmButtonColor: '#e64942',
showCancelButton: true,
focusCancel: true
confirmDelete({
title: this.$gettext('Delete Streamer?'),
confirmButtonText: this.$gettext('Delete'),
}).then((result) => {
if (result.value) {
this.axios.delete(url).then((resp) => {

View File

@ -43,6 +43,7 @@ import Icon from '~/components/Common/Icon';
import handleAxiosError from '~/functions/handleAxiosError';
import PlayButton from "~/components/Common/PlayButton";
import {DateTime} from 'luxon';
import confirmDelete from "~/functions/confirmDelete";
export default {
name: 'StreamerBroadcastsModal',
@ -125,15 +126,9 @@ export default {
}
},
doDelete (url) {
let buttonText = this.$gettext('Delete');
let buttonConfirmText = this.$gettext('Delete broadcast?');
Swal.fire({
title: buttonConfirmText,
confirmButtonText: buttonText,
confirmButtonColor: '#e64942',
showCancelButton: true,
focusCancel: true
confirmDelete({
title: this.$gettext('Delete Broadcast?'),
confirmButtonText: this.$gettext('Delete'),
}).then((result) => {
if (result.value) {
this.axios.delete(url).then((resp) => {

View File

@ -0,0 +1,19 @@
import _
from 'lodash';
import Swal
from 'sweetalert2';
export default function (options) {
let defaults = {
title: 'Delete Record?',
confirmButtonText: 'Delete',
confirmButtonColor: '#e64942',
showCancelButton: true,
focusCancel: true
};
let config = _.defaultsDeep(_.clone(options), defaults);
return Swal.fire(config);
};