Skip to content

Commit

Permalink
Added confirmation for approving rejected messages (#265)
Browse files Browse the repository at this point in the history
Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
  • Loading branch information
csharpfritz and github-actions[bot] authored Oct 30, 2023
1 parent 0576daf commit 8af4446
Show file tree
Hide file tree
Showing 5 changed files with 3,089 additions and 3,060 deletions.
1 change: 1 addition & 0 deletions src/TagzApp.Web/Pages/Moderation.cshtml
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@
@section Scripts {

<script src="~/js/masonry.js" asp-append-version="true"></script>
<script src="~/lib/sweetalert/dist/sweetalert.min.js"></script>
<script>
window.TagzApp.ListenForModerationContent("@Model.Tags.FirstOrDefault()");
Expand Down
8 changes: 8 additions & 0 deletions src/TagzApp.Web/libman.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,14 @@
"provider": "cdnjs",
"library": "[email protected]",
"destination": "wwwroot/lib/simplemde/"
},
{
"provider": "jsdelivr",
"library": "[email protected]",
"destination": "wwwroot/lib/sweetalert/",
"files":[
"dist/sweetalert.min.js"
]
}
]
}
37 changes: 28 additions & 9 deletions src/TagzApp.Web/wwwroot/js/site.js
Original file line number Diff line number Diff line change
Expand Up @@ -413,15 +413,34 @@
hoverPanel
.querySelector('i.approve')
.addEventListener('click', function (ev) {
connection.invoke(
'SetStatus',
hovered.getAttribute('data-provider'),
hovered.getAttribute('data-providerid'),
ModerationState.Approved,
);
hoverPanel.remove();
hovered.classList.remove('status-rejected');
hovered.classList.add('status-approved');
let approveFunc = function () {
connection.invoke(
'SetStatus',
hovered.getAttribute('data-provider'),
hovered.getAttribute('data-providerid'),
ModerationState.Approved,
);
hoverPanel.remove();
hovered.classList.remove('status-rejected');
hovered.classList.add('status-approved');
};

if (hovered.classList.contains('status-rejected')) {
// Confirm that we are flipping this
swal({
title: 'Are you sure?',
text: 'This message was previously rejected. Are you sure you want to approve it?',
icon: 'warning',
buttons: true,
dangerMode: true,
}).then((willApprove) => {
if (willApprove) {
approveFunc();
}
});
} else {
approveFunc();
}
});

hoverPanel
Expand Down
Loading

0 comments on commit 8af4446

Please sign in to comment.