Skip to content

Commit

Permalink
ufal/fe-remove-grid-option-in-the-search-page (#386)
Browse files Browse the repository at this point in the history
* Removed Grid view from the initial viewModeList

* Fixed failing test on clarin all licenses page.
  • Loading branch information
milanmajchrak authored Oct 17, 2023
1 parent 6d9a0c7 commit 498720e
Show file tree
Hide file tree
Showing 5 changed files with 25 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,27 +3,27 @@
<h5 class="card-header">{{ 'clarin.license.all-page.title' | translate }}</h5>
<ds-loading *ngIf="isLoading" class="text-center"></ds-loading>
<div class="card-body" *ngFor="let clarinLicense of (licensesRD$ | async)">
<h6 class="card-header border-bottom-0 license-card-border"><a [href]="clarinLicense.definition">{{ clarinLicense.name }}</a></h6>
<h6 class="card-header border-bottom-0 license-card-border"><a [href]="clarinLicense?.definition">{{ clarinLicense?.name }}</a></h6>
<div class="card-body rounded-bottom license-card-border">
<div>
<div><b>{{'clarin.license.all-page.source' | translate}}</b></div>
<div><a [href]="clarinLicense.definition">{{ clarinLicense.definition }}</a></div>
<div><a [href]="clarinLicense?.definition">{{ clarinLicense?.definition }}</a></div>
</div>
<div>
<div><b>{{'clarin.license.all-page.labels' | translate}}</b></div>
<span [ngClass]="'px-1 d-inline label label-license' + ' label-' + clarinLicense.clarinLicenseLabel.label + ' rounded text-white'">
{{clarinLicense.clarinLicenseLabel.title}}
<span [ngClass]="'px-1 d-inline label label-license' + ' label-' + clarinLicense?.clarinLicenseLabel?.label + ' rounded text-white'">
{{clarinLicense?.clarinLicenseLabel?.title}}
</span>
<span *ngFor="let clarinLicenseLabel of clarinLicense.extendedClarinLicenseLabels"
<span *ngFor="let clarinLicenseLabel of clarinLicense?.extendedClarinLicenseLabels"
class="px-1 label label-default rounded text-white ml-1">
{{clarinLicenseLabel.title}}
{{clarinLicenseLabel?.title}}
</span>
</div>
<div>
<div><b>{{'clarin.license.all-page.extra-information' | translate}}</b></div>
<span *ngIf="clarinLicense.requiredInfo == null">{{'clarin.license.all-page.extra-information.default' | translate}}
<span *ngIf="clarinLicense?.requiredInfo == null">{{'clarin.license.all-page.extra-information.default' | translate}}
</span>
<span *ngFor="let requiredInformation of clarinLicense.requiredInfo"
<span *ngFor="let requiredInformation of getRequiredInfo(clarinLicense)"
class="px-1 label label-default rounded text-white mr-1">
{{requiredInformation?.value}}
</span>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ import { ClarinLicense } from '../../core/shared/clarin/clarin-license.model';
import { ClarinLicenseDataService } from '../../core/data/clarin/clarin-license-data.service';
import { getFirstSucceededRemoteListPayload } from '../../core/shared/operators';
import { FindListOptions } from '../../core/data/find-list-options.model';
import { ClarinLicenseRequiredInfo } from '../../core/shared/clarin/clarin-license.resource-type';
import { ClarinLicenseRequiredInfoSerializer } from '../../core/shared/clarin/clarin-license-required-info-serializer';

@Component({
selector: 'ds-clarin-all-licenses-page',
Expand Down Expand Up @@ -68,4 +70,16 @@ export class ClarinAllLicensesPageComponent implements OnInit {
return pubLicenseArray.concat(acaResLicenseArray);
}

/**
* ClarinLicense has RequiredInfo stored as string in the database, convert this string value into
* list of ClarinLicenseRequiredInfo objects.
*/
public getRequiredInfo(clarinLicense: ClarinLicense): ClarinLicenseRequiredInfo[] {
let requiredInfo = clarinLicense.requiredInfo;
if (typeof requiredInfo === 'string') {
requiredInfo = ClarinLicenseRequiredInfoSerializer.Deserialize(requiredInfo);
}
return requiredInfo;
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ export const ClarinLicenseRequiredInfoSerializer = {
return requiredInfoString;
},

Deserialize(requiredInfoString: string): string[] {
Deserialize(requiredInfoString: string): ClarinLicenseRequiredInfo[] {
const requiredInfoArray = requiredInfoString.split(',');
if (isEmpty(requiredInfoArray)) {
return [];
Expand Down
2 changes: 1 addition & 1 deletion src/app/core/shared/clarin/clarin-license.model.ts
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ export class ClarinLicense extends ListableObject implements HALResource {
* The requiredInfo of this Clarin License object
*/
@autoserializeAs(ClarinLicenseRequiredInfoSerializer)
requiredInfo: string;
requiredInfo: any;

/**
* The non extended clarinLicenseLabel of this Clarin License object. Clarin License could have only one
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ export class ViewModeSwitchComponent implements OnInit, OnDestroy {
*/
ngOnInit(): void {
if (isEmpty(this.viewModeList)) {
this.viewModeList = [ViewMode.ListElement, ViewMode.GridElement];
this.viewModeList = [ViewMode.ListElement];
}

this.sub = this.searchService.getViewMode().pipe(
Expand Down

0 comments on commit 498720e

Please sign in to comment.