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,106 +68,105 @@
|
||||||
<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">
|
||||||
<li [class.uk-active]="showOptions.basketShowSources"
|
<ul class="uk-tab" uk-tab>
|
||||||
(click)="showOptions.basketswitchToSources()">
|
<li [class.uk-active]="showOptions.basketShowSources"
|
||||||
<a>
|
(click)="showOptions.basketswitchToSources()">
|
||||||
Sources to link ({{(sources.length + (inlineEntity ? 1 : 0)) |number}})
|
<a>
|
||||||
</a>
|
Sources to link ({{(sources.length + (inlineEntity ? 1 : 0)) |number}})
|
||||||
</li>
|
</a>
|
||||||
<li [class.uk-disabled]="sources.length == 0 && !inlineEntity"
|
</li>
|
||||||
[class.uk-active]="showOptions.basketShowLinksTo">
|
<li [class.uk-disabled]="sources.length == 0 && !inlineEntity"
|
||||||
<a (click)="showOptions.basketswitchToLinkTo()">Link to <span
|
[class.uk-active]="showOptions.basketShowLinksTo">
|
||||||
*ngIf="results.length> 0">({{(results.length) | number}})</span>
|
<a (click)="showOptions.basketswitchToLinkTo()">Link to <span
|
||||||
</a>
|
*ngIf="results.length> 0">({{(results.length) | number}})</span>
|
||||||
</li>
|
</a>
|
||||||
</ul>
|
</li>
|
||||||
<div *ngIf="showOptions.basketShowSources">
|
</ul>
|
||||||
<div class="uk-margin-remove-top uk-height-medium uk-overflow-auto ">
|
<div *ngIf="showOptions.basketShowSources">
|
||||||
<div *ngIf="showOptions.show == 'source'" class=" uk-padding-small " style="min-height:
|
<div class="uk-height-medium uk-overflow-auto">
|
||||||
17px;">
|
<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"
|
<start-over *ngIf="showOptions.show == 'source' && sources.length> 0"
|
||||||
[results]="sources"
|
[results]="sources"
|
||||||
[localStoragePrefix]="localStoragePrefix+'sources'"
|
[localStoragePrefix]="localStoragePrefix+'sources'"
|
||||||
message="all sources" class="uk-float-right"></start-over>
|
message="all sources" class="uk-float-right"></start-over>
|
||||||
<bulk-claim *ngIf="showOptions.show == 'source'" [results]="sources"
|
<bulk-claim *ngIf="showOptions.show == 'source'" [results]="sources"
|
||||||
[properties]=properties
|
[properties]=properties
|
||||||
[localStoragePrefix]="localStoragePrefix+'sources'" [basketLimit]="basketLimit"
|
[localStoragePrefix]="localStoragePrefix+'sources'" [basketLimit]="basketLimit"
|
||||||
>
|
>
|
||||||
</bulk-claim>
|
</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>
|
||||||
<div *ngIf="sources.length >= basketLimit " class="uk-alert uk-alert-warning uk-text-center">
|
<div class="uk-padding-small uk-padding-remove-horizontal">
|
||||||
Basket reached the size limit. No more sources can be added.
|
<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>
|
</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>
|
||||||
|
<div *ngIf="showOptions.basketShowLinksTo">
|
||||||
</div>
|
<div class="uk-height-medium uk-overflow-auto">
|
||||||
<div *ngIf="showOptions.basketShowLinksTo">
|
<div *ngIf="(results.length)> 0 || showOptions.show=='result'" class="uk-padding-small uk-padding-remove-horizontal" style="min-height: 17px;">
|
||||||
<div class="uk-height-medium uk-overflow-auto">
|
<start-over *ngIf=" (results.length)> 0"
|
||||||
<div *ngIf="(results.length)> 0 || showOptions.show=='result'" class="uk-padding-small" style="min-height: 17px;">
|
[results]="results" [localStoragePrefix]="localStoragePrefix+'results'"
|
||||||
<start-over *ngIf=" (results.length)> 0"
|
message="all results (projects, communities, research results)"
|
||||||
[results]="results" [localStoragePrefix]="localStoragePrefix+'results'"
|
class="uk-float-right"></start-over>
|
||||||
message="all results (projects, communities, research results)"
|
<bulk-claim *ngIf="showOptions.show=='result'" [results]="results" [properties]=properties
|
||||||
class="uk-float-right"></start-over>
|
[localStoragePrefix]="localStoragePrefix+'results'"
|
||||||
<bulk-claim *ngIf="showOptions.show=='result'" [results]="results" [properties]=properties
|
[basketLimit]="basketLimit"></bulk-claim>
|
||||||
[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>
|
</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>
|
||||||
</div>
|
</div>
|
||||||
<div *ngIf="showOptions.show == 'source'"
|
</div>
|
||||||
class="uk-card-footer uk-flex uk-flex-center clickable"
|
<div *ngIf="showOptions.show == 'source'"
|
||||||
[class.uk-tile-primary]="sources.length > 0"
|
class="uk-card-footer uk-flex uk-flex-center clickable"
|
||||||
[class.uk-background-muted]="sources.length == 0"
|
[class.uk-tile-primary]="sources.length > 0"
|
||||||
[class.uk-disabled]="sources.length == 0"
|
[class.uk-background-muted]="sources.length == 0"
|
||||||
(click)="stepHasChanged('target')">
|
[class.uk-disabled]="sources.length == 0"
|
||||||
<button class="uk-flex uk-flex-middle uk-button uk-button-text"
|
(click)="stepHasChanged('target')">
|
||||||
[class.uk-disabled]="sources.length == 0" [disabled]="sources.length == 0">
|
<button class="uk-flex uk-flex-middle uk-button uk-button-text"
|
||||||
<icon name="link" visuallyHidden="link" [flex]="true"></icon>
|
[class.uk-disabled]="sources.length == 0" [disabled]="sources.length == 0">
|
||||||
<div class="uk-width-expand uk-margin-small-left">STEP 2 - LINK SOURCES TO ENTITIES</div>
|
<icon name="link" visuallyHidden="link" [flex]="true"></icon>
|
||||||
</button>
|
<div class="uk-width-expand uk-margin-small-left">STEP 2 - LINK SOURCES TO ENTITIES</div>
|
||||||
|
</button>
|
||||||
|
|
||||||
</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]="results.length > 0"
|
[class.uk-tile-primary]="results.length > 0"
|
||||||
[class.uk-background-muted]="results.length == 0"
|
[class.uk-background-muted]="results.length == 0"
|
||||||
[class.uk-disabled]="results.length == 0" (click)="stepHasChanged('claim')">
|
[class.uk-disabled]="results.length == 0" (click)="stepHasChanged('claim')">
|
||||||
<button class="uk-flex uk-flex-middle uk-button uk-button-text"
|
<button class="uk-flex uk-flex-middle uk-button uk-button-text"
|
||||||
[class.uk-disabled]="results.length == 0" [disabled]="results.length == 0">
|
[class.uk-disabled]="results.length == 0" [disabled]="results.length == 0">
|
||||||
<icon *ngIf="inlineEntity" name="link" visuallyHidden="link" [flex]="true"></icon>
|
<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>
|
<div class="uk-width-expand uk-margin-small-left">STEP {{inlineEntity ? '2' : '3'}} - FINALISE AND FINISH</div>
|
||||||
</button>
|
</button>
|
||||||
</div>
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</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) {
|
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);
|
||||||
params += " (";
|
if(!includes) {
|
||||||
|
params += "(*=* NOT ";
|
||||||
|
} else {
|
||||||
|
params += " (";
|
||||||
|
}
|
||||||
if (forceQuotted) {
|
if (forceQuotted) {
|
||||||
/** Remove double quotes **/
|
/** Remove double quotes **/
|
||||||
fieldValue = fieldValue.replace(/["]+/g, '');
|
fieldValue = fieldValue.replace(/["]+/g, '');
|
||||||
|
|
Loading…
Reference in New Issue