mirror of
https://github.com/FoggedLens/iD.git
synced 2026-03-21 02:23:30 +00:00
Use summary to calculate # in Save button
This commit is contained in:
@@ -158,10 +158,6 @@ iD.History = function(context) {
|
||||
return this.difference().length() > 0;
|
||||
},
|
||||
|
||||
numChanges: function() {
|
||||
return this.difference().length();
|
||||
},
|
||||
|
||||
imageryUsed: function(sources) {
|
||||
if (sources) {
|
||||
imageryUsed = sources;
|
||||
|
||||
@@ -42,13 +42,13 @@ iD.ui.Save = function(context) {
|
||||
var numChanges = 0;
|
||||
|
||||
context.history().on('change.save', function() {
|
||||
var _ = history.numChanges();
|
||||
var _ = history.difference().summary().length;
|
||||
if (_ === numChanges)
|
||||
return;
|
||||
numChanges = _;
|
||||
|
||||
tooltip.title(iD.ui.tooltipHtml(t(numChanges > 0 ?
|
||||
'save.help' : 'save.no_changes'), key))
|
||||
'save.help' : 'save.no_changes'), key));
|
||||
|
||||
button
|
||||
.classed('disabled', numChanges === 0)
|
||||
|
||||
@@ -211,22 +211,6 @@ describe("iD.History", function () {
|
||||
});
|
||||
});
|
||||
|
||||
describe("#numChanges", function() {
|
||||
it("is 0 when there are no changes", function() {
|
||||
expect(history.numChanges()).to.eql(0);
|
||||
});
|
||||
|
||||
it("is the sum of all types of changes", function() {
|
||||
var node1 = iD.Node({id: "n1"}),
|
||||
node2 = iD.Node();
|
||||
history.merge({ n1: node1 });
|
||||
history.perform(function (graph) { return graph.remove(node1); });
|
||||
expect(history.numChanges()).to.eql(1);
|
||||
history.perform(function (graph) { return graph.replace(node2); });
|
||||
expect(history.numChanges()).to.eql(2);
|
||||
});
|
||||
});
|
||||
|
||||
describe("#reset", function () {
|
||||
it("clears the version stack", function () {
|
||||
history.perform(action, "annotation");
|
||||
|
||||
Reference in New Issue
Block a user