Skip to content

Commit

Permalink
FEATURE: Make collection export option dynamic (#523)
Browse files Browse the repository at this point in the history
* FEATURE: Make collection export option dynamic

Resolves #522

* REFACTOR: Minor changes

Changes:
 - New version 0.11.2
 - Rollback Gruntfile changes
 - .images call from JSON.stringify(opts.collection.images) attached to
generateExportJson
  • Loading branch information
VladimirMikulic authored and sashadev-sky committed Jan 13, 2020
1 parent 624e4c4 commit f6ef2c9
Show file tree
Hide file tree
Showing 4 changed files with 38 additions and 6 deletions.
20 changes: 18 additions & 2 deletions dist/leaflet.distortableimage.js
Original file line number Diff line number Diff line change
Expand Up @@ -3040,6 +3040,10 @@ L.DistortableCollection.Edit = L.Handler.extend({
},

cancelExport: function() {
if (!this.customCollection) {
this._exportOpts.collection = undefined;
}

clearInterval(this.updateInterval);
},

Expand Down Expand Up @@ -3116,6 +3120,11 @@ L.DistortableCollection.Edit = L.Handler.extend({

if (data.status === 'complete') {
clearInterval(self.updateInterval);

if (!self.customCollection) {
self._exportOpts.collection = undefined;
}

resolve();
if (data.jpg !== null) {
alert('Export succeeded. ' + opts.exportUrl + data.jpg);
Expand Down Expand Up @@ -3150,15 +3159,22 @@ L.DistortableCollection.Edit = L.Handler.extend({
crossDomain: true,
type: 'POST',
data: {
collection: JSON.stringify(opts.collection.images),
collection: JSON.stringify(opts.collection),
scale: opts.scale,
upload: true,
},
success: function(data) { opts.handleStatusRes(data); }, // this handles the initial response
});
}

opts.collection = opts.collection || this._group.generateExportJson();
// If the user has passed collection property
if (opts.collection) {
self.customCollection = true;
} else {
self.customCollection = false;
opts.collection = this._group.generateExportJson().images;
}

opts.frequency = opts.frequency || 3000;
opts.scale = opts.scale || 100; // switch it to _getAvgCmPerPixel !
opts.updater = opts.updater || _defaultUpdater;
Expand Down
2 changes: 1 addition & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "leaflet-distortableimage",
"version": "0.11.1",
"version": "0.11.2",
"description": "Leaflet plugin enabling image overlays to be distorted, stretched, and warped (built for Public Lab's MapKnitter: http://publiclab.org).",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1",
Expand Down
20 changes: 18 additions & 2 deletions src/edit/DistortableCollection.Edit.js
Original file line number Diff line number Diff line change
Expand Up @@ -199,6 +199,10 @@ L.DistortableCollection.Edit = L.Handler.extend({
},

cancelExport: function() {
if (!this.customCollection) {
this._exportOpts.collection = undefined;
}

clearInterval(this.updateInterval);
},

Expand Down Expand Up @@ -275,6 +279,11 @@ L.DistortableCollection.Edit = L.Handler.extend({

if (data.status === 'complete') {
clearInterval(self.updateInterval);

if (!self.customCollection) {
self._exportOpts.collection = undefined;
}

resolve();
if (data.jpg !== null) {
alert('Export succeeded. ' + opts.exportUrl + data.jpg);
Expand Down Expand Up @@ -309,15 +318,22 @@ L.DistortableCollection.Edit = L.Handler.extend({
crossDomain: true,
type: 'POST',
data: {
collection: JSON.stringify(opts.collection.images),
collection: JSON.stringify(opts.collection),
scale: opts.scale,
upload: true,
},
success: function(data) { opts.handleStatusRes(data); }, // this handles the initial response
});
}

opts.collection = opts.collection || this._group.generateExportJson();
// If the user has passed collection property
if (opts.collection) {
self.customCollection = true;
} else {
self.customCollection = false;
opts.collection = this._group.generateExportJson().images;
}

opts.frequency = opts.frequency || 3000;
opts.scale = opts.scale || 100; // switch it to _getAvgCmPerPixel !
opts.updater = opts.updater || _defaultUpdater;
Expand Down

0 comments on commit f6ef2c9

Please sign in to comment.