+ [readonly]="isEditMode()"
+ [errorMessages]="errorMessages">
{{ 'kb.kv-schemas.form.schema-name' | translate }}
diff --git a/libs/common/src/lib/knowledge-box-settings/kv-schemas/schema-form/schema-form.component.ts b/libs/common/src/lib/knowledge-box-settings/kv-schemas/schema-form/schema-form.component.ts
index 66037b4f39..88a98c5d6e 100644
--- a/libs/common/src/lib/knowledge-box-settings/kv-schemas/schema-form/schema-form.component.ts
+++ b/libs/common/src/lib/knowledge-box-settings/kv-schemas/schema-form/schema-form.component.ts
@@ -48,6 +48,10 @@ export class SchemaFormComponent {
isEditMode = computed(() => !!this.schema());
+ errorMessages = {
+ pattern: 'kb.kv-schemas.form.invalid-id',
+ };
+
constructor() {
effect(() => {
const s = this.schema();
@@ -79,7 +83,10 @@ export class SchemaFormComponent {
buildFieldGroup(field?: KVSchemaField): FormGroup {
return new FormGroup({
- key: new FormControl(field?.key ?? '', [Validators.required, Validators.pattern(this.config.identifierPattern)]),
+ key: new FormControl(field?.key ?? '', [
+ Validators.required,
+ Validators.pattern(this.config.fieldIdentifierPattern),
+ ]),
type: new FormControl
(field?.type ?? this.config.defaultFieldType, Validators.required),
description: new FormControl(field?.description ?? ''),
required: new FormControl(field?.required ?? true),
diff --git a/libs/common/src/lib/resources/edit-resource/edit-resource.component.html b/libs/common/src/lib/resources/edit-resource/edit-resource.component.html
index 1da53fb002..77b221b977 100644
--- a/libs/common/src/lib/resources/edit-resource/edit-resource.component.html
+++ b/libs/common/src/lib/resources/edit-resource/edit-resource.component.html
@@ -141,7 +141,11 @@
- {{ 'resource.field-' + field.field_type | translate }}
+ @if (field.field_type === 'key_value') {
+ {{ field.field_id }}
+ } @else {
+ {{ 'resource.field-' + field.field_type | translate }}
+ }
@if (field.hasError) {
diff --git a/libs/common/src/lib/search-widget/search-configuration/filter-expression-modal/add-filter-modal/add-filter-modal.component.html b/libs/common/src/lib/search-widget/search-configuration/filter-expression-modal/add-filter-modal/add-filter-modal.component.html
index 5c910ae948..411b336556 100644
--- a/libs/common/src/lib/search-widget/search-configuration/filter-expression-modal/add-filter-modal/add-filter-modal.component.html
+++ b/libs/common/src/lib/search-widget/search-configuration/filter-expression-modal/add-filter-modal/add-filter-modal.component.html
@@ -32,18 +32,25 @@
{{ 'search.configuration.filter-expression-modal.filters' | translate }}
- @if ((target | async) === 'field') {
+ @let targetValue = target | async;
+ @if (targetValue === 'field') {
@for (filter of fieldFilters; track filter) {
{{ 'search.configuration.filter-expression-modal.filter-type.' + filter | translate }}
}
- } @else {
+ } @else if (targetValue === 'paragraph') {
@for (filter of paragraphFilters; track filter) {
{{ 'search.configuration.filter-expression-modal.filter-type.' + filter | translate }}
}
+ } @else {
+ @for (filter of keyValueFilters; track filter) {
+
+ {{ 'search.configuration.filter-expression-modal.filter-type.' + filter | translate }}
+
+ }
}
}
@@ -234,7 +241,88 @@
{{ 'search.configuration.filter-expression-modal.origin-filter.value' | translate }}
}
+ @case ('key_value_eq') {
+
+ @if (selectedSchemaKey) {
+ @let type = (schemaField | async)?.type;
+ @if (type === 'text') {
+
+ {{ 'search.configuration.filter-expression-modal.key-value-filter.equal' | translate }}
+
+ } @else if (type === 'boolean') {
+
+ True
+ False
+
+ } @else if (type === 'float' || type === 'integer') {
+
+ {{ 'search.configuration.filter-expression-modal.key-value-filter.equal' | translate }}
+
+ } @else if (type === 'date') {
+
+ }
+ }
+ }
+ @case ('key_value_gte_lte') {
+
+ @if (selectedSchemaKey) {
+ @let type = (schemaField | async)?.type;
+ @if (type === 'float' || type === 'integer') {
+
+ {{ 'search.configuration.filter-expression-modal.key-value-filter.gte' | translate }}
+
+
+ {{ 'search.configuration.filter-expression-modal.key-value-filter.lte' | translate }}
+
+ } @else if (type === 'date') {
+
+
+ }
+ }
+ }
+ @case ('key_value_contains') {
+
+ @if (selectedSchemaKey) {
+
+ {{ 'search.configuration.filter-expression-modal.key-value-filter.contains' | translate }}
+
+ }
+ }
}
+
+
+ @for (schema of kvSchemas | async; track schema.id) {
+ {{ schema.id }}
+ }
+
+ @if (selectedSchema) {
+
+ }
+
}
diff --git a/libs/common/src/lib/search-widget/search-configuration/filter-expression-modal/add-filter-modal/add-filter-modal.component.ts b/libs/common/src/lib/search-widget/search-configuration/filter-expression-modal/add-filter-modal/add-filter-modal.component.ts
index 2c62bd63b2..254779e019 100644
--- a/libs/common/src/lib/search-widget/search-configuration/filter-expression-modal/add-filter-modal/add-filter-modal.component.ts
+++ b/libs/common/src/lib/search-widget/search-configuration/filter-expression-modal/add-filter-modal/add-filter-modal.component.ts
@@ -12,11 +12,12 @@ import {
} from '@guillotinaweb/pastanaga-angular';
import { TranslateModule } from '@ngx-translate/core';
import { LabelsService } from '@flaps/core';
-import { FIELD_TYPE, TypeParagraph } from '@nuclia/core';
+import { FIELD_TYPE, KVFieldType, TypeParagraph } from '@nuclia/core';
import { FormControl, FormGroup, ReactiveFormsModule, Validators } from '@angular/forms';
import { NerService } from '../../../../entities';
-import { BehaviorSubject, defer, filter, map, merge, of, switchMap } from 'rxjs';
+import { BehaviorSubject, combineLatest, defer, filter, map, merge, of, switchMap, take, tap } from 'rxjs';
import { AnyFilterExpression, FilterTarget } from '../filter-expression-modal.component';
+import { KvSchemasService } from '../../../../knowledge-box-settings/kv-schemas/kv-schemas.service';
@Component({
imports: [
@@ -72,6 +73,13 @@ export class AddFilterModalComponent {
paragraphFilters = ['label', 'kind'];
+ keyValueFilters = ['key_value_eq', 'key_value_gte_lte', 'key_value_contains'];
+
+ allowedFieldTypes: { [key: string]: string[] } = {
+ key_value_eq: ['text', 'boolean', 'integer', 'float', 'date'],
+ key_value_gte_lte: ['integer', 'float', 'date'],
+ };
+
prop = new FormControl