Tooltips for disabled operations (fixes #573)

This commit is contained in:
John Firebaugh
2013-03-29 12:17:39 -07:00
parent 52dd7bf869
commit b1daf85cfd
27 changed files with 198 additions and 122 deletions
-10
View File
@@ -1,14 +1,4 @@
describe("iD.actions.Connect", function() {
describe("#enabled", function () {
it("returns true for two or more nodes", function () {
expect(iD.actions.Connect(['a', 'b']).enabled()).to.be.true;
});
it("returns false for less than two nodes", function () {
expect(iD.actions.Connect(['a']).enabled()).to.be.false;
});
});
it("removes all but the final node", function() {
var graph = iD.Graph({
'a': iD.Node({id: 'a'}),
+7 -7
View File
@@ -1,12 +1,12 @@
describe("iD.actions.Disconnect", function () {
describe("#enabled", function () {
it("returns false for a node shared by less than two ways", function () {
describe("#disabled", function () {
it("returns 'not_connected' for a node shared by less than two ways", function () {
var graph = iD.Graph({'a': iD.Node()});
expect(iD.actions.Disconnect('a').enabled(graph)).to.equal(false);
expect(iD.actions.Disconnect('a').disabled(graph)).to.equal('not_connected');
});
it("returns true for a node appearing twice in the same way", function () {
it("returns falsy for a node appearing twice in the same way", function () {
// a ---- b
// | |
// d ---- c
@@ -17,10 +17,10 @@ describe("iD.actions.Disconnect", function () {
'd': iD.Node({id: 'd'}),
'w': iD.Way({id: 'w', nodes: ['a', 'b', 'c', 'd', 'a']})
});
expect(iD.actions.Disconnect('a').enabled(graph)).to.equal(true);
expect(iD.actions.Disconnect('a').disabled(graph)).not.to.be.ok;
});
it("returns true for a node shared by two or more ways", function () {
it("returns falsy for a node shared by two or more ways", function () {
// a ---- b ---- c
// |
// d
@@ -33,7 +33,7 @@ describe("iD.actions.Disconnect", function () {
'|': iD.Way({id: '|', nodes: ['d', 'b']})
});
expect(iD.actions.Disconnect('b').enabled(graph)).to.equal(true);
expect(iD.actions.Disconnect('b').disabled(graph)).not.to.be.ok;
});
});
+19 -11
View File
@@ -1,6 +1,6 @@
describe("iD.actions.Join", function () {
describe("#enabled", function () {
it("returns true for ways that share an end/start node", function () {
describe("#disabled", function () {
it("returns falsy for ways that share an end/start node", function () {
// a --> b ==> c
var graph = iD.Graph({
'a': iD.Node({id: 'a'}),
@@ -10,10 +10,10 @@ describe("iD.actions.Join", function () {
'=': iD.Way({id: '=', nodes: ['b', 'c']})
});
expect(iD.actions.Join(['-', '=']).enabled(graph)).to.be.true;
expect(iD.actions.Join(['-', '=']).disabled(graph)).not.to.be.ok;
});
it("returns true for ways that share a start/end node", function () {
it("returns falsy for ways that share a start/end node", function () {
// a <-- b <== c
var graph = iD.Graph({
'a': iD.Node({id: 'a'}),
@@ -23,10 +23,10 @@ describe("iD.actions.Join", function () {
'=': iD.Way({id: '=', nodes: ['c', 'b']})
});
expect(iD.actions.Join(['-', '=']).enabled(graph)).to.be.true;
expect(iD.actions.Join(['-', '=']).disabled(graph)).not.to.be.ok;
});
it("returns true for ways that share a start/start node", function () {
it("returns falsy for ways that share a start/start node", function () {
// a <-- b ==> c
var graph = iD.Graph({
'a': iD.Node({id: 'a'}),
@@ -36,10 +36,10 @@ describe("iD.actions.Join", function () {
'=': iD.Way({id: '=', nodes: ['b', 'c']})
});
expect(iD.actions.Join(['-', '=']).enabled(graph)).to.be.true;
expect(iD.actions.Join(['-', '=']).disabled(graph)).not.to.be.ok;
});
it("returns true for ways that share an end/end node", function () {
it("returns falsy for ways that share an end/end node", function () {
// a --> b <== c
var graph = iD.Graph({
'a': iD.Node({id: 'a'}),
@@ -49,10 +49,18 @@ describe("iD.actions.Join", function () {
'=': iD.Way({id: '=', nodes: ['c', 'b']})
});
expect(iD.actions.Join(['-', '=']).enabled(graph)).to.be.true;
expect(iD.actions.Join(['-', '=']).disabled(graph)).not.to.be.ok;
});
it("returns false for ways that don't share the necessary nodes", function () {
it("returns 'not_eligible' for non-line geometries", function () {
var graph = iD.Graph({
'a': iD.Node({id: 'a'})
});
expect(iD.actions.Join(['a']).disabled(graph)).to.equal('not_eligible');
});
it("returns 'not_adjacent' for ways that don't share the necessary nodes", function () {
// a -- b -- c
// |
// d
@@ -65,7 +73,7 @@ describe("iD.actions.Join", function () {
'=': iD.Way({id: '=', nodes: ['b', 'd']})
});
expect(iD.actions.Join(['-', '=']).enabled(graph)).to.be.false;
expect(iD.actions.Join(['-', '=']).disabled(graph)).to.equal('not_adjacent');
});
});
+2 -2
View File
@@ -8,7 +8,7 @@ describe("iD.actions.Merge", function () {
}),
action = iD.actions.Merge(['a', 'b', 'w']);
expect(action.enabled(graph)).to.be.true;
expect(action.disabled(graph)).not.to.be.ok;
graph = action(graph);
@@ -27,7 +27,7 @@ describe("iD.actions.Merge", function () {
}),
action = iD.actions.Merge(['a', 'b', 'w']);
expect(action.enabled(graph)).to.be.true;
expect(action.disabled(graph)).not.to.be.ok;
graph = action(graph);
+7 -7
View File
@@ -1,25 +1,25 @@
describe("iD.actions.Move", function() {
describe("#enabled", function() {
it("returns true by default", function() {
describe("#disabled", function() {
it("returns falsy by default", function() {
var node = iD.Node({loc: [0, 0]}),
action = iD.actions.Move([node.id], [0, 0], d3.geo.mercator()),
graph = iD.Graph([node]);
expect(action.enabled(graph)).to.be.true;
expect(action.disabled(graph)).not.to.be.ok;
});
it("returns false for an incomplete relation", function() {
it("returns 'incomplete_relation' for an incomplete relation", function() {
var relation = iD.Relation({members: [{id: 1}]}),
action = iD.actions.Move([relation.id], [0, 0], d3.geo.mercator()),
graph = iD.Graph([relation]);
expect(action.enabled(graph)).to.be.false;
expect(action.disabled(graph)).to.equal('incomplete_relation');
});
it("returns true for a complete relation", function() {
it("returns falsy for a complete relation", function() {
var node = iD.Node({loc: [0, 0]}),
relation = iD.Relation({members: [{id: node.id}]}),
action = iD.actions.Move([relation.id], [0, 0], d3.geo.mercator()),
graph = iD.Graph([node, relation]);
expect(action.enabled(graph)).to.be.true;
expect(action.disabled(graph)).not.to.be.ok;
});
});
+7 -7
View File
@@ -1,6 +1,6 @@
describe("iD.actions.Split", function () {
describe("#enabled", function () {
it("returns true for a non-end node of a single way", function () {
describe("#disabled", function () {
it("returns falsy for a non-end node of a single way", function () {
var graph = iD.Graph({
'a': iD.Node({id: 'a'}),
'b': iD.Node({id: 'b'}),
@@ -8,27 +8,27 @@ describe("iD.actions.Split", function () {
'-': iD.Way({id: '-', nodes: ['a', 'b', 'c']})
});
expect(iD.actions.Split('b').enabled(graph)).to.be.true;
expect(iD.actions.Split('b').disabled(graph)).not.to.be.ok;
});
it("returns false for the first node of a single way", function () {
it("returns 'not_eligible' for the first node of a single way", function () {
var graph = iD.Graph({
'a': iD.Node({id: 'a'}),
'b': iD.Node({id: 'b'}),
'-': iD.Way({id: '-', nodes: ['a', 'b']})
});
expect(iD.actions.Split('a').enabled(graph)).to.be.false;
expect(iD.actions.Split('a').disabled(graph)).to.equal('not_eligible');
});
it("returns false for the last node of a single way", function () {
it("returns 'not_eligible' for the last node of a single way", function () {
var graph = iD.Graph({
'a': iD.Node({id: 'a'}),
'b': iD.Node({id: 'b'}),
'-': iD.Way({id: '-', nodes: ['a', 'b']})
});
expect(iD.actions.Split('b').enabled(graph)).to.be.false;
expect(iD.actions.Split('b').disabled(graph)).to.equal('not_eligible');
});
});