60168: Browse-by startsWith text component

This commit is contained in:
Kristof De Langhe
2019-02-20 08:54:51 +01:00
parent 0da38dbd52
commit 16f448021b
5 changed files with 32 additions and 3 deletions

View File

@@ -285,6 +285,7 @@
"jump": "Jump to a point in the index:",
"choose_year": "(Choose year)",
"type_year": "Or type in a year:",
"type_text": "Or enter first few letters:",
"submit": "Go"
},
"metadata": {

View File

@@ -123,7 +123,11 @@ export class BrowseByMetadataPageComponent implements OnInit {
}
this.updateParent(params.scope);
}));
this.startsWithOptions = [];
this.updateStartsWithTextOptions();
}
updateStartsWithTextOptions() {
this.startsWithOptions = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'.split('');
}
/**

View File

@@ -45,7 +45,7 @@ export class BrowseByTitlePageComponent extends BrowseByMetadataPageComponent {
this.updatePageWithItems(browseParamsToOptions(params, this.paginationConfig, this.sortConfig, this.metadata), undefined);
this.updateParent(params.scope)
}));
this.startsWithOptions = [];
this.updateStartsWithTextOptions();
}
ngOnDestroy(): void {

View File

@@ -39,6 +39,14 @@ export class BrowseByStartsWithAbstractComponent implements OnInit, OnDestroy {
});
}
getStartsWithAsText() {
if (hasValue(this.startsWith)) {
return this.startsWith;
} else {
return '';
}
}
/**
* Get startsWith as a number;
*/

View File

@@ -1 +1,17 @@
<!-- To be implemented -->
<form class="w-100" [formGroup]="formData" (ngSubmit)="submitForm(formData.value)">
<div class="row">
<div class="col-12">
<ul class="list-inline">
<li class="list-inline-item" *ngFor="let option of startsWithOptions">
<a [routerLink]="[]" [queryParams]="{startsWith: option}" queryParamsHandling="merge">{{option}}</a>
</li>
</ul>
</div>
<div class="form-group input-group col-6">
<input class="form-control" placeholder="{{'browse.startsWith.type_text' | translate}}" type="text" name="startsWith" formControlName="startsWith" [value]="getStartsWithAsText()" />
<span class="input-group-append">
<button class="btn btn-secondary" type="submit">{{'browse.startsWith.submit' | translate}}</button>
</span>
</div>
</div>
</form>