[develop | DONE | ADDED ] add again publicationyear in criteria fields, add different list of verbs for numeric values
This commit is contained in:
parent
f2e2edd1f2
commit
c1e306cff0
|
@ -12,9 +12,9 @@ export class CriteriaUtils {
|
||||||
{value: 'fos', label: 'Field of Science'},
|
{value: 'fos', label: 'Field of Science'},
|
||||||
{value: 'sdg', label: 'SDG'},
|
{value: 'sdg', label: 'SDG'},
|
||||||
{value: 'publisher', label: 'Publisher'},
|
{value: 'publisher', label: 'Publisher'},
|
||||||
/*{value: 'publicationyear', label: 'Publication Year'}*/
|
{value: 'publicationyear', label: 'Publication Year'}
|
||||||
]
|
]
|
||||||
|
public readonly numericFields: string[] = ['publicationyear'];
|
||||||
public readonly verbs: Option[] = [
|
public readonly verbs: Option[] = [
|
||||||
{value: 'contains', label: 'contains'},
|
{value: 'contains', label: 'contains'},
|
||||||
{value: 'equals', label: 'equals'},
|
{value: 'equals', label: 'equals'},
|
||||||
|
@ -22,6 +22,11 @@ export class CriteriaUtils {
|
||||||
{value: 'not_equals', label: 'not equals'},
|
{value: 'not_equals', label: 'not equals'},
|
||||||
{value: 'starts_with', label: 'starts with'}
|
{value: 'starts_with', label: 'starts with'}
|
||||||
]
|
]
|
||||||
|
public readonly verbsForNumbers: Option[] = [
|
||||||
|
{value: 'equals', label: 'equals'},
|
||||||
|
{value: 'lesser_than', label: 'lesser than'},
|
||||||
|
{value: 'greater_than', label: 'greater than'}
|
||||||
|
]
|
||||||
|
|
||||||
public getFiltersAsText(criteria: Criteria[]): string {
|
public getFiltersAsText(criteria: Criteria[]): string {
|
||||||
let text = criteria.slice(0, 3).map((criterion, index) => (index + 1) + ". " + criterion.constraint.map(constraint => {
|
let text = criteria.slice(0, 3).map((criterion, index) => (index + 1) + ". " + criterion.constraint.map(constraint => {
|
||||||
|
@ -30,7 +35,7 @@ export class CriteriaUtils {
|
||||||
if (!constraint.verb.includes('_caseinsensitive')) {
|
if (!constraint.verb.includes('_caseinsensitive')) {
|
||||||
matchCase = true;
|
matchCase = true;
|
||||||
}
|
}
|
||||||
let verb = this.verbs.find(verb => verb.value === constraint.verb.replace("_caseinsensitive", "")).label;
|
let verb = [...this.verbs,...this.verbsForNumbers].find(verb => verb.value === constraint.verb.replace("_caseinsensitive", "")).label;
|
||||||
let value = '"' + constraint.value + '"' + (matchCase ? " (Match case)" : "");
|
let value = '"' + constraint.value + '"' + (matchCase ? " (Match case)" : "");
|
||||||
return field + " " + verb + " " + value;
|
return field + " " + verb + " " + value;
|
||||||
}).join(" <b>and</b> "));
|
}).join(" <b>and</b> "));
|
||||||
|
|
|
@ -40,13 +40,17 @@
|
||||||
</button>
|
</button>
|
||||||
</div>
|
</div>
|
||||||
<div class="uk-width-1-1" input type="select" inputClass="border-bottom" [placeholder]="{static: true, label: 'Choose a field'}"
|
<div class="uk-width-1-1" input type="select" inputClass="border-bottom" [placeholder]="{static: true, label: 'Choose a field'}"
|
||||||
[options]="criteriaUtils.fields" [formInput]="constraint.get('field')">
|
[options]="criteriaUtils.fields" [formInput]="constraint.get('field')" (valueChange)="resetFieldWhenValueChange(constraint)">
|
||||||
<label class="uk-text-uppercase uk-text-bold uk-width-1-3 uk-text-truncate">Field:</label>
|
<label class="uk-text-uppercase uk-text-bold uk-width-1-3 uk-text-truncate">Field:</label>
|
||||||
</div>
|
</div>
|
||||||
<div class="uk-width-1-1" input type="select" inputClass="border-bottom"
|
<div *ngIf="criteriaUtils.numericFields.indexOf(constraint.get('field').value) == -1" class="uk-width-1-1" input type="select" inputClass="border-bottom"
|
||||||
[options]="criteriaUtils.verbs" [formInput]="constraint.get('verb')">
|
[options]="criteriaUtils.verbs" [formInput]="constraint.get('verb')">
|
||||||
<label class="uk-text-uppercase uk-text-bold uk-width-1-3 uk-text-truncate">Operator:</label>
|
<label class="uk-text-uppercase uk-text-bold uk-width-1-3 uk-text-truncate">Operator:</label>
|
||||||
</div>
|
</div>
|
||||||
|
<div *ngIf="criteriaUtils.numericFields.indexOf(constraint.get('field').value) != -1" 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 class="uk-width-1-1" input [placeholder]="{static: true, label: 'Type a keyword'}"
|
<div class="uk-width-1-1" input [placeholder]="{static: true, label: 'Type a keyword'}"
|
||||||
[formInput]="constraint.get('value')">
|
[formInput]="constraint.get('value')">
|
||||||
<label class="uk-text-uppercase uk-text-bold uk-width-1-3 uk-text-truncate">Term:</label>
|
<label class="uk-text-uppercase uk-text-bold uk-width-1-3 uk-text-truncate">Term:</label>
|
||||||
|
@ -69,8 +73,10 @@
|
||||||
<div class="uk-flex uk-flex-middle uk-grid" uk-grid>
|
<div class="uk-flex uk-flex-middle uk-grid" uk-grid>
|
||||||
<div class="uk-width-1-4" input type="select" inputClass="border-bottom" [placeholder]="{static: true, label: 'Choose a field'}"
|
<div class="uk-width-1-4" input type="select" inputClass="border-bottom" [placeholder]="{static: true, label: 'Choose a field'}"
|
||||||
[options]="criteriaUtils.fields" [formInput]="constraint.get('field')"></div>
|
[options]="criteriaUtils.fields" [formInput]="constraint.get('field')"></div>
|
||||||
<div class="uk-width-1-4" input type="select" inputClass="border-bottom"
|
<div *ngIf="criteriaUtils.numericFields.indexOf(constraint.get('field').value) == -1" class="uk-width-1-4" input type="select" inputClass="border-bottom"
|
||||||
[options]="criteriaUtils.verbs" [formInput]="constraint.get('verb')"></div>
|
[options]="criteriaUtils.verbs" [formInput]="constraint.get('verb')"></div>
|
||||||
|
<div *ngIf="criteriaUtils.numericFields.indexOf(constraint.get('field').value) != -1" class="uk-width-1-4" input type="select" inputClass="border-bottom"
|
||||||
|
[options]="criteriaUtils.verbsForNumbers" [formInput]="constraint.get('verb')"></div>
|
||||||
<div *ngIf="constraint.get('field').value !== 'fos' && constraint.get('field').value !== 'sdg'" class="uk-width-1-4" inputClass="flat small" input [placeholder]="{static: true, label: 'Type a keyword'}"
|
<div *ngIf="constraint.get('field').value !== 'fos' && constraint.get('field').value !== 'sdg'" class="uk-width-1-4" inputClass="flat small" input [placeholder]="{static: true, label: 'Type a keyword'}"
|
||||||
[formInput]="constraint.get('value')"></div>
|
[formInput]="constraint.get('value')"></div>
|
||||||
<div *ngIf="constraint.get('field').value === 'fos'" class="uk-width-1-4" inputClass="flat small" input [placeholder]="{static: true, label: 'Choose a FoS'}"
|
<div *ngIf="constraint.get('field').value === 'fos'" class="uk-width-1-4" inputClass="flat small" input [placeholder]="{static: true, label: 'Choose a FoS'}"
|
||||||
|
|
|
@ -225,4 +225,14 @@ export class CriteriaComponent implements OnInit, OnChanges, AfterViewInit, OnDe
|
||||||
})
|
})
|
||||||
return selectionCriteria;
|
return selectionCriteria;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
resetFieldWhenValueChange(constraint){
|
||||||
|
// if field not numeric, but verb is numeric clear the verb
|
||||||
|
if(this.criteriaUtils.numericFields.indexOf(constraint.get('field').value) == -1 && this.criteriaUtils.verbs.indexOf(constraint.get('verb').value)){
|
||||||
|
constraint.get('verb').setValue(this.criteriaUtils.verbs[0].value);
|
||||||
|
}
|
||||||
|
if(this.criteriaUtils.numericFields.indexOf(constraint.get('field').value) != -1 && this.criteriaUtils.numericFields.indexOf(constraint.get('verb').value)){
|
||||||
|
constraint.get('verb').setValue(this.criteriaUtils.verbsForNumbers[0].value);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue