[new-search-extend-criteria | CHANGED | DONE]: Change some criteria to support soft autocomplete.

This commit is contained in:
Konstantinos Triantafyllou 2025-11-04 19:08:18 +02:00
parent b90cfc80b1
commit 699530aef7
9 changed files with 54 additions and 116 deletions

@ -1 +1 @@
Subproject commit edff7fa53adc46a7099a33e05c7d864dc33b599e
Subproject commit 32fa38e204e003216c5312ca352cd1abc818579f

View File

@ -49,7 +49,8 @@ import {OpenaireEntities} from "../../openaireLibrary/utils/properties/searchFie
<loading></loading>
</div>
<ng-container *ngIf="!loading">
<ng-container *ngIf="!this.communityService.selectedSubCommunity && previewSubCommunitiesCriteria.length > 0">
<ng-container
*ngIf="!this.communityService.selectedSubCommunity && previewSubCommunitiesCriteria.length > 0">
<ul class="uk-subnav uk-subnav-pill uk-margin-top" uk-margin uk-switcher>
<li class="uk-active"><a href="#">Set for community <span
*ngIf="selectionCriteria?.criteria?.length > 0"
@ -119,44 +120,42 @@ export class AdvancedCriteriaComponent implements OnInit, OnDestroy {
public criteriaUtils: CriteriaUtils = new CriteriaUtils();
private subscriptions: any[] = [];
@ViewChild('criteria') criteria: CriteriaComponent;
@ViewChild('filtersModal', { static: true }) filtersModal: FullScreenModalComponent;
@ViewChild('filtersModal', {static: true}) filtersModal: FullScreenModalComponent;
constructor(protected communityService: CommunityService,
private cdr: ChangeDetectorRef,
private advancedCriteriaService: AdvancedCriteriaService, private title: Title,
private route: ActivatedRoute, private _router: Router) {}
private route: ActivatedRoute, private _router: Router) {
}
ngOnInit() {
this.loading = true;
this.subscriptions.push(this.communityService.getCommunityAsObservable().subscribe(community => {
this.community = community;
this.title.setTitle(this.community.shortTitle.toUpperCase() + (this.communityService.selectedSubCommunity?':'+this.communityService.selectedSubCommunity?.label:"") +' | Advance Criteria');
this.title.setTitle(this.community.shortTitle.toUpperCase() + (this.communityService.selectedSubCommunity ? ':' + this.communityService.selectedSubCommunity?.label : "") + ' | Advance Criteria');
this.getCriteria();
}));
}
getCriteria(){
this.loading = true;
if(this.communityService.selectedSubCommunityId()){
this.subscriptions.push(this.advancedCriteriaService.getAdvancedCriteriaForSubcommunities(this.community.communityId,this.communityService.selectedSubCommunityId()).subscribe(
res => {
console.log(res)
this.selectionCriteria = res.selectionCriteria;
console.log(this.selectionCriteria);
this.loading = false;
}
) );
}else{
this.subscriptions.push(this.advancedCriteriaService.getAdvancedCriteriaForSubcommunities(this.community.communityId,this.communityService.selectedSubCommunityId).subscribe( res =>{
getCriteria() {
this.loading = true;
if (this.communityService.selectedSubCommunityId()) {
this.subscriptions.push(this.advancedCriteriaService.getAdvancedCriteriaForSubcommunities(this.community.communityId, this.communityService.selectedSubCommunityId()).subscribe(
res => {
this.selectionCriteria = res.selectionCriteria;
this.loading = false;
}
));
} else {
this.subscriptions.push(this.advancedCriteriaService.getAdvancedCriteriaForSubcommunities(this.community.communityId, this.communityService.selectedSubCommunityId).subscribe(res => {
this.selectionCriteria = this.community.selectionCriteria;
this.previewSubCommunitiesCriteria = res;
console.log(this.selectionCriteria, res);
this.loading = false;
}) );
}));
}
}
saveCriteria() {
let callback = (selectionCriteria): void => {
this.advancedCriteriaService.saveAdvancedCriteria(this.community.communityId, selectionCriteria, this.communityService.selectedSubCommunityId()).subscribe(() => {
@ -172,7 +171,7 @@ export class AdvancedCriteriaComponent implements OnInit, OnDestroy {
this.loading = true;
this.criteria.save(callback);
}
public openCriteria() {
this.criteria.reset();
this.filtersModal.title = 'Criteria';
@ -182,19 +181,20 @@ export class AdvancedCriteriaComponent implements OnInit, OnDestroy {
this.filtersModal.open();
this.cdr.detectChanges();
}
ngOnDestroy() {
this.subscriptions.forEach(subscription => {
if(subscription instanceof Subscription) {
if (subscription instanceof Subscription) {
subscription.unsubscribe();
}
})
}
subCommunityChanged(){
subCommunityChanged() {
this.getCriteria();
}
navigateToSub(communityId){
navigateToSub(communityId) {
this.communityService.setSelectedSubCommunity(communityId);
this._router.navigate([], {
relativeTo: this.route,

View File

@ -42,7 +42,7 @@
<div class="uk-card-body">
<result-preview [properties]="properties" [showOrganizations]="true"
[showSubjects]="true" [result]="getResultPreview(result)"
[externalUrl]="contentProviderUrl">
[externalUrl]="contentProviderUrl" [hasLink]="false">
</result-preview>
</div>
<div class="uk-card-footer uk-padding-remove-vertical">
@ -95,3 +95,4 @@
</ng-container>
</div>
</div>
</div>

View File

@ -81,7 +81,7 @@ export class AddContentProvidersComponent implements OnInit {
sub.unsubscribe();
}
});
console.log('destroy')
if (this.subResults) {
this.subResults.unsubscribe();
}

View File

@ -4,7 +4,7 @@ import {Criteria} from "../../openaireLibrary/utils/entities/contentProvider";
export class CriteriaUtils {
public readonly criteriaFields = {
["description"]: {value: 'description', label: 'Abstract', type: 'keyword',operator :"string"},
["access"]: {value: 'access', label: 'Access right', type: 'keyword',operator :"string"},
["access"]: {value: 'access', label: 'Access right', type: 'vocabulary',operator :"string", vocabularyId: 'access'},
["author"]: {value: 'author', label: 'Author\'s name', type: 'keyword',operator :"string"},
["orcid"]: {value: 'orcid', label: 'Author\'s ORCID', type: 'keyword',operator :"string"},
["contributor"]: {value: 'contributor', label: 'Contributor', type: 'keyword',operator :"string"},
@ -12,7 +12,7 @@ export class CriteriaUtils {
["language"]: {value: 'language', label: 'Language', type: 'vocabulary',operator :"exact", vocabularyId:"lang"},
["publisher"]: {value: 'publisher', label: 'Publisher', type: 'keyword',operator :"string"},
["publicationyear"]: {value: 'publicationyear', label: 'Publication Year', type: 'number',operator :"numeric"},
["sdg"]: {value: 'sdg', label: 'SDG', type: 'static',operator :"string"},
["sdg"]: {value: 'sdg', label: 'SDG', type: 'static',operator :"exact"},
["documentType"]: {value: 'documentType', label: 'Specific type', type: 'vocabulary',operator :"string" , vocabularyId:"type"},
["subject"]: {value: 'subject', label: 'Subject', type: 'keyword',operator :"string"},
["title"]: {value: 'title', label: 'Title', type: 'keyword',operator :"string"},

View File

@ -30,67 +30,6 @@
<label class="uk-text-bold uk-text-uppercase">Match Case</label>
</div>
</div>
<!-- <div *ngFor="let constraint of getConstraint(i).controls; let j=index" [formGroupName]="j.toString()"-->
<!-- class="uk-margin-bottom uk-hidden@l">-->
<!-- <div class="uk-flex-middle uk-grid-small uk-margin-medium-bottom" uk-grid>-->
<!-- <div class="uk-flex uk-flex-right uk-width-1-1">-->
<!-- <button class="uk-close uk-icon" (click)="removeConstraint(i, j)">-->
<!-- <icon name="close" ratio="1.5" [flex]="true"-->
<!-- [attr.uk-tooltip]="(getConstraint(i).length === 1?'By removing this constraint, the ' + entityType + ' will be removed too':null)"></icon>-->
<!-- </button>-->
<!-- </div>-->
<!-- <div class="uk-width-1-1" input type="select" inputClass="border-bottom" [placeholder]="{static: true, label: 'Choose a field'}"-->
<!-- [options]="fieldOptions" [formInput]="constraint.get('field')" (valueChange)="resetFieldWhenValueChange(constraint)">-->
<!-- <label class="uk-text-uppercase uk-text-bold uk-width-1-3 uk-text-truncate">Field:</label>-->
<!-- </div>-->
<!-- <div *ngIf="criteriaUtils.criteriaFields[constraint.get('field').value].operator == 'string'" class="uk-width-1-1" input type="select" inputClass="border-bottom"-->
<!-- [options]="criteriaUtils.verbs" [formInput]="constraint.get('verb')">-->
<!-- <label class="uk-text-uppercase uk-text-bold uk-width-1-3 uk-text-truncate">Operator:</label>-->
<!-- </div>-->
<!-- <div *ngIf="criteriaUtils.criteriaFields[constraint.get('field').value].operator == 'numeric'" class="uk-width-1-1" input type="select" inputClass="border-bottom"-->
<!-- [options]="criteriaUtils.verbsForNumbers" [formInput]="constraint.get('verb')">-->
<!-- <label class="uk-text-uppercase uk-text-bold uk-width-1-3 uk-text-truncate">Operator:</label>-->
<!-- </div>-->
<!-- <div *ngIf="criteriaUtils.criteriaFields[constraint.get('field').value].operator == 'exact'" class="uk-width-1-1" input type="select" inputClass="border-bottom"-->
<!-- [options]="criteriaUtils.verbsForExact" [formInput]="constraint.get('verb')">-->
<!-- <label class="uk-text-uppercase uk-text-bold uk-width-1-3 uk-text-truncate">Operator:</label>-->
<!-- </div>-->
<!-- <div *ngIf="criteriaUtils.criteriaFields[constraint.get('field').value].type == 'keyword'"-->
<!-- class="uk-width-1-1" input [placeholder]="{static: true, label: 'Type a keyword'}"-->
<!-- [formInput]="constraint.get('value')">-->
<!-- <label class="uk-text-uppercase uk-text-bold uk-width-1-3 uk-text-truncate">Term:</label>-->
<!-- </div>-->
<!-- <ng-container *ngIf="criteriaUtils.criteriaFields[constraint.get('field').value].type == 'vocabulary'">-->
<!-- <static-autocomplete [properties]=properties [vocabularyId]="criteriaUtils.criteriaFields[constraint.get('field').value].vocabularyId"-->
<!-- [fieldId]="criteriaUtils.criteriaFields[constraint.get('field').value].vocabularyId"-->
<!-- [selectedValue]="constraint.get('value').value" [showSelected]=true entityName="result"-->
<!-- [placeHolderMessage]="'Search for '+criteriaUtils.criteriaFields[constraint.get('field').value].label" [title]="criteriaUtils.criteriaFields[constraint.get('field').value].label"-->
<!-- [multipleSelections]=false-->
<!-- (selectedValueChanged)="constraint.get('value').setValue($event.value)"-->
<!-- [list]="vocabularyLists[criteriaUtils.criteriaFields[constraint.get('field').value].vocabularyId] "-->
<!-- (listUpdated)="vocabularyLists[criteriaUtils.criteriaFields[constraint.get('field').value].vocabularyId] = $event.value"-->
<!-- ></static-autocomplete>-->
<!-- </ng-container>-->
<!-- <div *ngIf="criteriaUtils.criteriaFields[constraint.get('field').value].type == 'static'"-->
<!-- class="uk-width-1-1" inputClass="flat small" input [placeholder]="{static: true, label: 'Choose a ' + criteriaUtils.criteriaFields[constraint.get('field').value].label}"-->
<!-- [formInput]="constraint.get('value')" type="select" [options]="staticLists[constraint.get('field').value]">-->
<!-- <label class="uk-text-uppercase uk-text-bold uk-width-1-3 uk-text-truncate">Term:</label>-->
<!-- </div>-->
<!-- <div class="uk-width-1-1" *ngIf="criteriaUtils.criteriaFields[constraint.get('field').value].type == 'keyword'">-->
<!-- <div class="uk-grid" uk-grid>-->
<!-- <label class="uk-text-uppercase uk-text-bold uk-width-1-3 uk-text-truncate">Match Case</label>-->
<!-- <div class="uk-width-expand">-->
<!-- <mat-slide-toggle [checked]="constraint.get('verb_suffix').value === ''"-->
<!-- [attr.uk-tooltip]="(constraint.get('verb_suffix').value === ''?('Only \'\'' + constraint.get('value').value + '\'\' matches'):-->
<!-- ('Both \'\'' + constraint.get('value').value.toUpperCase() + '\'\' and \'\'' + constraint.get('value').value.toLowerCase() + '\'\' match'))"-->
<!-- (change)="caseSensitive($event, constraint)"></mat-slide-toggle>-->
<!-- </div>-->
<!-- </div>-->
<!-- </div>-->
<!-- </div>-->
<!-- </div>-->
<div *ngFor="let constraint of getConstraint(i).controls; let j=index"
[formGroupName]="j.toString()" class="uk-margin-bottom ">
<div class="uk-flex uk-flex-middle uk-grid" uk-grid>
@ -105,10 +44,10 @@
<ng-container *ngIf="criteriaUtils.criteriaFields[constraint.get('field').value].type == 'vocabulary'">
<static-autocomplete [properties]=properties [vocabularyId]="criteriaUtils.criteriaFields[constraint.get('field').value].vocabularyId" class="uk-width-1-4@l uk-width-1-1@m"
[fieldId]="criteriaUtils.criteriaFields[constraint.get('field').value].vocabularyId"
[selectedValue]="constraint.get('value').value" [showSelected]=true entityName="result"
[selectedValue]="constraint.get('value').value" entityName="result" inputClass="flat"
[placeHolderMessage]="'Search for '+criteriaUtils.criteriaFields[constraint.get('field').value].label" [title]="criteriaUtils.criteriaFields[constraint.get('field').value].label"
[multipleSelections]=false
(selectedValueChanged)="constraint.get('value').setValue($event.value)"
[type]="criteriaUtils.criteriaFields[constraint.get('field').value].operator === 'string'?'autocomplete_soft':'autocomplete'"
[list]="vocabularyLists[criteriaUtils.criteriaFields[constraint.get('field').value].vocabularyId] "
(listUpdated)="vocabularyLists[criteriaUtils.criteriaFields[constraint.get('field').value].vocabularyId] = $event.value"
></static-autocomplete>
@ -119,7 +58,7 @@
[formInput]="constraint.get('value')"></div>
<ng-container *ngIf="criteriaUtils.criteriaFields[constraint.get('field').value].type == 'static'">
<div class="uk-width-1-4@l uk-width-1-1@m" inputClass="flat small" input [placeholder]="{static: true, label: 'Choose a ' + criteriaUtils.criteriaFields[constraint.get('field').value].label}"
[formInput]="constraint.get('value')" type="select" [options]="staticLists[constraint.get('field').value]"></div>
[formInput]="constraint.get('value')" [type]="criteriaUtils.criteriaFields[constraint.get('field').value].operator === 'string'?'autocomplete_soft':'select'" [options]="staticLists[constraint.get('field').value]"></div>
</ng-container>
<div class="uk-width-1-1@m uk-width-expand@l uk-grid">

View File

@ -102,7 +102,6 @@ export class CriteriaComponent implements OnInit, OnChanges, AfterViewInit, OnDe
criteria: this.fb.array([])
});
if (this.selectionCriteria?.criteria) {
this.selectionCriteria.criteria.forEach(criterion => {
let constraintArray: UntypedFormArray = this.fb.array([]);
criterion.constraint.forEach(constraint => {

View File

@ -24,11 +24,10 @@ import {UntypedFormBuilder} from "@angular/forms";
[communityContentProviders]="communityContentProviders"
[loading]="showLoadingInRemove" [community]="community"
(editCriteria)="openCriteria($event)"
(communityContentProvidersChanged)="communityContentProvidersChanged($event)">
</remove-content-providers>
<fs-modal #addContentProvidersModal>
<add-content-providers #addContentProviders [communityContentProviders]="communityContentProviders"
<fs-modal #addContentProvidersModal (cancelEmitter)="addView = false">
<add-content-providers [communityContentProviders]="communityContentProviders"
[community]="community"
(communityContentProvidersChanged)="communityContentProvidersChanged($event)"></add-content-providers>
</fs-modal>
@ -46,17 +45,17 @@ import {UntypedFormBuilder} from "@angular/forms";
<label class="uk-margin-medium-top uk-margin-small-left ">Suggest for deposit</label>
</div>
</div>
<div class="uk-hr" [class.uk-hidden]="!enabled">
<div class="uk-text-center uk-text-bold uk-text-large uk-margin-top ">Content filters</div>
<criteria #criteria *ngIf="dataProvider" [height]="'-1'"
[selectionCriteria]="dataProvider.selectioncriteria">
<div no-criteria>
<h5 class="uk-margin-small-bottom">No Filters for {{dataProvider.officialname}} yet</h5>
<i class="uk-display-block">If no Filters are specified, all {{openaireEntities.RESULTS | lowercase}} of this {{openaireEntities.DATASOURCE | lowercase}} will be included in your
{{openaireEntities.COMMUNITY | lowercase}}.
</i>
</div>
</criteria>
<div *ngIf="enabled" class="uk-hr">
<div class="uk-text-center uk-text-bold uk-text-large uk-margin-top ">Content filters</div>
<criteria #criteria *ngIf="dataProvider" [height]="-1"
[selectionCriteria]="dataProvider.selectioncriteria">
<div no-criteria>
<h5 class="uk-margin-small-bottom">No Filters for {{dataProvider.officialname}} yet</h5>
<i class="uk-display-block">If no Filters are specified, all {{openaireEntities.RESULTS | lowercase}} of this {{openaireEntities.DATASOURCE | lowercase}} will be included in your
{{openaireEntities.COMMUNITY | lowercase}}.
</i>
</div>
</criteria>
</div>
<div *ngIf="deposit" class="uk-hr">
@ -84,9 +83,8 @@ export class ManageContentProvidersComponent implements OnInit {
communityContentProviders: ContentProvider[] = [];
@ViewChild(RemoveContentProvidersComponent) removeContentProvidersComponent: RemoveContentProvidersComponent;
@ViewChild('criteria') criteria: CriteriaComponent;
@ViewChild('addContentProvidersModal', { static: true }) addContentProvidersModal: FullScreenModalComponent;
@ViewChild('addContentProvidersModal') addContentProvidersModal: FullScreenModalComponent;
@ViewChild('filtersModal', { static: true }) filtersModal: FullScreenModalComponent;
@ViewChild('depositModal', { static: true }) depositModal: FullScreenModalComponent;
private subscriptions: any[] = [];
public showLoadingInRemove: boolean = true;
public body: string = "Send from page";
@ -94,6 +92,7 @@ export class ManageContentProvidersComponent implements OnInit {
public openaireEntities = OpenaireEntities;
public community: CommunityInfo;
public dataProvider: ContentProvider;
public addView: boolean = false;
message = "";
deposit= false;
enabled = false;
@ -130,6 +129,8 @@ export class ManageContentProvidersComponent implements OnInit {
this.addContentProvidersModal.okButtonText = "Done";
this.addContentProvidersModal.back = true;
this.addContentProvidersModal.okButton = true;
this.addView = true;
this.cdr.detectChanges();
this.addContentProvidersModal.open();
}
@ -154,7 +155,6 @@ export class ManageContentProvidersComponent implements OnInit {
this.dataProvider.deposit = this.deposit;
this.dataProvider.message = this.message;
this.dataProvider.enabled = this.enabled;
console.log(this.dataProvider)
this.manageCommunityContentProvidersService.saveContentProvider(this.properties, this.dataProvider, this.communityService.selectedSubCommunityId()).subscribe(() => {
this.criteria.reset();
this.removeContentProvidersComponent.getCommunityContentProviders();
@ -166,7 +166,6 @@ export class ManageContentProvidersComponent implements OnInit {
});
}
this.removeContentProvidersComponent.loading = true;
console.log()
this.criteria.save(callback);
}

@ -1 +1 @@
Subproject commit db996ff8826a5f11eb5582f9089212d5d5294a7a
Subproject commit c19ab202810fb40abcc0ff7af5bb7ffcb0b2bd5c