Skip to content

Commit 6af7dbf

Browse files
authored
Merge pull request #1256 from hargata/Hargata/cleanup.delete
Consolidate all delete swals into a single function.
2 parents 79d1d88 + b9c2771 commit 6af7dbf

16 files changed

Lines changed: 30 additions & 133 deletions

Views/Admin/Index.cshtml

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -147,13 +147,7 @@
147147
}
148148
function deleteUser(userId) {
149149
event.stopPropagation();
150-
Swal.fire({
151-
title: "Confirm Deletion?",
152-
text: "Deleted Users cannot be restored.",
153-
showCancelButton: true,
154-
confirmButtonText: "Delete",
155-
confirmButtonColor: "#dc3545"
156-
}).then((result) => {
150+
confirmDelete("Deleted Users cannot be restored.",(result) => {
157151
if (result.isConfirmed) {
158152
$.post(`/Admin/DeleteUser?userId=${userId}`, function (data) {
159153
if (data) {

wwwroot/js/collisionrecord.js

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -43,13 +43,7 @@ function hideAddCollisionRecordModal() {
4343
}
4444
function deleteCollisionRecord(collisionRecordId) {
4545
$("#workAroundInput").show();
46-
Swal.fire({
47-
title: "Confirm Deletion?",
48-
text: "Deleted Repair Records cannot be restored.",
49-
showCancelButton: true,
50-
confirmButtonText: "Delete",
51-
confirmButtonColor: "#dc3545"
52-
}).then((result) => {
46+
confirmDelete("Deleted Repair Records cannot be restored.", (result) => {
5347
if (result.isConfirmed) {
5448
$.post(`/Vehicle/DeleteCollisionRecordById?collisionRecordId=${collisionRecordId}`, function (data) {
5549
if (data.success) {

wwwroot/js/equipmentrecord.js

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -39,13 +39,7 @@ function hideAddEquipmentRecordModal() {
3939
}
4040
function deleteEquipmentRecord(equipmentRecordId) {
4141
$("#workAroundInput").show();
42-
Swal.fire({
43-
title: "Confirm Deletion?",
44-
text: "Deleted Equipment Records cannot be restored.",
45-
showCancelButton: true,
46-
confirmButtonText: "Delete",
47-
confirmButtonColor: "#dc3545"
48-
}).then((result) => {
42+
confirmDelete("Deleted Equipment Records cannot be restored.", (result) => {
4943
if (result.isConfirmed) {
5044
$.post(`/Vehicle/DeleteEquipmentRecordById?equipmentRecordId=${equipmentRecordId}`, function (data) {
5145
if (data.success) {

wwwroot/js/garage.js

Lines changed: 2 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -130,13 +130,7 @@ function deleteCalendarReminderRecord(reminderRecordId, e) {
130130
event.stopPropagation();
131131
}
132132
$("#workAroundInput").show();
133-
Swal.fire({
134-
title: "Confirm Deletion?",
135-
text: "Deleted Reminders cannot be restored.",
136-
showCancelButton: true,
137-
confirmButtonText: "Delete",
138-
confirmButtonColor: "#dc3545"
139-
}).then((result) => {
133+
confirmDelete("Deleted Reminders cannot be restored.", (result) => {
140134
if (result.isConfirmed) {
141135
$.post(`/Vehicle/DeleteReminderRecordById?reminderRecordId=${reminderRecordId}`, function (data) {
142136
if (data.success) {
@@ -357,13 +351,7 @@ function deleteVehicles(vehicleIds) {
357351
return;
358352
}
359353
let messageWording = vehicleIds.length > 1 ? `these ${vehicleIds.length} vehicles` : 'this vehicle';
360-
Swal.fire({
361-
title: "Confirm Deletion?",
362-
text: `This will also delete all data tied to ${messageWording}. Deleted Vehicles and their associated data cannot be restored.`,
363-
showCancelButton: true,
364-
confirmButtonText: "Delete",
365-
confirmButtonColor: "#dc3545"
366-
}).then((result) => {
354+
confirmDelete(`This will also delete all data tied to ${messageWording}. Deleted Vehicles and their associated data cannot be restored.`, (result) => {
367355
if (result.isConfirmed) {
368356
$.post('/Vehicle/DeleteVehicles', { vehicleIds: vehicleIds }, function (data) {
369357
if (data.success) {

wwwroot/js/gasrecord.js

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -43,13 +43,7 @@ function hideAddGasRecordModal() {
4343
}
4444
function deleteGasRecord(gasRecordId) {
4545
$("#workAroundInput").show();
46-
Swal.fire({
47-
title: "Confirm Deletion?",
48-
text: "Deleted Gas Records cannot be restored.",
49-
showCancelButton: true,
50-
confirmButtonText: "Delete",
51-
confirmButtonColor: "#dc3545"
52-
}).then((result) => {
46+
confirmDelete("Deleted Gas Records cannot be restored.", (result) => {
5347
if (result.isConfirmed) {
5448
$.post(`/Vehicle/DeleteGasRecordById?gasRecordId=${gasRecordId}`, function (data) {
5549
if (data.success) {

wwwroot/js/inspectionrecord.js

Lines changed: 2 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -191,13 +191,7 @@ function saveInspectionRecordTemplateToVehicle(isEdit) {
191191
}
192192
function deleteInspectionRecordTemplate(inspectionRecordTemplateId) {
193193
$("#workAroundInput").show();
194-
Swal.fire({
195-
title: "Confirm Deletion?",
196-
text: "Deleted Inspection Templates cannot be restored.",
197-
showCancelButton: true,
198-
confirmButtonText: "Delete",
199-
confirmButtonColor: "#dc3545"
200-
}).then((result) => {
194+
confirmDelete("Deleted Inspection Templates cannot be restored.", (result) => {
201195
if (result.isConfirmed) {
202196
$.post(`/Vehicle/DeleteInspectionRecordTemplateById?inspectionRecordTemplateId=${inspectionRecordTemplateId}`, function (data) {
203197
$("#workAroundInput").hide();
@@ -413,13 +407,7 @@ function showEditInspectionRecordModal(inspectionRecordId) {
413407
}
414408
function deleteInspectionRecord(inspectionRecordId) {
415409
$("#workAroundInput").show();
416-
Swal.fire({
417-
title: "Confirm Deletion?",
418-
text: "Deleted Inspection Records cannot be restored.",
419-
showCancelButton: true,
420-
confirmButtonText: "Delete",
421-
confirmButtonColor: "#dc3545"
422-
}).then((result) => {
410+
confirmDelete("Deleted Inspection Records cannot be restored.", (result) => {
423411
if (result.isConfirmed) {
424412
$.post(`/Vehicle/DeleteInspectionRecordById?inspectionRecordId=${inspectionRecordId}`, function (data) {
425413
if (data.success) {

wwwroot/js/note.js

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -39,13 +39,7 @@ function hideAddNoteModal() {
3939
}
4040
function deleteNote(noteId) {
4141
$("#workAroundInput").show();
42-
Swal.fire({
43-
title: "Confirm Deletion?",
44-
text: "Deleted Notes cannot be restored.",
45-
showCancelButton: true,
46-
confirmButtonText: "Delete",
47-
confirmButtonColor: "#dc3545"
48-
}).then((result) => {
42+
confirmDelete("Deleted Notes cannot be restored.", (result) => {
4943
if (result.isConfirmed) {
5044
$.post(`/Vehicle/DeleteNoteById?noteId=${noteId}`, function (data) {
5145
if (data.success) {

wwwroot/js/odometerrecord.js

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -43,13 +43,7 @@ function hideAddOdometerRecordModal() {
4343
}
4444
function deleteOdometerRecord(odometerRecordId) {
4545
$("#workAroundInput").show();
46-
Swal.fire({
47-
title: "Confirm Deletion?",
48-
text: "Deleted Odometer Records cannot be restored.",
49-
showCancelButton: true,
50-
confirmButtonText: "Delete",
51-
confirmButtonColor: "#dc3545"
52-
}).then((result) => {
46+
confirmDelete("Deleted Odometer Records cannot be restored.", (result) => {
5347
if (result.isConfirmed) {
5448
$.post(`/Vehicle/DeleteOdometerRecordById?odometerRecordId=${odometerRecordId}`, function (data) {
5549
if (data.success) {

wwwroot/js/planrecord.js

Lines changed: 2 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -79,13 +79,7 @@ function hideAddPlanRecordModal() {
7979
}
8080
function deletePlanRecord(planRecordId, noModal) {
8181
$("#workAroundInput").show();
82-
Swal.fire({
83-
title: "Confirm Deletion?",
84-
text: "Deleted Plan Records cannot be restored.",
85-
showCancelButton: true,
86-
confirmButtonText: "Delete",
87-
confirmButtonColor: "#dc3545"
88-
}).then((result) => {
82+
confirmDelete("Deleted Plan Records cannot be restored.", (result) => {
8983
if (result.isConfirmed) {
9084
$.post(`/Vehicle/DeletePlanRecordById?planRecordId=${planRecordId}`, function (data) {
9185
if (data.success) {
@@ -161,13 +155,7 @@ function usePlannerRecordTemplate(planRecordTemplateId) {
161155

162156
function deletePlannerRecordTemplate(planRecordTemplateId) {
163157
$("#workAroundInput").show();
164-
Swal.fire({
165-
title: "Confirm Deletion?",
166-
text: "Deleted Plan Templates cannot be restored.",
167-
showCancelButton: true,
168-
confirmButtonText: "Delete",
169-
confirmButtonColor: "#dc3545"
170-
}).then((result) => {
158+
confirmDelete("Deleted Plan Templates cannot be restored.", (result) => {
171159
if (result.isConfirmed) {
172160
$.post(`/Vehicle/DeletePlanRecordTemplateById?planRecordTemplateId=${planRecordTemplateId}`, function (data) {
173161
$("#workAroundInput").hide();

wwwroot/js/reminderrecord.js

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -85,13 +85,7 @@ function deleteReminderRecord(reminderRecordId, e) {
8585
event.stopPropagation();
8686
}
8787
$("#workAroundInput").show();
88-
Swal.fire({
89-
title: "Confirm Deletion?",
90-
text: "Deleted Reminders cannot be restored.",
91-
showCancelButton: true,
92-
confirmButtonText: "Delete",
93-
confirmButtonColor: "#dc3545"
94-
}).then((result) => {
88+
confirmDelete("Deleted Reminders cannot be restored.", (result) => {
9589
if (result.isConfirmed) {
9690
$.post(`/Vehicle/DeleteReminderRecordById?reminderRecordId=${reminderRecordId}`, function (data) {
9791
if (data.success) {

0 commit comments

Comments
 (0)