Skip to content

Commit

Permalink
Only add ID for newly created nested field entries
Browse files Browse the repository at this point in the history
  • Loading branch information
tkleinke committed Oct 25, 2024
1 parent 0902473 commit 9c7c5dc
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 2 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ All plugin configuration takes place in base configuration.
* *Object type name*: The name of the object type for which to set up ID generation
* *Parent nested fields*:
* *Path to parent field*: The path to the nested field that contains the ID field and the base fields.
* *ID field name*: The name of the ID field to be filled out by the plugin. This has to be a numeric field. The field will only be updated if it is empty and if all base fields have been filled out by the user.
* *ID field name*: The name of the ID field to be filled out by the plugin. This has to be a numeric field. The field will only be updated if it is empty, if the parent field has been newly created and if all base fields have been filled out by the user.
* *Base field names*: The names of the base fields to consider when setting the ID. These can be text fields or fields of the [custom data type DANTE](https://github.com/programmfabrik/fylr-plugin-custom-data-type-dante).

## Example
Expand Down
3 changes: 2 additions & 1 deletion src/server/setIds.js
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,8 @@ async function addId(objectType, nestedFields, nestedField, nestedFieldPath, idF
if (!idFieldName?.length
|| !baseFieldNames
|| baseFieldNames.find(baseFieldName => !nestedField[baseFieldName])
|| nestedField[idFieldName]) return false;
|| nestedField[idFieldName]
|| nestedField._uuid) return false;

nestedField[idFieldName] = await getIdValue(
objectType, nestedFields, nestedField, nestedFieldPath, idFieldName, baseFieldNames
Expand Down

0 comments on commit 9c7c5dc

Please sign in to comment.