@konfuzio/document-validation-ui 0.1.6-multi-ann-set-2 → 0.1.6-pre-release

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": "@konfuzio/document-validation-ui",
3
- "version": "0.1.6-multi-ann-set-2",
3
+ "version": "0.1.6-pre-release",
4
4
  "repository": "git://github.com:konfuzio-ai/document-validation-ui.git",
5
5
  "main": "dist/app.js",
6
6
  "scripts": {
@@ -39,6 +39,7 @@
39
39
  "vue-i18n": "^8.27.1",
40
40
  "vue-i18n-bridge": "^9.2.2",
41
41
  "vue-konva": "^2.1.7",
42
+ "vue-observe-visibility": "^1.0.0",
42
43
  "vue-template-compiler": "^2.6.10",
43
44
  "vuedraggable": "^2.24.3",
44
45
  "vuex": "^3.6.2"
@@ -1,5 +1,5 @@
1
1
  <template>
2
- <div style="display: flex">
2
+ <div v-observe-visibility="visibilityChanged" style="display: flex">
3
3
  <img v-show="loaded" ref="imgTag" :height="height" />
4
4
  <slot v-if="!loaded" />
5
5
  </div>
@@ -27,16 +27,16 @@ export default {
27
27
  data() {
28
28
  return {
29
29
  loaded: false,
30
+ isVisible: false,
30
31
  };
31
32
  },
32
33
  watch: {
33
34
  imageUrl() {
34
- this.loadImage();
35
+ if (this.isVisible) {
36
+ this.loadImage();
37
+ }
35
38
  },
36
39
  },
37
- mounted() {
38
- this.loadImage();
39
- },
40
40
  methods: {
41
41
  loadImage() {
42
42
  if (!this.imageUrl) return;
@@ -56,6 +56,12 @@ export default {
56
56
  this.loaded = false;
57
57
  });
58
58
  },
59
+ visibilityChanged(isVisible) {
60
+ if (!this.isVisible && isVisible) {
61
+ this.isVisible = isVisible;
62
+ this.loadImage();
63
+ }
64
+ },
59
65
  },
60
66
  };
61
67
  </script>
@@ -26,15 +26,14 @@
26
26
  gap: 20px;
27
27
 
28
28
  .image-section {
29
+ cursor: grab;
29
30
  width: 138px;
30
31
  height: 138px;
31
32
  display: flex;
32
33
  align-items: center;
33
34
 
34
35
  .img-container {
35
- &:hover {
36
- cursor: pointer;
37
- }
36
+ cursor: pointer;
38
37
 
39
38
  .img-thumbnail {
40
39
  border: $component-border;
@@ -75,7 +75,7 @@
75
75
  />
76
76
  </div>
77
77
  <EmptyAnnotation
78
- v-else
78
+ v-else-if="!fromTable"
79
79
  :label="label"
80
80
  :annotation-set="annotationSet"
81
81
  :is-hovered="hoveredAnnotation"
@@ -140,14 +140,6 @@ export default {
140
140
  type: Boolean,
141
141
  default: true,
142
142
  },
143
- isSmall: {
144
- type: Boolean,
145
- default: false,
146
- },
147
- showHover: {
148
- type: Boolean,
149
- default: true,
150
- },
151
143
  fromTable: {
152
144
  type: Boolean,
153
145
  default: false,
@@ -498,6 +498,8 @@ export default {
498
498
  },
499
499
 
500
500
  openAnnotationSetTable(tableSet) {
501
+ this.$store.dispatch("selection/disableSelection");
502
+ this.$store.dispatch("document/resetEditAnnotation");
501
503
  if (this.showAnnSetTable && this.showAnnSetTable === tableSet) {
502
504
  this.$store.dispatch("display/toggleAnnSetTable", tableSet);
503
505
  } else {
@@ -49,29 +49,31 @@ export default {
49
49
  return this.showAnnSetTable[0].label_set.name;
50
50
  },
51
51
  coordinates() {
52
- let x = 0;
53
- let y = 0;
54
- const paddingTop = 55;
52
+ let xFinal = 0;
53
+ let yFinal = 0;
54
+ const paddingTop = 40;
55
55
 
56
56
  this.showAnnSetTable.forEach((annotationSet) => {
57
- if (
58
- annotationSet.labels &&
59
- annotationSet.labels.length > 0 &&
60
- annotationSet.labels[0].annotations
61
- ) {
62
- annotationSet.labels[0].annotations.forEach((annotation) => {
63
- annotation.span.forEach((span) => {
64
- if (x === 0 || span.x0 < x) {
65
- x = span.x0;
66
- }
67
- if (y === 0 || span.y0 < y) {
68
- y = span.y0 + paddingTop;
69
- }
57
+ if (annotationSet.labels) {
58
+ annotationSet.labels.forEach((label) => {
59
+ label.annotations.forEach((annotation) => {
60
+ annotation.span.forEach((span) => {
61
+ const { x, y } = this.bboxToPoint(this.page, {
62
+ x: span.x0,
63
+ y: span.y0,
64
+ });
65
+ if (xFinal === 0 || x < xFinal) {
66
+ xFinal = x;
67
+ }
68
+ if (yFinal === 0 || y < yFinal) {
69
+ yFinal = y - paddingTop;
70
+ }
71
+ });
70
72
  });
71
73
  });
72
74
  }
73
75
  });
74
- return this.bboxToPoint(this.page, { x, y });
76
+ return { x: xFinal, y: yFinal };
75
77
  },
76
78
  },
77
79
  methods: {
@@ -144,6 +144,7 @@ export default {
144
144
  });
145
145
  },
146
146
  chooseLabelSet(labelSet) {
147
+ // TODO: deprecated with new multi ann set table
147
148
  const tableSelection = {
148
149
  labelSet,
149
150
  position: {
@@ -196,6 +197,7 @@ export default {
196
197
  serverErrorMessage: this.$t("server_error"),
197
198
  defaultErrorMessage: this.$t("error_creating_multi_ann"),
198
199
  });
200
+ this.$store.dispatch("selection/disableSelection");
199
201
  this.$emit("finished");
200
202
  });
201
203
  },
@@ -106,12 +106,18 @@ export default {
106
106
  },
107
107
  computed: {
108
108
  ...mapState("display", ["showAnnSetTable"]),
109
+ ...mapState("document", ["annotations"]),
109
110
  },
110
111
  watch: {
111
112
  showAnnSetTable() {
112
113
  this.handleColumns();
113
114
  this.handleRows();
114
115
  },
116
+ annotations() {
117
+ // if there's a change in the annotations content, we update the table
118
+ this.handleColumns();
119
+ this.handleRows();
120
+ },
115
121
  },
116
122
  mounted() {
117
123
  this.handleColumns();
@@ -151,14 +157,18 @@ export default {
151
157
 
152
158
  this.showAnnSetTable.forEach((annotationSet) => {
153
159
  let row = {};
160
+ let toAdd = false; // to not push empty labels
154
161
 
155
162
  annotationSet.labels.forEach((label) => {
156
163
  if (label.annotations.length > 0) {
157
164
  row[label.id] = label.annotations[0];
158
165
  this.orderedAnnotations.push(label.annotations[0]);
166
+ toAdd = true;
159
167
  }
160
168
  });
161
- this.rows.push(row);
169
+ if (toAdd) {
170
+ this.rows.push(row);
171
+ }
162
172
  });
163
173
  },
164
174
 
@@ -222,6 +232,8 @@ export default {
222
232
 
223
233
  onDropdownChange(column, open) {
224
234
  this.editingLabels = [];
235
+ this.$store.dispatch("selection/disableSelection");
236
+ this.$store.dispatch("document/resetEditAnnotation");
225
237
  if (open) {
226
238
  if (this.openDropdown) {
227
239
  this.$refs[this.openDropdown][0].toggle();
package/src/main.js CHANGED
@@ -8,6 +8,8 @@ import { Integrations } from "@sentry/tracing";
8
8
  import i18n from "./i18n";
9
9
  import store from "./store";
10
10
  import { library } from "@fortawesome/fontawesome-svg-core";
11
+ import VueObserveVisibility from "vue-observe-visibility";
12
+
11
13
  // internal icons
12
14
  import {
13
15
  faArrowUp,
@@ -55,6 +57,7 @@ Vue.use(Buefy, {
55
57
  defaultIconPack: "fas",
56
58
  defaultIconComponent: "vue-fontawesome",
57
59
  });
60
+ Vue.use(VueObserveVisibility);
58
61
 
59
62
  // Sentry config
60
63
  if (process.env.NODE_ENV != "development") {