Compare commits

..

4 Commits

5 changed files with 29 additions and 8 deletions

View File

@ -14,7 +14,7 @@ export class CriteriaUtils {
{value: 'publisher', label: 'Publisher'},
{value: 'publicationyear', label: 'Publication Year'}
]
public readonly numericFields: string[] = ['publicationyear'];
public readonly verbs: Option[] = [
{value: 'contains', label: 'contains'},
{value: 'equals', label: 'equals'},
@ -22,6 +22,11 @@ export class CriteriaUtils {
{value: 'not_equals', label: 'not equals'},
{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 {
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')) {
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)" : "");
return field + " " + verb + " " + value;
}).join(" <b>and</b> "));

View File

@ -40,13 +40,17 @@
</button>
</div>
<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>
</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')">
<label class="uk-text-uppercase uk-text-bold uk-width-1-3 uk-text-truncate">Operator:</label>
</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'}"
[formInput]="constraint.get('value')">
<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-width-1-4" input type="select" inputClass="border-bottom" [placeholder]="{static: true, label: 'Choose a field'}"
[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>
<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'}"
[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'}"

View File

@ -225,4 +225,14 @@ export class CriteriaComponent implements OnInit, OnChanges, AfterViewInit, OnDe
})
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);
}
}
}

View File

@ -42,7 +42,7 @@ export class UsersManagersComponent implements OnInit {
this.link = this.getURL(this.community.communityId);
this.message = 'A manager has the right to access the administration part of Research Community Dashboard, ' +
'where he is able to customize and manage the content, invite other users as managers or members.';
if(community.status === "hidden") {
if(community.isPrivate()) {
this.inviteDisableMessage = "Community's status is Hidden and invitation to manage the Research community dashboard is disabled. Update the community status to enable invitations."
}
this.loading = false;

View File

@ -46,8 +46,8 @@ export class UsersSubscribersComponent implements OnInit {
this.link = this.getURL(this.community.communityId);
this.message = 'A member can access the community dashboard and link research results with projects, ' +
'communities and other research projects.';
if(community.status !== "all") {
this.inviteDisableMessage = "Community's status is " + (community.status === 'manager'?'Visible to managers':'Hidden') + " and invitation to join the Research community dashboard is disabled. Update the community status to enable invitations."
if(!community.isPublic()) {
this.inviteDisableMessage = "Community's status is " + (community.isRestricted()?'Visible to managers':'Hidden') + " and invitation to join the Research community dashboard is disabled. Update the community status to enable invitations."
}
this.loading = false;
}