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));
|
||||
}
|
||||
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,8 +68,9 @@
|
|||
<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>
|
||||
<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>
|
||||
|
@ -84,9 +85,8 @@
|
|||
</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;">
|
||||
<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'"
|
||||
|
@ -98,8 +98,7 @@
|
|||
</bulk-claim>
|
||||
|
||||
</div>
|
||||
<div class="uk-animation-slide-top-small uk-padding-small">
|
||||
|
||||
<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>
|
||||
|
@ -116,11 +115,10 @@
|
|||
</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;">
|
||||
<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)"
|
||||
|
@ -129,7 +127,7 @@
|
|||
[localStoragePrefix]="localStoragePrefix+'results'"
|
||||
[basketLimit]="basketLimit"></bulk-claim>
|
||||
</div>
|
||||
<div class="uk-padding-small uk-animation-slide-top-small">
|
||||
<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.
|
||||
|
@ -144,6 +142,8 @@
|
|||
</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"
|
||||
|
@ -170,7 +170,6 @@
|
|||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<!-- <helper position="right" styleName=" uk-width-1-5"></helper>-->
|
||||
</div>
|
||||
<div id="basketStickBottom"></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);
|
||||
if(!includes) {
|
||||
params += "(*=* NOT ";
|
||||
} else {
|
||||
params += " (";
|
||||
}
|
||||
if (forceQuotted) {
|
||||
/** Remove double quotes **/
|
||||
fieldValue = fieldValue.replace(/["]+/g, '');
|
||||
|
|
Loading…
Reference in New Issue