Skip to content

Commit 2d7e73a

Browse files
committed
Add default field "has children" to field specific search
1 parent 7e7fc3f commit 2d7e73a

File tree

3 files changed

+57
-42
lines changed

3 files changed

+57
-42
lines changed

core/src/basic-index-configuration.ts

+1
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ export const basicIndexConfiguration: Map<IndexDefinition> = {
2424
'id:match': { path: 'resource.id', pathArray: ['resource', 'id'], type: 'match' },
2525
'isRecordedIn:contain': { path: 'resource.relations.isRecordedIn', pathArray: ['resource', 'relations', 'isRecordedIn'], type: 'contain' },
2626
'isChildOf:contain': { path: 'resource.relations.isChildOf', pathArray: ['resource', 'relations', 'isChildOf'], type: 'contain', recursivelySearchable: true },
27+
'isChildOf:contained': { path: 'resource.relations.isChildOf', pathArray: ['resource', 'relations', 'isChildOf'], type: 'contained' },
2728
'isChildOf:exist': { path: 'resource.relations.isChildOf', pathArray: ['resource', 'relations', 'isChildOf'], type: 'exist' },
2829
'isPresentIn:contain': { path: 'resource.relations.isPresentIn', pathArray: ['resource', 'relations', 'isPresentIn'], type: 'contain' },
2930
'missingRelationTargetIds:contain': { path: 'warnings.missingRelationTargets.targetIds', pathArray: ['warnings', 'missingRelationTargets', 'targetIds'], type: 'contain' }

desktop/src/app/components/resources/searchbar/resources-search-constraints.component.ts

+49-37
Original file line numberDiff line numberDiff line change
@@ -41,43 +41,49 @@ export class ResourcesSearchConstraintsComponent extends SearchConstraintsCompon
4141

4242
public getFieldLabel(field: Field): string {
4343

44-
if (field.name === 'geometry') {
45-
return this.i18n({
46-
id: 'resources.searchBar.constraints.geometry',
47-
value: 'Geometrie'
48-
});
49-
} else if (field.name === 'isDepictedIn') {
50-
return this.i18n({
51-
id: 'resources.searchBar.constraints.linkedImages',
52-
value: 'Verknüpfte Bilder'
53-
});
54-
} else if (field.name === 'isSameAs') {
55-
return this.i18n({
56-
id: 'resources.searchBar.constraints.isSameAs',
57-
value: 'Verknüpfte identische Ressourcen'
58-
});
59-
} else if (field.name === 'isInstanceOf') {
60-
return this.i18n({
61-
id: 'resources.searchBar.constraints.isInstanceOf',
62-
value: 'Verknüpfte Typen'
63-
});
64-
} else if (field.name === 'hasInstance') {
65-
return this.i18n({
66-
id: 'resources.searchBar.constraints.hasInstance',
67-
value: 'Verknüpfte Funde'
68-
});
69-
} else if (field.name === 'isStoragePlaceOf') {
70-
return this.i18n({
71-
id: 'resources.searchBar.constraints.isStoragePlaceOf',
72-
value: 'Verknüpfte Objekte'
73-
});
74-
} else if (field.name === 'isStoredIn') {
75-
return this.i18n({
76-
id: 'resources.searchBar.constraints.isStoredIn',
77-
value: 'Verknüpfter Aufbewahrungsort'
78-
});
79-
} else {
80-
return super.getFieldLabel(field);
44+
switch (field.name) {
45+
case 'isChildOf':
46+
return this.i18n({
47+
id: 'resources.searchBar.constraints.hasChildren',
48+
value: 'Untergeordnete Ressourcen'
49+
});
50+
case 'geometry':
51+
return this.i18n({
52+
id: 'resources.searchBar.constraints.geometry',
53+
value: 'Geometrie'
54+
});
55+
case 'isDepictedIn':
56+
return this.i18n({
57+
id: 'resources.searchBar.constraints.linkedImages',
58+
value: 'Verknüpfte Bilder'
59+
});
60+
case 'isSameAs':
61+
return this.i18n({
62+
id: 'resources.searchBar.constraints.isSameAs',
63+
value: 'Verknüpfte identische Ressourcen'
64+
});
65+
case 'isInstanceOf':
66+
return this.i18n({
67+
id: 'resources.searchBar.constraints.isInstanceOf',
68+
value: 'Verknüpfte Typen'
69+
});
70+
case 'hasInstance':
71+
return this.i18n({
72+
id: 'resources.searchBar.constraints.hasInstance',
73+
value: 'Verknüpfte Funde'
74+
});
75+
case 'isStoragePlaceOf':
76+
return this.i18n({
77+
id: 'resources.searchBar.constraints.isStoragePlaceOf',
78+
value: 'Verknüpfte Objekte'
79+
});
80+
case 'isStoredIn':
81+
return this.i18n({
82+
id: 'resources.searchBar.constraints.isStoredIn',
83+
value: 'Verknüpfter Aufbewahrungsort'
84+
});
85+
default:
86+
return super.getFieldLabel(field);
8187
}
8288
}
8389

@@ -86,6 +92,12 @@ export class ResourcesSearchConstraintsComponent extends SearchConstraintsCompon
8692

8793
this.defaultFields = [];
8894

95+
this.defaultFields.push({
96+
name: 'isChildOf',
97+
inputType: 'default',
98+
constraintIndexed: true
99+
});
100+
89101
if (!this.viewFacade.isInTypesManagement()) {
90102
this.defaultFields.push({
91103
name: 'geometry',

desktop/src/app/components/widgets/search-constraints.component.ts

+7-5
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import { Component, Input, OnChanges, Renderer2 } from '@angular/core';
22
import { I18n } from '@ngx-translate/i18n-polyfill';
33
import { aFilter, clone, is, on } from 'tsfun';
44
import { CategoryForm, ConstraintIndex, Datastore, Field, ProjectConfiguration, Valuelist,
5-
ValuelistUtil, Labels } from 'idai-field-core';
5+
ValuelistUtil, Labels, IndexType } from 'idai-field-core';
66
import { SearchBarComponent } from './search-bar.component';
77

88

@@ -493,11 +493,13 @@ export abstract class SearchConstraintsComponent implements OnChanges {
493493
}
494494

495495

496-
private getIndexType(field: Field, searchTerm: string) {
496+
private getIndexType(field: Field, searchTerm: string): IndexType {
497497

498-
return this.isExistIndexSearch(searchTerm, this.getSearchInputType(field))
499-
? 'exist'
500-
: ConstraintIndex.getIndexType(field);
498+
return field.name === 'isChildOf'
499+
? 'contained'
500+
: this.isExistIndexSearch(searchTerm, this.getSearchInputType(field))
501+
? 'exist'
502+
: ConstraintIndex.getIndexType(field);
501503
}
502504

503505

0 commit comments

Comments
 (0)