Skip to content

Commit

Permalink
Fix issue on copy feature and split feature on not editable fields
Browse files Browse the repository at this point in the history
  • Loading branch information
volterra79 committed Jan 18, 2023
1 parent cc5e7a0 commit ce59759
Show file tree
Hide file tree
Showing 4 changed files with 48 additions and 2 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "editing",
"version": "3.5.3",
"version": "3.5.4",
"description": "",
"main": "index.js",
"directories": {
Expand Down
18 changes: 18 additions & 0 deletions workflows/steps/tasks/editingtask.js
Original file line number Diff line number Diff line change
Expand Up @@ -338,6 +338,24 @@ proto.evaluateGeometryExpressionField = async function({inputs, context, featur
return feature;
};

/**
*
* @param layer,
* @param feature
* @returns {
* <field_name1>: value,
* <field_name1>: value
* }
*/
proto.getNotEditableFieldsNoPkValues = function({layer, feature}){
return layer.getEditingNotEditableFields()
.filter(field => !layer.isPkField(field))
.reduce((accumulator, field) => {
accumulator[field] = feature.get(field);
return accumulator;
}, {});
};

/**
* set
* @param get_default_value to context of task
Expand Down
13 changes: 13 additions & 0 deletions workflows/steps/tasks/moveelementstask.js
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,20 @@ proto.run = function(inputs, context) {
.then(promises => {
promises.forEach(({status, value:feature}) => {
source.addFeature(feature);
/**
* @todo improve client core to handle this situation on sesssion.pushAdd not copy pk field not editable only
*/
const noteditablefieldsvalues = this.getNotEditableFieldsNoPkValues({
layer,
feature
});
session.pushAdd(layerId, feature);
if (Object.entries(noteditablefieldsvalues).length) {
const _feature = feature.clone();
Object.entries(noteditablefieldsvalues).forEach(([field, value]) => _feature.set(field, value));
session.pushUpdate(layerId, _feature, feature);
}

inputs.features.push(feature);
})
})
Expand Down
17 changes: 16 additions & 1 deletion workflows/steps/tasks/splitfeaturetask.js
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,22 @@ proto._handleSplitFeature = async function({feature, inputs, session, splittedGe
});
} catch(err){}

newFeatures.push(session.pushAdd(layerId, feature));
/**
* @todo improve client core to handle this situation on sesssion.pushAdd not copy pk field not editable only
*/
const noteditablefieldsvalues = this.getNotEditableFieldsNoPkValues({
layer,
feature
});

if (Object.entries(noteditablefieldsvalues).length) {
session.pushAdd(layerId, feature);
const _feature = feature.clone();
Object.entries(noteditablefieldsvalues).forEach(([field, value]) => _feature.set(field, value));
session.pushUpdate(layerId, _feature, feature);
newFeatures.push(_feature);
} else newFeatures.push(session.pushAdd(layerId, feature));

}
inputs.features.push(feature);
}
Expand Down

0 comments on commit ce59759

Please sign in to comment.