Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
refactor(project landing page): update metadata typings (DSP-1393) (#407
- Loading branch information
Snehal Kumbhar
committed
Mar 4, 2021
1 parent
6de83b8
commit b4f101b
Showing
10 changed files
with
111 additions
and
98 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
54 changes: 54 additions & 0 deletions
54
src/app/project/board/url-template/url-template.component.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
import { Component, Input, OnInit } from '@angular/core'; | ||
import { IUrl } from '@dasch-swiss/dsp-js'; | ||
|
||
@Component({ | ||
selector: 'app-url-template', | ||
template: ` | ||
<div *ngIf="urls"> | ||
<div *ngIf="templateType === 'string'"> | ||
<p *ngFor="let str of urls" class="remove-top-margin"> {{ str }} </p> | ||
</div> | ||
<div *ngIf="templateType === 'IUrl'"> | ||
<div class="metadata-property"> | ||
<div *ngIf="displayLabel" class="property-label display-inline-block"> | ||
{{ label }}: | ||
</div> | ||
<div [ngClass]="{'display-inline-block add-left-margin': displayLabel}"> | ||
<span *ngFor="let entry of urls" class="comma"> | ||
<a *ngIf="entry.name" href="{{ entry.url }}" target="_blank"> {{ entry.name }} </a> | ||
<a *ngIf="!entry.name" href="{{ entry.url }}" target="_blank"> {{ entry.url }} </a> | ||
</span> | ||
</div> | ||
</div> | ||
</div> | ||
</div> | ||
` | ||
}) | ||
export class UrlTemplateComponent implements OnInit { | ||
@Input() urls: IUrl | IUrl[] | string[]; | ||
|
||
@Input() label = 'URL(s)'; | ||
|
||
@Input() displayLabel = false; | ||
|
||
templateType: string; | ||
|
||
ngOnInit() { | ||
if (!(this.urls instanceof Array)) { | ||
this.urls = [this.urls]; | ||
} | ||
|
||
this.templateType = this.getTemplateType(this.urls[0]); | ||
} | ||
|
||
/** | ||
* determine if the object is of type string or IUrl | ||
* @param obj string | IUrl | ||
*/ | ||
getTemplateType (obj: IUrl | string): string { | ||
if (typeof obj === 'string') { | ||
return 'string'; | ||
} | ||
return 'IUrl'; | ||
} | ||
} |