Skip to content

Commit 6ab7696

Browse files
committed
Allow configuring user account for ID generation
1 parent 8d84031 commit 6ab7696

4 files changed

Lines changed: 18 additions & 11 deletions

File tree

README.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,13 +26,14 @@ For the plugin to work, a new object type has to be created. This object type ne
2626

2727
All plugin configuration takes place in base configuration.
2828

29+
* *User account for ID generation*: The user account that is to be used for generating new ID values. This account must have the rights to read and edit objects of the configured incrementer object type (see below) and also have system rights for accessing object types, users and workflows.
2930
* *Incrementer object type*: The object type that has been created for usage with the plugin
3031
* *Field name 'Incrementer ID'*: The name of the field to use for storing the ID in incrementer objects
3132
* *Field name 'Incrementer values'*: The name of the field to use for storing the values in incrementer objects
3233
* *Mask for reading and editing incrementer objects*: The mask to use when working with incrementer objects
3334
* *Incrementers*:
3435
* *Incrementer ID*: The unique ID of this specific incrementer
35-
* *Object types*: The object types for which this incrementer works
36+
* *Object types*: The object types for which this incrementer works (please note that the configured user account must have read rights for these object types)
3637
* *Path to parent field*: The path to the nested field that contains the ID field and the base fields (leave empty if the ID field and the base fields are on the root level of the object).
3738
* *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.
3839
* *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).

l10n/numeric-id-auto-incrementer.csv

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
key,de-DE,en-US
22
server.config.name.system.numericIdAutoIncrementer,Automatische Inkrementierung numerischer IDs,Numeric ID auto incrementer
3+
server.config.parameter.system.numericIdAutoIncrementer.user.label,Benutzeraccount für die ID-Generierung,User account for ID generation
34
server.config.parameter.system.numericIdAutoIncrementer.incrementer_object_type.label,Zähler-Objekttyp,Incrementer object type
45
server.config.parameter.system.numericIdAutoIncrementer.incrementer_id_field_name.label,Name des Feldes 'Zähler-ID',Field name 'Incrementer ID'
56
server.config.parameter.system.numericIdAutoIncrementer.incrementer_values_field_name.label,Name des Feldes 'Zähler-Werte',Field name 'Incrementer values'

manifest.master.yml

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -17,19 +17,22 @@ base_url_prefix: "webfrontend"
1717
base_config:
1818
- name: numericIdAutoIncrementer
1919
parameters:
20+
user:
21+
type: user
22+
position: 0
2023
incrementer_object_type:
2124
type: text
2225
plugin_type: objectTypeSelector
23-
position: 0
26+
position: 1
2427
incrementer_id_field_name:
2528
type: text
26-
position: 1
29+
position: 2
2730
incrementer_values_field_name:
2831
type: text
29-
position: 2
32+
position: 3
3033
incrementer_mask:
3134
type: text
32-
position: 3
35+
position: 4
3336
incrementers:
3437
type: table
3538
fields:
@@ -64,7 +67,7 @@ base_config:
6467
type: text
6568
position: 0
6669
position: 5
67-
position: 4
70+
position: 5
6871

6972
callbacks:
7073
db_pre_save:
@@ -73,6 +76,8 @@ callbacks:
7376
callback: setIds
7477
callbacks:
7578
setIds:
79+
plugin_user:
80+
base_config: "numericIdAutoIncrementer.user"
7681
exec:
7782
service: "node"
7883
commands:

src/server/setIds.js

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -206,7 +206,7 @@ function isEmptyObject(fieldValue) {
206206
}
207207

208208
async function fetchWorkflows() {
209-
const url = info.api_url + '/api/v1/transitions?access_token=' + info.api_user_access_token;
209+
const url = info.api_url + '/api/v1/transitions?access_token=' + info.plugin_user_access_token;
210210

211211
const response = await fetch(url, { method: 'GET' });
212212
if (!response.ok) throwErrorToFrontend('Fehler bei der Abfrage von Workflows');
@@ -215,7 +215,7 @@ async function fetchWorkflows() {
215215
}
216216

217217
async function fetchUser() {
218-
const url = info.api_url + '/api/v1/user/' + info.api_user.user._id + '?access_token=' + info.api_user_access_token;
218+
const url = info.api_url + '/api/v1/user/' + info.api_user.user._id + '?access_token=' + info.plugin_user_access_token;
219219

220220
const response = await fetch(url, { method: 'GET' });
221221
if (!response.ok) throwErrorToFrontend('Fehler bei der Abfrage von Userdaten');
@@ -225,7 +225,7 @@ async function fetchUser() {
225225
}
226226

227227
async function fetchObjectTypes() {
228-
const url = info.api_url + '/api/v1/objecttype?format=short&access_token=' + info.api_user_access_token;
228+
const url = info.api_url + '/api/v1/objecttype?format=short&access_token=' + info.plugin_user_access_token;
229229

230230
const response = await fetch(url, { method: 'GET' });
231231
if (!response.ok) throwErrorToFrontend('Fehler bei der Abfrage der konfigurierten Objekttypen');
@@ -234,7 +234,7 @@ async function fetchObjectTypes() {
234234
}
235235

236236
async function fetchObjects(objectType, mask) {
237-
const url = info.api_url + '/api/v1/db/' + objectType + '/' + mask + '/list?access_token=' + info.api_user_access_token;
237+
const url = info.api_url + '/api/v1/db/' + objectType + '/' + mask + '/list?access_token=' + info.plugin_user_access_token;
238238

239239
const response = await fetch(url, { method: 'GET' });
240240
if (!response.ok) throwErrorToFrontend('Fehler bei der Abfrage von Objekten des Typs ' + objectType);
@@ -244,7 +244,7 @@ async function fetchObjects(objectType, mask) {
244244
}
245245

246246
async function saveObject(object) {
247-
const url = info.api_url + '/api/v1/db/' + object._objecttype + '?access_token=' + info.api_user_access_token;
247+
const url = info.api_url + '/api/v1/db/' + object._objecttype + '?access_token=' + info.plugin_user_access_token;
248248

249249
const data = object[object._objecttype];
250250
data._version = data._version ? data._version += 1 : 1;

0 commit comments

Comments
 (0)