Skip to content

Commit

Permalink
🐛 revert features in editing
Browse files Browse the repository at this point in the history
  • Loading branch information
volterra79 committed Jul 3, 2024
1 parent c411b01 commit afa5af6
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 8 deletions.
2 changes: 1 addition & 1 deletion src/app/core/editing/editor.js
Original file line number Diff line number Diff line change
Expand Up @@ -226,7 +226,7 @@ proto._getFeatures = function(options={}) {
*/
proto.revert = function() {
const d = $.Deferred();
this._featuresstore.setFeatures(this._cloneFeatures(this._layer.readFeatures()));
this.getEditingSource().setFeatures(this._cloneFeatures(this.readFeatures()));
d.resolve();
return d.promise();
};
Expand Down
2 changes: 1 addition & 1 deletion src/app/core/layers/features/featuresstore.js
Original file line number Diff line number Diff line change
Expand Up @@ -207,7 +207,7 @@ proto._updateFeature = function(feature) {
});
};

proto.setFeatures = function(features) {
proto.setFeatures = function(features = []) {
this._features = features;
};

Expand Down
16 changes: 10 additions & 6 deletions src/app/core/layers/features/olfeaturesstore.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,12 @@ proto.getLength = function() {
};

//overwrite
proto.setFeatures = function(features=[]) {
features.forEach(feature => this._features.push(feature));
proto.setFeatures = function(features = []) {
//remove features
this._features.clear();
//add new features
this.addFeatures(features);
this._features.dispatchEvent('change');
};
// overwrite
proto.readFeatures = function() {
Expand All @@ -29,20 +33,20 @@ proto.getFeaturesCollection = function() {
};

proto.getFeatureById = function(featureId) {
return this._features.getArray().find(feature => feature.getId() == featureId);
return this._features.getArray().find(feature => featureId == feature.getId());
};

proto.getFeatureByUid = function(uid) {
return this._features.getArray().find(feature => feature.getUid() === uid);
return this._features.getArray().find(feature => uid === feature.getUid());
};

proto._addFeature = function(feature) {
this._features.push(feature);
// useful for ol.source.Vector
this._features.dispatchEvent('change')
this._features.dispatchEvent('change');
};

//sobtitute the feature after modify
//substitute the feature after modify
proto._updateFeature = function(feature) {
// set index at -1
let index = -1;
Expand Down

0 comments on commit afa5af6

Please sign in to comment.