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

feat(project landing page): add copy to clipboard functionality (DSP-1248) #368

Merged
merged 7 commits into from Jan 21, 2021
Merged
Show file tree
Hide file tree
Changes from 6 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 0 additions & 1 deletion package.json
Expand Up @@ -47,7 +47,6 @@
"json2typescript": "^1.0.6",
"jsonld": "^1.1.0",
"moment": "^2.27.0",
"ngx-clipboard": "^14.0.1",
"ngx-color-picker": "^10.0.1",
"openseadragon": "^2.4.0",
"rxjs": "~6.5.3",
Expand Down
2 changes: 1 addition & 1 deletion src/app/app.module.ts
@@ -1,3 +1,4 @@
import { ClipboardModule } from '@angular/cdk/clipboard';
import { CommonModule } from '@angular/common';
import { HttpClient, HttpClientModule } from '@angular/common/http';
import { APP_INITIALIZER, NgModule } from '@angular/core';
Expand Down Expand Up @@ -83,7 +84,6 @@ import { DatasetTabViewComponent } from './project/board/dataset-tab-view/datase
import { AttributionTabViewComponent } from './project/board/attribution-tab-view/attribution-tab-view.component';
import { TermsTabViewComponent } from './project/board/terms-tab-view/terms-tab-view.component';
import { ContactsTabViewComponent } from './project/board/contacts-tab-view/contacts-tab-view.component';
import { ClipboardModule } from 'ngx-clipboard';

import { AngularSplitModule } from 'angular-split';
import { PersonTemplateComponent } from './project/board/person-template/person-template.component';
Expand Down
32 changes: 22 additions & 10 deletions src/app/project/board/board.component.html
Expand Up @@ -125,31 +125,43 @@ <h3>Dataset(s)</h3>
</div>

<div class="metadata-box">
<h3 class="display-inline-block">Cite as</h3>
<div class="copy-to-clipboard">
<button title="Copy to clipboard" (click)="copyHowToCiteToClipboard();">
<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24">
<path d="M16 1H4c-1.1 0-2 .9-2 2v14h2V3h12V1zm3 4H8c-1.1 0-2 .9-2 2v14c0 1.1.9 2 2 2h11c1.1 0 2-.9 2-2V7c0-1.1-.9-2-2-2zm0 16H8V7h11v14z"/>
</svg>
<div>
<h3 class='display-inline-block'>Cite as</h3>
<button mat-button class="btn-copy-to-clipboard" [cdkCopyToClipboard]="selectedDataset.howToCite"
matTooltip="Copy citation url" matTooltipPosition="below" (click)="copyToClipboard('Citation link')">
<mat-icon class="icon-arkurl">content_copy</mat-icon>
</button>
</div>
<div class="sidenav-prop-text">
<p [innerHTML]="selectedDataset.howToCite"></p>
</div>
</div>

<div class="metadata-box">
<div class="sidenav-properties-container">
<div class="property">
<div class="property-label">
Persistent identifier
<div>
<div class="property-label display-inline-block">
Persistent identifier
</div>
<button mat-button class="btn-copy-to-clipboard" [cdkCopyToClipboard]="selectedDataset.project.id"
matTooltip="Copy persistent identifier" matTooltipPosition="below" (click)="copyToClipboard('Persistent identifier')">
<mat-icon class="icon-arkurl">content_copy</mat-icon>
</button>
</div>
<div class="sidenav-prop-text property-value">
<a href="{{ selectedDataset.project.id }}" target="_blank"> {{ selectedDataset.project.id }} </a>
</div>
</div>
<div class="property">
<div class="property-label">
License
<div>
<div class="property-label display-inline-block">
License
</div>
<button mat-button class="btn-copy-to-clipboard" [cdkCopyToClipboard]="selectedDataset.license.value"
matTooltip="Copy license" matTooltipPosition="below" (click)="copyToClipboard('License')">
<mat-icon class="icon-arkurl">content_copy</mat-icon>
</button>
</div>
<div class="sidenav-prop-text property-value">
<a href="{{ selectedDataset.license.value }}" target="_blank"> {{ selectedDataset.license.value }} </a>
Expand Down
13 changes: 4 additions & 9 deletions src/app/project/board/board.component.scss
Expand Up @@ -87,14 +87,9 @@ section {
display: inline-block;
}

.copy-to-clipboard {
display: inline-block;
float: right;

button {
cursor: pointer;
border: none;
}
.btn-copy-to-clipboard {
padding: 0px 10px;
min-width: auto;
}

.mat-radio-button {
Expand Down Expand Up @@ -155,7 +150,7 @@ section {
}

.property:not(:last-child) {
margin-bottom: 13px;
margin-bottom: 20px;
}
}

Expand Down
15 changes: 11 additions & 4 deletions src/app/project/board/board.component.ts
@@ -1,6 +1,7 @@
import { Component, Inject, OnInit } from '@angular/core';
import { MatDialog, MatDialogConfig } from '@angular/material/dialog';
import { MatRadioChange } from '@angular/material/radio';
import { MatSnackBar } from '@angular/material/snack-bar';
import { Title } from '@angular/platform-browser';
import { ActivatedRoute, Params } from '@angular/router';
import {
Expand All @@ -11,7 +12,6 @@ import {
ReadProject
} from '@dasch-swiss/dsp-js';
import { DspApiConnectionToken, Session, SessionService } from '@dasch-swiss/dsp-ui';
import { ClipboardService } from 'ngx-clipboard';
import { DialogComponent } from 'src/app/main/dialog/dialog.component';
import { ErrorHandlerService } from 'src/app/main/error/error-handler.service';
import { CacheService } from '../../main/cache/cache.service';
Expand Down Expand Up @@ -71,7 +71,7 @@ export class BoardComponent implements OnInit {
private _dialog: MatDialog,
private _route: ActivatedRoute,
private _titleService: Title,
private _clipboardService: ClipboardService
private _snackBar: MatSnackBar
) {
// get the shortcode of the current project
this._route.parent.paramMap.subscribe((params: Params) => {
Expand Down Expand Up @@ -422,8 +422,15 @@ export class BoardComponent implements OnInit {
this.selectedDataset = this.datasets[event.value];
}

copyHowToCiteToClipboard() {
this._clipboardService.copyFromContent(this.selectedDataset.howToCite);
// copy link to clipboard
copyToClipboard(msg: string) {
const message = 'Copied to clipboard!';
const action = msg;
this._snackBar.open(message, action, {
duration: 3000,
horizontalPosition: 'center',
verticalPosition: 'top'
});
}

openDialog(mode: string, name: string, id?: string): void {
Expand Down