mirror of
https://github.com/Dahlgren/arma-server-web-admin.git
synced 2024-08-30 17:22:10 +00:00
Better mission handling
This commit is contained in:
parent
5a2671a6d8
commit
788a7a2189
@ -7,7 +7,7 @@ define(function (require) {
|
|||||||
LayoutView = require('app/views/layout'),
|
LayoutView = require('app/views/layout'),
|
||||||
NavigationView = require('app/views/navigation'),
|
NavigationView = require('app/views/navigation'),
|
||||||
ServersView = require('app/views/servers/list'),
|
ServersView = require('app/views/servers/list'),
|
||||||
MissionsListView= require('app/views/missions/list'),
|
MissionsView = require('app/views/missions/index'),
|
||||||
ModsListView = require('app/views/mods/list'),
|
ModsListView = require('app/views/mods/list'),
|
||||||
ServerView = require('app/views/servers/view'),
|
ServerView = require('app/views/servers/view'),
|
||||||
Missions = require('app/collections/missions'),
|
Missions = require('app/collections/missions'),
|
||||||
@ -21,7 +21,7 @@ define(function (require) {
|
|||||||
layoutView = new LayoutView({el: $body}).render(),
|
layoutView = new LayoutView({el: $body}).render(),
|
||||||
navigationView = new NavigationView({servers: servers}),
|
navigationView = new NavigationView({servers: servers}),
|
||||||
serversView = new ServersView({collection: servers}),
|
serversView = new ServersView({collection: servers}),
|
||||||
missionsListView = new MissionsListView({collection: missions}),
|
missionsView = new MissionsView({missions: missions}),
|
||||||
modsListView = new ModsListView({collection: mods});
|
modsListView = new ModsListView({collection: mods});
|
||||||
|
|
||||||
return Backbone.Router.extend({
|
return Backbone.Router.extend({
|
||||||
@ -50,8 +50,8 @@ define(function (require) {
|
|||||||
},
|
},
|
||||||
|
|
||||||
missions: function () {
|
missions: function () {
|
||||||
layoutView.content.show(missionsListView);
|
layoutView.content.show(missionsView);
|
||||||
missionsListView.delegateEvents();
|
missionsView.delegateEvents();
|
||||||
},
|
},
|
||||||
|
|
||||||
mods: function () {
|
mods: function () {
|
||||||
|
@ -15,31 +15,27 @@ define(function (require) {
|
|||||||
return Marionette.ItemView.extend({
|
return Marionette.ItemView.extend({
|
||||||
template: _.template(tpl),
|
template: _.template(tpl),
|
||||||
|
|
||||||
|
events: {
|
||||||
|
'click form button': 'submit',
|
||||||
|
},
|
||||||
|
|
||||||
initialize: function (options) {
|
initialize: function (options) {
|
||||||
this.missions = options.missions;
|
this.missions = options.missions;
|
||||||
this.model = new Mission();
|
this.model = new Mission();
|
||||||
this.bind("ok", this.submit);
|
|
||||||
this.bind('shown', this.shown);
|
|
||||||
},
|
},
|
||||||
|
|
||||||
shown: function (modal) {
|
onShow: function () {
|
||||||
var $okBtn = modal.$el.find('.btn.ok');
|
var $okBtn = this.$el.find('form button[type=submit]');
|
||||||
$okBtn.addClass('ladda-button').attr('data-style', 'expand-left');
|
$okBtn.addClass('ladda-button').attr('data-style', 'expand-left');
|
||||||
|
|
||||||
this.laddaBtn = Ladda.create($okBtn.get(0));
|
this.laddaBtn = Ladda.create($okBtn.get(0));
|
||||||
},
|
},
|
||||||
|
|
||||||
submit: function (modal) {
|
submit: function () {
|
||||||
var self = this;
|
var self = this;
|
||||||
var $form = $('form');
|
var $form = $('form');
|
||||||
|
|
||||||
modal.preventClose();
|
|
||||||
|
|
||||||
$form.find('.form-group').removeClass('has-error');
|
|
||||||
$form.find('.help-block').text('');
|
|
||||||
|
|
||||||
this.laddaBtn.start();
|
this.laddaBtn.start();
|
||||||
modal.$el.find('.btn.cancel').addClass('disabled');
|
|
||||||
|
|
||||||
$.ajax("/api/missions", {
|
$.ajax("/api/missions", {
|
||||||
files: $form.find(":file"),
|
files: $form.find(":file"),
|
||||||
@ -47,8 +43,10 @@ define(function (require) {
|
|||||||
}).complete(function(data) {
|
}).complete(function(data) {
|
||||||
self.missions.fetch({success : function () {
|
self.missions.fetch({success : function () {
|
||||||
self.laddaBtn.stop();
|
self.laddaBtn.stop();
|
||||||
modal.close();
|
self.render();
|
||||||
}});
|
}});
|
||||||
|
}).error(function() {
|
||||||
|
self.laddaBtn.stop();
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
27
public/js/app/views/missions/index.js
Normal file
27
public/js/app/views/missions/index.js
Normal file
@ -0,0 +1,27 @@
|
|||||||
|
define(function (require) {
|
||||||
|
|
||||||
|
"use strict";
|
||||||
|
|
||||||
|
var $ = require('jquery'),
|
||||||
|
_ = require('underscore'),
|
||||||
|
Backbone = require('backbone'),
|
||||||
|
Marionette = require('marionette'),
|
||||||
|
FormView = require('app/views/missions/form'),
|
||||||
|
ListView = require('app/views/missions/list'),
|
||||||
|
tpl = require('text!tpl/missions/index.html');
|
||||||
|
|
||||||
|
return Marionette.Layout.extend({
|
||||||
|
template: _.template(tpl),
|
||||||
|
|
||||||
|
regions: {
|
||||||
|
formView: "#form",
|
||||||
|
listView: "#list",
|
||||||
|
},
|
||||||
|
|
||||||
|
onRender: function() {
|
||||||
|
this.formView.show(new FormView({missions: this.options.missions}));
|
||||||
|
this.listView.show(new ListView({collection: this.options.missions}));
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
|
});
|
@ -7,7 +7,6 @@ define(function (require) {
|
|||||||
Backbone = require('backbone'),
|
Backbone = require('backbone'),
|
||||||
Marionette = require('marionette'),
|
Marionette = require('marionette'),
|
||||||
ListItemView = require('app/views/missions/list_item'),
|
ListItemView = require('app/views/missions/list_item'),
|
||||||
FormView = require('app/views/missions/form'),
|
|
||||||
tpl = require('text!tpl/missions/list.html'),
|
tpl = require('text!tpl/missions/list.html'),
|
||||||
|
|
||||||
template = _.template(tpl);
|
template = _.template(tpl);
|
||||||
@ -16,15 +15,5 @@ define(function (require) {
|
|||||||
itemView: ListItemView,
|
itemView: ListItemView,
|
||||||
itemViewContainer: "tbody",
|
itemViewContainer: "tbody",
|
||||||
template: template,
|
template: template,
|
||||||
|
|
||||||
events: {
|
|
||||||
"click #upload": "upload"
|
|
||||||
},
|
|
||||||
|
|
||||||
upload: function (event) {
|
|
||||||
event.preventDefault();
|
|
||||||
var view = new FormView({missions: this.collection});
|
|
||||||
new Backbone.BootstrapModal({ content: view, animate: true }).open()
|
|
||||||
},
|
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
@ -4,4 +4,5 @@
|
|||||||
<input type="file" class="form-control path" name="mission" id="mission" data-field="mission">
|
<input type="file" class="form-control path" name="mission" id="mission" data-field="mission">
|
||||||
<span class="help-block">Only supports missions packed as a PBO</span>
|
<span class="help-block">Only supports missions packed as a PBO</span>
|
||||||
</div>
|
</div>
|
||||||
|
<button type="submit" class="btn btn-primary">Upload</button>
|
||||||
</form>
|
</form>
|
||||||
|
4
public/js/tpl/missions/index.html
Normal file
4
public/js/tpl/missions/index.html
Normal file
@ -0,0 +1,4 @@
|
|||||||
|
<div class="row">
|
||||||
|
<div class="col-md-4 col-md-push-8" id="form"></div>
|
||||||
|
<div class="col-md-8 col-md-pull-4" id="list"></div>
|
||||||
|
</div>
|
@ -9,5 +9,3 @@
|
|||||||
<!-- want to insert collection items, here -->
|
<!-- want to insert collection items, here -->
|
||||||
<tbody></tbody>
|
<tbody></tbody>
|
||||||
</table>
|
</table>
|
||||||
|
|
||||||
<a class="btn btn-primary" id="upload" href="#">Upload new mission</a>
|
|
||||||
|
Loading…
Reference in New Issue
Block a user