Skip to content

Commit

Permalink
Refactored the remove function of the project browser to move project…
Browse files Browse the repository at this point in the history
…s to trash instead of deleting them.
  • Loading branch information
BryanRumsey committed May 31, 2021
1 parent 66f6c24 commit 6f02544
Showing 1 changed file with 8 additions and 7 deletions.
15 changes: 8 additions & 7 deletions client/views/edit-project.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,24 +29,25 @@ let template = require('../templates/includes/editProject.pug');
module.exports = View.extend({
template: template,
events: {
'click [data-hook=remove-project-btn]' : 'handleRemoveProjectClick'
'click [data-hook=remove-project-btn]' : 'handleMoveToTrash'
},
initialize: function (attrs, options) {
View.prototype.initialize.apply(this, arguments);
},
render: function (attrs, options) {
View.prototype.render.apply(this, arguments);
},
handleRemoveProjectClick: function (e) {
if(document.querySelector('#deleteFileModal')) {
document.querySelector('#deleteFileModal').remove();
handleMoveToTrash: function (e) {
if(document.querySelector('#moveToTrashConfirmModal')) {
document.querySelector('#moveToTrashConfirmModal').remove();
}
let self = this;
let endpoint = path.join(app.getApiPath(), "file/delete")+"?path="+this.model.directory;
let modal = $(modals.deleteFileHtml("project")).modal();
let yesBtn = document.querySelector('#deleteFileModal .yes-modal-btn');
let modal = $(modals.moveToTrashConfirmHtml("model")).modal();
let yesBtn = document.querySelector('#moveToTrashConfirmModal .yes-modal-btn');
yesBtn.addEventListener('click', function (e) {
modal.modal('hide');
let queryStr = "?srcPath=" + self.model.directory + "&dstPath=" + path.join("trash", self.model.directory.split("/").pop());
let endpoint = path.join(app.getApiPath(), "file/move") + queryStr
app.getXHR(endpoint, {
success: function (err, response, body) {
self.model.collection.remove(self.model);
Expand Down

0 comments on commit 6f02544

Please sign in to comment.