mirror of
https://github.com/Dahlgren/arma-server-web-admin.git
synced 2024-08-30 17:22:10 +00:00
Download mods from play withSIX
This commit is contained in:
parent
6efdf0d34a
commit
21a9fd8e5f
@ -9,7 +9,8 @@ define(function (require) {
|
||||
return Backbone.Model.extend({
|
||||
defaults: {
|
||||
name: ''
|
||||
}
|
||||
},
|
||||
urlRoot: '/api/mods/',
|
||||
});
|
||||
|
||||
});
|
||||
|
46
public/js/app/views/mods/form.js
Normal file
46
public/js/app/views/mods/form.js
Normal file
@ -0,0 +1,46 @@
|
||||
define(function (require) {
|
||||
|
||||
'use strict';
|
||||
|
||||
var $ = require('jquery'),
|
||||
_ = require('underscore'),
|
||||
Backbone = require('backbone'),
|
||||
Marionette = require('marionette'),
|
||||
FormView = require('marionette-formview'),
|
||||
Mod = require('app/models/mod'),
|
||||
tpl = require('text!tpl/mods/form.html');
|
||||
|
||||
return Marionette.ItemView.extend({
|
||||
template: _.template(tpl),
|
||||
|
||||
initialize: function (options) {
|
||||
this.mods = options.mods;
|
||||
this.model = new Mod();
|
||||
this.bind('ok', this.submit);
|
||||
},
|
||||
|
||||
submit: function (modal) {
|
||||
var self = this;
|
||||
var $form = $('form');
|
||||
|
||||
modal.preventClose();
|
||||
|
||||
$form.find('.form-group').removeClass('has-error');
|
||||
$form.find('.help-block').text('');
|
||||
|
||||
this.model.save({ name: $form.find('.mod').val() }, {
|
||||
success: function () {
|
||||
self.mods.fetch({
|
||||
success : function () {
|
||||
modal.close();
|
||||
}
|
||||
});
|
||||
},
|
||||
error: function () {
|
||||
$form.find('.form-group').addClass('has-error');
|
||||
$form.find('.help-block').text('Problem downloading mod');
|
||||
}
|
||||
});
|
||||
},
|
||||
});
|
||||
});
|
@ -7,6 +7,7 @@ define(function (require) {
|
||||
Backbone = require('backbone'),
|
||||
Marionette = require('marionette'),
|
||||
ListItemView = require('app/views/mods/list_item'),
|
||||
FormView = require('app/views/mods/form'),
|
||||
tpl = require('text!tpl/mods/list.html'),
|
||||
|
||||
template = _.template(tpl);
|
||||
@ -16,6 +17,10 @@ define(function (require) {
|
||||
itemViewContainer: "tbody",
|
||||
template: template,
|
||||
|
||||
events: {
|
||||
"click #download": "download"
|
||||
},
|
||||
|
||||
initialize: function (options) {
|
||||
this.on("itemview:mods:update", this.update, this);
|
||||
},
|
||||
@ -23,5 +28,11 @@ define(function (require) {
|
||||
update: function() {
|
||||
this.collection.fetch();
|
||||
},
|
||||
|
||||
download: function (event) {
|
||||
event.preventDefault();
|
||||
var view = new FormView({mods: this.collection});
|
||||
new Backbone.BootstrapModal({ content: view }).open();
|
||||
},
|
||||
});
|
||||
});
|
||||
|
11
public/js/tpl/mods/form.html
Normal file
11
public/js/tpl/mods/form.html
Normal file
@ -0,0 +1,11 @@
|
||||
<p>
|
||||
Use foldername from <a href='http://play.withsix.com/' target=_blank>play withSIX</a>
|
||||
</p>
|
||||
|
||||
<form class="form" role="form">
|
||||
<div class="form-group">
|
||||
<label for="mod" class="control-label">Mod</label>
|
||||
<input type="text" class="form-control mod" name="mod" id="mod" data-field="mod">
|
||||
<span class="help-block"></span>
|
||||
</div>
|
||||
</form>
|
@ -8,3 +8,5 @@
|
||||
<!-- want to insert collection items, here -->
|
||||
<tbody></tbody>
|
||||
</table>
|
||||
|
||||
<a class="btn btn-primary" id="download" href="#">Download new mod</a>
|
||||
|
@ -66,7 +66,13 @@ exports.index = function(req, res){
|
||||
};
|
||||
|
||||
exports.create = function(req, res){
|
||||
res.send('create mod');
|
||||
downloadMod(req.body.name, function (mods, err) {
|
||||
if (mods && !err) {
|
||||
res.send(mods);
|
||||
} else {
|
||||
res.send(500, err);
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
exports.show = function(req, res){
|
||||
|
Loading…
Reference in New Issue
Block a user