Skip to content

Commit

Permalink
add centre ID, resolve issue 816
Browse files Browse the repository at this point in the history
  • Loading branch information
pjjin-design committed Dec 18, 2024
1 parent 63c94b9 commit e0d3692
Showing 1 changed file with 36 additions and 18 deletions.
54 changes: 36 additions & 18 deletions src/components/DatasetEditorForm.vue
Original file line number Diff line number Diff line change
Expand Up @@ -964,27 +964,45 @@ export default defineComponent({
const openMessageDialog = ref(false);
const copyIdentifier = () => {
const identifier = model.value.identification.identifier;
if (navigator.clipboard && navigator.clipboard.writeText) {
navigator.clipboard.writeText(identifier)
.then(() => {
message.value = "Identifier copied to clipboard!";
openMessageDialog.value = true;
})
.catch(err => {
console.error('Clipboard API error: ', err);
fallbackCopyManual(identifier);
});
} else {
fallbackCopyManual(identifier);
const identifier = model.value?.identification?.identifier;
if (!identifier) {
console.warn("Identifier is undefined. Cannot copy to clipboard.");
message.value = "No identifier to copy.";
openMessageDialog.value = true;
return;
}
if (navigator.clipboard && navigator.clipboard.writeText) {
navigator.clipboard.writeText(identifier)
.then(() => {
message.value = "Identifier copied to clipboard!";
openMessageDialog.value = true;
})
.catch(err => {
console.error('Clipboard API error: ', err);
fallbackCopyManual(identifier);
});
} else {
fallbackCopyManual(identifier);
}
};
const fallbackCopyManual = () => {
message.value = "Clipboard API not supported. Please copy the text manually.";
openMessageDialog.value = true;
const fallbackCopyManual = (text) => {
if (text) {
const textarea = document.createElement('textarea');
textarea.value = text;
document.body.appendChild(textarea);
textarea.select();
document.execCommand('copy');
document.body.removeChild(textarea);
message.value = "Text copied manually!";
openMessageDialog.value = true;
} else {
message.value = "No text available to copy.";
openMessageDialog.value = true;
}
};
const openValidationDialog = ref(false);
Expand Down

0 comments on commit e0d3692

Please sign in to comment.