Dashboard with servers

This commit is contained in:
Björn Dahlgren 2014-04-13 19:10:40 +02:00
parent 12a9435e17
commit 77026aa4bc
7 changed files with 79 additions and 13 deletions

View File

@ -6,7 +6,7 @@ define(function (require) {
Backbone = require('backbone'), Backbone = require('backbone'),
LayoutView = require('app/views/layout'), LayoutView = require('app/views/layout'),
NavigationView = require('app/views/navigation'), NavigationView = require('app/views/navigation'),
HomeView = require('app/views/home'), ServersView = require('app/views/servers/list'),
MissionsListView= require('app/views/missions/list'), MissionsListView= require('app/views/missions/list'),
ModsListView = require('app/views/mods/list'), ModsListView = require('app/views/mods/list'),
ServerView = require('app/views/servers/view'), ServerView = require('app/views/servers/view'),
@ -20,7 +20,7 @@ define(function (require) {
servers = new Servers(), servers = new Servers(),
layoutView = new LayoutView({el: $body}).render(), layoutView = new LayoutView({el: $body}).render(),
navigationView = new NavigationView({servers: servers}), navigationView = new NavigationView({servers: servers}),
homeView = new HomeView({servers: servers}), serversView = new ServersView({collection: servers}),
missionsListView = new MissionsListView({collection: missions}), missionsListView = new MissionsListView({collection: missions}),
modsListView = new ModsListView({collection: mods}); modsListView = new ModsListView({collection: mods});
@ -41,8 +41,8 @@ define(function (require) {
}, },
home: function () { home: function () {
layoutView.content.show(homeView); layoutView.content.show(serversView);
homeView.delegateEvents(); serversView.delegateEvents();
}, },
missions: function () { missions: function () {

View File

@ -1,29 +1,29 @@
define(function (require) { define(function (require) {
"use strict"; "use strict";
var $ = require('jquery'), var $ = require('jquery'),
_ = require('underscore'), _ = require('underscore'),
Backbone = require('backbone'), Backbone = require('backbone'),
Marionette = require('marionette'), Marionette = require('marionette'),
AddServerView = require('app/views/servers/add'), AddServerView = require('app/views/servers/add'),
tpl = require('text!tpl/home.html'); tpl = require('text!tpl/servers/empty.html');
return Marionette.ItemView.extend({ return Marionette.ItemView.extend({
template: _.template(tpl), template: _.template(tpl),
events: { events: {
"click #add-server": "addServer" "click #add-server": "addServer"
}, },
initialize: function (options) { initialize: function (options) {
this.servers = options.servers; this.servers = options.servers;
}, },
addServer: function () { addServer: function () {
var view = new AddServerView({servers: this.servers}); var view = new AddServerView({servers: this.servers});
new Backbone.BootstrapModal({ content: view, servers: this.servers }).open() new Backbone.BootstrapModal({ content: view, servers: this.servers }).open()
}, },
}); });
}); });

View File

@ -0,0 +1,36 @@
define(function (require) {
"use strict";
var $ = require('jquery'),
_ = require('underscore'),
Backbone = require('backbone'),
Marionette = require('marionette'),
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({
itemView: ListItemView,
itemViewContainer: "tbody",
template: template,
emptyView: EmptyView,
buildItemView: function(item, ItemViewType, itemViewOptions){
// build the final list of options for the item view type
var options = _.extend({model: item}, itemViewOptions);
if (ItemViewType == EmptyView) {
options = _.extend({servers: this.collection}, options);
}
// create the item view instance
var view = new ItemViewType(options);
// return it
return view;
},
});
});

View File

@ -0,0 +1,17 @@
define(function (require) {
"use strict";
var $ = require('jquery'),
_ = require('underscore'),
Backbone = require('backbone'),
Marionette = require('marionette'),
tpl = require('text!tpl/servers/list_item.html'),
template = _.template(tpl);
return Marionette.ItemView.extend({
tagName: "tr",
template: template
});
});

View File

@ -0,0 +1,10 @@
<table class="table table-striped">
<thead>
<tr>
<th>Server</th>
</tr>
</thead>
<!-- want to insert collection items, here -->
<tbody></tbody>
</table>

View File

@ -0,0 +1,3 @@
<td>
<a href='#servers/<%-id%>'><%-title%></a>
</td>