mirror of
https://github.com/Dahlgren/arma-server-web-admin.git
synced 2024-08-30 17:22:10 +00:00
Delete missions
This commit is contained in:
parent
0c57678db6
commit
76c05d9c7d
@ -1,17 +1,34 @@
|
||||
define(function (require) {
|
||||
|
||||
|
||||
"use strict";
|
||||
|
||||
|
||||
var $ = require('jquery'),
|
||||
_ = require('underscore'),
|
||||
Backbone = require('backbone'),
|
||||
Marionette = require('marionette'),
|
||||
tpl = require('text!tpl/missions/list_item.html'),
|
||||
|
||||
|
||||
template = _.template(tpl);
|
||||
|
||||
|
||||
return Marionette.ItemView.extend({
|
||||
tagName: "tr",
|
||||
template: template
|
||||
template: template,
|
||||
|
||||
events: {
|
||||
"click .delete": "delete"
|
||||
},
|
||||
|
||||
delete: function (event) {
|
||||
var self = this;
|
||||
event.preventDefault();
|
||||
$.ajax({
|
||||
url: "/api/missions/" + this.model.get('name'),
|
||||
type: 'DELETE',
|
||||
success: function (resp) {
|
||||
self.model.destroy();
|
||||
},
|
||||
error: $.noop
|
||||
});
|
||||
},
|
||||
});
|
||||
});
|
||||
|
@ -2,9 +2,10 @@
|
||||
<thead>
|
||||
<tr>
|
||||
<th>Mission</th>
|
||||
<th></th>
|
||||
</tr>
|
||||
</thead>
|
||||
|
||||
|
||||
<!-- want to insert collection items, here -->
|
||||
<tbody></tbody>
|
||||
</table>
|
||||
|
@ -1,3 +1,8 @@
|
||||
<td>
|
||||
<a href='#missions/<%-name%>'><%-name%></a>
|
||||
</td>
|
||||
</td>
|
||||
<td>
|
||||
<button type="button" class="btn btn-danger btn-xs delete">
|
||||
<span class="glyphicon glyphicon-remove"></span> Delete
|
||||
</button>
|
||||
</td>
|
||||
|
@ -18,7 +18,7 @@ exports.index = function(req, res){
|
||||
|
||||
exports.create = function(req, res){
|
||||
var missionFile = req.files.mission;
|
||||
|
||||
|
||||
fs.readFile(missionFile.path, function (err, data) {
|
||||
var newPath = config.path + '/mpmissions/' + missionFile.name;
|
||||
console.log(newPath);
|
||||
@ -33,5 +33,17 @@ exports.show = function(req, res){
|
||||
};
|
||||
|
||||
exports.destroy = function(req, res){
|
||||
res.send('destroy mission ' + req.params.mission);
|
||||
};
|
||||
var path = config.path + '/mpmissions/' + req.params.mission;
|
||||
|
||||
if (req.params.format) {
|
||||
path += '.' + req.params.format;
|
||||
}
|
||||
|
||||
fs.unlink(path, function (err) {
|
||||
if (err) {
|
||||
res.json(500, {success: false});
|
||||
} else {
|
||||
res.json({success: true});
|
||||
}
|
||||
});
|
||||
};
|
||||
|
Loading…
Reference in New Issue
Block a user