Skip to content

Commit 430f7aa

Browse files
authored
Merge pull request ABI-Software#36 from ddjnw1yu/multiple-neuron-selection
Multiple neuron selection
2 parents f1c0ad9 + e47ee46 commit 430f7aa

6 files changed

Lines changed: 95 additions & 57 deletions

File tree

package-lock.json

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@abi-software/map-utilities",
3-
"version": "1.4.2",
3+
"version": "1.5.0-beta.0",
44
"files": [
55
"dist/*",
66
"src/*",

src/components.d.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@ declare module 'vue' {
4545
ExternalResourceCard: typeof import('./components/Tooltip/ExternalResourceCard.vue')['default']
4646
HelpModeDialog: typeof import('./components/HelpModeDialog/HelpModeDialog.vue')['default']
4747
ProvenancePopup: typeof import('./components/Tooltip/ProvenancePopup.vue')['default']
48+
RelatedConnectivitiesButton: typeof import('./components/Tooltip/RelatedConnectivitiesButton.vue')['default']
4849
Tooltip: typeof import('./components/Tooltip/Tooltip.vue')['default']
4950
TreeControls: typeof import('./components/TreeControls/TreeControls.vue')['default']
5051
}

src/components/Tooltip/AnnotationPopup.vue

Lines changed: 24 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@
6767
<strong class="sub-title">Previous submissions:</strong>
6868
</el-row>
6969
<div class="entry" v-for="(sub, index) in prevSubs" :key="index">
70-
<el-row class="dialog-text">
70+
<el-row class="dialog-text" v-if="sub.creator">
7171
<strong>{{ formatTime(sub.created) }}</strong>
7272
{{ sub.creator.name }}
7373
</el-row>
@@ -91,7 +91,7 @@
9191
</div>
9292
</template>
9393
</template>
94-
<template v-if="authenticated">
94+
<template v-if="authenticated || offlineAnnotationEnabled">
9595
<template v-if="isEditable">
9696
<el-row class="dialog-spacer"></el-row>
9797
<el-row v-if="!editing">
@@ -259,6 +259,12 @@ export default {
259259
updatedCopyContent: function () {
260260
return this.getUpdateCopyContent();
261261
},
262+
offlineAnnotationEnabled: function () {
263+
if (this.entry) {
264+
return this.entry["offline"];
265+
}
266+
return false;
267+
},
262268
},
263269
methods: {
264270
previous: function () {
@@ -314,7 +320,15 @@ export default {
314320
return new Date(dateString).toLocaleDateString(undefined, options);
315321
},
316322
updatePrevSubmissions: function () {
317-
if (this.$annotator && this.authenticated) {
323+
if (this.offlineAnnotationEnabled) {
324+
const offlineAnnotations = JSON.parse(sessionStorage.getItem('anonymous-annotation')) || [];
325+
this.prevSubs = offlineAnnotations.filter((offline) => {
326+
return (
327+
offline.resource === this.entry.resourceId &&
328+
offline.item.id === this.entry.featureId
329+
)
330+
});
331+
} else if (this.$annotator && this.authenticated) {
318332
if (
319333
this.entry["resourceId"] &&
320334
this.entry["featureId"]
@@ -394,7 +408,6 @@ export default {
394408
this.$annotator
395409
?.addAnnotation(this.userApiKey, userAnnotation)
396410
.then(() => {
397-
this.$emit("annotation", userAnnotation);
398411
this.errorMessage = "";
399412
this.resetSubmission();
400413
this.updatePrevSubmissions();
@@ -403,6 +416,7 @@ export default {
403416
this.errorMessage =
404417
"There is a problem with the submission, please try again later";
405418
});
419+
this.$emit("annotation", userAnnotation);
406420
}
407421
}
408422
},
@@ -448,9 +462,11 @@ export default {
448462
if (this.prevSubs.length) {
449463
let annotationContent = '<div><strong>Annotations:</strong></div>\n<br>';
450464
this.prevSubs.map((sub, index) => {
451-
annotationContent += `<div><strong>Created:</strong>${this.formatTime(sub.created)}</div>\n<br>`;
452-
annotationContent += `<div><strong>Creator:</strong>${sub.creator.name}</div>\n<br>`;
453-
annotationContent += `<div><strong>Email:</strong>${sub.creator.email}</div>\n<br>`;
465+
if (sub.creator) {
466+
annotationContent += `<div><strong>Created:</strong>${this.formatTime(sub.created)}</div>\n<br>`;
467+
annotationContent += `<div><strong>Creator:</strong>${sub.creator.name}</div>\n<br>`;
468+
annotationContent += `<div><strong>Email:</strong>${sub.creator.email}</div>\n<br>`;
469+
}
454470
if (sub.body.evidence.length) {
455471
let evidenceContent = '';
456472
sub.body.evidence.forEach((evi, index) => {
@@ -494,10 +510,10 @@ export default {
494510
this.creator = userData;
495511
if (!userData.orcid) this.creator.orcid = "0000-0000-0000-0000";
496512
this.authenticated = true;
497-
this.updatePrevSubmissions();
498513
} else {
499514
this.errorMessage = "";
500515
}
516+
this.updatePrevSubmissions();
501517
});
502518
},
503519
};

src/components/Tooltip/ExternalResourceCard.vue

Lines changed: 28 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,8 @@
2222
v-for="reference of pubMedReferences"
2323
:key="reference.id"
2424
:class="{
25-
'loading': reference.citation && !reference.citation.error && reference.citation[citationType] === '',
26-
'error': reference.citation && reference.citation.error
25+
'loading': isCitationLoading(reference.citation),
26+
'error': isCitationError(reference.citation),
2727
}"
2828
>
2929
<template v-if="reference.citation">
@@ -50,49 +50,34 @@
5050
<template v-else>
5151
<span v-html="reference.citation[citationType]"></span>
5252

53-
<div class="reference-button-container">
54-
<el-button
55-
class="reference-icon-button"
56-
size="small"
57-
@click="showRelatedConnectivities(reference.resource)"
58-
>
59-
Show related connectivities
60-
</el-button>
61-
</div>
53+
<RelatedConnectivitiesButton
54+
:resource="reference.resource"
55+
@show-related-connectivities="showRelatedConnectivities"
56+
/>
6257

6358
<CopyToClipboard :content="reference.citation[citationType]" />
6459
</template>
6560
</template>
6661
</li>
6762

68-
<li v-for="reference of openLibReferences">
63+
<li v-for="reference of openLibReferences" :key="reference.id">
6964
<div v-html="formatCopyReference(reference)"></div>
7065

71-
<div class="reference-button-container">
72-
<el-button
73-
class="reference-icon-button"
74-
size="small"
75-
@click="showRelatedConnectivities(reference.resource)"
76-
>
77-
Show related connectivities
78-
</el-button>
79-
</div>
66+
<RelatedConnectivitiesButton
67+
:resource="reference.resource"
68+
@show-related-connectivities="showRelatedConnectivities"
69+
/>
8070

8171
<CopyToClipboard :content="formatCopyReference(reference)" />
8272
</li>
8373

84-
<li v-for="reference of isbnDBReferences">
74+
<li v-for="reference of isbnDBReferences" :key="reference.id">
8575
<a :href="reference.url" target="_blank">{{ reference.url }}</a>
8676

87-
<div class="reference-button-container">
88-
<el-button
89-
class="reference-icon-button"
90-
size="small"
91-
@click="showRelatedConnectivities(reference.resource)"
92-
>
93-
Show related connectivities
94-
</el-button>
95-
</div>
77+
<RelatedConnectivitiesButton
78+
:resource="reference.resource"
79+
@show-related-connectivities="showRelatedConnectivities"
80+
/>
9681

9782
<CopyToClipboard :content="reference.url" />
9883
</li>
@@ -103,6 +88,7 @@
10388
<script>
10489
import CopyToClipboard from '../CopyToClipboard/CopyToClipboard.vue';
10590
import { delay } from '../utilities';
91+
import RelatedConnectivitiesButton from './RelatedConnectivitiesButton.vue';
10692
10793
const CROSSCITE_API_HOST = 'https://citation.doi.org';
10894
const CITATION_OPTIONS = [
@@ -128,6 +114,10 @@ const LOADING_DELAY = 600;
128114
129115
export default {
130116
name: "ExternalResourceCard",
117+
components: {
118+
CopyToClipboard,
119+
RelatedConnectivitiesButton,
120+
},
131121
props: {
132122
resources: {
133123
type: Array,
@@ -411,6 +401,12 @@ export default {
411401
reloadCitation: function (reference) {
412402
this.generateCitationText(reference, this.citationType);
413403
},
404+
isCitationLoading: function (citation) {
405+
return citation && !citation[this.citationType] && !citation.error;
406+
},
407+
isCitationError: function (citation) {
408+
return citation && citation.error;
409+
},
414410
updateCopyContents: function () {
415411
const citationTypeObj = this.citationOptions.find((item) => item.value === this.citationType);
416412
let citationFormatStyle = '';
@@ -611,7 +607,7 @@ export default {
611607
&.loading {
612608
padding: 1rem;
613609
614-
&::before {
610+
&::after {
615611
content: "";
616612
display: block;
617613
width: 100%;
@@ -691,20 +687,6 @@ export default {
691687
cursor: pointer;
692688
}
693689
694-
.reference-button-container {
695-
margin-top: 0.5rem;
696-
}
697-
698-
.reference-icon-button {
699-
color: $app-primary-color !important;
700-
background-color: #f9f2fc !important;
701-
border-color: $app-primary-color !important;
702-
703-
&:hover {
704-
background-color: transparent !important;
705-
}
706-
}
707-
708690
@keyframes loadingAnimation {
709691
0% {
710692
background-position: -30vw 0;
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
<template>
2+
<div class="reference-button-container">
3+
<el-button
4+
class="reference-icon-button"
5+
size="small"
6+
@click="$emit('show-related-connectivities', resource)"
7+
>
8+
Show related connectivities
9+
</el-button>
10+
</div>
11+
</template>
12+
13+
<script>
14+
export default {
15+
name: "RelatedConnectivitiesButton",
16+
props: {
17+
resource: {
18+
type: String,
19+
required: true,
20+
},
21+
},
22+
};
23+
</script>
24+
25+
<style lang="scss" scoped>
26+
.reference-button-container {
27+
margin-top: 0.5rem;
28+
}
29+
30+
.reference-icon-button {
31+
color: $app-primary-color !important;
32+
background-color: #f9f2fc !important;
33+
border-color: $app-primary-color !important;
34+
35+
&:hover {
36+
background-color: transparent !important;
37+
}
38+
}
39+
</style>

0 commit comments

Comments
 (0)