Antonio-Maranhao commented on a change in pull request #1065: Remove JQuery
uses from documents addon
URL: https://github.com/apache/couchdb-fauxton/pull/1065#discussion_r173823997
##########
File path: app/addons/documents/doc-editor/actions.js
##########
@@ -79,33 +80,24 @@ function hideDeleteDocModal () {
}
function deleteDoc (doc) {
- var databaseName = doc.database.safeID();
- var query = '?rev=' + doc.get('_rev');
-
- $.ajax({
- url: FauxtonAPI.urls('document', 'server', databaseName, doc.safeID(),
query),
- type: 'DELETE',
- headers: {
- 'Accept': 'application/json',
- 'Content-Type': 'application/json',
- },
- xhrFields: {
- withCredentials: true
- },
- success: function () {
- FauxtonAPI.addNotification({
- msg: 'Your document has been successfully deleted.',
- clear: true
- });
- FauxtonAPI.navigate(FauxtonAPI.urls('allDocs', 'app', databaseName, ''));
- },
- error: function () {
- FauxtonAPI.addNotification({
- msg: 'Failed to delete your document!',
- type: 'error',
- clear: true
- });
+ const databaseName = doc.database.safeID();
+ const query = '?rev=' + doc.get('_rev');
+ const url = FauxtonAPI.urls('document', 'server', databaseName,
doc.safeID(), query);
+ deleteRequest(url).then(res => {
+ if (res.error) {
+ throw new Error(res.reason || res.error);
}
+ FauxtonAPI.addNotification({
+ msg: 'Your document has been successfully deleted.',
Review comment:
Added the type
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]
With regards,
Apache Git Services