1
0
Fork 0

Added a cascading unrender if clicking in Menu levels

This commit is contained in:
Michael Hackstein 2014-01-17 13:07:19 +01:00
parent 099fac2582
commit e5c9fbec3e
13 changed files with 88 additions and 8 deletions

View File

@ -41,10 +41,16 @@
}); });
}, },
render: function(){ unrender: function() {
$(this.el).html("");
this.shardsView.unrender();
},
render: function() {
$(this.el).html(this.template.render({ $(this.el).html(this.template.render({
collections: this.fakeData.collections collections: this.fakeData.collections
})); }));
this.shardsView.unrender();
return this; return this;
} }

View File

@ -32,6 +32,10 @@
}; };
}, },
unrender: function() {
$(this.el).html("");
},
render: function() { render: function() {
$(this.el).html(this.template.render({ $(this.el).html(this.template.render({
coordinators: this.fakeData.coordinators coordinators: this.fakeData.coordinators

View File

@ -39,10 +39,16 @@
this.colView.render(id); this.colView.render(id);
}, },
unrender: function() {
$(this.el).html("");
this.colView.unrender();
},
render: function(){ render: function(){
$(this.el).html(this.template.render({ $(this.el).html(this.template.render({
databases: this.fakeData.databases databases: this.fakeData.databases
})); }));
this.colView.unrender();
return this; return this;
} }

View File

@ -34,11 +34,13 @@
}, },
loadDBServers: function() { loadDBServers: function() {
this.coordinatorView.unrender();
this.serverView.render(); this.serverView.render();
this.render(true); this.render(true);
}, },
loadCoordinators: function() { loadCoordinators: function() {
this.serverView.unrender();
this.coordinatorView.render(); this.coordinatorView.render();
this.render(true); this.render(true);
}, },

View File

@ -60,7 +60,15 @@
this.render(true); this.render(true);
}, },
unrender: function() {
$(this.el).html("");
this.dbView.unrender();
},
render: function(minify){ render: function(minify){
if(!minify) {
this.dbView.unrender();
}
$(this.el).html(this.template.render({ $(this.el).html(this.template.render({
minify: minify, minify: minify,
servers: this.fakeData servers: this.fakeData

View File

@ -29,7 +29,11 @@
}; };
}, },
render: function(){ unrender: function() {
$(this.el).html("");
},
render: function() {
$(this.el).html(this.template.render({ $(this.el).html(this.template.render({
shards: this.fakeData.shards shards: this.fakeData.shards
})); }));

View File

@ -173,6 +173,7 @@ module.exports = function(karma) {
'frontend/js/views/clusterDashboardView.js', 'frontend/js/views/clusterDashboardView.js',
'frontend/js/views/clusterOverviewView.js', 'frontend/js/views/clusterOverviewView.js',
'frontend/js/views/clusterServerView.js', 'frontend/js/views/clusterServerView.js',
'frontend/js/views/clusterCoordinatorView.js',
'frontend/js/views/clusterDatabaseView.js', 'frontend/js/views/clusterDatabaseView.js',
'frontend/js/views/clusterCollectionView.js', 'frontend/js/views/clusterCollectionView.js',
'frontend/js/views/clusterShardsView.js', 'frontend/js/views/clusterShardsView.js',
@ -232,6 +233,7 @@ module.exports = function(karma) {
'test/specs/views/clusterDashboardViewSpec.js', 'test/specs/views/clusterDashboardViewSpec.js',
'test/specs/views/clusterOverviewViewSpec.js', 'test/specs/views/clusterOverviewViewSpec.js',
'test/specs/views/clusterServerViewSpec.js', 'test/specs/views/clusterServerViewSpec.js',
'test/specs/views/clusterCoordinatorViewSpec.js',
'test/specs/views/clusterDatabaseViewSpec.js', 'test/specs/views/clusterDatabaseViewSpec.js',
'test/specs/views/clusterCollectionViewSpec.js', 'test/specs/views/clusterCollectionViewSpec.js',
'test/specs/views/clusterShardsViewSpec.js', 'test/specs/views/clusterShardsViewSpec.js',

View File

@ -13,7 +13,8 @@
div.id = "clusterCollections"; div.id = "clusterCollections";
document.body.appendChild(div); document.body.appendChild(div);
shardsView = { shardsView = {
render: function(){} render: function() {},
unrender: function() {}
}; };
spyOn(window, "ClusterShardsView").andReturn(shardsView); spyOn(window, "ClusterShardsView").andReturn(shardsView);
uiMatchers.define(this); uiMatchers.define(this);
@ -64,13 +65,15 @@
people people
]; ];
spyOn(shardsView, "render"); spyOn(shardsView, "render");
spyOn(shardsView, "unrender");
view = new window.ClusterCollectionView(); view = new window.ClusterCollectionView();
view.fakeData.collections = colls; view.fakeData.collections = colls;
view.render(); view.render();
}); });
it("should not render the server view", function() { it("should not unrender the server view", function() {
expect(shardsView.render).not.toHaveBeenCalled(); expect(shardsView.render).not.toHaveBeenCalled();
expect(shardsView.unrender).toHaveBeenCalled();
}); });
it("should render the documents collection", function() { it("should render the documents collection", function() {
@ -85,6 +88,14 @@
checkButtonContent(people, "danger"); checkButtonContent(people, "danger");
}); });
it("should offer an unrender function", function() {
shardsView.unrender.reset();
view.unrender();
expect($(div).html()).toEqual("");
expect(shardsView.unrender).toHaveBeenCalled();
});
describe("user actions", function() { describe("user actions", function() {
var info; var info;

View File

@ -79,6 +79,11 @@
checkTile(chantalle, "success"); checkTile(chantalle, "success");
}); });
it("should allow an unrender function", function() {
view.unrender();
expect($(div).html()).toEqual("");
});
}); });
}); });

View File

@ -13,7 +13,8 @@
div.id = "clusterDatabases"; div.id = "clusterDatabases";
document.body.appendChild(div); document.body.appendChild(div);
colView = { colView = {
render: function(){} render: function() {},
unrender: function() {}
}; };
spyOn(window, "ClusterCollectionView").andReturn(colView); spyOn(window, "ClusterCollectionView").andReturn(colView);
uiMatchers.define(this); uiMatchers.define(this);
@ -47,6 +48,7 @@
beforeEach(function() { beforeEach(function() {
spyOn(colView, "render"); spyOn(colView, "render");
spyOn(colView, "unrender");
db1 = { db1 = {
name: "_system", name: "_system",
status: "ok" status: "ok"
@ -71,6 +73,7 @@
it("should not render the Server view", function() { it("should not render the Server view", function() {
expect(colView.render).not.toHaveBeenCalled(); expect(colView.render).not.toHaveBeenCalled();
expect(colView.unrender).toHaveBeenCalled();
}); });
it("should render the ok database", function() { it("should render the ok database", function() {
@ -85,6 +88,13 @@
checkButtonContent(db3, "danger"); checkButtonContent(db3, "danger");
}); });
it("should offer an unrender function", function() {
colView.unrender.reset();
view.unrender();
expect($(div).html()).toEqual("");
expect(colView.unrender).toHaveBeenCalled();
});
describe("user actions", function() { describe("user actions", function() {
var db; var db;

View File

@ -13,10 +13,12 @@
div.id = "clusterOverview"; div.id = "clusterOverview";
document.body.appendChild(div); document.body.appendChild(div);
serverView = { serverView = {
render: function() {} render: function() {},
unrender: function() {}
}; };
coordinatorView = { coordinatorView = {
render: function() {} render: function() {},
unrender: function() {}
}; };
spyOn(window, "ClusterServerView").andReturn(serverView); spyOn(window, "ClusterServerView").andReturn(serverView);
spyOn(window, "ClusterCoordinatorView").andReturn(coordinatorView); spyOn(window, "ClusterCoordinatorView").andReturn(coordinatorView);
@ -52,12 +54,14 @@
it("should be able to navigate to db servers", function() { it("should be able to navigate to db servers", function() {
$("#dbserver").click(); $("#dbserver").click();
expect(serverView.render).toHaveBeenCalledWith(); expect(serverView.render).toHaveBeenCalledWith();
expect(coordinatorView.unrender).toHaveBeenCalled();
expect(view.render).toHaveBeenCalledWith(true); expect(view.render).toHaveBeenCalledWith(true);
}); });
it("should be able to navigate to coordinators", function() { it("should be able to navigate to coordinators", function() {
$("#coordinator").click(); $("#coordinator").click();
expect(coordinatorView.render).toHaveBeenCalledWith(); expect(coordinatorView.render).toHaveBeenCalledWith();
expect(serverView.unrender).toHaveBeenCalled();
expect(view.render).toHaveBeenCalledWith(true); expect(view.render).toHaveBeenCalledWith(true);
}); });
@ -79,7 +83,9 @@
beforeEach(function() { beforeEach(function() {
spyOn(serverView, "render"); spyOn(serverView, "render");
spyOn(serverView, "unrender");
spyOn(coordinatorView, "render"); spyOn(coordinatorView, "render");
spyOn(coordinatorView, "unrender");
view = new window.ClusterOverviewView(); view = new window.ClusterOverviewView();
// Fake Data Injection to be removed // Fake Data Injection to be removed
view.fakeData = { view.fakeData = {

View File

@ -13,7 +13,8 @@
div.id = "clusterServers"; div.id = "clusterServers";
document.body.appendChild(div); document.body.appendChild(div);
dbView = { dbView = {
render: function(){} render: function() {},
unrender: function() {}
}; };
spyOn(window, "ClusterDatabaseView").andReturn(dbView); spyOn(window, "ClusterDatabaseView").andReturn(dbView);
uiMatchers.define(this); uiMatchers.define(this);
@ -77,6 +78,7 @@
beforeEach(function() { beforeEach(function() {
spyOn(dbView, "render"); spyOn(dbView, "render");
spyOn(dbView, "unrender");
view = new window.ClusterServerView(); view = new window.ClusterServerView();
okPair = { okPair = {
primary: { primary: {
@ -145,8 +147,17 @@
it("should not render the Database view", function() { it("should not render the Database view", function() {
expect(dbView.render).not.toHaveBeenCalled(); expect(dbView.render).not.toHaveBeenCalled();
expect(dbView.unrender).toHaveBeenCalled();
}); });
it("should offer an unrender function", function() {
dbView.unrender.reset();
view.unrender();
expect($(div).html()).toEqual("");
expect(dbView.unrender).toHaveBeenCalled();
});
describe("minified version", function() { describe("minified version", function() {
var checkButtonContent = function(btn, pair, cls) { var checkButtonContent = function(btn, pair, cls) {

View File

@ -67,6 +67,11 @@
checkButtonContent(s3, "danger"); checkButtonContent(s3, "danger");
}); });
it("should offer an unrender function", function() {
view.unrender();
expect($(div).html()).toEqual("");
});
}); });