@abi-software/flatmapvuer 1.0.1 → 1.1.0-beta.0

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/flatmapvuer",
3
- "version": "1.0.1",
3
+ "version": "1.1.0-beta.0",
4
4
  "license": "Apache-2.0",
5
5
  "files": [
6
6
  "dist/*",
@@ -43,8 +43,8 @@
43
43
  "./src/*": "./src/*"
44
44
  },
45
45
  "dependencies": {
46
- "@abi-software/flatmap-viewer": "2.6.2",
47
- "@abi-software/sparc-annotation": "0.2.0",
46
+ "@abi-software/sparc-annotation": "0.3.1",
47
+ "@abi-software/flatmap-viewer": "^2.8.0",
48
48
  "@abi-software/svg-sprite": "1.0.0",
49
49
  "@element-plus/icons-vue": "^2.3.1",
50
50
  "css-element-queries": "^1.2.2",
package/src/App.vue CHANGED
@@ -218,12 +218,12 @@ export default {
218
218
  position: 'absolute',
219
219
  },
220
220
  displayCloseButton: false,
221
- initial: 'Rat (NPO)',
221
+ initial: 'Rat',
222
222
  helpMode: false,
223
223
  mapSettings: [],
224
224
  //flatmapAPI: "https://mapcore-demo.org/current/flatmap/v2/"
225
225
  //flatmapAPI: "https://mapcore-demo.org/devel/flatmap/v3/"
226
- //flatmapAPI: "https://mapcore-demo.org/current/flatmap/v3/"
226
+ //flatmapAPI: "https://mapcoe-demo.org/current/flatmap/v3/",
227
227
  flatmapAPI: 'https://mapcore-demo.org/devel/flatmap/v4/',
228
228
  //flatmapAPI: "https://mapcore-demo.org/fccb/flatmap/"
229
229
  //flatmapAPI: "https://mapcore-demo.org/staging/flatmap/v1/"
@@ -60,52 +60,70 @@
60
60
  <template v-if="isEditable">
61
61
  <el-row class="dialog-spacer"></el-row>
62
62
  <el-row v-if="!editing">
63
- <el-icon class="standard-icon"><el-icon-edit @click="editing = true"/></el-icon>
63
+ <el-icon class="standard-icon">
64
+ <el-icon-edit @click="editing = true" />
65
+ </el-icon>
66
+ <el-icon
67
+ class="standard-icon"
68
+ v-if="isDeleted"
69
+ >
70
+ <el-icon-delete @click="submit"/>
71
+ </el-icon>
72
+ <el-icon
73
+ class="standard-icon"
74
+ v-else-if="isPositionUpdated"
75
+ >
76
+ <el-icon-finished @click="submit" />
77
+ </el-icon>
64
78
  </el-row>
65
79
  <template v-else>
66
80
  <el-row class="dialog-text">
67
81
  <strong class="sub-title">Suggest changes:</strong>
68
82
  </el-row>
69
- <el-row class="dialog-text">
70
- <strong>Evidence:</strong>
71
- </el-row>
72
- <el-row v-for="(value, index) in evidence" :key="value">
73
- <el-col :span="20">
74
- {{ evidence[index] }}
75
- </el-col>
76
- <el-col :span="4">
77
- <el-icon class="standard-icon"><el-icon-close @click="removeEvidence(index)" /></el-icon>
78
- </el-col>
79
- </el-row>
80
- <el-row>
81
- <el-input
82
- size="small"
83
- placeholder="Enter"
84
- v-model="newEvidence"
85
- @change="evidenceEntered($event)"
86
- >
87
- <template #prepend>
88
- <el-select
89
- :teleported="false"
90
- v-model="evidencePrefix"
91
- placeholder="Select"
92
- class="select-box"
93
- popper-class="flatmap_dropdown"
94
- >
95
- <el-option
96
- v-for="item in evidencePrefixes"
97
- :key="item"
98
- :label="item"
99
- :value="item"
83
+ <template v-if="!isDeleted">
84
+ <el-row class="dialog-text">
85
+ <strong>Evidence:</strong>
86
+ </el-row>
87
+ <el-row v-for="(value, index) in evidence" :key="value">
88
+ <el-col :span="20">
89
+ {{ evidence[index] }}
90
+ </el-col>
91
+ <el-col :span="4">
92
+ <el-icon class="standard-icon">
93
+ <el-icon-close @click="removeEvidence(index)" />
94
+ </el-icon>
95
+ </el-col>
96
+ </el-row>
97
+ <el-row>
98
+ <el-input
99
+ size="small"
100
+ placeholder="Enter"
101
+ v-model="newEvidence"
102
+ @change="evidenceEntered($event)"
103
+ >
104
+ <template #prepend>
105
+ <el-select
106
+ :teleported="false"
107
+ v-model="evidencePrefix"
108
+ placeholder="Select"
109
+ class="select-box"
110
+ popper-class="flatmap_dropdown"
100
111
  >
101
- <el-row>
102
- <el-col :span="12">{{ item }}</el-col>
103
- </el-row>
104
- </el-option>
105
- </el-select>
106
- </template>
107
- </el-input>
108
- </el-row>
112
+ <el-option
113
+ v-for="item in evidencePrefixes"
114
+ :key="item"
115
+ :label="item"
116
+ :value="item"
117
+ >
118
+ <el-row>
119
+ <el-col :span="12">{{ item }}</el-col>
120
+ </el-row>
121
+ </el-option>
122
+ </el-select>
123
+ </template>
124
+ </el-input>
125
+ </el-row>
126
+ </template>
109
127
  <el-row>
110
128
  <strong>Comment:</strong>
111
129
  </el-row>
@@ -139,10 +157,10 @@ import {
139
157
  ArrowDown as ElIconArrowDown,
140
158
  Edit as ElIconEdit,
141
159
  Close as ElIconClose,
160
+ Delete as ElIconDelete,
161
+ Finished as ElIconFinished,
142
162
  } from '@element-plus/icons-vue'
143
163
  /* eslint-disable no-alert, no-console */
144
- /* eslint-disable no-alert, no-console */
145
- import { AnnotationService } from '@abi-software/sparc-annotation'
146
164
  import {
147
165
  ElButton as Button,
148
166
  ElCol as Col,
@@ -171,7 +189,7 @@ export default {
171
189
  type: Object,
172
190
  },
173
191
  },
174
- inject: ['flatmapAPI', 'userApiKey'],
192
+ inject: ['flatmapAPI', '$annotator', 'userApiKey'],
175
193
  data: function () {
176
194
  return {
177
195
  displayPair: {
@@ -191,15 +209,29 @@ export default {
191
209
  prevSubs: [],
192
210
  showSubmissions: true,
193
211
  errorMessage: '',
194
- creator: undefined,
212
+ creator: undefined
195
213
  }
196
214
  },
197
215
  computed: {
198
216
  isEditable: function () {
199
217
  return (
200
- this.annotationEntry['resource'] && this.annotationEntry['featureId']
218
+ this.annotationEntry['resourceId'] &&
219
+ this.annotationEntry['featureId']
201
220
  )
202
221
  },
222
+ isPositionUpdated: function () {
223
+ return (
224
+ this.annotationEntry['resourceId'] &&
225
+ this.annotationEntry['type'] === 'updated' &&
226
+ this.annotationEntry['positionUpdated']
227
+ )
228
+ },
229
+ isDeleted: function () {
230
+ return (
231
+ this.annotationEntry['resourceId'] &&
232
+ this.annotationEntry['type'] === 'deleted'
233
+ )
234
+ }
203
235
  },
204
236
  methods: {
205
237
  evidenceEntered: function (value) {
@@ -222,13 +254,13 @@ export default {
222
254
  updatePrevSubmissions: function () {
223
255
  if (this.$annotator && this.authenticated) {
224
256
  if (
225
- this.annotationEntry['resource'] &&
257
+ this.annotationEntry['resourceId'] &&
226
258
  this.annotationEntry['featureId']
227
259
  ) {
228
260
  this.$annotator
229
261
  .itemAnnotations(
230
262
  this.userApiKey,
231
- this.annotationEntry['resource'],
263
+ this.annotationEntry['resourceId'],
232
264
  this.annotationEntry['featureId']
233
265
  )
234
266
  .then((value) => {
@@ -241,9 +273,24 @@ export default {
241
273
  }
242
274
  },
243
275
  submit: function () {
276
+ // User can either update/delete annotation directly
277
+ // or provide extra comments for update/delete action
278
+ if (
279
+ this.annotationEntry['type'] === 'updated' &&
280
+ this.annotationEntry['positionUpdated']
281
+ ) {
282
+ this.comment = this.comment ?
283
+ `Position Updated: ${this.comment}` :
284
+ 'Position Updated'
285
+ } else if (this.annotationEntry['type'] === 'deleted') {
286
+ this.comment = this.comment ?
287
+ `Feature Deleted: ${this.comment}` :
288
+ 'Feature Deleted'
289
+ }
290
+
244
291
  if (this.evidence.length > 0 || this.comment) {
245
292
  if (
246
- this.annotationEntry['resource'] &&
293
+ this.annotationEntry['resourceId'] &&
247
294
  this.annotationEntry['featureId']
248
295
  ) {
249
296
  const evidenceURLs = []
@@ -260,17 +307,26 @@ export default {
260
307
  }
261
308
  })
262
309
  const userAnnotation = {
263
- resource: this.annotationEntry['resource'],
264
- item: this.annotationEntry['featureId'],
310
+ resource: this.annotationEntry['resourceId'],
311
+ item: Object.assign({id: this.annotationEntry['featureId']},
312
+ Object.fromEntries(
313
+ Object.entries(this.annotationEntry)
314
+ .filter(([key]) => ['label', 'models'].includes(key)))),
265
315
  body: {
266
316
  evidence: evidenceURLs,
267
317
  comment: this.comment,
268
318
  },
319
+ feature: this.annotationEntry['feature']
320
+ }
321
+ Object.assign(userAnnotation.body, this.annotationEntry['body'])
322
+ if (this.annotationEntry['type'] === 'deleted') {
323
+ userAnnotation.feature = undefined
269
324
  }
270
325
  if (this.creator) userAnnotation.creator = this.creator
271
326
  this.$annotator
272
327
  .addAnnotation(this.userApiKey, userAnnotation)
273
328
  .then(() => {
329
+ this.$emit('annotation', userAnnotation)
274
330
  this.errorMessage = ''
275
331
  this.resetSubmission()
276
332
  this.updatePrevSubmissions()
@@ -305,11 +361,6 @@ export default {
305
361
  },
306
362
  },
307
363
  mounted: function () {
308
- if (!this.$annotator) {
309
- this.$annotator = new AnnotationService(
310
- `${this.flatmapAPI}annotator`
311
- )
312
- }
313
364
  this.$annotator.authenticate(this.userApiKey).then((userData) => {
314
365
  if (userData.name && userData.email) {
315
366
  this.creator = userData
@@ -0,0 +1,127 @@
1
+ <template>
2
+ <div class="dialog-container">
3
+ <el-row>
4
+ <span class="dialog-title" v-if="drawing">Finalise drawing</span>
5
+ <span class="dialog-title" v-else>Visualise connection</span>
6
+ <el-row v-if="drawing">
7
+ <el-col :span="13">
8
+ <el-button type="primary" plain @click="$emit('confirm', true)">
9
+ Confirm
10
+ </el-button>
11
+ </el-col>
12
+ <el-col :span="11">
13
+ <el-button type="primary" plain @click="$emit('cancel', true)">
14
+ Cancel
15
+ </el-button>
16
+ </el-col>
17
+ </el-row>
18
+ <el-row v-else>
19
+ <el-button type="primary" plain @click="$emit('display', false)">
20
+ Close
21
+ </el-button>
22
+ </el-row>
23
+ </el-row>
24
+ <el-row v-if="connection">
25
+ <el-col>
26
+ <b><span>Related Features</span></b>
27
+ <el-row v-for="(value, key) in entry" :key="key">
28
+ <el-col :span="20">
29
+ <el-card shadow="hover" @click="handleTooltipOpen(key)">
30
+ <span>{{ capitalise(value.label) }}</span>
31
+ </el-card>
32
+ </el-col>
33
+ <el-col :span="4" v-if="key === tooltipId">
34
+ <el-icon><el-icon-circle-close @click="handleTooltipClose" /></el-icon>
35
+ </el-col>
36
+ </el-row>
37
+ </el-col>
38
+ </el-row>
39
+ </div>
40
+ </template>
41
+
42
+ <script>
43
+ /* eslint-disable no-alert, no-console */
44
+ import { CircleClose as ElIconCircleClose } from '@element-plus/icons-vue'
45
+ import {
46
+ ElRow as Row,
47
+ ElCol as Col,
48
+ ElCard as Card
49
+ } from 'element-plus'
50
+
51
+ export default {
52
+ name: 'ConnectionDialog',
53
+ components: {
54
+ Row,
55
+ Col,
56
+ Card
57
+ },
58
+ props: {
59
+ entry: {
60
+ type: Object,
61
+ },
62
+ drawing: {
63
+ type: Boolean,
64
+ default: false,
65
+ },
66
+ connection: {
67
+ type: Boolean,
68
+ default: false,
69
+ },
70
+ },
71
+ data: function () {
72
+ return {
73
+ tooltipId: undefined
74
+ }
75
+ },
76
+ watch: {
77
+ connection: function () {
78
+ this.tooltipId = undefined
79
+ },
80
+ },
81
+ methods: {
82
+ capitalise: function (label) {
83
+ return label[0].toUpperCase() + label.slice(1);
84
+ },
85
+ handleTooltipOpen: function (value) {
86
+ this.tooltipId = value
87
+ this.$emit('tooltip', value)
88
+ },
89
+ handleTooltipClose: function () {
90
+ this.tooltipId = undefined
91
+ this.$emit('popup', true)
92
+ }
93
+ }
94
+ }
95
+ </script>
96
+
97
+ <style lang="scss" scoped>
98
+ .dialog-container {
99
+ width: 200px;
100
+ height: fit-content;
101
+ text-align: justify;
102
+ border-radius: 4px;
103
+ box-shadow: 0 1px 2px rgba(0, 0, 0, 0.1);
104
+ pointer-events: auto;
105
+ background: #fff;
106
+ border: 1px solid $app-primary-color;
107
+ display: flex;
108
+ flex-direction: column;
109
+ padding: .8em;
110
+ }
111
+
112
+ .dialog-title {
113
+ font-size: 18px;
114
+ font-weight: bold;
115
+ color: rgb(131, 0, 191);
116
+ }
117
+
118
+ .el-icon {
119
+ cursor: pointer;
120
+ }
121
+
122
+ :deep(.el-card) {
123
+ --el-card-padding: 8px;
124
+ border: 0;
125
+ cursor: pointer;
126
+ }
127
+ </style>