Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ufal/fe-remove-grid-option-in-the-search-page #386

Merged
merged 2 commits into from
Oct 17, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading