geonetwork-ui 2.11.0-dev.0559cfd9d → 2.11.0-dev.05fe30eee
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/fesm2022/geonetwork-ui.mjs +373 -181
- package/fesm2022/geonetwork-ui.mjs.map +1 -1
- package/index.d.ts +74 -10
- package/index.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/libs/api/repository/src/lib/gn4/gn4-repository.ts +78 -1
- package/src/libs/api/repository/src/lib/gn4/platform/gn4-platform.service.ts +11 -0
- package/src/libs/common/domain/src/lib/model/record/flags.model.ts +1 -0
- package/src/libs/common/domain/src/lib/model/record/index.ts +1 -0
- package/src/libs/common/domain/src/lib/platform.service.interface.ts +1 -0
- package/src/libs/common/domain/src/lib/repository/records-repository.interface.ts +19 -0
- package/src/libs/feature/editor/src/lib/components/record-form/form-field/form-field-constraints/form-field-constraints.component.ts +3 -5
- package/src/libs/feature/editor/src/lib/components/record-form/form-field/form-field-contacts/form-field-contacts.component.ts +2 -2
- package/src/libs/feature/editor/src/lib/components/record-form/form-field/form-field-record-flags/form-field-record-flag-component.css +0 -0
- package/src/libs/feature/editor/src/lib/components/record-form/form-field/form-field-record-flags/form-field-record-flag-component.html +18 -0
- package/src/libs/feature/editor/src/lib/components/record-form/form-field/form-field-record-flags/form-field-record-flag-component.ts +86 -0
- package/src/libs/feature/editor/src/lib/components/record-form/form-field/form-field.component.html +100 -88
- package/src/libs/feature/editor/src/lib/components/record-form/form-field/form-field.component.ts +11 -4
- package/src/libs/feature/editor/src/lib/components/record-form/record-form.component.ts +18 -4
- package/src/libs/feature/editor/src/lib/expressions.ts +67 -0
- package/src/libs/feature/editor/src/lib/fields.config.ts +13 -0
- package/src/libs/feature/editor/src/lib/models/editor-config.model.ts +10 -4
- package/src/libs/util/app-config/src/index.ts +1 -0
- package/src/libs/util/app-config/src/lib/app-config.ts +338 -284
- package/src/libs/util/app-config/src/lib/model.ts +17 -0
- package/src/libs/util/app-config/src/lib/parse-utils.ts +8 -4
- package/translations/de.json +4 -0
- package/translations/en.json +4 -0
- package/translations/es.json +4 -0
- package/translations/fr.json +4 -0
- package/translations/it.json +4 -0
- package/translations/nl.json +4 -0
- package/translations/pt.json +4 -0
- package/translations/sk.json +4 -0
|
@@ -17,10 +17,14 @@ const TOKEN_OPERATOR_LOGICAL = ['==', '!=']
|
|
|
17
17
|
const TOKEN_STRING_LITERAL = ["'", '"']
|
|
18
18
|
const TOKEN_GROUP_START = '('
|
|
19
19
|
const TOKEN_GROUP_END = ')'
|
|
20
|
+
const TOKEN_OPERATOR_BOOLEAN = ['&&', '||']
|
|
21
|
+
const TOKEN_OPERATOR_NOT = '!'
|
|
20
22
|
|
|
21
23
|
// See https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Operator_precedence
|
|
22
24
|
const OPERATORS_BY_PRECEDENCE: string[][] = [
|
|
23
25
|
[TOKEN_OPERATOR_TERNARY_FIRST, TOKEN_OPERATOR_TERNARY_SECOND],
|
|
26
|
+
TOKEN_OPERATOR_BOOLEAN,
|
|
27
|
+
[TOKEN_OPERATOR_NOT],
|
|
24
28
|
TOKEN_OPERATOR_LOGICAL,
|
|
25
29
|
]
|
|
26
30
|
const ALL_OPERATORS = OPERATORS_BY_PRECEDENCE.flat()
|
|
@@ -161,6 +165,18 @@ function evaluateInternal(
|
|
|
161
165
|
continue
|
|
162
166
|
}
|
|
163
167
|
|
|
168
|
+
// BOOLEAN LITERAL
|
|
169
|
+
const isBooleanLiteral =
|
|
170
|
+
readNext(expression, pos, 4) === 'true' ||
|
|
171
|
+
readNext(expression, pos, 5) === 'false'
|
|
172
|
+
if (isBooleanLiteral) {
|
|
173
|
+
const literal = readNext(expression, pos, 4) === 'true' ? 'true' : 'false'
|
|
174
|
+
pos += literal.length
|
|
175
|
+
const booleanLiteral = literal === 'true'
|
|
176
|
+
currentEvaluator = () => booleanLiteral
|
|
177
|
+
continue
|
|
178
|
+
}
|
|
179
|
+
|
|
164
180
|
// SYMBOL (NAME)
|
|
165
181
|
const isSymbol = /[a-zA-Z]/.test(readNext(expression, pos))
|
|
166
182
|
if (isSymbol) {
|
|
@@ -291,6 +307,57 @@ function evaluateInternal(
|
|
|
291
307
|
continue
|
|
292
308
|
}
|
|
293
309
|
|
|
310
|
+
// BOOLEAN OPERATORS
|
|
311
|
+
const isBooleanOperator = TOKEN_OPERATOR_BOOLEAN.some(
|
|
312
|
+
(token) => readNext(expression, pos, token.length) === token
|
|
313
|
+
)
|
|
314
|
+
if (isBooleanOperator) {
|
|
315
|
+
const matchingOperator = TOKEN_OPERATOR_BOOLEAN.find(
|
|
316
|
+
(token) => readNext(expression, pos, token.length) === token
|
|
317
|
+
)
|
|
318
|
+
const isAnd = matchingOperator === '&&'
|
|
319
|
+
pos += matchingOperator.length
|
|
320
|
+
const leftEvaluator = currentEvaluator
|
|
321
|
+
const rightExpression = readUntilNextOperator(
|
|
322
|
+
expression,
|
|
323
|
+
pos,
|
|
324
|
+
matchingOperator
|
|
325
|
+
)
|
|
326
|
+
pos += rightExpression.length
|
|
327
|
+
const rightEvaluator = evaluateInternal(
|
|
328
|
+
rightExpression,
|
|
329
|
+
currentContext
|
|
330
|
+
).evaluator
|
|
331
|
+
|
|
332
|
+
currentEvaluator = (context) => {
|
|
333
|
+
return isAnd
|
|
334
|
+
? Boolean(leftEvaluator(context) && rightEvaluator(context))
|
|
335
|
+
: Boolean(leftEvaluator(context) || rightEvaluator(context))
|
|
336
|
+
}
|
|
337
|
+
continue
|
|
338
|
+
}
|
|
339
|
+
|
|
340
|
+
// PREFIX OPERATORS
|
|
341
|
+
const isNotOperator = readNext(expression, pos) === TOKEN_OPERATOR_NOT
|
|
342
|
+
if (isNotOperator) {
|
|
343
|
+
pos++
|
|
344
|
+
const operandExpression = readUntilNextOperator(
|
|
345
|
+
expression,
|
|
346
|
+
pos,
|
|
347
|
+
TOKEN_OPERATOR_NOT
|
|
348
|
+
)
|
|
349
|
+
pos += operandExpression.length
|
|
350
|
+
const operandEvaluator = evaluateInternal(
|
|
351
|
+
operandExpression,
|
|
352
|
+
currentContext
|
|
353
|
+
).evaluator
|
|
354
|
+
|
|
355
|
+
currentEvaluator = (context) => {
|
|
356
|
+
return !operandEvaluator(context)
|
|
357
|
+
}
|
|
358
|
+
continue
|
|
359
|
+
}
|
|
360
|
+
|
|
294
361
|
// TERNARY OPERATOR
|
|
295
362
|
const isTernary = readNext(expression, pos) === TOKEN_OPERATOR_TERNARY_FIRST
|
|
296
363
|
if (isTernary) {
|
|
@@ -37,6 +37,19 @@ export const DEFAULT_CONFIGURATION: EditorConfig = {
|
|
|
37
37
|
labelKey: marker('editor.record.form.field.title'),
|
|
38
38
|
},
|
|
39
39
|
},
|
|
40
|
+
{
|
|
41
|
+
model: 'flags',
|
|
42
|
+
modelSpecifier: 'flags:IS_REFERENCE_DATASET',
|
|
43
|
+
formFieldConfig: {
|
|
44
|
+
labelKey: marker(
|
|
45
|
+
'editor.record.form.field.flags.IS_REFERENCE_DATASET'
|
|
46
|
+
),
|
|
47
|
+
hintKey: marker(
|
|
48
|
+
'editor.record.form.field.hint.flags.IS_REFERENCE_DATASET'
|
|
49
|
+
),
|
|
50
|
+
},
|
|
51
|
+
hidden: '${record.kind != "dataset" || !user.isAdmin}',
|
|
52
|
+
},
|
|
40
53
|
{
|
|
41
54
|
model: 'abstract',
|
|
42
55
|
formFieldConfig: {
|
|
@@ -1,4 +1,7 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import {
|
|
2
|
+
CatalogRecordKeys,
|
|
3
|
+
RecordFlag,
|
|
4
|
+
} from '../../../../../../libs/common/domain/src/lib/model/record'
|
|
2
5
|
|
|
3
6
|
// Expressions should be enclosed in `${}` to be recognized as such
|
|
4
7
|
// eg. ${dateNow()}
|
|
@@ -15,6 +18,8 @@ export interface FormFieldConfig {
|
|
|
15
18
|
invalidHintKey?: string
|
|
16
19
|
}
|
|
17
20
|
|
|
21
|
+
export type FormFieldModel = CatalogRecordKeys | 'flags'
|
|
22
|
+
|
|
18
23
|
// Specifiers let us use specific components
|
|
19
24
|
// This is used for instance to target only certain online resources in a field
|
|
20
25
|
type OnlineLinkResourceSpecifier = `onlineResourceType:link`
|
|
@@ -25,11 +30,12 @@ type OnlineSingleLinkResourceSpecifier = `onlineResourceType:singleLink`
|
|
|
25
30
|
// When set on the `contacts` field, contacts are rendered as editable detail
|
|
26
31
|
// fields (ContactDetailsFormComponent) instead of cards (ContactCardComponent)
|
|
27
32
|
type EditableContactDetailsSpecifier = `contact:editableDetails`
|
|
28
|
-
export type
|
|
33
|
+
export type FormFieldModelSpecifier =
|
|
29
34
|
| OnlineLinkResourceSpecifier
|
|
30
35
|
| DatasetDistributionsSpecifier
|
|
31
36
|
| OnlineSingleLinkResourceSpecifier
|
|
32
37
|
| EditableContactDetailsSpecifier
|
|
38
|
+
| `flags:${RecordFlag}`
|
|
33
39
|
|
|
34
40
|
export type FormFieldComponentName =
|
|
35
41
|
| 'form-field-constraints-shortcuts'
|
|
@@ -37,8 +43,8 @@ export type FormFieldComponentName =
|
|
|
37
43
|
|
|
38
44
|
export interface EditorFieldIdentification {
|
|
39
45
|
// name of the target field in the record; will not change the record directly if not defined
|
|
40
|
-
model?:
|
|
41
|
-
modelSpecifier?:
|
|
46
|
+
model?: FormFieldModel
|
|
47
|
+
modelSpecifier?: FormFieldModelSpecifier
|
|
42
48
|
|
|
43
49
|
// if no model is given, a component can be shown instead
|
|
44
50
|
componentName?: FormFieldComponentName
|