@konfuzio/document-validation-ui 0.1.10-dev.12 → 0.1.10-dev.13

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.
@@ -69,7 +69,9 @@ export default {
69
69
  locale: {
70
70
  type: String,
71
71
  required: false,
72
+ default: "en",
72
73
  },
74
+ // eslint-disable-next-line vue/prop-name-casing
73
75
  documents_list_path: {
74
76
  type: String,
75
77
  required: false,
@@ -4,7 +4,7 @@
4
4
  ref="modal"
5
5
  v-model="show"
6
6
  :can-cancel="['x', 'outside']"
7
- class="modal-absolute modal-400 modal-no-footer"
7
+ class="modal-absolute modal-400 modal-no-footer model-overflow-visible"
8
8
  :on-cancel="close"
9
9
  >
10
10
  <section class="modal-card-body">
@@ -149,7 +149,7 @@ export default {
149
149
  }
150
150
  );
151
151
 
152
- this.$emit("labelSet", this.selectedLabelSet);
152
+ this.$emit("finish", this.selectedLabelSet);
153
153
  this.close();
154
154
  },
155
155
  setSelectedLabelSet(labelSet) {
@@ -157,6 +157,7 @@ export default {
157
157
  this.selectedLabelSet = labelSet;
158
158
  },
159
159
  close() {
160
+ this.$store.dispatch("display/showChooseLabelSetModal", null);
160
161
  this.$emit("close");
161
162
  },
162
163
  createLabelsList(labels) {
@@ -100,7 +100,7 @@ import AnnotationRow from "../DocumentAnnotations/AnnotationRow";
100
100
  import DraggableIcon from "../../assets/images/DraggableIcon";
101
101
 
102
102
  export default {
103
- name: "MultiAnnotationTablePopup",
103
+ name: "MultiAnnotationTableOverlay",
104
104
  components: {
105
105
  AnnotationRow,
106
106
  DraggableIcon,
@@ -12,6 +12,11 @@
12
12
  :left="documentContainerLeftPadding"
13
13
  :width="documentContainerWidth"
14
14
  />
15
+ <ChooseLabelSetModal
16
+ v-if="showChooseLabelSetModal && showChooseLabelSetModal.show"
17
+ :is-multiple-annotations="showChooseLabelSetModal.isMultipleAnnotations"
18
+ @finish="showChooseLabelSetModal.finish"
19
+ />
15
20
 
16
21
  <transition name="slide-fade">
17
22
  <div
@@ -50,6 +55,7 @@ import { DocumentEdit } from "./DocumentEdit";
50
55
  import ErrorMessage from "./ErrorMessage";
51
56
  import NotOptimizedViewportModal from "../components/DocumentModals/NotOptimizedViewportModal";
52
57
  import DocumentErrorModal from "../components/DocumentModals/DocumentErrorModal";
58
+ import ChooseLabelSetModal from "../components/DocumentAnnotations/ChooseLabelSetModal";
53
59
 
54
60
  /**
55
61
  * This component shows the PDF pages in a scrolling component and
@@ -67,6 +73,7 @@ export default {
67
73
  NotOptimizedViewportModal,
68
74
  DocumentErrorModal,
69
75
  MultiAnnotationTableOverlay,
76
+ ChooseLabelSetModal,
70
77
  },
71
78
  data() {
72
79
  return {
@@ -84,6 +91,7 @@ export default {
84
91
  "pageWidthScale",
85
92
  "currentPage",
86
93
  "showAnnSetTable",
94
+ "showChooseLabelSetModal",
87
95
  ]),
88
96
  ...mapState("document", [
89
97
  "showActionError",
@@ -18,14 +18,6 @@
18
18
  :container-height="scaledViewport.height"
19
19
  @close="closePopups"
20
20
  />
21
- <MultiAnnotationTablePopup
22
- v-if="newMultiAnnotationSetTable"
23
- :table-position="newMultiAnnotationSetTable.position"
24
- :page-size="scaledViewport"
25
- :label-set="newMultiAnnotationSetTable.labelSet"
26
- :grouped-entities="newMultiAnnotationSetTable.entities"
27
- @close="closePopups"
28
- />
29
21
 
30
22
  <AnnSetTableOptions v-if="showAnnSetTable" :page="page" />
31
23
 
@@ -117,7 +109,6 @@
117
109
  :page="page"
118
110
  @buttonEnter="onElementEnter"
119
111
  @buttonLeave="onElementLeave"
120
- @finished="handleMultiAnnSelectionFinished"
121
112
  />
122
113
  </v-layer>
123
114
  </v-stage>
@@ -136,7 +127,6 @@ import api from "../../api";
136
127
  import BoxSelection from "./BoxSelection";
137
128
  import MultiAnnSelection from "./MultiAnnSelection";
138
129
  import NewAnnotation from "./NewAnnotation";
139
- import MultiAnnotationTablePopup from "./MultiAnnotationTablePopup";
140
130
  import AnnSetTableOptions from "./AnnSetTableOptions";
141
131
 
142
132
  export default {
@@ -145,7 +135,6 @@ export default {
145
135
  BoxSelection,
146
136
  MultiAnnSelection,
147
137
  NewAnnotation,
148
- MultiAnnotationTablePopup,
149
138
  AnnSetTableOptions,
150
139
  },
151
140
 
@@ -160,7 +149,6 @@ export default {
160
149
  return {
161
150
  image: null,
162
151
  newAnnotation: [],
163
- newMultiAnnotationSetTable: null,
164
152
  };
165
153
  },
166
154
 
@@ -460,10 +448,6 @@ export default {
460
448
  this.$refs.stage.$el.style.cursor = "inherit";
461
449
  },
462
450
 
463
- handleMultiAnnSelectionFinished(newMultiAnnotationSetTable) {
464
- this.newMultiAnnotationSetTable = newMultiAnnotationSetTable;
465
- },
466
-
467
451
  /**
468
452
  * Konva draws pages like this.
469
453
  */
@@ -556,7 +540,6 @@ export default {
556
540
  };
557
541
  },
558
542
  closePopups(closeNewAnnotaton) {
559
- this.newMultiAnnotationSetTable = null;
560
543
  if (closeNewAnnotaton) {
561
544
  this.newAnnotation = [];
562
545
  }
@@ -132,34 +132,12 @@ export default {
132
132
  },
133
133
  methods: {
134
134
  openMultiAnnotationModal() {
135
- this.$buefy.modal.open({
136
- parent: this.$parent,
137
- component: ChooseLabelSetModal,
138
- hasModalCard: true,
139
- trapFocus: true,
140
- canCancel: false,
141
- customClass: "dv-ui-theme invisible-parent-modal",
142
- props: { isMultipleAnnotations: true },
143
- events: {
144
- labelSet: this.submitAnnotations,
145
- },
135
+ this.$store.dispatch("display/showChooseLabelSetModal", {
136
+ show: true,
137
+ isMultipleAnnotations: true,
138
+ finish: this.submitAnnotations,
146
139
  });
147
140
  },
148
- chooseLabelSet(labelSet) {
149
- // TODO: deprecated with new multi ann set table
150
- const tableSelection = {
151
- labelSet,
152
- position: {
153
- x: this.selection.start.x,
154
- y: this.selection.start.y,
155
- width: this.selection.end.x - this.selection.start.x,
156
- height: this.selection.end.y - this.selection.start.y,
157
- },
158
- entities: this.entities,
159
- };
160
- this.$store.dispatch("selection/disableSelection");
161
- this.$emit("finished", tableSelection);
162
- },
163
141
 
164
142
  async submitAnnotations(labelSet) {
165
143
  const columns = labelSet.labels.map((label) => {
@@ -259,15 +259,7 @@ export default {
259
259
  this.loading = false;
260
260
  });
261
261
  },
262
- disableLabelSetModalShowing() {
263
- // timeout to stop propagation of click event
264
- setTimeout(() => {
265
- this.isAnnSetModalShowing = false;
266
- }, 500);
267
- },
268
262
  chooseLabelSet(labelSet) {
269
- this.disableLabelSetModalShowing();
270
-
271
263
  const newSet = {
272
264
  label_set: labelSet,
273
265
  labels: labelSet.labels,
@@ -277,20 +269,10 @@ export default {
277
269
  this.selectedSet = newSet;
278
270
  },
279
271
  openAnnotationSetCreation() {
280
- this.isAnnSetModalShowing = true;
281
-
282
- this.$buefy.modal.open({
283
- parent: this.$parent,
284
- component: ChooseLabelSetModal,
285
- hasModalCard: true,
286
- trapFocus: true,
287
- canCancel: false,
288
- onCancel: this.disableLabelSetModalShowing,
289
- customClass: "dv-ui-theme invisible-parent-modal",
290
- events: {
291
- labelSet: this.chooseLabelSet,
292
- close: this.disableLabelSetModalShowing,
293
- },
272
+ this.$store.dispatch("display/showChooseLabelSetModal", {
273
+ show: true,
274
+ isMultipleAnnotations: true,
275
+ finish: this.chooseLabelSet,
294
276
  });
295
277
  },
296
278
  setTooltipText() {
@@ -131,5 +131,6 @@
131
131
  "edit_label": "Label editieren",
132
132
  "delete_label": "Label löschen",
133
133
  "table": "Tabelle",
134
- "prepare_document": "Dokument vorbereiten"
134
+ "prepare_document": "Dokument vorbereiten",
135
+ "delete_table": "Tabelle löschen"
135
136
  }
@@ -131,5 +131,6 @@
131
131
  "missing_from_document": "Missing from the document",
132
132
  "edit_label": "Edit label",
133
133
  "delete_label": "Delete label",
134
- "table": "Table"
134
+ "table": "Table",
135
+ "delete_table": "Delete table"
135
136
  }
@@ -131,5 +131,6 @@
131
131
  "table": "Tabla",
132
132
  "new_multi_ann_description": "Seleccione un modelo de datos de los existentes, luego deseleccione las etiquetas que no existen en este documento.",
133
133
  "new_multi_ann_title": "Crear múltiples anotaciones",
134
- "prepare_document": "Prepare el documento"
134
+ "prepare_document": "Prepare el documento",
135
+ "delete_table": "Eliminar tabla"
135
136
  }
@@ -31,6 +31,7 @@ const state = {
31
31
  categorizeModalIsActive: false,
32
32
  pageChangedFromThumbnail: false,
33
33
  showAnnSetTable: null,
34
+ showChooseLabelSetModal: null,
34
35
  };
35
36
 
36
37
  const getters = {
@@ -236,6 +237,9 @@ const actions = {
236
237
  showAnnSetTable({ commit }, tableSet) {
237
238
  commit("SET_ANN_SET_TABLE", tableSet);
238
239
  },
240
+ showChooseLabelSetModal({ commit }, options) {
241
+ commit("SET_SHOW_CHOOSE_LABEL_SET_MODAL", options);
242
+ },
239
243
  toggleAnnSetTable({ commit }, tableSet) {
240
244
  commit("TOGGLE_ANN_SET_TABLE", tableSet);
241
245
  },
@@ -286,6 +290,9 @@ const mutations = {
286
290
  SET_PAGE_CHANGED_FROM_THUMBNAIL: (state, value) => {
287
291
  state.pageChangedFromThumbnail = value;
288
292
  },
293
+ SET_SHOW_CHOOSE_LABEL_SET_MODAL: (state, options) => {
294
+ state.showChooseLabelSetModal = options;
295
+ },
289
296
  };
290
297
 
291
298
  export default {
@@ -1,226 +0,0 @@
1
- <template>
2
- <div
3
- class="multi-ann-table-popup"
4
- :style="{
5
- left: `${tablePosition.x}px`,
6
- top: `${tablePosition.y - 22}px`,
7
- width: `${tablePosition.width}px`,
8
- height: `${tablePosition.height}px`,
9
- maxWidth: `${pageSize.width}px`,
10
- maxHeight: `${pageSize.height}px`,
11
- }"
12
- >
13
- <b-table
14
- ref="table"
15
- class="full-height"
16
- detail-icon="faScissors"
17
- :data="rows"
18
- :columns="columns"
19
- :narrowed="true"
20
- :bordered="true"
21
- draggable-column
22
- @columndragstart="columndragstart"
23
- @columndrop="columndrop"
24
- @columndragover="columndragover"
25
- @columndragleave="columndragleave"
26
- >
27
- </b-table>
28
- </div>
29
- </template>
30
-
31
- <script>
32
- import { mapState } from "vuex";
33
-
34
- export default {
35
- name: "MultiAnnotationTablePopup",
36
-
37
- props: {
38
- tablePosition: {
39
- required: true,
40
- type: Object,
41
- default: null,
42
- },
43
- pageSize: {
44
- required: true,
45
- type: Object,
46
- default: null,
47
- },
48
- labelSet: {
49
- required: true,
50
- type: Object,
51
- default: null,
52
- },
53
- groupedEntities: {
54
- required: true,
55
- type: Object,
56
- default: null,
57
- },
58
- },
59
- data() {
60
- const columns = this.labelSet.labels.map((label) => {
61
- return {
62
- field: `${label.id}`,
63
- label: label.name,
64
- centered: true,
65
- };
66
- });
67
- return {
68
- rows: [],
69
- columns,
70
- counter: 0,
71
- draggingColumn: null,
72
- draggingColumnIndex: null,
73
- orderedEntities: [],
74
- };
75
- },
76
- computed: {
77
- ...mapState("document", ["documentId"]),
78
- },
79
- mounted() {
80
- this.handleRows();
81
- setTimeout(() => {
82
- // prevent click propagation when opening the popup
83
- document.body.addEventListener("click", this.clickOutside);
84
- this.$refs.table.$el.scrollIntoView({
85
- behavior: "smooth",
86
- block: "nearest",
87
- inline: "center",
88
- });
89
- }, 200);
90
-
91
- // show action bar
92
- this.$store.dispatch("display/showDocumentActionBar", {
93
- show: true,
94
- text: this.$t("drag_drop_columns_multi_ann"),
95
- icon: "drag",
96
- loading: false,
97
- action: () => {
98
- this.submitAnnotations();
99
- this.$emit("close");
100
- },
101
- });
102
- },
103
- destroyed() {
104
- this.$store.dispatch("display/showDocumentActionBar", { show: false });
105
- this.$store.dispatch("selection/disableSelection");
106
- document.body.removeEventListener("click", this.clickOutside);
107
- },
108
- methods: {
109
- handleRows() {
110
- this.rows = [];
111
- this.orderedEntities = []; // this will match the order of entities in the table so we have a way of tracking them once we submit
112
- let rowIndex = 0;
113
-
114
- Object.entries(this.groupedEntities).forEach(([key, groupedEntity]) => {
115
- let row = null;
116
- this.columns.forEach((column, index) => {
117
- let spans = [];
118
- if (
119
- Object.entries(groupedEntity)[index] &&
120
- Object.entries(groupedEntity)[index].length > 0
121
- ) {
122
- spans = Object.entries(groupedEntity)[index][1];
123
- }
124
- const entityExists = spans.length > 0;
125
-
126
- let textContent = "";
127
-
128
- spans.forEach((entity) => {
129
- textContent = `${textContent} ${entity.offset_string}`;
130
- });
131
-
132
- row = {
133
- ...row,
134
- [column.field]: textContent,
135
- };
136
- if (entityExists) {
137
- const customEntity = {
138
- spans: [...spans],
139
- label_id: column.field,
140
- row_index: rowIndex,
141
- };
142
-
143
- this.orderedEntities.push(customEntity);
144
- }
145
- });
146
- if (row !== null) {
147
- rowIndex++;
148
- }
149
- this.rows.push(row);
150
- });
151
- },
152
-
153
- clickOutside(event) {
154
- if (!(this.$el == event.target || this.$el.contains(event.target))) {
155
- this.$emit("close");
156
- }
157
- },
158
- async submitAnnotations() {
159
- this.$store.dispatch("display/showDocumentActionBar", {
160
- show: true,
161
- loading: false,
162
- action: true,
163
- });
164
-
165
- this.orderedEntities.forEach((orderedEntity) => {
166
- annotations.push({
167
- document: this.documentId,
168
- span: orderedEntity.spans,
169
- label: orderedEntity.label_id,
170
- is_correct: true,
171
- revised: false,
172
- label_set: labelSet.id,
173
- set_reference: orderedEntity.row_index,
174
- });
175
- });
176
-
177
- this.$store
178
- .dispatch("document/createAnnotation", annotations)
179
- .then(() => {
180
- this.$emit("close");
181
- })
182
- .catch((error) => {
183
- this.$store.dispatch("document/createErrorMessage", {
184
- error,
185
- serverErrorMessage: this.$t("server_error"),
186
- defaultErrorMessage: this.$t("error_creating_multi_ann"),
187
- });
188
- });
189
- },
190
- deleteRow(index) {
191
- this.rows.splice(index, 1);
192
- },
193
-
194
- //#region Column Drag
195
- columndragstart(payload) {
196
- this.draggingColumn = payload.column;
197
- this.draggingColumnIndex = payload.index;
198
- payload.event.dataTransfer.effectAllowed = "copy";
199
- },
200
- columndragover(payload) {
201
- payload.event.dataTransfer.dropEffect = "copy";
202
- payload.event.target.closest("th").classList.add("is-selected");
203
- payload.event.preventDefault();
204
- },
205
- columndragleave(payload) {
206
- payload.event.target.closest("th").classList.remove("is-selected");
207
- payload.event.preventDefault();
208
- },
209
- columndrop(payload) {
210
- payload.event.target.closest("th").classList.remove("is-selected");
211
- const droppedOnColumnIndex = payload.index;
212
-
213
- const column = this.columns[this.draggingColumnIndex];
214
- this.columns.splice(this.draggingColumnIndex, 1);
215
- this.columns.splice(droppedOnColumnIndex, 0, column);
216
- this.handleRows();
217
- },
218
- //#endregion
219
- },
220
- };
221
- </script>
222
- <style
223
- scoped
224
- lang="scss"
225
- src="../../assets/scss/multi_ann_table_popup.scss"
226
- ></style>