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() localStoragePrefix: string = "";
|
||||||
@Input() basketLimit;
|
@Input() basketLimit;
|
||||||
|
|
||||||
public isSelected(result: ClaimEntity) {
|
public isSelected(item: ClaimEntity) {
|
||||||
let found: boolean = false;
|
return !!this.selectedResults.find(result => item.id === result.id);
|
||||||
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;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
add(item: ClaimEntity) {
|
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);
|
let found: boolean = this.isSelected(item);
|
||||||
if (!found) {
|
if (!found) {
|
||||||
this.selectedResults.push(item);
|
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!', {
|
UIkit.notification(item.type + ' added in your basket!', {
|
||||||
status: 'success',
|
status: 'success',
|
||||||
timeout: 4000,
|
timeout: 4000,
|
||||||
|
@ -80,8 +58,8 @@ export class ClaimResultsComponent {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
remove(item: any) {
|
remove(item: ClaimEntity) {
|
||||||
const index: number = this.selectedResults.indexOf(item);
|
const index: number = this.selectedResults.findIndex(result => item.id === result.id);
|
||||||
if (index > -1) {
|
if (index > -1) {
|
||||||
this.selectedResults.splice(index, 1);
|
this.selectedResults.splice(index, 1);
|
||||||
if (this.selectedResults != null) {
|
if (this.selectedResults != null) {
|
||||||
|
|
|
@ -4,7 +4,7 @@
|
||||||
<breadcrumbs [breadcrumbs]="breadcrumbs"></breadcrumbs>
|
<breadcrumbs [breadcrumbs]="breadcrumbs"></breadcrumbs>
|
||||||
</div>
|
</div>
|
||||||
</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">
|
<div class="uk-section-xsmall">
|
||||||
<stepper>
|
<stepper>
|
||||||
<step *ngIf="!inlineEntity" [status]="stepStatus('source')" stepId="source" stepNumber="1"
|
<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 *ngIf="showOptions.show != 'claim'" class="uk-width-1-3">
|
||||||
<div id="basket" uk-sticky=" offset: 220; top:#basketStickTop; bottom: #basketStickBottom; media: @m"
|
<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;">
|
class="uk-card uk-card-default linkingBasket" style="z-index: 0!important;">
|
||||||
<div class="uk-card-body uk-padding-remove">
|
<div class="uk-card-body uk-padding-small">
|
||||||
<ul class="uk-padding-small uk-padding-remove-bottom" uk-tab>
|
<div class="uk-margin-right">
|
||||||
|
<ul class="uk-tab" uk-tab>
|
||||||
<li [class.uk-active]="showOptions.basketShowSources"
|
<li [class.uk-active]="showOptions.basketShowSources"
|
||||||
(click)="showOptions.basketswitchToSources()">
|
(click)="showOptions.basketswitchToSources()">
|
||||||
<a>
|
<a>
|
||||||
|
@ -84,9 +85,8 @@
|
||||||
</li>
|
</li>
|
||||||
</ul>
|
</ul>
|
||||||
<div *ngIf="showOptions.basketShowSources">
|
<div *ngIf="showOptions.basketShowSources">
|
||||||
<div class="uk-margin-remove-top uk-height-medium uk-overflow-auto ">
|
<div class="uk-height-medium uk-overflow-auto">
|
||||||
<div *ngIf="showOptions.show == 'source'" class=" uk-padding-small " style="min-height:
|
<div *ngIf="showOptions.show == 'source'" class="uk-padding-small uk-padding-remove-horizontal" style="min-height:17px;">
|
||||||
17px;">
|
|
||||||
<start-over *ngIf="showOptions.show == 'source' && sources.length> 0"
|
<start-over *ngIf="showOptions.show == 'source' && sources.length> 0"
|
||||||
[results]="sources"
|
[results]="sources"
|
||||||
[localStoragePrefix]="localStoragePrefix+'sources'"
|
[localStoragePrefix]="localStoragePrefix+'sources'"
|
||||||
|
@ -98,8 +98,7 @@
|
||||||
</bulk-claim>
|
</bulk-claim>
|
||||||
|
|
||||||
</div>
|
</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">
|
<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.
|
No Sources added yet. Start adding sources from the left panel. Or upload a DOI's CSV file.
|
||||||
</div>
|
</div>
|
||||||
|
@ -116,11 +115,10 @@
|
||||||
</claim-selected-results>
|
</claim-selected-results>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
<div *ngIf="showOptions.basketShowLinksTo">
|
<div *ngIf="showOptions.basketShowLinksTo">
|
||||||
<div class="uk-height-medium uk-overflow-auto">
|
<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"
|
<start-over *ngIf=" (results.length)> 0"
|
||||||
[results]="results" [localStoragePrefix]="localStoragePrefix+'results'"
|
[results]="results" [localStoragePrefix]="localStoragePrefix+'results'"
|
||||||
message="all results (projects, communities, research results)"
|
message="all results (projects, communities, research results)"
|
||||||
|
@ -129,7 +127,7 @@
|
||||||
[localStoragePrefix]="localStoragePrefix+'results'"
|
[localStoragePrefix]="localStoragePrefix+'results'"
|
||||||
[basketLimit]="basketLimit"></bulk-claim>
|
[basketLimit]="basketLimit"></bulk-claim>
|
||||||
</div>
|
</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 "
|
<div *ngIf="results.length >= basketLimit "
|
||||||
class="uk-alert uk-alert-warning uk-text-center">
|
class="uk-alert uk-alert-warning uk-text-center">
|
||||||
Basket reached the size limit. No more entities can be added.
|
Basket reached the size limit. No more entities can be added.
|
||||||
|
@ -144,6 +142,8 @@
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
<div *ngIf="showOptions.show == 'source'"
|
<div *ngIf="showOptions.show == 'source'"
|
||||||
class="uk-card-footer uk-flex uk-flex-center clickable"
|
class="uk-card-footer uk-flex uk-flex-center clickable"
|
||||||
[class.uk-tile-primary]="sources.length > 0"
|
[class.uk-tile-primary]="sources.length > 0"
|
||||||
|
@ -170,7 +170,6 @@
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
|
||||||
<!-- <helper position="right" styleName=" uk-width-1-5"></helper>-->
|
<!-- <helper position="right" styleName=" uk-width-1-5"></helper>-->
|
||||||
</div>
|
</div>
|
||||||
<div id="basketStickBottom"></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) {
|
public static createKeywordQuery(entityType: string, value: string, id, operatorId, countParams = 0, includes: boolean = true) {
|
||||||
let params = "";
|
let params = "";
|
||||||
let doisParams = "";
|
let doisParams = "";
|
||||||
if(!includes) {
|
|
||||||
params += "(*=* NOT ";
|
|
||||||
}
|
|
||||||
var DOIs: Identifier[] = Identifier.getIdentifiersFromString(value);
|
var DOIs: Identifier[] = Identifier.getIdentifiersFromString(value);
|
||||||
if ((entityType == 'publication' || entityType == 'dataset' || entityType == 'software' || entityType == 'other' || entityType == "result" || entityType == "dataprovider" || entityType == "service")) {
|
if ((entityType == 'publication' || entityType == 'dataset' || entityType == 'software' || entityType == 'other' || entityType == "result" || entityType == "dataprovider" || entityType == "service")) {
|
||||||
for (let identifier of DOIs) {
|
for (let identifier of DOIs) {
|
||||||
|
@ -990,20 +987,17 @@ export class NewSearchPageComponent implements OnInit, OnDestroy, OnChanges {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (doisParams.length > 0) {
|
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 {
|
} else {
|
||||||
//if it is PIDs but no doisquery produced, forced to use quotes as the query will fail due to special characters
|
//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,
|
params += this.createQuotedKeywordQuery(value, id, operatorId, countParams, true,
|
||||||
(DOIs.length > 0 && doisParams.length == 0));
|
(DOIs.length > 0 && doisParams.length == 0), includes);
|
||||||
}
|
|
||||||
if(!includes) {
|
|
||||||
params += ")";
|
|
||||||
}
|
}
|
||||||
return params;
|
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 params = "";
|
||||||
let countQuote = (fieldValue.match(/'/g) || []).length;
|
let countQuote = (fieldValue.match(/'/g) || []).length;
|
||||||
let countDoubleQuote = (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) : [];
|
quotedParts = (fieldValue) ? fieldValue.match(/(["'])(.*?)*?\1/g) : [];
|
||||||
}
|
}
|
||||||
params += (countParams == 0 ? "" : fieldOperator);
|
params += (countParams == 0 ? "" : fieldOperator);
|
||||||
|
if(!includes) {
|
||||||
|
params += "(*=* NOT ";
|
||||||
|
} else {
|
||||||
params += " (";
|
params += " (";
|
||||||
|
}
|
||||||
if (forceQuotted) {
|
if (forceQuotted) {
|
||||||
/** Remove double quotes **/
|
/** Remove double quotes **/
|
||||||
fieldValue = fieldValue.replace(/["]+/g, '');
|
fieldValue = fieldValue.replace(/["]+/g, '');
|
||||||
|
|
Loading…
Reference in New Issue