@abi-software/map-utilities 1.4.1-beta.0 → 1.4.1-beta.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -6,7 +6,7 @@
6
6
  <CopyToClipboard label="Copy list to clipboard" :content="referecesListContent" />
7
7
  </div>
8
8
  </div>
9
- <div class="citation-tabs" v-if="referencesWithDOI">
9
+ <div class="citation-tabs" v-if="useDOIFormatter ? referencesWithDOI : pubMedReferences.length">
10
10
  <el-button
11
11
  link
12
12
  v-for="citationOption of citationOptions"
@@ -102,7 +102,7 @@
102
102
 
103
103
  <script>
104
104
  import CopyToClipboard from '../CopyToClipboard/CopyToClipboard.vue';
105
- import { delay } from '../utilities';
105
+ import { delay, getCitationById } from '../utilities';
106
106
 
107
107
  const CROSSCITE_API_HOST = 'https://citation.doi.org';
108
108
  const CITATION_OPTIONS = [
@@ -128,11 +128,18 @@ const LOADING_DELAY = 600;
128
128
 
129
129
  export default {
130
130
  name: "ExternalResourceCard",
131
+ components: {
132
+ CopyToClipboard,
133
+ },
131
134
  props: {
132
135
  resources: {
133
136
  type: Array,
134
137
  default: () => [],
135
138
  },
139
+ useDOIFormatter: {
140
+ type: Boolean,
141
+ default: true,
142
+ }
136
143
  },
137
144
  data: function () {
138
145
  return {
@@ -338,7 +345,14 @@ export default {
338
345
 
339
346
  if (type === 'doi' || doi) {
340
347
  const doiID = type === 'doi' ? id : doi;
341
- this.getCitationTextByDOI(doiID).then((text) => {
348
+ const fetchCitationFromAPI = this.useDOIFormatter ?
349
+ this.getCitationTextByDOI(doiID) :
350
+ getCitationById(doiID, {
351
+ type: 'doi',
352
+ format: citationType
353
+ });
354
+
355
+ fetchCitationFromAPI.then((text) => {
342
356
  const formattedText = this.replaceLinkInText(text);
343
357
  reference.citation[citationType] = formattedText;
344
358
  this.updateCopyContents();
@@ -349,45 +363,61 @@ export default {
349
363
  };
350
364
  });
351
365
  } else if (type === 'pmid') {
352
- this.getDOIFromPubMedID(id).then((data) => {
353
- if (data?.result) {
354
- const resultObj = data.result[id];
355
- const articleIDs = resultObj?.articleids || [];
356
- const doiObj = articleIDs.find((item) => item.idtype === 'doi');
357
- const doiID = doiObj?.value;
358
-
359
- if (doiID) {
360
- reference['doi'] = doiID;
361
- this.getCitationTextByDOI(doiID).then((text) => {
362
- const formattedText = this.replaceLinkInText(text);
366
+ if (this.useDOIFormatter) {
367
+ this.getDOIFromPubMedID(id).then((data) => {
368
+ if (data?.result) {
369
+ const resultObj = data.result[id];
370
+ const articleIDs = resultObj?.articleids || [];
371
+ const doiObj = articleIDs.find((item) => item.idtype === 'doi');
372
+ const doiID = doiObj?.value;
373
+
374
+ if (doiID) {
375
+ reference['doi'] = doiID;
376
+ this.getCitationTextByDOI(doiID).then((text) => {
377
+ const formattedText = this.replaceLinkInText(text);
378
+ reference.citation[citationType] = formattedText;
379
+ this.updateCopyContents();
380
+ }).catch((error) => {
381
+ reference.citation['error'] = {
382
+ type: citationType,
383
+ ref: 'doi',
384
+ };
385
+ });
386
+ } else {
387
+ // If there has no doi in PubMed
388
+ const { title, pubdate, authors } = resultObj;
389
+ const authorNames = authors ? authors.map((author) => author.name) : [];
390
+ const formattedText = this.formatCopyReference({
391
+ title: title || '',
392
+ date: pubdate || '',
393
+ authors: authorNames,
394
+ url: `https://pubmed.ncbi.nlm.nih.gov/${id}`,
395
+ });
363
396
  reference.citation[citationType] = formattedText;
364
397
  this.updateCopyContents();
365
- }).catch((error) => {
366
- reference.citation['error'] = {
367
- type: citationType,
368
- ref: 'doi',
369
- };
370
- });
371
- } else {
372
- // If there has no doi in PubMed
373
- const { title, pubdate, authors } = resultObj;
374
- const authorNames = authors ? authors.map((author) => author.name) : [];
375
- const formattedText = this.formatCopyReference({
376
- title: title || '',
377
- date: pubdate || '',
378
- authors: authorNames,
379
- url: `https://pubmed.ncbi.nlm.nih.gov/${id}`,
380
- });
381
- reference.citation[citationType] = formattedText;
382
- this.updateCopyContents();
398
+ }
383
399
  }
384
- }
385
- }).catch((error) => {
386
- reference.citation['error'] = {
387
- type: citationType,
388
- ref: 'pubmed',
389
- };
390
- });
400
+ }).catch((error) => {
401
+ reference.citation['error'] = {
402
+ type: citationType,
403
+ ref: 'pubmed',
404
+ };
405
+ });
406
+ } else {
407
+ getCitationById(id, {
408
+ type: 'pmid',
409
+ format: citationType
410
+ }).then((text) => {
411
+ const formattedText = this.replaceLinkInText(text);
412
+ reference.citation[citationType] = formattedText;
413
+ this.updateCopyContents();
414
+ }).catch((error) => {
415
+ reference.citation['error'] = {
416
+ type: citationType,
417
+ ref: 'pubmed',
418
+ };
419
+ });
420
+ }
391
421
  }
392
422
  }
393
423
  },
@@ -171,6 +171,11 @@
171
171
  </template>
172
172
 
173
173
  <script>
174
+ import {
175
+ ArrowUp as ElIconArrowUp,
176
+ ArrowDown as ElIconArrowDown,
177
+ Warning as ElIconWarning,
178
+ } from '@element-plus/icons-vue'
174
179
  import EventBus from "../EventBus.js";
175
180
 
176
181
  const titleCase = (str) => {
@@ -186,6 +191,11 @@ const capitalise = function (str) {
186
191
 
187
192
  export default {
188
193
  name: "ProvenancePopup",
194
+ components: {
195
+ ElIconArrowUp,
196
+ ElIconArrowDown,
197
+ ElIconWarning,
198
+ },
189
199
  props: {
190
200
  tooltipEntry: {
191
201
  type: Object,
@@ -1,6 +1,7 @@
1
1
  import AnnotationPopup from "./Tooltip/AnnotationPopup.vue";
2
2
  import CreateTooltipContent from "./Tooltip/CreateTooltipContent.vue";
3
3
  import ConnectivityGraph from "./ConnectivityGraph/ConnectivityGraph.vue";
4
+ import ConnectivityList from "./ConnectivityList/ConnectivityList.vue";
4
5
  import CopyToClipboard from "./CopyToClipboard/CopyToClipboard.vue";
5
6
  import DrawToolbar from "./DrawToolbar/DrawToolbar.vue";
6
7
  import HelpModeDialog from "./HelpModeDialog/HelpModeDialog.vue";
@@ -12,6 +13,7 @@ export {
12
13
  AnnotationPopup,
13
14
  CreateTooltipContent,
14
15
  ConnectivityGraph,
16
+ ConnectivityList,
15
17
  CopyToClipboard,
16
18
  DrawToolbar,
17
19
  HelpModeDialog,
@@ -1,3 +1,9 @@
1
+ import { Cite, plugins } from '@citation-js/core';
2
+ import '@citation-js/plugin-doi';
3
+ import '@citation-js/plugin-csl';
4
+ import '@citation-js/plugin-bibtex';
5
+ import '@citation-js/plugin-pubmed';
6
+
1
7
  const capitalise = term => {
2
8
  if (term)
3
9
  return term.charAt(0).toUpperCase() + term.slice(1);
@@ -48,8 +54,42 @@ const delay = (ms) => {
48
54
  return new Promise(resolve => setTimeout(resolve, ms));
49
55
  };
50
56
 
57
+ /**
58
+ * @param {id} id - DOI or PMID
59
+ * @param {options:type} type - type of the ID, e.g., 'pmid'
60
+ * @param {options:format} format - 'apa' (default), 'chicago', 'ieee', 'bibtex', etc.
61
+ * @returns {citation} formatted citation text
62
+ */
63
+ const getCitationById = async (id, { type, format }) => {
64
+ // because 'chicago' and 'ieee' are not in citation.js default styles
65
+ if ((format !== 'bibtex') && (format !== 'apa')) {
66
+ const xml = `https://raw.githubusercontent.com/citation-style-language/styles/refs/heads/master/${format}.csl`;
67
+ const response = await fetch(xml);
68
+ const template = await response.text();
69
+ let config = plugins.config.get('@csl');
70
+ config.templates.add(format, template);
71
+ }
72
+
73
+ const option = {};
74
+
75
+ if (type === 'pmid') {
76
+ option['forceType'] = '@pubmed/id';
77
+ }
78
+
79
+ const cite = await Cite.async(id, option);
80
+ const citation = (format === 'bibtex') ?
81
+ cite.format(format) :
82
+ cite.format('bibliography', {
83
+ format: 'html',
84
+ template: format || 'apa', // default as 'apa' style
85
+ lang: 'en-US'
86
+ })
87
+ return citation;
88
+ };
89
+
51
90
  export {
52
91
  capitalise,
53
92
  xmlToJSON,
54
93
  delay,
94
+ getCitationById,
55
95
  };
@@ -10,6 +10,7 @@ declare module 'vue' {
10
10
  AnnotationPopup: typeof import('./components/Tooltip/AnnotationPopup.vue')['default']
11
11
  ConnectionDialog: typeof import('./components/DrawToolbar/ConnectionDialog.vue')['default']
12
12
  ConnectivityGraph: typeof import('./components/ConnectivityGraph/ConnectivityGraph.vue')['default']
13
+ ConnectivityList: typeof import('./components/ConnectivityList/ConnectivityList.vue')['default']
13
14
  CopyToClipboard: typeof import('./components/CopyToClipboard/CopyToClipboard.vue')['default']
14
15
  CreateTooltipContent: typeof import('./components/Tooltip/CreateTooltipContent.vue')['default']
15
16
  DrawToolbar: typeof import('./components/DrawToolbar/DrawToolbar.vue')['default']