You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Expected behaviour
When a user creates a new observation and selects a preset, the tags field in the preset definition should be written to the newly created observation. E.g. if the user creates a new observation and selects a "River" preset, and the River preset is defined by this JSON:
Then the newly created observation should have "type": "animal" as one of its tags.
Current behaviour
The tags property of the preset definition is ignored, and instead a field categoryId is written to the newly created observation's tags, with the value being the id of the preset. This code is here:
Modify the category chooser code to merge the value of preset.tags into draftValue.tags when updating the draft.
We need to handle the user changing the preset/category for an observation after they have previously selected a category. Changing a category should:
Remove tags that were applied by the previously matched category (e.g. if the user had previously selected the preset "animal" for the observation, which writes the tag "type": "animal" to the observation, then this tag should be removed when the user changes the category.
Do not remove any other tags (e.g. the user could have filled in details or notes, which are also stored as tags on the observation).
The special categoryId tag should change to the ID of the newly selected category (note: this already happens in existing code).
Tags should only be removed if there is an exact match. E.g. if the observation was previously categorized as "animal", which wrote the tag "type": "animal", but if the user had changed the tag to be "type": "monkey", then changing the category should not delete that tag, but the tag may be over written if the newly selected category/preset contains a new value for that tag.
e.g.
constoldPreset=presets[draftValue.tags.categoryId]constnewPreset=presets[newCategoryId]constnewDraftValue={
...draftValue,tags: {categoryId: newCategoryId}}// Copy across user-edited tagsObject.keys(draftValue.tags).forEach(key=>{// Skip copying tags that come from the previously selected presetif(typeofoldPreset.tags[key]!=='undefined'&&draftValue.tags[key]===oldPreset.tags[key])returnnewDraftValue.tags[key]=oldDraftValue.tags[key]}// Apply tags from newly selected presetnewDraftValue.tags={
...newDraftValue.tags,
...newPreset.tags}
Tags that come from the preset should not show in any of the views of the observation (e.g. the user should not see the tag "type": "animal" in the observation details view.
Further work
Currently we use the special categoryId tag to match observations to their corresponding preset. I think we can leave this behaviour in this first iteration, but in the future we should use the tags property to find the best matching preset, using a similar strategy to what iD Editor uses. This would mean that an observation with the tags { type: "animal" } would match a preset "animal" with the tags { type: "animal" }, but an observation with the tags { type: "animal", animalType: "monkey" } would match a preset "monkey" with the tags { type: "animal", animalType: "monkey" }.
The text was updated successfully, but these errors were encountered:
Expected behaviour
When a user creates a new observation and selects a preset, the
tags
field in the preset definition should be written to the newly created observation. E.g. if the user creates a new observation and selects a "River" preset, and the River preset is defined by this JSON:Then the newly created observation should have
"type": "animal"
as one of its tags.Current behaviour
The
tags
property of the preset definition is ignored, and instead a fieldcategoryId
is written to the newly created observation's tags, with the value being theid
of the preset. This code is here:mapeo-mobile/src/frontend/screens/CategoryChooser.js
Lines 81 to 89 in 53c5655
Implementation ideas
preset.tags
intodraftValue.tags
when updating the draft."type": "animal"
to the observation, then this tag should be removed when the user changes the category.categoryId
tag should change to the ID of the newly selected category (note: this already happens in existing code)."type": "animal"
, but if the user had changed the tag to be"type": "monkey"
, then changing the category should not delete that tag, but the tag may be over written if the newly selected category/preset contains a new value for that tag.e.g.
"type": "animal"
in the observation details view.Further work
Currently we use the special
categoryId
tag to match observations to their corresponding preset. I think we can leave this behaviour in this first iteration, but in the future we should use thetags
property to find the best matching preset, using a similar strategy to what iD Editor uses. This would mean that an observation with the tags{ type: "animal" }
would match a preset "animal" with the tags{ type: "animal" }
, but an observation with the tags{ type: "animal", animalType: "monkey" }
would match a preset "monkey" with the tags{ type: "animal", animalType: "monkey" }
.The text was updated successfully, but these errors were encountered: