Skip to content

Commit

Permalink
Merge pull request #6796 from ChurchCRM/fix-bad-delete-ajax
Browse files Browse the repository at this point in the history
fix javascript calls to delete routes which currently don't work
  • Loading branch information
DawoudIO authored Jan 1, 2024
2 parents 4748abe + e6c99c9 commit ee95ff7
Show file tree
Hide file tree
Showing 6 changed files with 10 additions and 16 deletions.
3 changes: 1 addition & 2 deletions react/components/Events/ExistingEvent.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -172,12 +172,11 @@ class ExistingEvent extends React.Component<EventFormProps, EventFormState> {
delete() {
fetch(CRMRoot + "/api/events/" + this.props.eventId, {
credentials: "include",
method: "POST",
method: "DELETE",
headers: {
Accept: "application/json",
"Content-Type": "application/json",
},
body: JSON.stringify({ _METHOD: "DELETE" }),
}).then(() => this.exit());
}

Expand Down
12 changes: 6 additions & 6 deletions src/skin/js/CRMJSOM.js
Original file line number Diff line number Diff line change
Expand Up @@ -125,9 +125,9 @@ window.CRM.cart = {
},
removePerson: function (Persons, callback) {
window.CRM.APIRequest({
method: "POST",
method: "DELETE",
path: "cart/",
data: JSON.stringify({ _METHOD: "DELETE", Persons: Persons }),
data: JSON.stringify({ Persons: Persons }),
}).done(function (data) {
window.CRM.cart.refresh();
if (callback) {
Expand Down Expand Up @@ -394,7 +394,7 @@ window.CRM.groups = {
window.CRM.groups
.getRoles(selectOptions.GroupID)
.done(function (rdata) {
rolesList = $.map(rdata.ListOptions, function (item) {
rolesList = $.map(rdata, function (item) {
var o = {
text: i18next.t(item.OptionName), // to translate the Teacher and Student in localize text
id: item.OptionId,
Expand Down Expand Up @@ -426,7 +426,7 @@ window.CRM.groups = {
bootbox.dialog(options).init(initFunction).show();

window.CRM.groups.get().done(function (rdata) {
groupsList = $.map(rdata.Groups, function (item) {
groupsList = $.map(rdata, function (item) {
var o = {
text: item.Name,
id: item.Id,
Expand All @@ -442,14 +442,14 @@ window.CRM.groups = {

$groupSelect2.on("select2:select", function (e) {
var targetGroupId = $(
"#targetGroupSelection option:selected",
"#targetGroupSelection option:selected"
).val();
$parent = $("#targetRoleSelection").parent();
$("#targetRoleSelection").empty();
window.CRM.groups
.getRoles(targetGroupId)
.done(function (rdata) {
rolesList = $.map(rdata.ListOptions, function (item) {
rolesList = $.map(rdata, function (item) {
var o = {
text: i18next.t(item.OptionName), // this is for the Teacher and Student role
id: item.OptionId,
Expand Down
5 changes: 1 addition & 4 deletions src/skin/js/FamilyView.js
Original file line number Diff line number Diff line change
Expand Up @@ -298,17 +298,14 @@ $(document).ready(function () {

$("#deletePhoto").click(function () {
$.ajax({
type: "POST",
type: "DELETE",
url:
window.CRM.root +
"/api/family/" +
window.CRM.currentFamily +
"/photo",
encode: true,
dataType: "json",
data: {
_METHOD: "DELETE",
},
}).done(function (data) {
location.reload();
});
Expand Down
3 changes: 1 addition & 2 deletions src/skin/js/GroupEditor.js
Original file line number Diff line number Diff line change
Expand Up @@ -109,11 +109,10 @@ $("document").ready(function () {
$(document).on("click", ".deleteRole", function (e) {
var roleID = e.currentTarget.id.split("-")[1];
$.ajax({
method: "POST",
method: "DELETE",
url:
window.CRM.root + "/api/groups/" + groupID + "/roles/" + roleID,
encode: true,
data: { _METHOD: "DELETE" },
dataType: "json",
}).done(function (data) {
dataT.clear();
Expand Down
1 change: 0 additions & 1 deletion src/skin/js/users.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@ function deleteUser(userId, userName) {
window.CRM.APIRequest({
method: "DELETE",
path: "user/" + userId + "/",
data: { _METHOD: "DELETE" },
}).done(function () {
window.location.href = window.CRM.root + "/UserList.php";
});
Expand Down
2 changes: 1 addition & 1 deletion src/v2/templates/cart/cartlisting.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
</td>
<td><?= $Person->getAddress() ?></td>
<td><?= $Person->getEmail() ?></td>
<td><a class="RemoveFromPeopleCart" data-personid="<?= $Person->getId() ?>"><?= gettext('Remove') ?></a>
<td><button class="RemoveFromPeopleCart" data-personid="<?= $Person->getId() ?>"><?= gettext('Remove') ?></button>
</td>
<td><?= $Person->getClassificationName() ?></td>
<td><?= $Person->getFamilyRoleName() ?></td>
Expand Down

0 comments on commit ee95ff7

Please sign in to comment.