Skip to content

Commit

Permalink
Graphical representation display of record life cycle
Browse files Browse the repository at this point in the history
  • Loading branch information
Shay Hadar authored and Shay Hadar committed Dec 16, 2021
1 parent 4aa852c commit 7cf27a2
Show file tree
Hide file tree
Showing 5 changed files with 58 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,20 @@
<div class="full-view-line-field-label" *ngIf="field.hasLabel()">
{{field.getLabel()}}
</div>
<a *ngIf="field.isLinkable() else noLink" (click)="onFullViewLink(field.getLink(), field.getContent())">
{{field.getContent()}}
</a>
<ng-template #noLink>
{{field.getContent()}}
</ng-template>

<div [ngSwitch]="field.getLinkState()">
<div *ngSwitchCase="linkState.NoLink">
{{field.getContent()}}
</div>
<a *ngSwitchCase="linkState.InternalLink" (click)="onFullViewLink(field.getLink(), field.getContent())">
{{field.getContent()}}
</a>
<a *ngSwitchCase="linkState.ExternalLink" [href]="field.getExternalLink()" target="_blank">
{{field.getContent()}}
</a>
<!-- <some-element *ngSwitchDefault>...</some-element> -->
</div>

</div>
</div>
</div>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { Component, Input, Output, EventEmitter } from '@angular/core';
import { SearchType } from '../../user-controls/search-form/search-form-utils';
import { LinkState } from '../results-types/results-common';


@Component({
Expand All @@ -13,6 +14,7 @@ export class FullviewDisplayComponent {
@Input() resultFullDisplay;
@Output() onFullViewLinkSelected = new EventEmitter<FullViewLink>();

linkState: typeof LinkState = LinkState;

constructor() { }

Expand Down
35 changes: 32 additions & 3 deletions cloudapp/src/app/catalog/results-types/results-common.ts
Original file line number Diff line number Diff line change
Expand Up @@ -176,19 +176,26 @@ export class ViewLine {
}
}

export enum LinkState {
NoLink,
InternalLink,
ExternalLink
}

export class ViewField {

private label: string;
private content: string;
private link: string;
private onlyLabel: boolean;

private externalLink: string;

constructor(ViewFieldBuilder: ViewFieldBuilder) {
this.label = ViewFieldBuilder.getLabel();
this.content = ViewFieldBuilder.getContent();
this.link = ViewFieldBuilder.getLink();
this.onlyLabel = ViewFieldBuilder.isOnlyLabel()? true : false;
this.externalLink = ViewFieldBuilder.getExternalLink();
}

getLabel() {
Expand All @@ -207,17 +214,30 @@ export class ViewField {
return this.link;
}

getExternalLink() {
return this.externalLink;
}

hasContent() {
return (this.content != "" && this.content != undefined);
}

isLinkable() {
isInternalLink() {
return (this.link != null);
}

isOnlyLabel() {
return this.onlyLabel;
}

getLinkState() : LinkState {

if(this.link != null)
return LinkState.InternalLink;
if(this.externalLink != null)
return LinkState.ExternalLink;
return LinkState.NoLink;
}
}

export class ViewFieldBuilder {
Expand All @@ -226,10 +246,10 @@ export class ViewFieldBuilder {
private _content: string;
private _link: string;
private _onlyLabel: boolean = true;
private _externalLink: string;

constructor() { }


getLabel() {
return this._label;
}
Expand Down Expand Up @@ -262,6 +282,15 @@ export class ViewFieldBuilder {
return this;
}

externalLink(externalLink: string) {
this._externalLink = externalLink;
return this;
}

getExternalLink() {
return this._externalLink;
}

build() {
return new ViewField(this);
}
Expand Down
10 changes: 9 additions & 1 deletion cloudapp/src/app/catalog/results-types/serials.ts
Original file line number Diff line number Diff line change
Expand Up @@ -296,8 +296,16 @@ export class SerialFullDisplay extends IDisplayLines {
fieldsArray = new Array<ViewField>();
fieldsArray.push(new ViewFieldBuilder().content(this.record.PRICE).build());
this.addLine(new ViewFieldBuilder().label("PRICE").build(), fieldsArray);

// FID external link
let externalLink = "https://mokuren.nii.ac.jp/cgi-bin/map/map-frame.cgi?encode=UTF-8";
externalLink += "&ncid=" + this.record.ID;
externalLink += "&fid=" + this.record.FID;
externalLink += "&cgi=http://ci.nii.ac.jp/ncid/";

fieldsArray = new Array<ViewField>();
fieldsArray.push(new ViewFieldBuilder().content(this.record.FID).build());
fieldsArray.push(new ViewFieldBuilder().content(this.record.FID).externalLink(externalLink).build());

this.addLine(new ViewFieldBuilder().label("FID").build(), fieldsArray);
this.record.BHNT?.forEach(bhnt=>{
fieldsArray = new Array<ViewField>();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
<div class="card-content-field" *ngFor="let field of line.getContent()">
<div class="card-content-field-label" *ngIf="field.hasLabel()"
[innerHTML]="field.getLabel() | translate"></div>
<a class="card-content-field-content" *ngIf="field.isLinkable() else noLink"
<a class="card-content-field-content" *ngIf="field.isInternalLink() else noLink"
(click)="onTitleClick(recordIndex)"
[innerHTML]="field.getContent() | translate"></a>
<ng-template #noLink>
Expand Down

0 comments on commit 7cf27a2

Please sign in to comment.