mirror of
https://github.com/Dahlgren/arma-server-web-admin.git
synced 2024-08-30 17:22:10 +00:00
c58ec6f308
Backbone to 1.3.3 Marionette to 2.4.7 Underscore to 1.8.3 Fixes collection sorting when new items are added
48 lines
1.4 KiB
JavaScript
48 lines
1.4 KiB
JavaScript
define(function (require) {
|
|
|
|
"use strict";
|
|
|
|
var $ = require('jquery'),
|
|
_ = require('underscore'),
|
|
Backbone = require('backbone'),
|
|
Marionette = require('marionette'),
|
|
Server = require('app/models/server'),
|
|
AddServerView = require('app/views/servers/form'),
|
|
EmptyView = require('app/views/servers/empty'),
|
|
ListItemView = require('app/views/servers/list_item'),
|
|
tpl = require('text!tpl/servers/list.html'),
|
|
|
|
template = _.template(tpl);
|
|
|
|
return Marionette.CompositeView.extend({
|
|
childView: ListItemView,
|
|
childViewContainer: "tbody",
|
|
template: template,
|
|
|
|
emptyView: EmptyView,
|
|
|
|
events: {
|
|
"click #add-server": "addServer"
|
|
},
|
|
|
|
buildChildView: function(item, ChildViewType, childViewOptions){
|
|
// build the final list of options for the item view type
|
|
var options = _.extend({model: item}, childViewOptions);
|
|
|
|
if (ChildViewType == EmptyView) {
|
|
options = _.extend({servers: this.collection}, options);
|
|
}
|
|
|
|
// create the item view instance
|
|
var view = new ChildViewType(options);
|
|
// return it
|
|
return view;
|
|
},
|
|
|
|
addServer: function () {
|
|
var view = new AddServerView({model: new Server(), servers: this.collection});
|
|
new Backbone.BootstrapModal({ content: view, servers: this.collection }).open()
|
|
},
|
|
});
|
|
});
|