diff --git a/Makefile b/Makefile index 6933eee9..a93c62f9 100644 --- a/Makefile +++ b/Makefile @@ -29,6 +29,18 @@ ui: mkdir -p umap/static/umap/vendors/georsstogeojson/ && cp -r node_modules/georsstogeojson/GeoRSSToGeoJSON.js umap/static/umap/vendors/georsstogeojson/ mkdir -p umap/static/umap/vendors/togpx/ && cp -r node_modules/togpx/togpx.js umap/static/umap/vendors/togpx/ mkdir -p umap/static/umap/vendors/tokml && cp -r node_modules/tokml/tokml.js umap/static/umap/vendors/tokml +installjs: + npm install +testjsfx: + firefox umap/static/umap/test/index.html +testjs: node_modules + @./node_modules/mocha-phantomjs/bin/mocha-phantomjs --view 1024x768 umap/static/umap/test/index.html +i18n: + node node_modules/leaflet-i18n/bin/i18n.js --dir_path=umap/static/umap/js/ --dir_path=umap/static/umap/vendors/measurable/ --locale_dir_path=umap/static/umap/locale/ --locale_codes=en --mode=json --clean --default_values +# tx_push: +# tx push -s +# tx_pull: +# tx pull .PHONY: ui diff --git a/package-lock.json b/package-lock.json index ff0961c3..3cc78942 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,6 +1,6 @@ { - "name": "leaflet-storage", - "version": "0.8.2", + "name": "umap", + "version": "1.0.0-alpha.1", "lockfileVersion": 1, "requires": true, "dependencies": { diff --git a/umap/static/umap/test/Controls.js b/umap/static/umap/test/Controls.js index 0e45aeee..a1daf55d 100644 --- a/umap/static/umap/test/Controls.js +++ b/umap/static/umap/test/Controls.js @@ -1,4 +1,4 @@ -describe('L.Storage.Controls', function(){ +describe('L.Utorage.Controls', function(){ before(function () { this.server = sinon.fakeServer.create(); diff --git a/umap/static/umap/test/DataLayer.js b/umap/static/umap/test/DataLayer.js index 808824fa..c19933b7 100644 --- a/umap/static/umap/test/DataLayer.js +++ b/umap/static/umap/test/DataLayer.js @@ -83,20 +83,14 @@ describe('L.DataLayer', function () { cleanAlert(); this.server.flush(); this.server.respondWith('POST', '/map/99/update/settings/', JSON.stringify({id: 99})); - // this.server.respondWith('POST', '/map/99/datalayer/update/62/', [412, {}, '']); - this.server.respondWith('POST', '/map/99/datalayer/update/62/', function (request) { - console.log('YESYESYEYESYEYEYEYSES') - request.respond() - }); + this.server.respondWith('POST', '/map/99/datalayer/update/62/', [412, {}, '']); happen.click(editButton); input = qs('form.storage-form input[name="name"]'); input.value = 'a new name'; happen.once(input, {type: 'input'}); clickSave(); this.server.respond(); - console.log('between responses') this.server.respond(); - console.log(this.map._container.classList) assert(L.DomUtil.hasClass(this.map._container, 'storage-alert')); assert.notEqual(this.map.dirty_datalayers.indexOf(this.datalayer), -1); forceButton = qs('#storage-alert-container .storage-action'); diff --git a/umap/static/umap/test/Feature.js b/umap/static/umap/test/Feature.js index 41409456..52e4ebe9 100644 --- a/umap/static/umap/test/Feature.js +++ b/umap/static/umap/test/Feature.js @@ -1,4 +1,4 @@ -describe('L.Storage.FeatureMixin', function () { +describe('L.Utorage.FeatureMixin', function () { before(function () { this.server = sinon.fakeServer.create(); @@ -69,7 +69,6 @@ describe('L.Storage.FeatureMixin', function () { var input = qs('#storage-feature-shape-properties input[name="stroke"]'); assert.ok(input); input.checked = false; - console.log(input, input.checked) happen.once(input, {type: 'change'}); assert.ok(qs('path[stroke="none"]')); assert.ok(qs('path[fill="none"]')); // Polyline fill is unchanged @@ -132,7 +131,6 @@ describe('L.Storage.FeatureMixin', function () { it('should generate a valid geojson', function () { setFeatures(this.datalayer); assert.ok(poly); - console.log(poly.toGeoJSON().geometry); assert.deepEqual(poly.toGeoJSON().geometry, {'type': 'Polygon', 'coordinates': [[[11.25, 53.585984], [10.151367, 52.975108], [12.689209, 52.167194], [14.084473, 53.199452], [12.634277, 53.618579], [11.25, 53.585984], [11.25, 53.585984]]]}); // Ensure original latlngs has not been modified assert.equal(poly.getLatLngs()[0].length, 6); diff --git a/umap/static/umap/test/Map.js b/umap/static/umap/test/Map.js index 289adece..ed26ebec 100644 --- a/umap/static/umap/test/Map.js +++ b/umap/static/umap/test/Map.js @@ -1,4 +1,4 @@ -describe('L.Storage.Map', function(){ +describe('L.Utorage.Map', function(){ before(function () { this.server = sinon.fakeServer.create(); diff --git a/umap/static/umap/test/Polygon.js b/umap/static/umap/test/Polygon.js index 58519010..317181ea 100644 --- a/umap/static/umap/test/Polygon.js +++ b/umap/static/umap/test/Polygon.js @@ -1,4 +1,4 @@ -describe('L.Storage.Polygon', function () { +describe('L.Utorage.Polygon', function () { var p2ll, map; before(function () { @@ -23,7 +23,7 @@ describe('L.Storage.Polygon', function () { describe('#isMulti()', function () { it('should return false for basic Polygon', function () { - var layer = new L.S.Polygon(this.map, [[1, 2], [3, 4], [5, 6]], {datalayer: this.datalayer}); + var layer = new L.U.Polygon(this.map, [[1, 2], [3, 4], [5, 6]], {datalayer: this.datalayer}); assert.notOk(layer.isMulti()) }); @@ -31,12 +31,12 @@ describe('L.Storage.Polygon', function () { var latlngs = [ [[p2ll(100, 150), p2ll(150, 200), p2ll(200, 100)]] ], - layer = new L.S.Polygon(this.map, latlngs, {datalayer: this.datalayer}); + layer = new L.U.Polygon(this.map, latlngs, {datalayer: this.datalayer}); assert.notOk(layer.isMulti()) }); it('should return false for simple Polygon with hole', function () { - var layer = new L.S.Polygon(this.map, [[[1, 2], [3, 4], [5, 6]], [[7, 8], [9, 10], [11, 12]]], {datalayer: this.datalayer}); + var layer = new L.U.Polygon(this.map, [[[1, 2], [3, 4], [5, 6]], [[7, 8], [9, 10], [11, 12]]], {datalayer: this.datalayer}); assert.notOk(layer.isMulti()) }); @@ -49,7 +49,7 @@ describe('L.Storage.Polygon', function () { [[7, 8], [9, 10], [11, 12]] ] ]; - var layer = new L.S.Polygon(this.map, latLngs, {datalayer: this.datalayer}); + var layer = new L.U.Polygon(this.map, latLngs, {datalayer: this.datalayer}); assert.ok(layer.isMulti()) }); @@ -58,7 +58,7 @@ describe('L.Storage.Polygon', function () { [[[10, 20], [30, 40], [50, 60]]], [[[0, 10], [10, 10], [10, 0]], [[2, 3], [2, 4], [3, 4]]] ]; - var layer = new L.S.Polygon(this.map, latLngs, {datalayer: this.datalayer}); + var layer = new L.U.Polygon(this.map, latLngs, {datalayer: this.datalayer}); assert.ok(layer.isMulti()) }); @@ -78,7 +78,7 @@ describe('L.Storage.Polygon', function () { [[p2ll(100, 150), p2ll(150, 200), p2ll(200, 100)]], [[p2ll(300, 350), p2ll(350, 400), p2ll(400, 300)]] ], - layer = new L.S.Polygon(this.map, latlngs, {datalayer: this.datalayer}).addTo(this.datalayer); + layer = new L.U.Polygon(this.map, latlngs, {datalayer: this.datalayer}).addTo(this.datalayer); happen.once(layer._path, {type: 'contextmenu'}); assert.equal(qst('Remove shape from the multi'), 1); }); @@ -87,7 +87,7 @@ describe('L.Storage.Polygon', function () { var latlngs = [ [[p2ll(100, 150), p2ll(150, 200), p2ll(200, 100)]] ], - layer = new L.S.Polygon(this.map, latlngs, {datalayer: this.datalayer}).addTo(this.datalayer); + layer = new L.U.Polygon(this.map, latlngs, {datalayer: this.datalayer}).addTo(this.datalayer); happen.once(layer._path, {type: 'contextmenu'}); assert.notOk(qst('Remove shape from the multi')); }); @@ -96,7 +96,7 @@ describe('L.Storage.Polygon', function () { var latlngs = [ [[p2ll(100, 150), p2ll(150, 200), p2ll(200, 100)]] ], - layer = new L.S.Polygon(this.map, latlngs, {datalayer: this.datalayer}).addTo(this.datalayer); + layer = new L.U.Polygon(this.map, latlngs, {datalayer: this.datalayer}).addTo(this.datalayer); happen.once(layer._path, {type: 'contextmenu'}); assert.notOk(qst('Extract shape to separate feature')); }); @@ -106,7 +106,7 @@ describe('L.Storage.Polygon', function () { [[p2ll(100, 150), p2ll(150, 200), p2ll(200, 100)]], [[p2ll(300, 350), p2ll(350, 400), p2ll(400, 300)]] ], - layer = new L.S.Polygon(this.map, latlngs, {datalayer: this.datalayer}).addTo(this.datalayer); + layer = new L.U.Polygon(this.map, latlngs, {datalayer: this.datalayer}).addTo(this.datalayer); happen.once(layer._path, {type: 'contextmenu'}); assert.ok(qst('Extract shape to separate feature')); }); @@ -116,7 +116,7 @@ describe('L.Storage.Polygon', function () { [[p2ll(100, 150), p2ll(150, 200), p2ll(200, 100)]], [[p2ll(300, 350), p2ll(350, 400), p2ll(400, 300)]] ], - layer = new L.S.Polygon(this.map, latlngs, {datalayer: this.datalayer}).addTo(this.datalayer); + layer = new L.U.Polygon(this.map, latlngs, {datalayer: this.datalayer}).addTo(this.datalayer); happen.once(layer._path, {type: 'contextmenu'}); assert.notOk(qst('Transform to lines')); }); @@ -128,7 +128,7 @@ describe('L.Storage.Polygon', function () { [p2ll(120, 150), p2ll(150, 180), p2ll(180, 120)] ] ], - layer = new L.S.Polygon(this.map, latlngs, {datalayer: this.datalayer}).addTo(this.datalayer); + layer = new L.U.Polygon(this.map, latlngs, {datalayer: this.datalayer}).addTo(this.datalayer); happen.once(layer._path, {type: 'contextmenu'}); assert.notOk(qst('Transform to lines')); }); @@ -137,21 +137,21 @@ describe('L.Storage.Polygon', function () { var latlngs = [ [[p2ll(100, 150), p2ll(150, 200), p2ll(200, 100)]] ]; - new L.S.Polygon(this.map, latlngs, {datalayer: this.datalayer}).addTo(this.datalayer); + new L.U.Polygon(this.map, latlngs, {datalayer: this.datalayer}).addTo(this.datalayer); happen.at('contextmenu', 150, 150); assert.equal(qst('Transform to lines'), 1); }); it('should not allow to transfer shape when not editedFeature', function () { - new L.S.Polygon(this.map, [p2ll(100, 150), p2ll(100, 200), p2ll(200, 150)], {datalayer: this.datalayer}).addTo(this.datalayer); + new L.U.Polygon(this.map, [p2ll(100, 150), p2ll(100, 200), p2ll(200, 150)], {datalayer: this.datalayer}).addTo(this.datalayer); happen.at('contextmenu', 110, 160); assert.equal(qst('Delete this feature'), 1); // Make sure we have right clicked on the polygon. assert.notOk(qst('Transfer shape to edited feature')); }); it('should not allow to transfer shape when editedFeature is not a polygon', function () { - var layer = new L.S.Polygon(this.map, [p2ll(100, 150), p2ll(100, 200), p2ll(200, 150)], {datalayer: this.datalayer}).addTo(this.datalayer), - other = new L.S.Polyline(this.map, [p2ll(200, 250), p2ll(200, 300)], {datalayer: this.datalayer}).addTo(this.datalayer); + var layer = new L.U.Polygon(this.map, [p2ll(100, 150), p2ll(100, 200), p2ll(200, 150)], {datalayer: this.datalayer}).addTo(this.datalayer), + other = new L.U.Polyline(this.map, [p2ll(200, 250), p2ll(200, 300)], {datalayer: this.datalayer}).addTo(this.datalayer); other.edit(); happen.once(layer._path, {type: 'contextmenu'}); assert.equal(qst('Delete this feature'), 1); // Make sure we have right clicked on the polygon. @@ -160,9 +160,9 @@ describe('L.Storage.Polygon', function () { it('should allow to transfer shape when another polygon is edited', function (done) { this.datalayer.empty(); - var layer = new L.S.Polygon(this.map, [p2ll(200, 300), p2ll(300, 200), p2ll(200, 100)], {datalayer: this.datalayer}).addTo(this.datalayer); + var layer = new L.U.Polygon(this.map, [p2ll(200, 300), p2ll(300, 200), p2ll(200, 100)], {datalayer: this.datalayer}).addTo(this.datalayer); layer.edit(); // This moves the map to put "other" at the center. - var other = new L.S.Polygon(this.map, [p2ll(100, 150), p2ll(100, 200), p2ll(200, 150)], {datalayer: this.datalayer}).addTo(this.datalayer); + var other = new L.U.Polygon(this.map, [p2ll(100, 150), p2ll(100, 200), p2ll(200, 150)], {datalayer: this.datalayer}).addTo(this.datalayer); happen.once(other._path, {type: 'contextmenu'}); assert.equal(qst('Transfer shape to edited feature'), 1); done(); @@ -179,13 +179,13 @@ describe('L.Storage.Polygon', function () { }); it('"add shape" control should be visible when editing a Polygon', function () { - var layer = new L.S.Polygon(this.map, [p2ll(100, 100), p2ll(100, 200)], {datalayer: this.datalayer}).addTo(this.datalayer); + var layer = new L.U.Polygon(this.map, [p2ll(100, 100), p2ll(100, 200)], {datalayer: this.datalayer}).addTo(this.datalayer); layer.edit(); assert.ok(qs('.storage-draw-polygon-multi')); }); it('"add shape" control should extend the same multi', function () { - var layer = new L.S.Polygon(this.map, [p2ll(100, 150), p2ll(150, 200), p2ll(200, 100)], {datalayer: this.datalayer}).addTo(this.datalayer); + var layer = new L.U.Polygon(this.map, [p2ll(100, 150), p2ll(150, 200), p2ll(200, 100)], {datalayer: this.datalayer}).addTo(this.datalayer); layer.edit(); assert.notOk(layer.isMulti()); happen.click(qs('.storage-draw-polygon-multi')); @@ -204,8 +204,8 @@ describe('L.Storage.Polygon', function () { it('should transfer simple polygon shape to another polygon', function () { var latlngs = [p2ll(100, 150), p2ll(100, 200), p2ll(200, 100)], - layer = new L.S.Polygon(this.map, latlngs, {datalayer: this.datalayer}).addTo(this.datalayer), - other = new L.S.Polygon(this.map, [p2ll(200, 350), p2ll(200, 300), p2ll(300, 200)], {datalayer: this.datalayer}).addTo(this.datalayer); + layer = new L.U.Polygon(this.map, latlngs, {datalayer: this.datalayer}).addTo(this.datalayer), + other = new L.U.Polygon(this.map, [p2ll(200, 350), p2ll(200, 300), p2ll(300, 200)], {datalayer: this.datalayer}).addTo(this.datalayer); assert.ok(this.map.hasLayer(layer)); layer.transferShape(p2ll(150, 150), other); assert.equal(other._latlngs.length, 2); @@ -221,8 +221,8 @@ describe('L.Storage.Polygon', function () { ], [[p2ll(200, 300), p2ll(300, 200)]] ], - layer = new L.S.Polygon(this.map, latlngs, {datalayer: this.datalayer}).addTo(this.datalayer), - other = new L.S.Polygon(this.map, [p2ll(200, 350), p2ll(200, 300), p2ll(300, 200)], {datalayer: this.datalayer}).addTo(this.datalayer); + layer = new L.U.Polygon(this.map, latlngs, {datalayer: this.datalayer}).addTo(this.datalayer), + other = new L.U.Polygon(this.map, [p2ll(200, 350), p2ll(200, 300), p2ll(300, 200)], {datalayer: this.datalayer}).addTo(this.datalayer); assert.ok(this.map.hasLayer(layer)); layer.transferShape(p2ll(150, 150), other); assert.equal(other._latlngs.length, 2); @@ -237,7 +237,7 @@ describe('L.Storage.Polygon', function () { it('should not allow to isolate simple polygon', function () { var latlngs = [p2ll(100, 150), p2ll(100, 200), p2ll(200, 100)], - layer = new L.S.Polygon(this.map, latlngs, {datalayer: this.datalayer}).addTo(this.datalayer); + layer = new L.U.Polygon(this.map, latlngs, {datalayer: this.datalayer}).addTo(this.datalayer); assert.equal(this.datalayer._index.length, 1); assert.ok(this.map.hasLayer(layer)); layer.isolateShape(p2ll(150, 150)); @@ -253,7 +253,7 @@ describe('L.Storage.Polygon', function () { ], [[p2ll(200, 300), p2ll(300, 200)]] ], - layer = new L.S.Polygon(this.map, latlngs, {datalayer: this.datalayer}).addTo(this.datalayer); + layer = new L.U.Polygon(this.map, latlngs, {datalayer: this.datalayer}).addTo(this.datalayer); assert.equal(this.datalayer._index.length, 1); assert.ok(this.map.hasLayer(layer)); var other = layer.isolateShape(p2ll(150, 150)); @@ -272,7 +272,7 @@ describe('L.Storage.Polygon', function () { it('should clone polygon', function () { var latlngs = [p2ll(100, 150), p2ll(100, 200), p2ll(200, 100)], - layer = new L.S.Polygon(this.map, latlngs, {datalayer: this.datalayer}).addTo(this.datalayer); + layer = new L.U.Polygon(this.map, latlngs, {datalayer: this.datalayer}).addTo(this.datalayer); assert.equal(this.datalayer._index.length, 1); other = layer.clone(); assert.ok(this.map.hasLayer(other)); diff --git a/umap/static/umap/test/Polyline.js b/umap/static/umap/test/Polyline.js index c54ed7c5..708f672d 100644 --- a/umap/static/umap/test/Polyline.js +++ b/umap/static/umap/test/Polyline.js @@ -1,4 +1,4 @@ -describe('L.Storage.Polyline', function () { +describe('L.Utorage.Polyline', function () { var p2ll, map; before(function () { @@ -23,12 +23,12 @@ describe('L.Storage.Polyline', function () { describe('#isMulti()', function () { it('should return false for basic Polyline', function () { - var layer = new L.S.Polyline(this.map, [[1, 2], [3, 4], [5, 6]], {datalayer: this.datalayer}); + var layer = new L.U.Polyline(this.map, [[1, 2], [3, 4], [5, 6]], {datalayer: this.datalayer}); assert.notOk(layer.isMulti()) }); it('should return false for nested basic Polyline', function () { - var layer = new L.S.Polyline(this.map, [[[1, 2], [3, 4], [5, 6]]], {datalayer: this.datalayer}); + var layer = new L.U.Polyline(this.map, [[[1, 2], [3, 4], [5, 6]]], {datalayer: this.datalayer}); assert.notOk(layer.isMulti()) }); @@ -41,7 +41,7 @@ describe('L.Storage.Polyline', function () { [[7, 8], [9, 10], [11, 12]] ] ]; - var layer = new L.S.Polyline(this.map, latLngs, {datalayer: this.datalayer}); + var layer = new L.U.Polyline(this.map, latLngs, {datalayer: this.datalayer}); assert.ok(layer.isMulti()) }); @@ -61,7 +61,7 @@ describe('L.Storage.Polyline', function () { [p2ll(100, 100), p2ll(100, 200)], [p2ll(300, 350), p2ll(350, 400), p2ll(400, 300)] ], - layer = new L.S.Polyline(this.map, latlngs, {datalayer: this.datalayer}).addTo(this.datalayer); + layer = new L.U.Polyline(this.map, latlngs, {datalayer: this.datalayer}).addTo(this.datalayer); happen.once(layer._path, {type: 'contextmenu'}) assert.equal(qst('Remove shape from the multi'), 1); }); @@ -70,7 +70,7 @@ describe('L.Storage.Polyline', function () { var latlngs = [ [p2ll(100, 100), p2ll(100, 200)] ], - layer = new L.S.Polyline(this.map, latlngs, {datalayer: this.datalayer}).addTo(this.datalayer); + layer = new L.U.Polyline(this.map, latlngs, {datalayer: this.datalayer}).addTo(this.datalayer); happen.once(layer._path, {type: 'contextmenu'}) assert.notOk(qst('Remove shape from the multi')); }); @@ -79,7 +79,7 @@ describe('L.Storage.Polyline', function () { var latlngs = [ [p2ll(100, 100), p2ll(100, 200)] ], - layer = new L.S.Polyline(this.map, latlngs, {datalayer: this.datalayer}).addTo(this.datalayer); + layer = new L.U.Polyline(this.map, latlngs, {datalayer: this.datalayer}).addTo(this.datalayer); happen.once(layer._path, {type: 'contextmenu'}) assert.notOk(qst('Extract shape to separate feature')); }); @@ -89,7 +89,7 @@ describe('L.Storage.Polyline', function () { [p2ll(100, 150), p2ll(100, 200)], [p2ll(300, 350), p2ll(350, 400), p2ll(400, 300)] ], - layer = new L.S.Polyline(this.map, latlngs, {datalayer: this.datalayer}).addTo(this.datalayer); + layer = new L.U.Polyline(this.map, latlngs, {datalayer: this.datalayer}).addTo(this.datalayer); happen.once(layer._path, {type: 'contextmenu'}); assert.ok(qst('Extract shape to separate feature')); }); @@ -99,35 +99,35 @@ describe('L.Storage.Polyline', function () { [p2ll(100, 150), p2ll(100, 200)], [p2ll(300, 350), p2ll(350, 400), p2ll(400, 300)] ], - layer = new L.S.Polyline(this.map, latlngs, {datalayer: this.datalayer}).addTo(this.datalayer); + layer = new L.U.Polyline(this.map, latlngs, {datalayer: this.datalayer}).addTo(this.datalayer); happen.once(layer._path, {type: 'contextmenu'}); assert.notOk(qst('Transform to polygon')); }); it('should allow to transform to polygon when not multi', function () { var latlngs = [p2ll(100, 150), p2ll(100, 200), p2ll(200, 100)], - layer = new L.S.Polyline(this.map, latlngs, {datalayer: this.datalayer}).addTo(this.datalayer); + layer = new L.U.Polyline(this.map, latlngs, {datalayer: this.datalayer}).addTo(this.datalayer); happen.once(layer._path, {type: 'contextmenu'}); assert.equal(qst('Transform to polygon'), 1); }); it('should not allow to transfer shape when not editedFeature', function () { - var layer = new L.S.Polyline(this.map, [p2ll(100, 150), p2ll(100, 200)], {datalayer: this.datalayer}).addTo(this.datalayer); + var layer = new L.U.Polyline(this.map, [p2ll(100, 150), p2ll(100, 200)], {datalayer: this.datalayer}).addTo(this.datalayer); happen.once(layer._path, {type: 'contextmenu'}); assert.notOk(qst('Transfer shape to edited feature')); }); it('should not allow to transfer shape when editedFeature is not a line', function () { - var layer = new L.S.Polyline(this.map, [p2ll(100, 150), p2ll(100, 200)], {datalayer: this.datalayer}).addTo(this.datalayer), - other = new L.S.Polygon(this.map, [p2ll(200, 300), p2ll(300, 200), p2ll(200, 100)], {datalayer: this.datalayer}).addTo(this.datalayer); + var layer = new L.U.Polyline(this.map, [p2ll(100, 150), p2ll(100, 200)], {datalayer: this.datalayer}).addTo(this.datalayer), + other = new L.U.Polygon(this.map, [p2ll(200, 300), p2ll(300, 200), p2ll(200, 100)], {datalayer: this.datalayer}).addTo(this.datalayer); other.edit(); happen.once(layer._path, {type: 'contextmenu'}); assert.notOk(qst('Transfer shape to edited feature')); }); it('should allow to transfer shape when another line is edited', function () { - var layer = new L.S.Polyline(this.map, [p2ll(100, 150), p2ll(100, 200), p2ll(200, 100)], {datalayer: this.datalayer}).addTo(this.datalayer), - other = new L.S.Polyline(this.map, [p2ll(200, 300), p2ll(300, 200)], {datalayer: this.datalayer}).addTo(this.datalayer); + var layer = new L.U.Polyline(this.map, [p2ll(100, 150), p2ll(100, 200), p2ll(200, 100)], {datalayer: this.datalayer}).addTo(this.datalayer), + other = new L.U.Polyline(this.map, [p2ll(200, 300), p2ll(300, 200)], {datalayer: this.datalayer}).addTo(this.datalayer); other.edit(); happen.once(layer._path, {type: 'contextmenu'}); assert.equal(qst('Transfer shape to edited feature'), 1); @@ -138,7 +138,7 @@ describe('L.Storage.Polyline', function () { [p2ll(100, 100), p2ll(100, 200)], [p2ll(300, 350), p2ll(350, 400), p2ll(400, 300)] ], - layer = new L.S.Polyline(this.map, latlngs, {datalayer: this.datalayer}).addTo(this.datalayer); + layer = new L.U.Polyline(this.map, latlngs, {datalayer: this.datalayer}).addTo(this.datalayer); happen.once(layer._path, {type: 'contextmenu'}) assert.equal(qst('Merge lines'), 1); }); @@ -147,7 +147,7 @@ describe('L.Storage.Polyline', function () { var latlngs = [ [p2ll(100, 100), p2ll(100, 200)] ], - layer = new L.S.Polyline(this.map, latlngs, {datalayer: this.datalayer}).addTo(this.datalayer); + layer = new L.U.Polyline(this.map, latlngs, {datalayer: this.datalayer}).addTo(this.datalayer); happen.once(layer._path, {type: 'contextmenu'}) assert.notOk(qst('Merge lines')); }); @@ -156,7 +156,7 @@ describe('L.Storage.Polyline', function () { var latlngs = [ [p2ll(300, 350), p2ll(350, 400), p2ll(400, 300)] ], - layer = new L.S.Polyline(this.map, latlngs, {datalayer: this.datalayer}).addTo(this.datalayer); + layer = new L.U.Polyline(this.map, latlngs, {datalayer: this.datalayer}).addTo(this.datalayer); layer.enableEdit(); happen.at('contextmenu', 350, 400); assert.equal(qst('Split line'), 1); @@ -166,7 +166,7 @@ describe('L.Storage.Polyline', function () { var latlngs = [ [p2ll(300, 350), p2ll(350, 400), p2ll(400, 300)] ], - layer = new L.S.Polyline(this.map, latlngs, {datalayer: this.datalayer}).addTo(this.datalayer); + layer = new L.U.Polyline(this.map, latlngs, {datalayer: this.datalayer}).addTo(this.datalayer); layer.enableEdit(); happen.at('contextmenu', 300, 350); assert.equal(qst('Delete this feature'), 1); // Make sure we have clicked on the vertex. @@ -177,7 +177,7 @@ describe('L.Storage.Polyline', function () { var latlngs = [ [p2ll(300, 350), p2ll(350, 400), p2ll(400, 300)] ], - layer = new L.S.Polyline(this.map, latlngs, {datalayer: this.datalayer}).addTo(this.datalayer); + layer = new L.U.Polyline(this.map, latlngs, {datalayer: this.datalayer}).addTo(this.datalayer); layer.enableEdit(); happen.at('contextmenu', 400, 300); assert.equal(qst('Delete this feature'), 1); // Make sure we have clicked on the vertex. @@ -195,13 +195,13 @@ describe('L.Storage.Polyline', function () { }); it('"add shape" control should be visible when editing a Polyline', function () { - var layer = new L.S.Polyline(this.map, [p2ll(100, 100), p2ll(100, 200)], {datalayer: this.datalayer}).addTo(this.datalayer); + var layer = new L.U.Polyline(this.map, [p2ll(100, 100), p2ll(100, 200)], {datalayer: this.datalayer}).addTo(this.datalayer); layer.edit(); assert.ok(qs('.storage-draw-polyline-multi')); }); it('"add shape" control should extend the same multi', function () { - var layer = new L.S.Polyline(this.map, [p2ll(100, 100), p2ll(100, 200)], {datalayer: this.datalayer}).addTo(this.datalayer); + var layer = new L.U.Polyline(this.map, [p2ll(100, 100), p2ll(100, 200)], {datalayer: this.datalayer}).addTo(this.datalayer); layer.edit(); assert.notOk(layer.isMulti()); happen.click(qs('.storage-draw-polyline-multi')); @@ -220,8 +220,8 @@ describe('L.Storage.Polyline', function () { it('should transfer simple line shape to another line', function () { var latlngs = [p2ll(100, 150), p2ll(100, 200), p2ll(200, 100)], - layer = new L.S.Polyline(this.map, latlngs, {datalayer: this.datalayer}).addTo(this.datalayer), - other = new L.S.Polyline(this.map, [p2ll(200, 300), p2ll(300, 200)], {datalayer: this.datalayer}).addTo(this.datalayer); + layer = new L.U.Polyline(this.map, latlngs, {datalayer: this.datalayer}).addTo(this.datalayer), + other = new L.U.Polyline(this.map, [p2ll(200, 300), p2ll(300, 200)], {datalayer: this.datalayer}).addTo(this.datalayer); assert.ok(this.map.hasLayer(layer)); layer.transferShape(p2ll(150, 150), other); assert.equal(other._latlngs.length, 2); @@ -234,8 +234,8 @@ describe('L.Storage.Polyline', function () { [p2ll(100, 150), p2ll(100, 200), p2ll(200, 100)], [p2ll(200, 300), p2ll(300, 200)] ], - layer = new L.S.Polyline(this.map, latlngs, {datalayer: this.datalayer}).addTo(this.datalayer), - other = new L.S.Polyline(this.map, [p2ll(250, 300), p2ll(350, 200)], {datalayer: this.datalayer}).addTo(this.datalayer); + layer = new L.U.Polyline(this.map, latlngs, {datalayer: this.datalayer}).addTo(this.datalayer), + other = new L.U.Polyline(this.map, [p2ll(250, 300), p2ll(350, 200)], {datalayer: this.datalayer}).addTo(this.datalayer); assert.ok(this.map.hasLayer(layer)); layer.transferShape(p2ll(150, 150), other); assert.equal(other._latlngs.length, 2); @@ -253,7 +253,7 @@ describe('L.Storage.Polyline', function () { [[0, 0], [0, 1]], [[0, 1], [0, 2]], ], - layer = new L.S.Polyline(this.map, latlngs, {datalayer: this.datalayer}).addTo(this.datalayer); + layer = new L.U.Polyline(this.map, latlngs, {datalayer: this.datalayer}).addTo(this.datalayer); layer.mergeShapes(); layer.disableEdit(); // Remove vertex from latlngs to compare them. assert.deepEqual(layer.getLatLngs(), [L.latLng([0, 0]), L.latLng([0, 1]), L.latLng([0, 2])]); @@ -265,7 +265,7 @@ describe('L.Storage.Polyline', function () { [[0, 0], [0, 1]], [[0, 2], [0, 1]], ], - layer = new L.S.Polyline(this.map, latlngs, {datalayer: this.datalayer}).addTo(this.datalayer); + layer = new L.U.Polyline(this.map, latlngs, {datalayer: this.datalayer}).addTo(this.datalayer); layer.mergeShapes(); layer.disableEdit(); assert.deepEqual(layer.getLatLngs(), [L.latLng([0, 0]), L.latLng([0, 1]), L.latLng([0, 2])]); @@ -278,7 +278,7 @@ describe('L.Storage.Polyline', function () { it('should not allow to isolate simple line', function () { var latlngs = [p2ll(100, 150), p2ll(100, 200), p2ll(200, 100)], - layer = new L.S.Polyline(this.map, latlngs, {datalayer: this.datalayer}).addTo(this.datalayer); + layer = new L.U.Polyline(this.map, latlngs, {datalayer: this.datalayer}).addTo(this.datalayer); assert.equal(this.datalayer._index.length, 1); assert.ok(this.map.hasLayer(layer)); layer.isolateShape(p2ll(150, 150)); @@ -291,7 +291,7 @@ describe('L.Storage.Polyline', function () { [p2ll(100, 150), p2ll(100, 200), p2ll(200, 100)], [[p2ll(200, 300), p2ll(300, 200)]] ], - layer = new L.S.Polyline(this.map, latlngs, {datalayer: this.datalayer}).addTo(this.datalayer); + layer = new L.U.Polyline(this.map, latlngs, {datalayer: this.datalayer}).addTo(this.datalayer); assert.equal(this.datalayer._index.length, 1); assert.ok(this.map.hasLayer(layer)); var other = layer.isolateShape(p2ll(150, 150)); @@ -310,7 +310,7 @@ describe('L.Storage.Polyline', function () { it('should clone polyline', function () { var latlngs = [p2ll(100, 150), p2ll(100, 200), p2ll(200, 100)], - layer = new L.S.Polyline(this.map, latlngs, {datalayer: this.datalayer}).addTo(this.datalayer); + layer = new L.U.Polyline(this.map, latlngs, {datalayer: this.datalayer}).addTo(this.datalayer); assert.equal(this.datalayer._index.length, 1); other = layer.clone(); assert.ok(this.map.hasLayer(other)); diff --git a/umap/static/umap/test/_pre.js b/umap/static/umap/test/_pre.js index b5d766a7..0db7532e 100644 --- a/umap/static/umap/test/_pre.js +++ b/umap/static/umap/test/_pre.js @@ -30,7 +30,6 @@ var disableEdit = function () { happen.click(qs('a.leaflet-control-edit-disable')); }; var clickSave = function () { - console.log(qs('a.leaflet-control-edit-save').classList) happen.click(qs('a.leaflet-control-edit-save')); }; var clickCancel = function () { @@ -178,7 +177,7 @@ function initMap (options) { }; default_options.properties.datalayers.push(defaultDatalayerData()); options.properties = L.extend({}, default_options.properties, options); - return new L.Storage.Map("map", options); + return new L.U.Map("map", options); } var RESPONSES = { diff --git a/umap/static/umap/test/index.html b/umap/static/umap/test/index.html index 0a147d45..4e455a84 100644 --- a/umap/static/umap/test/index.html +++ b/umap/static/umap/test/index.html @@ -1,54 +1,54 @@ - Leaflet.Storage Tests + Umap front Tests - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - - - - + + + + +