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

Change dataset details page PID text to a input field with copy button #1051

Merged
merged 5 commits into from
Apr 24, 2023
Merged
Show file tree
Hide file tree
Changes from 4 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 @@ -66,7 +66,14 @@
</tr>
<tr>
<th>PID</th>
<td>{{ dataset.pid }}</td>
<td>
<mat-form-field class="full-width">
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Instead of creating a full functional text box, can we just add the copy button, like is done under user settings with the scicat token

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

From the best practice point of view, especially if you are an accessibility enthusiast, I wouldn't recommend to use onClick in a span to make it a button.
But in our case, I think it is completely fine to follow the pattern what we already have for consistency, and you can add an aria attribute if you want to.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Okay i will check that from the settings page and improve the current code

<input matInput type="text" [value]="dataset.pid" disabled>
<button matSuffix mat-icon-button aria-label="copy" (click)="copyIntoClipboard(dataset.pid)">
<mat-icon>content_copy</mat-icon>
</button>
</mat-form-field>
</td>
</tr>
<tr *ngIf="dataset.type as value">
<th>Type</th>
Expand Down
9 changes: 8 additions & 1 deletion src/app/datasets/dataset-detail/dataset-detail.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,8 @@ import {
FormGroup,
Validators,
} from "@angular/forms";
import {Clipboard} from "@angular/cdk/clipboard";

/**
* Component to show details for a data set, using the
* form component
Expand Down Expand Up @@ -82,7 +84,8 @@ export class DatasetDetailComponent
public dialog: MatDialog,
private store: Store,
private router: Router,
private fb: FormBuilder
private fb: FormBuilder,
private clipboard: Clipboard
) {}

ngOnInit() {
Expand Down Expand Up @@ -315,4 +318,8 @@ export class DatasetDetailComponent
subscription.unsubscribe();
});
}

copyIntoClipboard(pid: string) {
this.clipboard.copy(pid);
}
}