Fix query when any field not includes is not at first field. Align basket in liking. Fix a bug while try to remove a result after page reload.
This commit is contained in:
parent
f4a723d3ac
commit
63fe4d2e5a
|
@ -41,37 +41,15 @@ export class ClaimResultsComponent {
|
|||
@Input() localStoragePrefix: string = "";
|
||||
@Input() basketLimit;
|
||||
|
||||
public isSelected(result: ClaimEntity) {
|
||||
let found: boolean = false;
|
||||
const id = result.id;
|
||||
for (let _i = 0; _i < this.selectedResults.length; _i++) {
|
||||
let item = this.selectedResults[_i];
|
||||
if (item.id && item.id == id) {
|
||||
found = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
return found;
|
||||
// indexOf doesn't work when results came from
|
||||
// return this.selectedResults.indexOf(entity)!=-1;
|
||||
public isSelected(item: ClaimEntity) {
|
||||
return !!this.selectedResults.find(result => item.id === result.id);
|
||||
}
|
||||
|
||||
add(item: ClaimEntity) {
|
||||
// if (this.selectedResults.length > this.basketLimit) {
|
||||
// UIkit.notification({
|
||||
// message: 'Your basket exceeds the number of allowed results (150)',
|
||||
// status: 'warning',
|
||||
// timeout: 1500,
|
||||
// pos: 'top-center'
|
||||
// });
|
||||
// return;
|
||||
// }
|
||||
let found: boolean = this.isSelected(item);
|
||||
if (!found) {
|
||||
this.selectedResults.push(item);
|
||||
if (this.selectedResults != null) {
|
||||
localStorage.setItem(this.localStoragePrefix, JSON.stringify(this.selectedResults));
|
||||
}
|
||||
localStorage.setItem(this.localStoragePrefix, JSON.stringify(this.selectedResults));
|
||||
UIkit.notification(item.type + ' added in your basket!', {
|
||||
status: 'success',
|
||||
timeout: 4000,
|
||||
|
@ -80,8 +58,8 @@ export class ClaimResultsComponent {
|
|||
}
|
||||
}
|
||||
|
||||
remove(item: any) {
|
||||
const index: number = this.selectedResults.indexOf(item);
|
||||
remove(item: ClaimEntity) {
|
||||
const index: number = this.selectedResults.findIndex(result => item.id === result.id);
|
||||
if (index > -1) {
|
||||
this.selectedResults.splice(index, 1);
|
||||
if (this.selectedResults != null) {
|
||||
|
|
|
@ -4,7 +4,7 @@
|
|||
<breadcrumbs [breadcrumbs]="breadcrumbs"></breadcrumbs>
|
||||
</div>
|
||||
</div>
|
||||
<div uk-sticky="offset: 65; top:#pageTop; bottom: #pageBottom; media: @m" class="uk-blur-background">
|
||||
<div uk-sticky="offset: 65; bottom: #pageBottom; media: @m" class="uk-blur-background">
|
||||
<div class="uk-section-xsmall">
|
||||
<stepper>
|
||||
<step *ngIf="!inlineEntity" [status]="stepStatus('source')" stepId="source" stepNumber="1"
|
||||
|
@ -68,106 +68,105 @@
|
|||
<div *ngIf="showOptions.show != 'claim'" class="uk-width-1-3">
|
||||
<div id="basket" uk-sticky=" offset: 220; top:#basketStickTop; bottom: #basketStickBottom; media: @m"
|
||||
class="uk-card uk-card-default linkingBasket" style="z-index: 0!important;">
|
||||
<div class="uk-card-body uk-padding-remove">
|
||||
<ul class="uk-padding-small uk-padding-remove-bottom" uk-tab>
|
||||
<li [class.uk-active]="showOptions.basketShowSources"
|
||||
(click)="showOptions.basketswitchToSources()">
|
||||
<a>
|
||||
Sources to link ({{(sources.length + (inlineEntity ? 1 : 0)) |number}})
|
||||
</a>
|
||||
</li>
|
||||
<li [class.uk-disabled]="sources.length == 0 && !inlineEntity"
|
||||
[class.uk-active]="showOptions.basketShowLinksTo">
|
||||
<a (click)="showOptions.basketswitchToLinkTo()">Link to <span
|
||||
*ngIf="results.length> 0">({{(results.length) | number}})</span>
|
||||
</a>
|
||||
</li>
|
||||
</ul>
|
||||
<div *ngIf="showOptions.basketShowSources">
|
||||
<div class="uk-margin-remove-top uk-height-medium uk-overflow-auto ">
|
||||
<div *ngIf="showOptions.show == 'source'" class=" uk-padding-small " style="min-height:
|
||||
17px;">
|
||||
<start-over *ngIf="showOptions.show == 'source' && sources.length> 0"
|
||||
[results]="sources"
|
||||
[localStoragePrefix]="localStoragePrefix+'sources'"
|
||||
message="all sources" class="uk-float-right"></start-over>
|
||||
<bulk-claim *ngIf="showOptions.show == 'source'" [results]="sources"
|
||||
[properties]=properties
|
||||
[localStoragePrefix]="localStoragePrefix+'sources'" [basketLimit]="basketLimit"
|
||||
>
|
||||
</bulk-claim>
|
||||
<div class="uk-card-body uk-padding-small">
|
||||
<div class="uk-margin-right">
|
||||
<ul class="uk-tab" uk-tab>
|
||||
<li [class.uk-active]="showOptions.basketShowSources"
|
||||
(click)="showOptions.basketswitchToSources()">
|
||||
<a>
|
||||
Sources to link ({{(sources.length + (inlineEntity ? 1 : 0)) |number}})
|
||||
</a>
|
||||
</li>
|
||||
<li [class.uk-disabled]="sources.length == 0 && !inlineEntity"
|
||||
[class.uk-active]="showOptions.basketShowLinksTo">
|
||||
<a (click)="showOptions.basketswitchToLinkTo()">Link to <span
|
||||
*ngIf="results.length> 0">({{(results.length) | number}})</span>
|
||||
</a>
|
||||
</li>
|
||||
</ul>
|
||||
<div *ngIf="showOptions.basketShowSources">
|
||||
<div class="uk-height-medium uk-overflow-auto">
|
||||
<div *ngIf="showOptions.show == 'source'" class="uk-padding-small uk-padding-remove-horizontal" style="min-height:17px;">
|
||||
<start-over *ngIf="showOptions.show == 'source' && sources.length> 0"
|
||||
[results]="sources"
|
||||
[localStoragePrefix]="localStoragePrefix+'sources'"
|
||||
message="all sources" class="uk-float-right"></start-over>
|
||||
<bulk-claim *ngIf="showOptions.show == 'source'" [results]="sources"
|
||||
[properties]=properties
|
||||
[localStoragePrefix]="localStoragePrefix+'sources'" [basketLimit]="basketLimit"
|
||||
>
|
||||
</bulk-claim>
|
||||
|
||||
</div>
|
||||
<div class="uk-animation-slide-top-small uk-padding-small">
|
||||
|
||||
<div *ngIf="sources.length == 0 && !inlineEntity " class="uk-text-center uk-text-meta">
|
||||
No Sources added yet. Start adding sources from the left panel. Or upload a DOI's CSV file.
|
||||
</div>
|
||||
<div *ngIf="sources.length >= basketLimit " class="uk-alert uk-alert-warning uk-text-center">
|
||||
Basket reached the size limit. No more sources can be added.
|
||||
<div class="uk-padding-small uk-padding-remove-horizontal">
|
||||
<div *ngIf="sources.length == 0 && !inlineEntity " class="uk-text-center uk-text-meta">
|
||||
No Sources added yet. Start adding sources from the left panel. Or upload a DOI's CSV file.
|
||||
</div>
|
||||
<div *ngIf="sources.length >= basketLimit " class="uk-alert uk-alert-warning uk-text-center">
|
||||
Basket reached the size limit. No more sources can be added.
|
||||
</div>
|
||||
<claim-selected-results *ngIf="inlineEntity" [results]="[inlineEntity]"
|
||||
[localStoragePrefix]="localStoragePrefix+'sources'" class=""
|
||||
[enableRemove]="false" type="source">
|
||||
</claim-selected-results>
|
||||
<claim-selected-results *ngIf="sources.length > 0" [results]="sources"
|
||||
[localStoragePrefix]="localStoragePrefix+'sources'" class=""
|
||||
[enableRemove]="true" type="source">
|
||||
</claim-selected-results>
|
||||
</div>
|
||||
<claim-selected-results *ngIf="inlineEntity" [results]="[inlineEntity]"
|
||||
[localStoragePrefix]="localStoragePrefix+'sources'" class=""
|
||||
[enableRemove]="false" type="source">
|
||||
</claim-selected-results>
|
||||
<claim-selected-results *ngIf="sources.length > 0" [results]="sources"
|
||||
[localStoragePrefix]="localStoragePrefix+'sources'" class=""
|
||||
[enableRemove]="true" type="source">
|
||||
</claim-selected-results>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
<div *ngIf="showOptions.basketShowLinksTo">
|
||||
<div class="uk-height-medium uk-overflow-auto">
|
||||
<div *ngIf="(results.length)> 0 || showOptions.show=='result'" class="uk-padding-small" style="min-height: 17px;">
|
||||
<start-over *ngIf=" (results.length)> 0"
|
||||
[results]="results" [localStoragePrefix]="localStoragePrefix+'results'"
|
||||
message="all results (projects, communities, research results)"
|
||||
class="uk-float-right"></start-over>
|
||||
<bulk-claim *ngIf="showOptions.show=='result'" [results]="results" [properties]=properties
|
||||
[localStoragePrefix]="localStoragePrefix+'results'"
|
||||
[basketLimit]="basketLimit"></bulk-claim>
|
||||
</div>
|
||||
<div class="uk-padding-small uk-animation-slide-top-small">
|
||||
<div *ngIf="results.length >= basketLimit "
|
||||
class="uk-alert uk-alert-warning uk-text-center">
|
||||
Basket reached the size limit. No more entities can be added.
|
||||
</div>
|
||||
<claim-selected-results sectionTitle="Selected Results" [results]="results"
|
||||
[localStoragePrefix]="localStoragePrefix+'results'" type="target">
|
||||
</claim-selected-results>
|
||||
<div *ngIf="(results.length) == 0 " class=" uk-text-center">
|
||||
No entities to link with the sources. Start adding entities from the left panel.
|
||||
<div *ngIf="showOptions.basketShowLinksTo">
|
||||
<div class="uk-height-medium uk-overflow-auto">
|
||||
<div *ngIf="(results.length)> 0 || showOptions.show=='result'" class="uk-padding-small uk-padding-remove-horizontal" style="min-height: 17px;">
|
||||
<start-over *ngIf=" (results.length)> 0"
|
||||
[results]="results" [localStoragePrefix]="localStoragePrefix+'results'"
|
||||
message="all results (projects, communities, research results)"
|
||||
class="uk-float-right"></start-over>
|
||||
<bulk-claim *ngIf="showOptions.show=='result'" [results]="results" [properties]=properties
|
||||
[localStoragePrefix]="localStoragePrefix+'results'"
|
||||
[basketLimit]="basketLimit"></bulk-claim>
|
||||
</div>
|
||||
<div class="uk-padding-small uk-padding-remove-horizontal">
|
||||
<div *ngIf="results.length >= basketLimit "
|
||||
class="uk-alert uk-alert-warning uk-text-center">
|
||||
Basket reached the size limit. No more entities can be added.
|
||||
</div>
|
||||
<claim-selected-results sectionTitle="Selected Results" [results]="results"
|
||||
[localStoragePrefix]="localStoragePrefix+'results'" type="target">
|
||||
</claim-selected-results>
|
||||
<div *ngIf="(results.length) == 0 " class=" uk-text-center">
|
||||
No entities to link with the sources. Start adding entities from the left panel.
|
||||
</div>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div *ngIf="showOptions.show == 'source'"
|
||||
class="uk-card-footer uk-flex uk-flex-center clickable"
|
||||
[class.uk-tile-primary]="sources.length > 0"
|
||||
[class.uk-background-muted]="sources.length == 0"
|
||||
[class.uk-disabled]="sources.length == 0"
|
||||
(click)="stepHasChanged('target')">
|
||||
<button class="uk-flex uk-flex-middle uk-button uk-button-text"
|
||||
[class.uk-disabled]="sources.length == 0" [disabled]="sources.length == 0">
|
||||
<icon name="link" visuallyHidden="link" [flex]="true"></icon>
|
||||
<div class="uk-width-expand uk-margin-small-left">STEP 2 - LINK SOURCES TO ENTITIES</div>
|
||||
</button>
|
||||
</div>
|
||||
<div *ngIf="showOptions.show == 'source'"
|
||||
class="uk-card-footer uk-flex uk-flex-center clickable"
|
||||
[class.uk-tile-primary]="sources.length > 0"
|
||||
[class.uk-background-muted]="sources.length == 0"
|
||||
[class.uk-disabled]="sources.length == 0"
|
||||
(click)="stepHasChanged('target')">
|
||||
<button class="uk-flex uk-flex-middle uk-button uk-button-text"
|
||||
[class.uk-disabled]="sources.length == 0" [disabled]="sources.length == 0">
|
||||
<icon name="link" visuallyHidden="link" [flex]="true"></icon>
|
||||
<div class="uk-width-expand uk-margin-small-left">STEP 2 - LINK SOURCES TO ENTITIES</div>
|
||||
</button>
|
||||
|
||||
</div>
|
||||
<div *ngIf="showOptions.show != 'source'"
|
||||
class="uk-card-footer uk-flex uk-flex-center clickable"
|
||||
[class.uk-tile-primary]="results.length > 0"
|
||||
[class.uk-background-muted]="results.length == 0"
|
||||
[class.uk-disabled]="results.length == 0" (click)="stepHasChanged('claim')">
|
||||
<button class="uk-flex uk-flex-middle uk-button uk-button-text"
|
||||
[class.uk-disabled]="results.length == 0" [disabled]="results.length == 0">
|
||||
<icon *ngIf="inlineEntity" name="link" visuallyHidden="link" [flex]="true"></icon>
|
||||
<div class="uk-width-expand uk-margin-small-left">STEP {{inlineEntity ? '2' : '3'}} - FINALISE AND FINISH</div>
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
<div *ngIf="showOptions.show != 'source'"
|
||||
class="uk-card-footer uk-flex uk-flex-center clickable"
|
||||
[class.uk-tile-primary]="results.length > 0"
|
||||
[class.uk-background-muted]="results.length == 0"
|
||||
[class.uk-disabled]="results.length == 0" (click)="stepHasChanged('claim')">
|
||||
<button class="uk-flex uk-flex-middle uk-button uk-button-text"
|
||||
[class.uk-disabled]="results.length == 0" [disabled]="results.length == 0">
|
||||
<icon *ngIf="inlineEntity" name="link" visuallyHidden="link" [flex]="true"></icon>
|
||||
<div class="uk-width-expand uk-margin-small-left">STEP {{inlineEntity ? '2' : '3'}} - FINALISE AND FINISH</div>
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
|
|
@ -971,9 +971,6 @@ export class NewSearchPageComponent implements OnInit, OnDestroy, OnChanges {
|
|||
public static createKeywordQuery(entityType: string, value: string, id, operatorId, countParams = 0, includes: boolean = true) {
|
||||
let params = "";
|
||||
let doisParams = "";
|
||||
if(!includes) {
|
||||
params += "(*=* NOT ";
|
||||
}
|
||||
var DOIs: Identifier[] = Identifier.getIdentifiersFromString(value);
|
||||
if ((entityType == 'publication' || entityType == 'dataset' || entityType == 'software' || entityType == 'other' || entityType == "result" || entityType == "dataprovider" || entityType == "service")) {
|
||||
for (let identifier of DOIs) {
|
||||
|
@ -990,20 +987,17 @@ export class NewSearchPageComponent implements OnInit, OnDestroy, OnChanges {
|
|||
}
|
||||
}
|
||||
if (doisParams.length > 0) {
|
||||
params += this.createQuotedKeywordQuery(value, id, operatorId, countParams, true, true) + " or " + doisParams + ")";
|
||||
params += this.createQuotedKeywordQuery(value, id, operatorId, countParams, true, true, includes) + " or " + doisParams + ")";
|
||||
} else {
|
||||
//if it is PIDs but no doisquery produced, forced to use quotes as the query will fail due to special characters
|
||||
params += this.createQuotedKeywordQuery(value, id, operatorId, countParams, true,
|
||||
(DOIs.length > 0 && doisParams.length == 0));
|
||||
}
|
||||
if(!includes) {
|
||||
params += ")";
|
||||
(DOIs.length > 0 && doisParams.length == 0), includes);
|
||||
}
|
||||
return params;
|
||||
|
||||
}
|
||||
|
||||
private static createQuotedKeywordQuery(fieldValue: string, fieldId, fieldOperator, countParams: number, isSearchAll: boolean, forceQuotted: boolean = false) {
|
||||
private static createQuotedKeywordQuery(fieldValue: string, fieldId, fieldOperator, countParams: number, isSearchAll: boolean, forceQuotted: boolean = false, includes: boolean = true) {
|
||||
let params = "";
|
||||
let countQuote = (fieldValue.match(/'/g) || []).length;
|
||||
let countDoubleQuote = (fieldValue.match(/"/g) || []).length;
|
||||
|
@ -1012,7 +1006,11 @@ export class NewSearchPageComponent implements OnInit, OnDestroy, OnChanges {
|
|||
quotedParts = (fieldValue) ? fieldValue.match(/(["'])(.*?)*?\1/g) : [];
|
||||
}
|
||||
params += (countParams == 0 ? "" : fieldOperator);
|
||||
params += " (";
|
||||
if(!includes) {
|
||||
params += "(*=* NOT ";
|
||||
} else {
|
||||
params += " (";
|
||||
}
|
||||
if (forceQuotted) {
|
||||
/** Remove double quotes **/
|
||||
fieldValue = fieldValue.replace(/["]+/g, '');
|
||||
|
|
Loading…
Reference in New Issue