mirror of
https://github.com/Dahlgren/arma-server-web-admin.git
synced 2024-08-30 17:22:10 +00:00
Merge pull request #90 from Dahlgren/feature/marionette-2
Update frontend dependencies
This commit is contained in:
commit
09c44ef585
@ -14,11 +14,13 @@ define(function (require) {
|
||||
Logs = require('app/collections/logs'),
|
||||
Missions = require('app/collections/missions'),
|
||||
Mods = require('app/collections/mods'),
|
||||
Settings = require('app/models/settings'),
|
||||
Servers = require('app/collections/servers'),
|
||||
|
||||
$body = $('body'),
|
||||
missions = new Missions(),
|
||||
mods = new Mods(),
|
||||
settings = new Settings(),
|
||||
servers = new Servers(),
|
||||
layoutView = new LayoutView({el: $body}).render();
|
||||
|
||||
@ -33,18 +35,19 @@ define(function (require) {
|
||||
},
|
||||
|
||||
initialize: function () {
|
||||
layoutView.navigation.show(new NavigationView({servers: servers}));
|
||||
layoutView.navigation.show(new NavigationView({settings: settings, servers: servers}));
|
||||
sweetAlertInitialize();
|
||||
missions.fetch();
|
||||
settings.fetch();
|
||||
|
||||
var initialized = false;
|
||||
|
||||
var socket = io.connect();
|
||||
socket.on('mods', function (_mods) {
|
||||
mods.set(_mods).sort();
|
||||
mods.set(_mods);
|
||||
});
|
||||
socket.on('servers', function (_servers) {
|
||||
servers.set(_servers).sort();
|
||||
servers.set(_servers);
|
||||
|
||||
if (!initialized) {
|
||||
initialized = true;
|
||||
|
@ -8,7 +8,7 @@ define(function (require) {
|
||||
Marionette = require('marionette'),
|
||||
tpl = require('text!tpl/layout.html');
|
||||
|
||||
return Marionette.Layout.extend({
|
||||
return Marionette.LayoutView.extend({
|
||||
template: _.template(tpl),
|
||||
|
||||
regions: {
|
||||
|
@ -12,8 +12,8 @@ define(function (require) {
|
||||
template = _.template(tpl);
|
||||
|
||||
return Marionette.CompositeView.extend({
|
||||
itemView: ListItemView,
|
||||
itemViewContainer: "tbody",
|
||||
childView: ListItemView,
|
||||
childViewContainer: "tbody",
|
||||
template: template,
|
||||
});
|
||||
});
|
||||
|
@ -16,10 +16,10 @@ define(function (require) {
|
||||
template: template,
|
||||
|
||||
events: {
|
||||
"click .destroy": "destroy",
|
||||
"click .destroy": "deleteLog",
|
||||
},
|
||||
|
||||
destroy: function (event) {
|
||||
deleteLog: function (event) {
|
||||
var self = this;
|
||||
sweetAlert({
|
||||
title: "Are you sure?",
|
||||
|
@ -11,7 +11,7 @@ define(function (require) {
|
||||
ListView = require('app/views/missions/list'),
|
||||
tpl = require('text!tpl/missions/index.html');
|
||||
|
||||
return Marionette.Layout.extend({
|
||||
return Marionette.LayoutView.extend({
|
||||
template: _.template(tpl),
|
||||
|
||||
regions: {
|
||||
|
@ -12,12 +12,8 @@ define(function (require) {
|
||||
template = _.template(tpl);
|
||||
|
||||
return Marionette.CompositeView.extend({
|
||||
itemView: ListItemView,
|
||||
itemViewContainer: "tbody",
|
||||
childView: ListItemView,
|
||||
childViewContainer: "tbody",
|
||||
template: template,
|
||||
|
||||
initialize: function (options) {
|
||||
this.listenTo(this.collection, "change reset", this.render);
|
||||
},
|
||||
});
|
||||
});
|
||||
|
@ -16,10 +16,10 @@ define(function (require) {
|
||||
template: template,
|
||||
|
||||
events: {
|
||||
"click .delete": "delete"
|
||||
"click .delete": "deleteMission"
|
||||
},
|
||||
|
||||
delete: function (event) {
|
||||
deleteMission: function (event) {
|
||||
var self = this;
|
||||
sweetAlert({
|
||||
title: "Are you sure?",
|
||||
|
@ -20,7 +20,6 @@ define(function (require) {
|
||||
|
||||
initialize: function (options) {
|
||||
this.missions = options.missions;
|
||||
this.model = new Mission();
|
||||
},
|
||||
|
||||
submit: function () {
|
||||
|
@ -12,18 +12,14 @@ define(function (require) {
|
||||
template = _.template(tpl);
|
||||
|
||||
return Marionette.CompositeView.extend({
|
||||
itemView: ListItemView,
|
||||
itemViewContainer: "tbody",
|
||||
childView: ListItemView,
|
||||
childViewContainer: "tbody",
|
||||
template: template,
|
||||
|
||||
events: {
|
||||
"click #refresh": "refresh",
|
||||
},
|
||||
|
||||
initialize: function (options) {
|
||||
this.listenTo(this.collection, "change reset", this.render);
|
||||
},
|
||||
|
||||
refresh: function (event) {
|
||||
event.preventDefault();
|
||||
$.ajax({
|
||||
|
@ -17,10 +17,10 @@ define(function (require) {
|
||||
template: template,
|
||||
|
||||
events: {
|
||||
"click .destroy": "destroy",
|
||||
"click .destroy": "deleteMod",
|
||||
},
|
||||
|
||||
destroy: function (event) {
|
||||
deleteMod: function (event) {
|
||||
var self = this;
|
||||
sweetAlert({
|
||||
title: "Are you sure?",
|
||||
|
@ -19,6 +19,7 @@ define(function (require) {
|
||||
},
|
||||
|
||||
initialize: function (options) {
|
||||
this.settings = options.settings;
|
||||
this.servers = options.servers;
|
||||
this.serversListView = new ServersListView({ collection: this.servers })
|
||||
},
|
||||
@ -30,7 +31,7 @@ define(function (require) {
|
||||
|
||||
settings: function (event) {
|
||||
event.preventDefault();
|
||||
var view = new SettingsView();
|
||||
var view = new SettingsView({ model: this.settings });
|
||||
new Backbone.BootstrapModal({ content: view, animate: true, cancelText: false }).open();
|
||||
}
|
||||
});
|
||||
|
@ -10,6 +10,6 @@ define(function (require) {
|
||||
|
||||
return Marionette.CollectionView.extend({
|
||||
tagName: 'ul',
|
||||
itemView: ListItemView,
|
||||
childView: ListItemView,
|
||||
});
|
||||
});
|
||||
|
@ -9,7 +9,7 @@ define(function (require) {
|
||||
swal = require('sweet-alert'),
|
||||
tpl = require('text!tpl/servers/info.html');
|
||||
|
||||
return Marionette.Layout.extend({
|
||||
return Marionette.LayoutView.extend({
|
||||
template: _.template(tpl),
|
||||
|
||||
events: {
|
||||
|
@ -15,8 +15,8 @@ define(function (require) {
|
||||
template = _.template(tpl);
|
||||
|
||||
return Marionette.CompositeView.extend({
|
||||
itemView: ListItemView,
|
||||
itemViewContainer: "tbody",
|
||||
childView: ListItemView,
|
||||
childViewContainer: "tbody",
|
||||
template: template,
|
||||
|
||||
emptyView: EmptyView,
|
||||
@ -25,20 +25,16 @@ define(function (require) {
|
||||
"click #add-server": "addServer"
|
||||
},
|
||||
|
||||
initialize: function (options) {
|
||||
this.listenTo(this.collection, "change reset", this.render);
|
||||
},
|
||||
|
||||
buildItemView: function(item, ItemViewType, itemViewOptions){
|
||||
buildChildView: function(item, ChildViewType, childViewOptions){
|
||||
// build the final list of options for the item view type
|
||||
var options = _.extend({model: item}, itemViewOptions);
|
||||
var options = _.extend({model: item}, childViewOptions);
|
||||
|
||||
if (ItemViewType == EmptyView) {
|
||||
if (ChildViewType == EmptyView) {
|
||||
options = _.extend({servers: this.collection}, options);
|
||||
}
|
||||
|
||||
// create the item view instance
|
||||
var view = new ItemViewType(options);
|
||||
var view = new ChildViewType(options);
|
||||
// return it
|
||||
return view;
|
||||
},
|
||||
|
@ -10,14 +10,14 @@ define(function (require) {
|
||||
tpl = require('text!tpl/servers/missions/available/list.html');
|
||||
|
||||
return Marionette.CompositeView.extend({
|
||||
itemView: ListItemView,
|
||||
itemViewContainer: "tbody",
|
||||
childView: ListItemView,
|
||||
childViewContainer: "tbody",
|
||||
template: _.template(tpl),
|
||||
|
||||
buildItemView: function(item, ItemViewType, itemViewOptions){
|
||||
buildChildView: function(item, ChildViewType, childViewOptions){
|
||||
var self = this;
|
||||
var options = _.extend({model: item}, itemViewOptions);
|
||||
var view = new ItemViewType(options);
|
||||
var options = _.extend({model: item}, childViewOptions);
|
||||
var view = new ChildViewType(options);
|
||||
view.on('add', function (model) {
|
||||
self.trigger('add', model);
|
||||
});
|
||||
|
@ -11,7 +11,7 @@ define(function (require) {
|
||||
RotationListView = require('app/views/servers/missions/rotation/list'),
|
||||
tpl = require('text!tpl/servers/missions/index.html');
|
||||
|
||||
return Marionette.Layout.extend({
|
||||
return Marionette.LayoutView.extend({
|
||||
template: _.template(tpl),
|
||||
|
||||
regions: {
|
||||
@ -25,7 +25,6 @@ define(function (require) {
|
||||
|
||||
initialize: function (options) {
|
||||
this.missions = options.missions;
|
||||
this.model = options.server;
|
||||
|
||||
this.rotationCollection = new MissionRotations(this.model.get('missions'));
|
||||
|
||||
|
@ -11,8 +11,8 @@ define(function (require) {
|
||||
tpl = require('text!tpl/servers/missions/rotation/list.html');
|
||||
|
||||
return Marionette.CompositeView.extend({
|
||||
itemView: ListItemView,
|
||||
itemViewContainer: "tbody",
|
||||
childView: ListItemView,
|
||||
childViewContainer: "tbody",
|
||||
template: _.template(tpl),
|
||||
|
||||
events: {
|
||||
|
@ -12,7 +12,7 @@ define(function (require) {
|
||||
tpl = require('text!tpl/servers/mods/list.html');
|
||||
|
||||
return ModsListView.extend({
|
||||
itemView: ListItemView,
|
||||
childView: ListItemView,
|
||||
template: _.template(tpl),
|
||||
|
||||
events: {
|
||||
@ -20,9 +20,9 @@ define(function (require) {
|
||||
"click .uncheck-all": "uncheckAll",
|
||||
},
|
||||
|
||||
buildItemView: function(item, ItemViewType, itemViewOptions){
|
||||
var options = _.extend({model: item, server: this.options.server}, itemViewOptions);
|
||||
var view = new ItemViewType(options);
|
||||
buildChildView: function(item, ChildViewType, childViewOptions){
|
||||
var options = _.extend({model: item, server: this.options.server}, childViewOptions);
|
||||
var view = new ChildViewType(options);
|
||||
return view;
|
||||
},
|
||||
|
||||
|
@ -12,22 +12,21 @@ define(function (require) {
|
||||
tpl = require('text!tpl/servers/parameters/list.html');
|
||||
|
||||
return Marionette.CompositeView.extend({
|
||||
itemView: ListItemView,
|
||||
itemViewContainer: "tbody",
|
||||
childView: ListItemView,
|
||||
childViewContainer: "tbody",
|
||||
template: _.template(tpl),
|
||||
|
||||
events: {
|
||||
"click .add-parameter": "addParameter",
|
||||
},
|
||||
|
||||
initialize: function (options) {
|
||||
this.model = options.server;
|
||||
modelEvents: {
|
||||
"change": "serverUpdated",
|
||||
},
|
||||
|
||||
this.collection = new Parameters(this.model.get('parameters').map(function (parameter) {
|
||||
return new Parameter({
|
||||
parameter: parameter,
|
||||
});
|
||||
}));
|
||||
initialize: function (options) {
|
||||
this.collection = new Parameters();
|
||||
this.serverUpdated();
|
||||
},
|
||||
|
||||
addParameter: function (e) {
|
||||
@ -42,6 +41,14 @@ define(function (require) {
|
||||
}),
|
||||
};
|
||||
},
|
||||
|
||||
serverUpdated: function () {
|
||||
this.collection.reset(this.model.get('parameters').map(function (parameter) {
|
||||
return new Parameter({
|
||||
parameter: parameter,
|
||||
});
|
||||
}));
|
||||
},
|
||||
});
|
||||
|
||||
});
|
||||
|
@ -8,7 +8,7 @@ define(function (require) {
|
||||
Marionette = require('marionette'),
|
||||
tpl = require('text!tpl/servers/players.html');
|
||||
|
||||
return Marionette.Layout.extend({
|
||||
return Marionette.LayoutView.extend({
|
||||
template: _.template(tpl),
|
||||
templateHelpers: {
|
||||
players: function(){
|
||||
|
@ -15,7 +15,7 @@ define(function (require) {
|
||||
PlayersView = require('app/views/servers/players'),
|
||||
tpl = require('text!tpl/servers/view.html');
|
||||
|
||||
return Marionette.Layout.extend({
|
||||
return Marionette.LayoutView.extend({
|
||||
template: _.template(tpl),
|
||||
|
||||
regions: {
|
||||
@ -43,9 +43,9 @@ define(function (require) {
|
||||
|
||||
onRender: function() {
|
||||
this.infoView.show(new InfoView({model: this.model}));
|
||||
this.missionsView.show(new MissionsView({missions: this.missions, server: this.model}));
|
||||
this.missionsView.show(new MissionsView({missions: this.missions, model: this.model}));
|
||||
this.modsView.show(new ModsListView({collection: this.mods, server: this.model}));
|
||||
this.parametersView.show(new ParametersListView({server: this.model}));
|
||||
this.parametersView.show(new ParametersListView({model: this.model}));
|
||||
this.playersView.show(new PlayersView({model: this.model}));
|
||||
this.settingsView.show(new FormView({model: this.model}));
|
||||
},
|
||||
|
@ -6,7 +6,6 @@ define(function (require) {
|
||||
_ = require('underscore'),
|
||||
Backbone = require('backbone'),
|
||||
Marionette = require('marionette'),
|
||||
Settings = require('app/models/settings'),
|
||||
tpl = require('text!tpl/settings.html');
|
||||
|
||||
return Marionette.ItemView.extend({
|
||||
@ -16,11 +15,6 @@ define(function (require) {
|
||||
'change': 'render',
|
||||
},
|
||||
|
||||
initialize: function () {
|
||||
this.model = new Settings()
|
||||
this.model.fetch();
|
||||
},
|
||||
|
||||
templateHelpers: {
|
||||
isTypeChecked: function(type) {
|
||||
return this.type === type ? 'checked' : '';
|
||||
|
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
Loading…
Reference in New Issue
Block a user