Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature/enable creation of several features at once #133

Open
wants to merge 2 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 17 additions & 0 deletions src/Mapbender/DataManagerBundle/Resources/public/TableRenderer.js
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,23 @@
this.showRow(dtRow.node());
}
},
/**
* @param {Object} item
* @param {Boolean} show to automatically update pagination
*/
addOrRefreshRow: function(item, show) {
var dt = this.getDatatablesInstance_();

var rowExists = dt.rows(function(_, data) {
return data === item;
}).count() > 0;

if (rowExists) {
this.refreshRow(item, show);
} else {
this.addRow(item, show);
}
},
/**
* Switch pagination so the given tr element is on the current page
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -439,8 +439,8 @@
* @return {string}
* @private
*/
_generateNamespacedId: function(schema, feature) {
return [this.element.attr('id'), schema.schemaName, this._getUniqueItemId(feature)].join('-');
_generateNamespacedId: function(schema, feature, index = null) {
return [this.element.attr('id'), schema.schemaName, this._getUniqueItemId(feature), ...(index !== null ? [index] : [])].join('-');
},
_afterSave: function(schema, feature, originalId, responseData) {
// unravel dm-incompatible response format
Expand Down Expand Up @@ -515,7 +515,7 @@
var feature = features[i];
var itemSchema = this.getItemSchema(feature);
continueDrawing = continueDrawing || itemSchema.continueDrawingAfterSave;
var mapId = this._generateNamespacedId(itemSchema, feature);
var mapId = this._generateNamespacedId(itemSchema, feature, i);
featureMap[mapId] = feature;
postData.features.push({
schemaName: itemSchema.schemaName,
Expand All @@ -538,7 +538,8 @@
feature.setGeometry(geometry);
widget._replaceItemData(itemSchema, feature, savedItem.properties || {});
feature.set('dirty', false);
widget.tableRenderer.refreshRow(feature, false);
feature.set('oldGeometry', geometry);
widget.tableRenderer.addOrRefreshRow(feature, true);
widget._saveEvent(itemSchema, feature, widget._getUniqueItemId(feature));
}
$.notify(Mapbender.trans('mb.data.store.save.successfully'), 'info');
Expand All @@ -553,6 +554,8 @@
$('.-fn-toggle-tool', widget.element).removeClass('active');
});
}

return promise;
},
updateSaveAll: function() {
var $saveAllButton = $('.-fn-save-all', this.element);
Expand Down