@abi-software/map-utilities 1.4.3-isan.0 → 1.4.3-isan.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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@abi-software/map-utilities",
3
- "version": "1.4.3-isan.0",
3
+ "version": "1.4.3-isan.1",
4
4
  "files": [
5
5
  "dist/*",
6
6
  "src/*",
@@ -1,5 +1,31 @@
1
1
  <template>
2
2
  <el-main class="main">
3
+ <div v-if="annotationEntry.length > 1" class="toggle-button">
4
+ <el-popover width="auto" trigger="hover" :teleported="false">
5
+ <template #reference>
6
+ <el-button
7
+ class="button"
8
+ @click="previous"
9
+ :disabled="this.entryIndex === 0"
10
+ >
11
+ Previous
12
+ </el-button>
13
+ </template>
14
+ <span>{{ previousLabel }}</span>
15
+ </el-popover>
16
+ <el-popover width="auto" trigger="hover" :teleported="false">
17
+ <template #reference>
18
+ <el-button
19
+ class="button"
20
+ @click="next"
21
+ :disabled="this.entryIndex === this.annotationEntry.length - 1"
22
+ >
23
+ Next
24
+ </el-button>
25
+ </template>
26
+ <span>{{ nextLabel }}</span>
27
+ </el-popover>
28
+ </div>
3
29
  <div class="block">
4
30
  <el-row class="info-field">
5
31
  <div class="title">Feature Annotations</div>
@@ -7,16 +33,16 @@
7
33
  <copy-to-clipboard :content="updatedCopyContent" />
8
34
  </div>
9
35
  </el-row>
10
- <template v-if="annotationEntry">
36
+ <template v-if="entry">
11
37
  <el-row
12
38
  v-for="(key, label) in displayPair"
13
- v-show="annotationEntry[key]"
39
+ v-show="entry[key]"
14
40
  class="dialog-text"
15
41
  :key="key"
16
42
  >
17
43
  <strong>{{ label }}: </strong>&nbsp;
18
- <span v-if="label !== 'Ontology'">{{ annotationEntry[key] }}</span>
19
- <a v-else :href="ontologyLink" target="_blank">{{ annotationEntry[key] }}</a>
44
+ <span v-if="label !== 'Ontology'">{{ entry[key] }}</span>
45
+ <a v-else :href="ontologyLink" target="_blank">{{ entry[key] }}</a>
20
46
  </el-row>
21
47
  <template v-if="prevSubs.length > 0">
22
48
  <div
@@ -158,7 +184,7 @@ export default {
158
184
  name: "AnnotationPopup",
159
185
  props: {
160
186
  annotationEntry: {
161
- type: Object,
187
+ type: Array,
162
188
  },
163
189
  },
164
190
  inject: ["$annotator", "userApiKey"],
@@ -187,31 +213,47 @@ export default {
187
213
  errorMessage: "",
188
214
  creator: undefined,
189
215
  copyContent: '',
216
+ entryIndex: 0,
190
217
  };
191
218
  },
192
219
  computed: {
220
+ entry: function () {
221
+ return this.annotationEntry[this.entryIndex];
222
+ },
223
+ previousLabel: function () {
224
+ if (this.entryIndex === 0) {
225
+ return "This is the first item. Click 'Next' to see more information.";
226
+ }
227
+ return this.annotationEntry[this.entryIndex - 1]?.label;
228
+ },
229
+ nextLabel: function () {
230
+ if (this.entryIndex === this.annotationEntry.length - 1) {
231
+ return "This is the last item. Click 'Previous' to see more information.";
232
+ }
233
+ return this.annotationEntry[this.entryIndex + 1]?.label;
234
+ },
193
235
  isEditable: function () {
194
236
  return (
195
- this.annotationEntry["resourceId"] && this.annotationEntry["featureId"]
237
+ this.entry["resourceId"] && this.entry["featureId"]
196
238
  );
197
239
  },
198
240
  isPositionUpdated: function () {
199
241
  return (
200
- this.annotationEntry["resourceId"] &&
201
- this.annotationEntry["type"] === "updated" &&
202
- this.annotationEntry["positionUpdated"]
242
+ this.entry["resourceId"] &&
243
+ this.entry["type"] === "updated" &&
244
+ this.entry["positionUpdated"]
203
245
  );
204
246
  },
205
247
  isDeleted: function () {
206
248
  return (
207
- this.annotationEntry["resourceId"] &&
208
- this.annotationEntry["type"] === "deleted"
249
+ this.entry["resourceId"] &&
250
+ this.entry["type"] === "deleted"
209
251
  );
210
252
  },
211
253
  ontologyLink: function () {
212
- const models = this.annotationEntry['models'];
254
+ const models = this.entry['models'];
213
255
  if (models && models.startsWith("UBERON")) {
214
- return `http://purl.obolibrary.org/obo/${this.annotationEntry.models.replace(":", "_")}`;
256
+ return `http://purl.obolibrary.org/obo/${this.entry.models.replace(":", "_")}`;
215
257
  }
216
258
  },
217
259
  updatedCopyContent: function () {
@@ -219,6 +261,16 @@ export default {
219
261
  },
220
262
  },
221
263
  methods: {
264
+ previous: function () {
265
+ if (this.entryIndex !== 0) {
266
+ this.entryIndex = this.entryIndex - 1;
267
+ }
268
+ },
269
+ next: function () {
270
+ if (this.entryIndex !== this.annotationEntry.length - 1) {
271
+ this.entryIndex = this.entryIndex + 1;
272
+ }
273
+ },
222
274
  processEvidences: function(sub) {
223
275
  const evidences = [];
224
276
  if (sub?.body?.evidence) {
@@ -264,14 +316,14 @@ export default {
264
316
  updatePrevSubmissions: function () {
265
317
  if (this.$annotator && this.authenticated) {
266
318
  if (
267
- this.annotationEntry["resourceId"] &&
268
- this.annotationEntry["featureId"]
319
+ this.entry["resourceId"] &&
320
+ this.entry["featureId"]
269
321
  ) {
270
322
  this.$annotator
271
323
  ?.itemAnnotations(
272
324
  this.userApiKey,
273
- this.annotationEntry["resourceId"],
274
- this.annotationEntry["featureId"]
325
+ this.entry["resourceId"],
326
+ this.entry["featureId"]
275
327
  )
276
328
  .then((value) => {
277
329
  this.prevSubs = value;
@@ -286,13 +338,13 @@ export default {
286
338
  // User can either update/delete annotation directly
287
339
  // or provide extra comments for update/delete action
288
340
  if (
289
- this.annotationEntry["type"] === "updated" &&
290
- this.annotationEntry["positionUpdated"]
341
+ this.entry["type"] === "updated" &&
342
+ this.entry["positionUpdated"]
291
343
  ) {
292
344
  this.comment = this.comment
293
345
  ? `Position Updated: ${this.comment}`
294
346
  : "Position Updated";
295
- } else if (this.annotationEntry["type"] === "deleted") {
347
+ } else if (this.entry["type"] === "deleted") {
296
348
  this.comment = this.comment
297
349
  ? `Feature Deleted: ${this.comment}`
298
350
  : "Feature Deleted";
@@ -300,8 +352,8 @@ export default {
300
352
 
301
353
  if (this.evidence.length > 0 || this.comment) {
302
354
  if (
303
- this.annotationEntry["resourceId"] &&
304
- this.annotationEntry["featureId"]
355
+ this.entry["resourceId"] &&
356
+ this.entry["featureId"]
305
357
  ) {
306
358
  const evidenceURLs = [];
307
359
  this.evidence.forEach((evidence) => {
@@ -319,11 +371,11 @@ export default {
319
371
  }
320
372
  });
321
373
  const userAnnotation = {
322
- resource: this.annotationEntry["resourceId"],
374
+ resource: this.entry["resourceId"],
323
375
  item: Object.assign(
324
- { id: this.annotationEntry["featureId"] },
376
+ { id: this.entry["featureId"] },
325
377
  Object.fromEntries(
326
- Object.entries(this.annotationEntry).filter(([key]) =>
378
+ Object.entries(this.entry).filter(([key]) =>
327
379
  ["label", "models"].includes(key)
328
380
  )
329
381
  )
@@ -332,10 +384,10 @@ export default {
332
384
  evidence: evidenceURLs,
333
385
  comment: this.comment,
334
386
  },
335
- feature: this.annotationEntry["feature"],
387
+ feature: this.entry["feature"],
336
388
  };
337
- Object.assign(userAnnotation.body, this.annotationEntry["body"]);
338
- if (this.annotationEntry["type"] === "deleted") {
389
+ Object.assign(userAnnotation.body, this.entry["body"]);
390
+ if (this.entry["type"] === "deleted") {
339
391
  userAnnotation.feature = undefined;
340
392
  }
341
393
  if (this.creator) userAnnotation.creator = this.creator;
@@ -364,33 +416,33 @@ export default {
364
416
  this.comment = "";
365
417
  },
366
418
  getUpdateCopyContent: function () {
367
- if (!this.annotationEntry) {
419
+ if (!this.entry) {
368
420
  return '';
369
421
  }
370
422
 
371
423
  const contentArray = [];
372
424
 
373
425
  // featureId
374
- if (this.annotationEntry.featureId) {
375
- contentArray.push(`<div><strong>Feature ID:</strong>${this.annotationEntry.featureId}</div>`);
426
+ if (this.entry.featureId) {
427
+ contentArray.push(`<div><strong>Feature ID:</strong>${this.entry.featureId}</div>`);
376
428
  }
377
429
 
378
430
  // label
379
- if (this.annotationEntry.label) {
380
- contentArray.push(`<div><strong>Label:</strong>${this.annotationEntry.label}</div>`);
431
+ if (this.entry.label) {
432
+ contentArray.push(`<div><strong>Label:</strong>${this.entry.label}</div>`);
381
433
  }
382
434
 
383
435
  // models
384
- if (this.annotationEntry.models) {
385
- contentArray.push(`<div><strong>Ontology:</strong>${this.annotationEntry.models}</div>`);
436
+ if (this.entry.models) {
437
+ contentArray.push(`<div><strong>Ontology:</strong>${this.entry.models}</div>`);
386
438
  if (this.ontologyLink) {
387
439
  contentArray.push(`<div><strong>Ontology Link:</strong>${this.ontologyLink}</div>`);
388
440
  }
389
441
  }
390
442
 
391
443
  // resourceId
392
- if (this.annotationEntry.resourceId) {
393
- contentArray.push(`<div><strong>Resource:</strong>${this.annotationEntry.resourceId}</div>`);
444
+ if (this.entry.resourceId) {
445
+ contentArray.push(`<div><strong>Resource:</strong>${this.entry.resourceId}</div>`);
394
446
  }
395
447
 
396
448
  if (this.prevSubs.length) {
@@ -416,15 +468,15 @@ export default {
416
468
  },
417
469
  },
418
470
  watch: {
419
- annotationEntry: {
471
+ entry: {
472
+ deep: true,
473
+ immediate: true,
420
474
  handler: function (newVal, oldVal) {
421
475
  if (newVal !== oldVal) {
422
476
  this.resetSubmission();
423
477
  this.updatePrevSubmissions();
424
478
  }
425
479
  },
426
- immediate: false,
427
- deep: false,
428
480
  },
429
481
  },
430
482
  mounted: function () {
@@ -443,6 +495,36 @@ export default {
443
495
  </script>
444
496
 
445
497
  <style lang="scss" scoped>
498
+ .toggle-button {
499
+ display: flex;
500
+ justify-content: space-between;
501
+ margin-bottom: 30px;
502
+
503
+ .is-disabled {
504
+ color: #fff !important;
505
+ background-color: #ac76c5 !important;
506
+ border: 1px solid #ac76c5 !important;
507
+ }
508
+
509
+ .button {
510
+ margin-left: 0px !important;
511
+ margin-top: 0px !important;
512
+ font-size: 14px !important;
513
+ background-color: $app-primary-color;
514
+ color: #fff;
515
+
516
+ & + .button {
517
+ margin-top: 10px !important;
518
+ }
519
+
520
+ &:hover {
521
+ color: #fff !important;
522
+ background: #ac76c5 !important;
523
+ border: 1px solid #ac76c5 !important;
524
+ }
525
+ }
526
+ }
527
+
446
528
  .info-field {
447
529
  padding: 0;
448
530
  display: flex;
@@ -26,7 +26,7 @@ export default {
26
26
  default: false,
27
27
  },
28
28
  annotationEntry: {
29
- type: Object,
29
+ type: Array,
30
30
  },
31
31
  },
32
32
  mounted: function() {